From: Clément Galland Date: Thu, 19 Oct 2017 13:47:03 +0000 (+0000) Subject: Dns logger display flags information X-Git-Tag: suricata-4.1.0-beta1~495 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3396747cd657daa76f09a8744461c80589662460;p=thirdparty%2Fsuricata.git Dns logger display flags information --- diff --git a/rust/src/dns/log.rs b/rust/src/dns/log.rs index c1334ba3e9..58935bd923 100644 --- a/rust/src/dns/log.rs +++ b/rust/src/dns/log.rs @@ -379,6 +379,22 @@ fn dns_log_json_answer(header: &DNSHeader, answer: &DNSAnswerEntry) js.set_string("type", "answer"); js.set_integer("id", header.tx_id as u64); + js.set_string("flags", format!("{:x}", header.flags).as_str()); + if header.flags & 0x8000 != 0 { + js.set_boolean("qr", true); + } + if header.flags & 0x0400 != 0 { + js.set_boolean("aa", true); + } + if header.flags & 0x0200 != 0 { + js.set_boolean("tc", true); + } + if header.flags & 0x0100 != 0 { + js.set_boolean("rd", true); + } + if header.flags & 0x0080 != 0 { + js.set_boolean("ra", true); + } js.set_string("rcode", &dns_rcode_string(header.flags)); js.set_string_from_bytes("rrname", &answer.name); js.set_string("rrtype", &dns_rrtype_string(answer.rrtype)); diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 3e2aae735d..d18ca84b84 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -467,8 +467,19 @@ static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, /* dns */ char flags[7] = ""; - snprintf(flags, sizeof(flags), "0x%4x", tx->flags); + snprintf(flags, sizeof(flags), "%4x", tx->flags); json_object_set_new(js, "flags", json_string(flags)); + if (tx->flags & 0x8000) + json_object_set_new(js, "qr", json_true()); + if (tx->flags & 0x0400) + json_object_set_new(js, "aa", json_true()); + if (tx->flags & 0x0200) + json_object_set_new(js, "tc", json_true()); + if (tx->flags & 0x0100) + json_object_set_new(js, "rd", json_true()); + if (tx->flags & 0x0080) + json_object_set_new(js, "ra", json_true()); + /* rcode */ char rcode[16] = "";