Debian Codegraph @

third_party/rust/dns-parser/src/structs.rs

raw
1 use {QueryType, QueryClass, Name, Class, Header, RData};
2 use rdata::opt;
3
4
5 /// Parsed DNS packet
6 #[derive(Debug)]
7 #[allow(missing_docs)] // should be covered by spec
8 pub struct Packet<'a> {
9 pub header: Header,
10 pub questions: Vec<Question<'a>>,
11 pub answers: Vec<ResourceRecord<'a>>,
12 pub nameservers: Vec<ResourceRecord<'a>>,
13 pub additional: Vec<ResourceRecord<'a>>,
14 /// Optional Pseudo-RR
15 /// When present it is sent as an RR in the additional section. In this RR
16 /// the `class` and `ttl` fields store max udp packet size and flags
17 /// respectively. To keep `ResourceRecord` clean we store the OPT record
18 /// here.
19 pub opt: Option<opt::Record<'a>>,
20 }
21
22 /// A parsed chunk of data in the Query section of the packet
23 #[derive(Debug)]
24 #[allow(missing_docs)] // should be covered by spec
25 pub struct Question<'a> {
26 pub qname: Name<'a>,
27 /// Whether or not we prefer unicast responses.
28 /// This is used in multicast DNS.
29 pub prefer_unicast: bool,
30 pub qtype: QueryType,
31 pub qclass: QueryClass,
32 }
33
34 /// A single DNS record
35 ///
36 /// We aim to provide whole range of DNS records available. But as time is
37 /// limited we have some types of packets which are parsed and other provided
38 /// as unparsed slice of bytes.
39 #[derive(Debug)]
40 #[allow(missing_docs)] // should be covered by spec
41 pub struct ResourceRecord<'a> {
42 pub name: Name<'a>,
43 /// Whether or not the set of resource records is fully contained in the
44 /// packet, or whether there will be more resource records in future
45 /// packets. Only used for multicast DNS.
46 pub multicast_unique: bool,
47 pub cls: Class,
48 pub ttl: u32,
49 pub data: RData<'a>,
50 }