Crates.io | w5500-dns |
lib.rs | w5500-dns |
version | 0.5.0 |
source | src |
created_at | 2022-03-20 19:32:51.301813 |
updated_at | 2024-06-09 20:10:48.53505 |
description | DNS client for the Wiznet W5500 internet offload chip. |
homepage | https://github.com/newAM/w5500-rs |
repository | https://github.com/newAM/w5500-rs |
max_upload_size | |
id | 553702 |
size | 75,229 |
DNS client for the Wiznet W5500 SPI internet offload chip.
Please proceed with caution, and review the code before use in a production environment.
This code was developed for one-off hobby projects.
use w5500_dns::{hl::block, ll::Sn, servers, Client as DnsClient, Hostname, Response};
const DNS_SOCKET: Sn = Sn::Sn3;
const DNS_SRC_PORT: u16 = 45917;
let mut dns_client: DnsClient =
DnsClient::new(DNS_SOCKET, DNS_SRC_PORT, servers::CLOUDFLARE, random_number);
let hostname: Hostname = Hostname::new("docs.rs").expect("hostname is invalid");
let mut hostname_buffer: [u8; 16] = [0; 16];
let query_id: u16 = dns_client.a_question(&mut w5500, &hostname)?;
let mut response: Response<_> =
block!(dns_client.response(&mut w5500, &mut hostname_buffer, query_id))?;
while let Some(rr) = response.next_rr()? {
println!("name: {:?}", rr.name);
println!("TTL: {}", rr.ttl);
println!("IP: {:?}", rr.rdata);
}
response.done()?;
All features are disabled by default.