diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2023-03-01 01:13:25 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2023-03-01 01:13:25 -0500 |
commit | b7676d06363f71b4a856c5f5815f75e2bf7ca8ec (patch) | |
tree | b7e188aa4e1abaa69b1b9ee4fb6cd5a0ad60637d /packet/src/query.rs | |
parent | gpl (diff) | |
download | wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.tar.gz wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.tar.bz2 wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.zip |
inital working dns
Diffstat (limited to 'packet/src/query.rs')
-rw-r--r-- | packet/src/query.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/packet/src/query.rs b/packet/src/query.rs new file mode 100644 index 0000000..ac993bd --- /dev/null +++ b/packet/src/query.rs @@ -0,0 +1,33 @@ +#[derive(PartialEq, Eq, Debug, Clone, Hash, Copy)] +pub enum QueryType { + UNKNOWN(u16), + A, // 1 + NS, // 2 + CNAME, // 5 + MX, // 15 + AAAA, // 28 +} + +impl QueryType { + pub fn to_num(&self) -> u16 { + match *self { + QueryType::UNKNOWN(x) => x, + QueryType::A => 1, + QueryType::NS => 2, + QueryType::CNAME => 5, + QueryType::MX => 15, + QueryType::AAAA => 28, + } + } + + pub fn from_num(num: u16) -> QueryType { + match num { + 1 => QueryType::A, + 2 => QueryType::NS, + 5 => QueryType::CNAME, + 15 => QueryType::MX, + 28 => QueryType::AAAA, + _ => QueryType::UNKNOWN(num), + } + } +}
\ No newline at end of file |