mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
[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]
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
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
|
4593. [doc] Update README using markdown, remove outdated FAQ
|
||||||
file in favor of the knowledge base.
|
file in favor of the knowledge base.
|
||||||
|
|
||||||
|
14
README
14
README
@@ -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
|
number of changes from BIND 9.11 and earlier releases. New features
|
||||||
include:
|
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
|
* 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
|
* 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
|
* 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
|
* Logging channels and dnstap output files can now be configured to use
|
||||||
a timestamp as the suffix when rolling to a new file
|
a timestamp as the suffix when rolling to a new file.
|
||||||
* named-checkconf -l lists zones found in named.conf
|
* named-checkconf -l lists zones found in named.conf.
|
||||||
* Added support for the EDNS Padding and Keepalive options
|
* Added support for the EDNS Padding and Keepalive options.
|
||||||
|
|
||||||
Building BIND
|
Building BIND
|
||||||
|
|
||||||
|
14
README.md
14
README.md
@@ -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
|
number of changes from BIND 9.11 and earlier releases. New features
|
||||||
include:
|
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
|
* 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
|
* `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
|
* 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
|
* Logging channels and `dnstap` output files can now be configured to use a
|
||||||
timestamp as the suffix when rolling to a new file
|
timestamp as the suffix when rolling to a new file.
|
||||||
* `named-checkconf -l` lists zones found in `named.conf`
|
* `named-checkconf -l` lists zones found in `named.conf`.
|
||||||
* Added support for the EDNS Padding and Keepalive options
|
* Added support for the EDNS Padding and Keepalive options.
|
||||||
|
|
||||||
### <a name="build"/> Building BIND
|
### <a name="build"/> Building BIND
|
||||||
|
|
||||||
|
@@ -55,6 +55,7 @@ MDIG=$TOP/bin/tools/mdig
|
|||||||
NZD2NZF=$TOP/bin/tools/named-nzd2nzf
|
NZD2NZF=$TOP/bin/tools/named-nzd2nzf
|
||||||
FSTRM_CAPTURE=@FSTRM_CAPTURE@
|
FSTRM_CAPTURE=@FSTRM_CAPTURE@
|
||||||
FEATURETEST=$TOP/bin/tests/system/feature-test
|
FEATURETEST=$TOP/bin/tests/system/feature-test
|
||||||
|
WIRETEST=$TOP/bin/tests/wire_test
|
||||||
|
|
||||||
RANDFILE=$TOP/bin/tests/system/random.data
|
RANDFILE=$TOP/bin/tests/system/random.data
|
||||||
|
|
||||||
@@ -172,3 +173,4 @@ export SAMPLEUPDATE
|
|||||||
export SIGNER
|
export SIGNER
|
||||||
export SUBDIRS
|
export SUBDIRS
|
||||||
export TESTSOCK6
|
export TESTSOCK6
|
||||||
|
export WIRETEST
|
||||||
|
@@ -10,7 +10,7 @@ rm -f */named.memstats
|
|||||||
rm -f */named.run
|
rm -f */named.run
|
||||||
rm -f */named.stats
|
rm -f */named.stats
|
||||||
rm -f dig.out*
|
rm -f dig.out*
|
||||||
rm -f dnstap.out
|
rm -f dnstap.out dnstap.hex
|
||||||
rm -f dnstap.out.save
|
rm -f dnstap.out.save
|
||||||
rm -f fstrm_capture.out
|
rm -f fstrm_capture.out
|
||||||
rm -f ns*/dnstap.out
|
rm -f ns*/dnstap.out
|
||||||
|
@@ -357,6 +357,14 @@ if [ $HAS_PYYAML -ne 0 ] ; then
|
|||||||
status=`expr $status + $ret`
|
status=`expr $status + $ret`
|
||||||
fi
|
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
|
if [ -n "$FSTRM_CAPTURE" ] ; then
|
||||||
$DIG +short @10.53.0.4 -p 5300 a.example > dig.out
|
$DIG +short @10.53.0.4 -p 5300 a.example > dig.out
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/commandline.h>
|
#include <isc/commandline.h>
|
||||||
|
#include <isc/hex.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/print.h>
|
#include <isc/print.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_boolean_t memrecord = ISC_FALSE;
|
isc_boolean_t memrecord = ISC_FALSE;
|
||||||
isc_boolean_t printmessage = ISC_FALSE;
|
isc_boolean_t printmessage = ISC_FALSE;
|
||||||
|
isc_boolean_t hexmessage = ISC_FALSE;
|
||||||
isc_boolean_t yaml = ISC_FALSE;
|
isc_boolean_t yaml = ISC_FALSE;
|
||||||
|
|
||||||
const char *program = "dnstap-read";
|
const char *program = "dnstap-read";
|
||||||
@@ -76,9 +78,10 @@ fatal(const char *format, ...) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
usage(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-m\ttrace memory allocations\n");
|
||||||
fprintf(stderr, "\t-p\tprint the full DNS message\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");
|
fprintf(stderr, "\t-y\tprint YAML format (implies -p)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +103,33 @@ print_dtdata(dns_dtdata_t *dt) {
|
|||||||
isc_buffer_free(&b);
|
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
|
static void
|
||||||
print_packet(dns_dtdata_t *dt, const dns_master_style_t *style) {
|
print_packet(dns_dtdata_t *dt, const dns_master_style_t *style) {
|
||||||
isc_buffer_t *b = NULL;
|
isc_buffer_t *b = NULL;
|
||||||
@@ -277,7 +307,7 @@ main(int argc, char *argv[]) {
|
|||||||
dns_dthandle_t *handle = NULL;
|
dns_dthandle_t *handle = NULL;
|
||||||
int rv = 0, ch;
|
int rv = 0, ch;
|
||||||
|
|
||||||
while ((ch = isc_commandline_parse(argc, argv, "mpy")) != -1) {
|
while ((ch = isc_commandline_parse(argc, argv, "mpxy")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'm':
|
case 'm':
|
||||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||||
@@ -286,6 +316,9 @@ main(int argc, char *argv[]) {
|
|||||||
case 'p':
|
case 'p':
|
||||||
printmessage = ISC_TRUE;
|
printmessage = ISC_TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
hexmessage = ISC_TRUE;
|
||||||
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
yaml = ISC_TRUE;
|
yaml = ISC_TRUE;
|
||||||
dns_master_indentstr = " ";
|
dns_master_indentstr = " ";
|
||||||
@@ -338,6 +371,9 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (yaml) {
|
if (yaml) {
|
||||||
print_yaml(dt);
|
print_yaml(dt);
|
||||||
|
} else if (hexmessage) {
|
||||||
|
print_dtdata(dt);
|
||||||
|
print_hex(dt);
|
||||||
} else if (printmessage) {
|
} else if (printmessage) {
|
||||||
print_dtdata(dt);
|
print_dtdata(dt);
|
||||||
print_packet(dt, &dns_master_style_debug);
|
print_packet(dt, &dns_master_style_debug);
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
<command>dnstap-read</command>
|
<command>dnstap-read</command>
|
||||||
<arg choice="opt" rep="norepeat"><option>-m</option></arg>
|
<arg choice="opt" rep="norepeat"><option>-m</option></arg>
|
||||||
<arg choice="opt" rep="norepeat"><option>-p</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="opt" rep="norepeat"><option>-y</option></arg>
|
||||||
<arg choice="req" rep="norepeat"><replaceable class="parameter">file</replaceable></arg>
|
<arg choice="req" rep="norepeat"><replaceable class="parameter">file</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
@@ -81,6 +82,17 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term>-y</term>
|
<term>-y</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@@ -149,6 +149,13 @@
|
|||||||
|
|
||||||
<section xml:id="relnotes_features"><info><title>New Features</title></info>
|
<section xml:id="relnotes_features"><info><title>New Features</title></info>
|
||||||
<itemizedlist>
|
<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>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The <command>host -A</command> option returns most
|
The <command>host -A</command> option returns most
|
||||||
|
Reference in New Issue
Block a user