Skip to content

Commit

Permalink
implementation of TSIG in qtype and rtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Litr0 committed Oct 31, 2023
1 parent 71e2551 commit b38784a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/message/type_qtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum Qtype {
TXT,
DNAME,
ANY,
TSIG,
AXFR,
MAILB,
MAILA,
Expand All @@ -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,
Expand All @@ -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"),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/message/type_rtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub enum Rtype {
MX,
TXT,
DNAME,
TSIG,
UNKNOWN(u16),
}

Expand All @@ -31,6 +32,7 @@ impl Rtype{
Rtype::MX => 15,
Rtype::TXT => 16,
Rtype::DNAME => 39,
Rtype::TSIG => 250,
Rtype::UNKNOWN(val) => val
}
}
Expand All @@ -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,
Expand All @@ -66,6 +69,7 @@ impl Rtype{
15 => Rtype::MX,
16 => Rtype::TXT,
39 => Rtype::DNAME,
250 => Rtype::TSIG,
_ => Rtype::UNKNOWN(val),
}
}
Expand All @@ -84,6 +88,7 @@ impl Rtype{
"MX" => Rtype::MX,
"TXT" => Rtype::TXT,
"DNAME" => Rtype::DNAME,
"TSIG" => Rtype::TSIG,
_ => Rtype::UNKNOWN(99),
}
}
Expand Down

0 comments on commit b38784a

Please sign in to comment.