From b38784a912f2019334a2259d1a523519afc0ae1e Mon Sep 17 00:00:00 2001 From: Litr0 Date: Tue, 31 Oct 2023 17:00:40 -0300 Subject: [PATCH] implementation of TSIG in qtype and rtype --- src/message/type_qtype.rs | 7 ++++++- src/message/type_rtype.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/message/type_qtype.rs b/src/message/type_qtype.rs index 967bc43e..ccaaf533 100644 --- a/src/message/type_qtype.rs +++ b/src/message/type_qtype.rs @@ -13,6 +13,7 @@ pub enum Qtype { TXT, DNAME, ANY, + TSIG, AXFR, MAILB, MAILA, @@ -36,6 +37,7 @@ impl Qtype{ Qtype::TXT => 16, Qtype::DNAME => 39, Qtype::AXFR => 252, + Qtype::TSIG => 250, Qtype::MAILB => 253, Qtype::MAILA => 254, Qtype::ANY => 255, @@ -56,6 +58,7 @@ impl Qtype{ Qtype::MX => String::from("MX"), Qtype::TXT => String::from("TXT"), Qtype::DNAME => String::from("DNAME"), + Qtype::TSIG => String::from("TSIG"), Qtype::AXFR => String::from("AXFR"), Qtype::MAILB => String::from("MAILB"), Qtype::MAILA => String::from("MAILA"), @@ -64,7 +67,7 @@ impl Qtype{ } } - /// Function to get the String equivalent of a type + /// Function to get the int equivalent of a type pub fn from_int_to_qtype(val: u16) -> Qtype{ match val { 1 => Qtype::A, @@ -78,6 +81,7 @@ impl Qtype{ 15 => Qtype::MX, 16 => Qtype::TXT, 39 => Qtype::DNAME, + 250 => Qtype::TSIG, 252 => Qtype::AXFR, 253 => Qtype::MAILB, 254 => Qtype::MAILA, @@ -100,6 +104,7 @@ impl Qtype{ "MX" => Qtype::MX, "TXT" => Qtype::TXT, "DNAME" => Qtype::DNAME, + "TSIG" => Qtype::TSIG, "AXFR" => Qtype::AXFR, "MAILB" => Qtype::MAILB, "MAILA" => Qtype::MAILA, diff --git a/src/message/type_rtype.rs b/src/message/type_rtype.rs index 51629952..aeaeaea3 100644 --- a/src/message/type_rtype.rs +++ b/src/message/type_rtype.rs @@ -12,6 +12,7 @@ pub enum Rtype { MX, TXT, DNAME, + TSIG, UNKNOWN(u16), } @@ -31,6 +32,7 @@ impl Rtype{ Rtype::MX => 15, Rtype::TXT => 16, Rtype::DNAME => 39, + Rtype::TSIG => 250, Rtype::UNKNOWN(val) => val } } @@ -48,11 +50,12 @@ impl Rtype{ Rtype::MX => String::from("MX"), Rtype::TXT => String::from("TXT"), Rtype::DNAME => String::from("DNAME"), + Rtype::TSIG => String::from("TSIG"), Rtype::UNKNOWN(_val) => String::from("UNKNOWN TYPE") } } - /// Function to get the String equivalent of a type + /// Function to get the int equivalent of a type pub fn from_int_to_rtype(val: u16) -> Rtype{ match val { 1 => Rtype::A, @@ -66,6 +69,7 @@ impl Rtype{ 15 => Rtype::MX, 16 => Rtype::TXT, 39 => Rtype::DNAME, + 250 => Rtype::TSIG, _ => Rtype::UNKNOWN(val), } } @@ -84,6 +88,7 @@ impl Rtype{ "MX" => Rtype::MX, "TXT" => Rtype::TXT, "DNAME" => Rtype::DNAME, + "TSIG" => Rtype::TSIG, _ => Rtype::UNKNOWN(99), } }