rust-dnsbox/lib/dnsbox-base/src/records/structs.rs

433 lines
10 KiB
Rust
Raw Normal View History

2017-12-16 20:58:18 +00:00
use common_types::*;
use std::net::{Ipv4Addr, Ipv6Addr};
// unless otherwise documented, class should probably be IN (0x0001)
2017-12-21 12:32:14 +00:00
// deriving RRData will add a unit test to make sure the type is
// registered; there must be a records::types::$name `Type` constant
// with the same name as the struct.
2017-12-16 20:58:18 +00:00
// class IN
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct A {
addr: Ipv4Addr,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct NS {
nsdname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MD {
madname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MF {
madname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct CNAME {
cname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct SOA {
mname: DnsCompressedName,
rname: DnsCompressedName,
serial: u32,
refresh: u32,
retry: u32,
expire: u32,
minimum: u32,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MB {
madname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MG {
mgmname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MR {
newname: DnsCompressedName,
}
2017-12-21 12:32:14 +00:00
// not allowed in zone files anyway, i.e. no text representation.
// content not restricted either, just some bytes. no need to parse it.
//
// class independent pub struct NULL;
2017-12-16 20:58:18 +00:00
2017-12-21 12:32:14 +00:00
// text representation like: `WKS 127.0.0.1 TCP smtp http 110`. would
// have to parse protocol and service names.
//
2017-12-16 20:58:18 +00:00
// class IN
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
// pub struct WKS {
// address: Ipv4Addr,
// protocol: u8,
// bitmap: ..., // remaining bytes
// }
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct PTR {
ptrdname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct HINFO {
cpu: ShortText,
os: ShortText,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MINFO {
rmailbx: DnsCompressedName,
emailbx: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct MX {
preference: u16,
mxname: DnsCompressedName,
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct TXT {
text: LongText,
}
// end of RFC 1035: no DnsCompressedName below!
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct RP {
2017-12-21 12:32:14 +00:00
mbox: DnsCanonicalName,
txt: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct AFSDB {
subtype: u16,
2017-12-21 12:32:14 +00:00
hostname: DnsCanonicalName,
}
// https://tools.ietf.org/html/rfc1183#section-3.1 says "its format in
// master files is a <character-string>" which say nothing about the
// binary encoding; later it says "<PSDN-address> is a string of decimal
// digits", so it would seem that there is no length encoding or
// restriction.
//
// wireshark and bind use <character-string> though (bind also wants at
// least 4 bytes in the field: probably due to "beginning with the 4
// digit DNIC").
//
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
// pub struct X25 {
// psdn_address: ShortText,
// }
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
// pub struct ISDN {
// isdn_address: ShortText,
// subaddress: Option<ShortText>,
// }
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct RT {
preference: u16,
intermediate: DnsCanonicalName,
}
2017-12-16 20:58:18 +00:00
// pub struct NSAP;
2017-12-21 12:32:14 +00:00
#[allow(non_camel_case_types)]
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
#[RRTypeName = "NSAP-PTR"]
pub struct NSAP_PTR {
owner: DnsCanonicalName,
}
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct SIG {
rr_type: Type,
algorithm: u8,
labels: u8,
// RFC says this can be omitted in text form if it is the same as
// the TTL on the SIG record. not supported to be omitted here
// (TODO?).
original_ttl: u32,
signature_expiration: Time,
signature_inception: Time,
key_tag: u16,
signers_name: DnsCanonicalName,
signature: Base64RemainingBlob,
}
// class independent
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct KEY {
flags: u16,
protocol: u8,
algorithm: u8,
2017-12-21 12:32:14 +00:00
public_key: Base64RemainingBlob,
}
// class IN
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct PX {
preference: u16,
map822: DnsCanonicalName,
mapx400: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// pub struct GPOS;
// class IN
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct AAAA {
addr: Ipv6Addr,
}
2017-12-21 12:32:14 +00:00
pub use super::weird_structs::LOC;
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct NXT {
next: DnsCanonicalName,
types: NxtTypeBitmap,
}
2017-12-16 20:58:18 +00:00
// pub struct EID;
// pub struct NIMLOC;
// class IN
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct SRV {
preference: u16,
weight: u16,
port: u16,
2017-12-21 12:32:14 +00:00
target: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// pub struct ATMA;
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct NAPTR {
order: u16,
preference: u16,
flags: ShortText,
service: ShortText,
regexp: ShortText,
2017-12-21 12:32:14 +00:00
replacement: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// class IN
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct KX {
preference: u16,
2017-12-21 12:32:14 +00:00
exchanger: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// class ??
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct CERT {
cert_type: u16,
key_tag: u16,
algorithm: u8,
2017-12-21 12:32:14 +00:00
certificate: Base64RemainingBlob,
2017-12-16 20:58:18 +00:00
}
2017-12-21 12:32:14 +00:00
pub use super::weird_structs::A6;
2017-12-16 20:58:18 +00:00
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct DNAME {
2017-12-21 12:32:14 +00:00
target: DnsCanonicalName,
2017-12-16 20:58:18 +00:00
}
// pub struct SINK;
// OPT should be decoded at "transport level", abuses ttl and class
// fields too.
// pub struct OPT;
// pub struct APL;
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct DS {
key_tag: u16,
algorithm: u8,
digest_type: u8,
digest: HexRemainingBlob,
}
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct SSHFP {
algorithm: u8,
fingerprint_type: u8,
2017-12-21 12:32:14 +00:00
// RFC 4255 doesn't specify whether whitespace is allowed.
// `HexRemainingBlob` allows whitespace.
2017-12-16 20:58:18 +00:00
fingerprint: HexRemainingBlob,
}
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct IPSECKEY;
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct RRSIG {
rr_type: Type,
algorithm: u8,
labels: u8,
original_ttl: u32,
2017-12-21 12:32:14 +00:00
signature_expiration: Time,
signature_inception: Time,
2017-12-16 20:58:18 +00:00
key_tag: u16,
2017-12-21 12:32:14 +00:00
signers_name: DnsCanonicalName,
signature: Base64RemainingBlob,
2017-12-16 20:58:18 +00:00
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct NSEC {
2017-12-21 12:32:14 +00:00
next: DnsCanonicalName,
types: NsecTypeBitmap,
2017-12-16 20:58:18 +00:00
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct DNSKEY {
flags: u16,
protocol: u8,
algorithm: u8,
2017-12-21 12:32:14 +00:00
public_key: Base64RemainingBlob,
2017-12-16 20:58:18 +00:00
}
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct DHCID;
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct NSEC3 {
hash_algorithm: u8,
flags: u8,
iterations: u16,
salt: HexShortBlob,
2017-12-21 12:32:14 +00:00
next_hashed: NextHashedOwnerName,
types: NsecTypeBitmap,
2017-12-16 20:58:18 +00:00
}
// class independent
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct NSEC3PARAM {
hash_algorithm: u8,
flags: u8,
iterations: u16,
salt: HexShortBlob,
}
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct TLSA;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct SMIMEA;
// pub struct HIP;
// pub struct NINFO;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct RKEY;
// pub struct TALINK;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct CDS;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct CDNSKEY;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct OPENPGPKEY;
// pub struct CSYNC;
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
pub struct SPF {
text: LongText,
}
// pub struct UINFO;
// pub struct UID;
// pub struct GID;
// pub struct UNSPEC;
// pub struct NID;
// pub struct L32;
// pub struct L64;
// pub struct LP;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct EUI48;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct EUI64;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct TKEY;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct TSIG;
// pub struct IXFR; // qtype only?
// pub struct AXFR; // qtype only?
// pub struct MAILB; // qtype only?
// pub struct MAILA; // qtype only?
// pub struct ANY; // qtype only?
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct URI {
priority: u16,
weight: u16,
target: UriText,
}
2017-12-16 20:58:18 +00:00
2017-12-21 12:32:14 +00:00
#[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
pub struct CAA {
flags: u8,
tag: UnquotedShortText,
value: RemainingText,
}
2017-12-16 20:58:18 +00:00
// pub struct AVC;
// pub struct DOA;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct DLV;
// pub struct ADDR;
2017-12-21 12:32:14 +00:00
// #[derive(Clone, PartialEq, Eq, Debug, DnsPacketData, DnsTextData, RRData)]
2017-12-16 20:58:18 +00:00
// pub struct ALIAS;