Commit f5c39b07 authored by Evan Hunt's avatar Evan Hunt

[master] hex output mode for dnstap-read

4594.	[func]		"dnstap-read -x" prints a hex dump of the wire
			format of each logged DNS message. [RT #44816]
parent 95f7e98d
4594. [func] "dnstap-read -x" prints a hex dump of the wire
format of each logged DNS message. [RT #44816]
4593. [doc] Update README using markdown, remove outdated FAQ
file in favor of the knowledge base.
......
......@@ -94,16 +94,18 @@ BIND 9.12.0 is the newest development branch of BIND 9. It includes a
number of changes from BIND 9.11 and earlier releases. New features
include:
* dnstap-read -x prints a hex dump of the wire format of each logged DNS
message.
* The query handling code has been substantially refactored for improved
readability, maintainability and testability
readability, maintainability and testability .
* dnstap output files can now be configured to roll automatically when
reaching a given size
reaching a given size.
* Log file timestamps can now also be formatted in ISO 8601 (local) or
ISO 8601 (UTC) formats
ISO 8601 (UTC) formats.
* Logging channels and dnstap output files can now be configured to use
a timestamp as the suffix when rolling to a new file
* named-checkconf -l lists zones found in named.conf
* Added support for the EDNS Padding and Keepalive options
a timestamp as the suffix when rolling to a new file.
* named-checkconf -l lists zones found in named.conf.
* Added support for the EDNS Padding and Keepalive options.
Building BIND
......
......@@ -100,16 +100,18 @@ BIND 9.12.0 is the newest development branch of BIND 9. It includes a
number of changes from BIND 9.11 and earlier releases. New features
include:
* `dnstap-read -x` prints a hex dump of the wire format of each logged
DNS message.
* The query handling code has been substantially refactored for improved
readability, maintainability and testability
readability, maintainability and testability .
* `dnstap` output files can now be configured to roll automatically when
reaching a given size
reaching a given size.
* Log file timestamps can now also be formatted in ISO 8601 (local) or ISO
8601 (UTC) formats
8601 (UTC) formats.
* Logging channels and `dnstap` output files can now be configured to use a
timestamp as the suffix when rolling to a new file
* `named-checkconf -l` lists zones found in `named.conf`
* Added support for the EDNS Padding and Keepalive options
timestamp as the suffix when rolling to a new file.
* `named-checkconf -l` lists zones found in `named.conf`.
* Added support for the EDNS Padding and Keepalive options.
### <a name="build"/> Building BIND
......
......@@ -55,6 +55,7 @@ MDIG=$TOP/bin/tools/mdig
NZD2NZF=$TOP/bin/tools/named-nzd2nzf
FSTRM_CAPTURE=@FSTRM_CAPTURE@
FEATURETEST=$TOP/bin/tests/system/feature-test
WIRETEST=$TOP/bin/tests/wire_test
RANDFILE=$TOP/bin/tests/system/random.data
......@@ -172,3 +173,4 @@ export SAMPLEUPDATE
export SIGNER
export SUBDIRS
export TESTSOCK6
export WIRETEST
......@@ -10,7 +10,7 @@ rm -f */named.memstats
rm -f */named.run
rm -f */named.stats
rm -f dig.out*
rm -f dnstap.out
rm -f dnstap.out dnstap.hex
rm -f dnstap.out.save
rm -f fstrm_capture.out
rm -f ns*/dnstap.out
......
......@@ -357,6 +357,14 @@ if [ $HAS_PYYAML -ne 0 ] ; then
status=`expr $status + $ret`
fi
echo "I:checking dnstap-read hex output"
hex=`$DNSTAPREAD -x ns3/dnstap.out | tail -1`
echo $hex | $WIRETEST > dnstap.hex
grep 'status: NOERROR' dnstap.hex > /dev/null 2>&1 || ret=1
grep 'ANSWER: 3, AUTHORITY: 1' dnstap.hex > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo "I: failed"; fi
status=`expr $status + $ret`
if [ -n "$FSTRM_CAPTURE" ] ; then
$DIG +short @10.53.0.4 -p 5300 a.example > dig.out
......
......@@ -30,6 +30,7 @@
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/hex.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/string.h>
......@@ -45,6 +46,7 @@
isc_mem_t *mctx = NULL;
isc_boolean_t memrecord = ISC_FALSE;
isc_boolean_t printmessage = ISC_FALSE;
isc_boolean_t hexmessage = ISC_FALSE;
isc_boolean_t yaml = ISC_FALSE;
const char *program = "dnstap-read";
......@@ -76,9 +78,10 @@ fatal(const char *format, ...) {
static void
usage(void) {
fprintf(stderr, "dnstap-read [-mp] [filename]\n");
fprintf(stderr, "dnstap-read [-mpxy] [filename]\n");
fprintf(stderr, "\t-m\ttrace memory allocations\n");
fprintf(stderr, "\t-p\tprint the full DNS message\n");
fprintf(stderr, "\t-x\tuse hex format to print DNS message\n");
fprintf(stderr, "\t-y\tprint YAML format (implies -p)\n");
}
......@@ -100,6 +103,33 @@ print_dtdata(dns_dtdata_t *dt) {
isc_buffer_free(&b);
}
static void
print_hex(dns_dtdata_t *dt) {
isc_buffer_t *b = NULL;
isc_result_t result;
size_t textlen;
if (dt->msg == NULL) {
return;
}
textlen = (dt->msgdata.length * 2) + 1;
isc_buffer_allocate(mctx, &b, textlen);
if (b == NULL) {
fatal("out of memory");
}
result = isc_hex_totext(&dt->msgdata, 0, "", b);
CHECKM(result, "isc_hex_totext");
printf("%.*s\n", (int) isc_buffer_usedlength(b),
(char *) isc_buffer_base(b));
cleanup:
if (b != NULL)
isc_buffer_free(&b);
}
static void
print_packet(dns_dtdata_t *dt, const dns_master_style_t *style) {
isc_buffer_t *b = NULL;
......@@ -277,7 +307,7 @@ main(int argc, char *argv[]) {
dns_dthandle_t *handle = NULL;
int rv = 0, ch;
while ((ch = isc_commandline_parse(argc, argv, "mpy")) != -1) {
while ((ch = isc_commandline_parse(argc, argv, "mpxy")) != -1) {
switch (ch) {
case 'm':
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
......@@ -286,6 +316,9 @@ main(int argc, char *argv[]) {
case 'p':
printmessage = ISC_TRUE;
break;
case 'x':
hexmessage = ISC_TRUE;
break;
case 'y':
yaml = ISC_TRUE;
dns_master_indentstr = " ";
......@@ -338,6 +371,9 @@ main(int argc, char *argv[]) {
if (yaml) {
print_yaml(dt);
} else if (hexmessage) {
print_dtdata(dt);
print_hex(dt);
} else if (printmessage) {
print_dtdata(dt);
print_packet(dt, &dns_master_style_debug);
......
......@@ -40,6 +40,7 @@
<command>dnstap-read</command>
<arg choice="opt" rep="norepeat"><option>-m</option></arg>
<arg choice="opt" rep="norepeat"><option>-p</option></arg>
<arg choice="opt" rep="norepeat"><option>-x</option></arg>
<arg choice="opt" rep="norepeat"><option>-y</option></arg>
<arg choice="req" rep="norepeat"><replaceable class="parameter">file</replaceable></arg>
</cmdsynopsis>
......@@ -81,6 +82,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term>-x</term>
<listitem>
<para>
After printing the <command>dnstap</command> data, print
a hex dump of the wire form of the DNS message that was
encapsulated in the <command>dnstap</command> frame.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-y</term>
<listitem>
......
......@@ -149,6 +149,13 @@
<section xml:id="relnotes_features"><info><title>New Features</title></info>
<itemizedlist>
<listitem>
<para>
The <command>dnstap-read -x</command> option prints a hex
dump of the wire format DNS message encapsulated in each
<command>dnstap</command> log entry. [RT #44816]
</para>
</listitem>
<listitem>
<para>
The <command>host -A</command> option returns most
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment