From 59556f6b3ca6a1dd967faff84fca60bdbc777c09 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sun, 8 May 2022 20:57:37 +0200 Subject: [PATCH] Added dns body models --- src/proto.rs | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/proto.rs b/src/proto.rs index 9c2f26f..5d3625d 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -156,11 +156,47 @@ pub struct DNSHeader { } #[derive(Debug, Clone)] -pub struct DNSQuery { - pub hdr: DNSHeader, +pub enum DNSClass { + Internet = 1, + Any = 255, +} + +#[derive(Debug, Clone)] +pub enum DNSType { + HostAddress = 1, + NameServer = 2, + CanonicalName = 5, + StartOfZoneAuthority = 6, + WellKnownServiceDescription = 11, + DomainNamePointer = 12, + HostInformation = 13, + MailListInformation = 14, + MailExchange = 15, + TextStrings = 16, + Any = 255, +} + +#[derive(Debug, Clone)] +pub struct DNSQuestion { pub name: String, - pub qclass: u16, - pub qtype: u16, + pub r#type: DNSType, + pub class: DNSClass, +} + +pub struct DNSResourceRecord { + pub name: String, + pub r#type: DNSType, + pub class: DNSClass, + pub ttl: u32, + pub data: String, +} + +pub struct DNSMessage { + pub header: DNSHeader, + pub questions: Vec, + pub answers: Vec, + pub authorities: Vec, + pub additionals: Vec, } impl DNSHeader {