xous-core/services/dns/src/api.rs
bunnie 0dbf1661cb add TCP to hosted mode emulation
Total bodge -- we lop off the TCP stack at the Xous API level, and
substitute it with a native host TCP stack.

Caveat hacker: this means that a lot of OS-specific net properties
will carry through to the hosted mode emulation. This is adequate
for "smoke testing" a build but do not be shocked, *shocked* if
there are more bugs to be found because of some weird host integration
issue.
2022-02-20 21:31:32 +08:00

47 lines
1.3 KiB
Rust

#[allow(dead_code)]
pub(crate) const SERVER_NAME_DNS: &str = "_DNS Resolver Middleware_";
use net::NetIpAddr;
use rkyv::{Archive, Deserialize, Serialize};
#[allow(dead_code)]
pub(crate) const DNS_NAME_LENGTH_LIMIT: usize = 256;
#[allow(dead_code)]
pub(crate) const DNS_PKT_MAX_LEN: usize = 512;
/// These opcodes can be called by anyone at any time
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
pub(crate) enum Opcode {
Lookup,
Flush,
/// used internally to update the TTL field, and eventually expire the cache (unless cache is frozen)
UpdateTtl,
/// issuing this opcode causes all future attempts to change the DNS server configs to be ignored. This also freezes the cache.
FreezeConfig,
/// this allows automatic updates to the DNS server configs based on DHCP. This is the default state.
ThawConfig,
Quit,
}
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive, Archive, Serialize, Deserialize, Copy, Clone)]
#[repr(u16)]
pub enum DnsResponseCode {
NoError = 0,
FormatError = 1,
ServerFailure = 2,
NameError = 3,
NotImplemented = 4,
Refused = 5,
UnknownError,
NetworkError,
NoServerSpecified,
}
#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)]
pub struct DnsResponse {
pub addr: Option<NetIpAddr>,
pub code: DnsResponseCode,
}