summaryrefslogtreecommitdiffstats
path: root/third_party/rust/dns-parser/src/structs.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/rust/dns-parser/src/structs.rs
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/dns-parser/src/structs.rs')
-rw-r--r--third_party/rust/dns-parser/src/structs.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/third_party/rust/dns-parser/src/structs.rs b/third_party/rust/dns-parser/src/structs.rs
new file mode 100644
index 0000000000..4f60639047
--- /dev/null
+++ b/third_party/rust/dns-parser/src/structs.rs
@@ -0,0 +1,50 @@
+use {QueryType, QueryClass, Name, Class, Header, RData};
+use rdata::opt;
+
+
+/// Parsed DNS packet
+#[derive(Debug)]
+#[allow(missing_docs)] // should be covered by spec
+pub struct Packet<'a> {
+ pub header: Header,
+ pub questions: Vec<Question<'a>>,
+ pub answers: Vec<ResourceRecord<'a>>,
+ pub nameservers: Vec<ResourceRecord<'a>>,
+ pub additional: Vec<ResourceRecord<'a>>,
+ /// Optional Pseudo-RR
+ /// When present it is sent as an RR in the additional section. In this RR
+ /// the `class` and `ttl` fields store max udp packet size and flags
+ /// respectively. To keep `ResourceRecord` clean we store the OPT record
+ /// here.
+ pub opt: Option<opt::Record<'a>>,
+}
+
+/// A parsed chunk of data in the Query section of the packet
+#[derive(Debug)]
+#[allow(missing_docs)] // should be covered by spec
+pub struct Question<'a> {
+ pub qname: Name<'a>,
+ /// Whether or not we prefer unicast responses.
+ /// This is used in multicast DNS.
+ pub prefer_unicast: bool,
+ pub qtype: QueryType,
+ pub qclass: QueryClass,
+}
+
+/// A single DNS record
+///
+/// We aim to provide whole range of DNS records available. But as time is
+/// limited we have some types of packets which are parsed and other provided
+/// as unparsed slice of bytes.
+#[derive(Debug)]
+#[allow(missing_docs)] // should be covered by spec
+pub struct ResourceRecord<'a> {
+ pub name: Name<'a>,
+ /// Whether or not the set of resource records is fully contained in the
+ /// packet, or whether there will be more resource records in future
+ /// packets. Only used for multicast DNS.
+ pub multicast_unique: bool,
+ pub cls: Class,
+ pub ttl: u32,
+ pub data: RData<'a>,
+}