Skip to content
Permalink
Browse files

dns: add SRV query and answer parsing

  • Loading branch information...
regit committed May 29, 2019
1 parent fa0008d commit 5508abeb38561eb37a0e1fbfc8f4f9a3118e8095
Showing with 14 additions and 0 deletions.
  1. +3 −0 rust/src/dns/log.rs
  2. +11 −0 rust/src/dns/parser.rs
@@ -433,6 +433,7 @@ fn dns_log_json_answer_detail(answer: &DNSAnswerEntry) -> Json
DNS_RECORD_TYPE_CNAME |
DNS_RECORD_TYPE_MX |
DNS_RECORD_TYPE_TXT |
DNS_RECORD_TYPE_SRV |
DNS_RECORD_TYPE_PTR => {
jsa.set_string_from_bytes("rdata", &answer.data);
},
@@ -503,6 +504,7 @@ fn dns_log_json_answer(response: &DNSResponse, flags: u64) -> Json
DNS_RECORD_TYPE_CNAME |
DNS_RECORD_TYPE_MX |
DNS_RECORD_TYPE_TXT |
DNS_RECORD_TYPE_SRV |
DNS_RECORD_TYPE_PTR => {
if !answer_types.contains_key(&type_string) {
answer_types.insert(type_string.to_string(),
@@ -637,6 +639,7 @@ fn dns_log_json_answer_v1(header: &DNSHeader, answer: &DNSAnswerEntry)
DNS_RECORD_TYPE_CNAME |
DNS_RECORD_TYPE_MX |
DNS_RECORD_TYPE_TXT |
DNS_RECORD_TYPE_SRV |
DNS_RECORD_TYPE_PTR => {
js.set_string_from_bytes("rdata", &answer.data);
},
@@ -270,6 +270,17 @@ pub fn dns_parse_rdata<'a>(input: &'a [u8], message: &'a [u8], rrtype: u16)
(name)
))(input)
},
DNS_RECORD_TYPE_SRV => {
// For SRV we skip over priority, weight and port (prov) fields before
// parsing out the name.
closure!(&'a [u8], do_parse!(
be_u16 >>
be_u16 >>
be_u16 >> // port we will need to parse it
name: apply!(dns_parse_name, message) >>
(name)
))(input)
},
DNS_RECORD_TYPE_TXT => {
closure!(&'a [u8], do_parse!(
len: be_u8 >>

0 comments on commit 5508abe

Please sign in to comment.
You can’t perform that action at this time.