#dns #w5500 #wiznet #server-client

无std w5500-dns

Wiznet W5500互联网卸载芯片的DNS客户端

7个版本 (4个重大更新)

0.5.0 2024年6月9日
0.4.0 2023年10月2日
0.3.0 2023年8月6日
0.2.0 2022年5月14日
0.1.0-alpha.02022年3月20日

#338 in 嵌入式开发

MIT许可证

130KB
2K SLoC

w5500-dns

Wiznet W5500 SPI互联网卸载芯片的DNS客户端。

警告

请谨慎操作,并在生产环境中使用前审查代码。

此代码是为一次性爱好项目开发的。

限制

  • 无DNS缓存。
  • 仅支持A查询。
  • 仅支持单个挂起的查询。
  • 仅支持查询中的一个问题。

示例

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()?;

相关规范

功能标志

默认禁用所有功能。

  • eh0: 通过 w5500-hl 透传。
  • eh1: 通过 w5500-hl 透传。
  • defmt: 使用 defmt 启用日志记录。也是通过 w5500-hl 透传。
  • log: 使用 log 启用日志记录。

依赖项

~340–530KB