From: Mark Andrews Date: Thu, 23 Jun 2016 23:37:04 +0000 (+1000) Subject: 4394. [func] Add rndc command "dnstap-reopen" to close and X-Git-Tag: v9.11.0b1~23 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=7d262a3647a517a86d6d83058aedd18b7a6b06df;p=thirdparty%2Fbind9.git 4394. [func] Add rndc command "dnstap-reopen" to close and reopen dnstap output filed. [RT #41803] --- diff --git a/CHANGES b/CHANGES index 810b749a4b1..2ba23ca48f0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4394. [func] Add rndc command "dnstap-reopen" to close and + reopen dnstap output filed. [RT #41803] + 4393. [bug] Address potential NULL pointer dereferences in dnstap code. diff --git a/bin/named/control.c b/bin/named/control.c index d947ebbfcae..67e44694542 100644 --- a/bin/named/control.c +++ b/bin/named/control.c @@ -281,6 +281,8 @@ ns_control_docommand(isccc_sexpr_t *message, isc_boolean_t readonly, result = ns_server_testgen(lex, text); } else if (command_compare(command, NS_COMMAND_MKEYS)) { result = ns_server_mkeys(ns_g_server, lex, text); + } else if (command_compare(command, NS_COMMAND_DNSTAPREOPEN)) { + result = ns_server_dnstap_reopen(ns_g_server); } else { isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_CONTROL, ISC_LOG_WARNING, diff --git a/bin/named/include/named/control.h b/bin/named/include/named/control.h index b271d402a84..70c5d4755c9 100644 --- a/bin/named/include/named/control.h +++ b/bin/named/include/named/control.h @@ -72,6 +72,7 @@ #define NS_COMMAND_NTA "nta" #define NS_COMMAND_TESTGEN "testgen" #define NS_COMMAND_MKEYS "managed-keys" +#define NS_COMMAND_DNSTAPREOPEN "dnstap-reopen" isc_result_t ns_controls_create(ns_server_t *server, ns_controls_t **ctrlsp); diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h index 18c4538e395..4f9b364739b 100644 --- a/bin/named/include/named/server.h +++ b/bin/named/include/named/server.h @@ -745,4 +745,10 @@ ns_server_testgen(isc_lex_t *lex, isc_buffer_t **text); isc_result_t ns_server_mkeys(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text); +/*% + * Close and reopen DNSTAP output file. + */ +isc_result_t +ns_server_dnstap_reopen(ns_server_t *server); + #endif /* NAMED_SERVER_H */ diff --git a/bin/named/server.c b/bin/named/server.c index 61433dab176..5e3e2b1cbcf 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -12189,3 +12189,16 @@ ns_server_mkeys(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text) { return (result); } + +isc_result_t +ns_server_dnstap_reopen(ns_server_t *server) { + +#if HAVE_DNSTAP + if (server->dtenv != NULL) + return(dns_dt_reopen(server->dtenv)); + return (ISC_R_NOTFOUND); +#else + UNUSED(server); + return (ISC_R_NOTIMPLEMENTED); +#endif +} diff --git a/bin/rndc/rndc.docbook b/bin/rndc/rndc.docbook index 39ed7d06f49..0f5fe195d94 100644 --- a/bin/rndc/rndc.docbook +++ b/bin/rndc/rndc.docbook @@ -44,6 +44,7 @@ 2013 2014 2015 + 2016 Internet Systems Consortium, Inc. ("ISC") @@ -313,6 +314,16 @@ + + dnstap-reopen + + + Close and re-open DNSTAP output files. This allows the files + to be renamed externally then to be re-opened. + + + + dumpdb -all|-cache|-zone|-adb|-bad|-fail view ... diff --git a/bin/tests/system/dnstap/clean.sh b/bin/tests/system/dnstap/clean.sh index 5003c135ad9..6cf3112d366 100644 --- a/bin/tests/system/dnstap/clean.sh +++ b/bin/tests/system/dnstap/clean.sh @@ -20,3 +20,4 @@ rm -f */named.stats rm -f dig.out* rm -f ns*/named.lock rm -f ns*/dnstap.out +rm -f ns*/dnstap.out.save diff --git a/bin/tests/system/dnstap/tests.sh b/bin/tests/system/dnstap/tests.sh index 54b35e96ed1..76133281ef7 100644 --- a/bin/tests/system/dnstap/tests.sh +++ b/bin/tests/system/dnstap/tests.sh @@ -21,6 +21,18 @@ RNDCCMD="$RNDC -p 9953 -c ../common/rndc.conf" status=0 +$DIG +short @10.53.0.3 -p 5300 a.example > dig.out + +mv ns1/dnstap.out ns1/dnstap.out.save +mv ns2/dnstap.out ns2/dnstap.out.save +mv ns3/dnstap.out ns3/dnstap.out.save + +sleep 2 + +$RNDCCMD -s 10.53.0.1 dnstap-reopen | sed 's/^/I:ns1 /' +$RNDCCMD -s 10.53.0.2 dnstap-reopen | sed 's/^/I:ns2 /' +$RNDCCMD -s 10.53.0.3 dnstap-reopen | sed 's/^/I:ns3 /' + $DIG +short @10.53.0.3 -p 5300 a.example > dig.out sleep 1 @@ -34,34 +46,35 @@ $RNDCCMD -s 10.53.0.2 stop | sed 's/^/I:ns2 /' $RNDCCMD -s 10.53.0.3 stop | sed 's/^/I:ns3 /' sleep 1 -udp1=`$DNSTAPREAD ns1/dnstap.out | grep "UDP " | wc -l` -tcp1=`$DNSTAPREAD ns1/dnstap.out | grep "TCP " | wc -l` -aq1=`$DNSTAPREAD ns1/dnstap.out | grep "AQ " | wc -l` -ar1=`$DNSTAPREAD ns1/dnstap.out | grep "AR " | wc -l` -cq1=`$DNSTAPREAD ns1/dnstap.out | grep "CQ " | wc -l` -cr1=`$DNSTAPREAD ns1/dnstap.out | grep "CR " | wc -l` -rq1=`$DNSTAPREAD ns1/dnstap.out | grep "RQ " | wc -l` -rr1=`$DNSTAPREAD ns1/dnstap.out | grep "RR " | wc -l` +udp1=`$DNSTAPREAD ns1/dnstap.out.save | grep "UDP " | wc -l` +tcp1=`$DNSTAPREAD ns1/dnstap.out.save | grep "TCP " | wc -l` +aq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "AQ " | wc -l` +ar1=`$DNSTAPREAD ns1/dnstap.out.save | grep "AR " | wc -l` +cq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "CQ " | wc -l` +cr1=`$DNSTAPREAD ns1/dnstap.out.save | grep "CR " | wc -l` +rq1=`$DNSTAPREAD ns1/dnstap.out.save | grep "RQ " | wc -l` +rr1=`$DNSTAPREAD ns1/dnstap.out.save | grep "RR " | wc -l` -udp2=`$DNSTAPREAD ns2/dnstap.out | grep "UDP " | wc -l` -tcp2=`$DNSTAPREAD ns2/dnstap.out | grep "TCP " | wc -l` -aq2=`$DNSTAPREAD ns2/dnstap.out | grep "AQ " | wc -l` -ar2=`$DNSTAPREAD ns2/dnstap.out | grep "AR " | wc -l` -cq2=`$DNSTAPREAD ns2/dnstap.out | grep "CQ " | wc -l` -cr2=`$DNSTAPREAD ns2/dnstap.out | grep "CR " | wc -l` -rq2=`$DNSTAPREAD ns2/dnstap.out | grep "RQ " | wc -l` -rr2=`$DNSTAPREAD ns2/dnstap.out | grep "RR " | wc -l` +udp2=`$DNSTAPREAD ns2/dnstap.out.save | grep "UDP " | wc -l` +tcp2=`$DNSTAPREAD ns2/dnstap.out.save | grep "TCP " | wc -l` +aq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "AQ " | wc -l` +ar2=`$DNSTAPREAD ns2/dnstap.out.save | grep "AR " | wc -l` +cq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "CQ " | wc -l` +cr2=`$DNSTAPREAD ns2/dnstap.out.save | grep "CR " | wc -l` +rq2=`$DNSTAPREAD ns2/dnstap.out.save | grep "RQ " | wc -l` +rr2=`$DNSTAPREAD ns2/dnstap.out.save | grep "RR " | wc -l` -udp3=`$DNSTAPREAD ns3/dnstap.out | grep "UDP " | wc -l` -tcp3=`$DNSTAPREAD ns3/dnstap.out | grep "TCP " | wc -l` -aq3=`$DNSTAPREAD ns3/dnstap.out | grep "AQ " | wc -l` -ar3=`$DNSTAPREAD ns3/dnstap.out | grep "AR " | wc -l` -cq3=`$DNSTAPREAD ns3/dnstap.out | grep "CQ " | wc -l` -cr3=`$DNSTAPREAD ns3/dnstap.out | grep "CR " | wc -l` -rq3=`$DNSTAPREAD ns3/dnstap.out | grep "RQ " | wc -l` -rr3=`$DNSTAPREAD ns3/dnstap.out | grep "RR " | wc -l` +udp3=`$DNSTAPREAD ns3/dnstap.out.save | grep "UDP " | wc -l` +tcp3=`$DNSTAPREAD ns3/dnstap.out.save | grep "TCP " | wc -l` +aq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "AQ " | wc -l` +ar3=`$DNSTAPREAD ns3/dnstap.out.save | grep "AR " | wc -l` +cq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "CQ " | wc -l` +cr3=`$DNSTAPREAD ns3/dnstap.out.save | grep "CR " | wc -l` +rq3=`$DNSTAPREAD ns3/dnstap.out.save | grep "RQ " | wc -l` +rr3=`$DNSTAPREAD ns3/dnstap.out.save | grep "RR " | wc -l` -echo "I:checking UDP message counts" +echo "I:checking initial message counts" +echo "I: checking UDP message counts" ret=0 [ $udp1 -eq 0 ] || { echo "ns1 $udp1 expected 0" ; ret=1 @@ -72,10 +85,10 @@ ret=0 [ $udp3 -eq 4 ] || { echo "ns3 $udp3 expected 4" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking TCP message counts" +echo "I: checking TCP message counts" ret=0 [ $tcp1 -eq 6 ] || { echo "ns1 $tcp1 expected 6" ; ret=1 @@ -86,10 +99,10 @@ ret=0 [ $tcp3 -eq 6 ] || { echo "ns3 $tcp3 expected 6" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking AUTH_QUERY message counts" +echo "I: checking AUTH_QUERY message counts" ret=0 [ $aq1 -eq 2 ] || { echo "ns1 $aq1 exepcted 2" ; ret=1 @@ -100,10 +113,10 @@ ret=0 [ $aq3 -eq 0 ] || { echo "ns3 $aq3 expected 0" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking AUTH_RESPONSE message counts" +echo "I: checking AUTH_RESPONSE message counts" ret=0 [ $ar1 -eq 2 ] || { echo "ns1 $ar1 expected 2" ; ret=1 @@ -114,10 +127,10 @@ ret=0 [ $ar3 -eq 0 ] || { echo "ns3 $ar3 expected 0" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking CLIENT_QUERY message counts" +echo "I: checking CLIENT_QUERY message counts" ret=0 [ $cq1 -eq 1 ] || { echo "ns1 $cq1 expected 1" ; ret=1 @@ -128,10 +141,10 @@ ret=0 [ $cq3 -eq 2 ] || { echo "ns3 $cq3 expected 2" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking CLIENT_RESPONSE message counts" +echo "I: checking CLIENT_RESPONSE message counts" ret=0 [ $cr1 -eq 1 ] || { echo "ns1 $cr1 expected 1" ; ret=1 @@ -142,10 +155,10 @@ ret=0 [ $cr3 -eq 2 ] || { echo "ns3 $cr3 expected 2" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking RESOLVER_QUERY message counts" +echo "I: checking RESOLVER_QUERY message counts" ret=0 [ $rq1 -eq 0 ] || { echo "ns1 $rq1 expected 0" ; ret=1 @@ -156,10 +169,10 @@ ret=0 [ $rq3 -eq 3 ] || { echo "ns3 $rq3 expected 3" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` -echo "I:checking RESOLVER_RESPONSE message counts" +echo "I: checking RESOLVER_RESPONSE message counts" ret=0 [ $rr1 -eq 0 ] || { echo "ns1 $rr1 expected 0" ; ret=1 @@ -170,7 +183,148 @@ ret=0 [ $rr3 -eq 3 ] || { echo "ns3 $rr3 expected 3" ; ret=1 } -if [ $ret != 0 ]; then echo "I:failed"; fi +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +udp1=`$DNSTAPREAD ns1/dnstap.out | grep "UDP " | wc -l` +tcp1=`$DNSTAPREAD ns1/dnstap.out | grep "TCP " | wc -l` +aq1=`$DNSTAPREAD ns1/dnstap.out | grep "AQ " | wc -l` +ar1=`$DNSTAPREAD ns1/dnstap.out | grep "AR " | wc -l` +cq1=`$DNSTAPREAD ns1/dnstap.out | grep "CQ " | wc -l` +cr1=`$DNSTAPREAD ns1/dnstap.out | grep "CR " | wc -l` +rq1=`$DNSTAPREAD ns1/dnstap.out | grep "RQ " | wc -l` +rr1=`$DNSTAPREAD ns1/dnstap.out | grep "RR " | wc -l` + +udp2=`$DNSTAPREAD ns2/dnstap.out | grep "UDP " | wc -l` +tcp2=`$DNSTAPREAD ns2/dnstap.out | grep "TCP " | wc -l` +aq2=`$DNSTAPREAD ns2/dnstap.out | grep "AQ " | wc -l` +ar2=`$DNSTAPREAD ns2/dnstap.out | grep "AR " | wc -l` +cq2=`$DNSTAPREAD ns2/dnstap.out | grep "CQ " | wc -l` +cr2=`$DNSTAPREAD ns2/dnstap.out | grep "CR " | wc -l` +rq2=`$DNSTAPREAD ns2/dnstap.out | grep "RQ " | wc -l` +rr2=`$DNSTAPREAD ns2/dnstap.out | grep "RR " | wc -l` + +udp3=`$DNSTAPREAD ns3/dnstap.out | grep "UDP " | wc -l` +tcp3=`$DNSTAPREAD ns3/dnstap.out | grep "TCP " | wc -l` +aq3=`$DNSTAPREAD ns3/dnstap.out | grep "AQ " | wc -l` +ar3=`$DNSTAPREAD ns3/dnstap.out | grep "AR " | wc -l` +cq3=`$DNSTAPREAD ns3/dnstap.out | grep "CQ " | wc -l` +cr3=`$DNSTAPREAD ns3/dnstap.out | grep "CR " | wc -l` +rq3=`$DNSTAPREAD ns3/dnstap.out | grep "RQ " | wc -l` +rr3=`$DNSTAPREAD ns3/dnstap.out | grep "RR " | wc -l` + +echo "I:checking reopened message counts" + +echo "I: checking UDP message counts" +ret=0 +[ $udp1 -eq 0 ] || { + echo "ns1 $udp1 expected 0" ; ret=1 +} +[ $udp2 -eq 0 ] || { + echo "ns2 $udp2 expected 0" ; ret=1 +} +[ $udp3 -eq 2 ] || { + echo "ns3 $udp3 expected 2" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking TCP message counts" +ret=0 +[ $tcp1 -eq 0 ] || { + echo "ns1 $tcp1 expected 0" ; ret=1 +} +[ $tcp2 -eq 0 ] || { + echo "ns2 $tcp2 expected 0" ; ret=1 +} +[ $tcp3 -eq 0 ] || { + echo "ns3 $tcp3 expected 0" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking AUTH_QUERY message counts" +ret=0 +[ $aq1 -eq 0 ] || { + echo "ns1 $aq1 exepcted 0" ; ret=1 +} +[ $aq2 -eq 0 ] || { + echo "ns2 $aq2 expected 0" ; ret=1 +} +[ $aq3 -eq 0 ] || { + echo "ns3 $aq3 expected 0" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking AUTH_RESPONSE message counts" +ret=0 +[ $ar1 -eq 0 ] || { + echo "ns1 $ar1 expected 0" ; ret=1 +} +[ $ar2 -eq 0 ] || { + echo "ns2 $ar2 expected 0" ; ret=1 +} +[ $ar3 -eq 0 ] || { + echo "ns3 $ar3 expected 0" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking CLIENT_QUERY message counts" +ret=0 +[ $cq1 -eq 0 ] || { + echo "ns1 $cq1 expected 0" ; ret=1 +} +[ $cq2 -eq 0 ] || { + echo "ns2 $cq2 expected 0" ; ret=1 +} +[ $cq3 -eq 1 ] || { + echo "ns3 $cq3 expected 1" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking CLIENT_RESPONSE message counts" +ret=0 +[ $cr1 -eq 0 ] || { + echo "ns1 $cr1 expected 0" ; ret=1 +} +[ $cr2 -eq 0 ] || { + echo "ns2 $cr2 expected 0" ; ret=1 +} +[ $cr3 -eq 1 ] || { + echo "ns3 $cr3 expected 1" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking RESOLVER_QUERY message counts" +ret=0 +[ $rq1 -eq 0 ] || { + echo "ns1 $rq1 expected 0" ; ret=1 +} +[ $rq2 -eq 0 ] || { + echo "ns2 $rq2 expected 0" ; ret=1 +} +[ $rq3 -eq 0 ] || { + echo "ns3 $rq3 expected 0" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi +status=`expr $status + $ret` + +echo "I: checking RESOLVER_RESPONSE message counts" +ret=0 +[ $rr1 -eq 0 ] || { + echo "ns1 $rr1 expected 0" ; ret=1 +} +[ $rr2 -eq 0 ] || { + echo "ns2 $rr2 expected 0" ; ret=1 +} +[ $rr3 -eq 0 ] || { + echo "ns3 $rr3 expected 0" ; ret=1 +} +if [ $ret != 0 ]; then echo "I: failed"; fi status=`expr $status + $ret` echo "I:exit status: $status" diff --git a/configure b/configure index 3cddc2722cd..47f723a4c51 100755 --- a/configure +++ b/configure @@ -705,6 +705,7 @@ W3M DBLATEX PDFLATEX LATEX +DNSTAP_PB_C_H DNSTAPHTML DNSTAPMAN DNSTAPTARGETS @@ -20263,11 +20264,12 @@ DNSTAPOBJS= DNSTAPTARGETS= DNSTAPMAN= DNSTAPHTML= +DNSTAP_PB_C_H= if test "x$use_dnstap" != "xno"; then - if ! $use_threads; then - as_fn_error $? "Dnstap requires threads." "$LINENO" 5 - fi - # Extract the first word of "protoc-c", so it can be a program name with args. + if ! $use_threads; then + as_fn_error $? "Dnstap requires threads." "$LINENO" 5 + fi + # Extract the first word of "protoc-c", so it can be a program name with args. set dummy protoc-c; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } @@ -20307,38 +20309,38 @@ $as_echo "no" >&6; } fi - if test -z "$PROTOC_C"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The protoc-c program was not found." >&5 + if test -z "$PROTOC_C"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The protoc-c program was not found." >&5 $as_echo "$as_me: WARNING: The protoc-c program was not found." >&2;} - fi + fi # Check whether --with-protobuf-c was given. if test "${with_protobuf_c+set}" = set; then : withval=$with_protobuf_c; - # workaround for protobuf-c includes at old dir - # before protobuf-c-1.0.0 - if test -f $withval/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I$withval/include/google" - else - CFLAGS="$CFLAGS -I$withval/include" - fi - LDFLAGS="$LDFLAGS -L$withval/lib" + # workaround for protobuf-c includes at old dir + # before protobuf-c-1.0.0 + if test -f $withval/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I$withval/include/google" + else + CFLAGS="$CFLAGS -I$withval/include" + fi + LDFLAGS="$LDFLAGS -L$withval/lib" else - # workaround for protobuf-c includes at old dir - # before protobuf-c-1.0.0 - if test -f /usr/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I/usr/include/google" - else - if test -f /usr/local/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I/usr/local/include/google" - LDFLAGS="$LDFLAGS -L/usr/local/lib" - fi - fi + # workaround for protobuf-c includes at old dir + # before protobuf-c-1.0.0 + if test -f /usr/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I/usr/include/google" + else + if test -f /usr/local/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I/usr/local/include/google" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + fi + fi fi @@ -20346,13 +20348,13 @@ fi # Check whether --with-libfstrm was given. if test "${with_libfstrm+set}" = set; then : withval=$with_libfstrm; - CFLAGS="$CFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" + CFLAGS="$CFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fstrm_iothr_init" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fstrm_iothr_init" >&5 $as_echo_n "checking for library containing fstrm_iothr_init... " >&6; } if ${ac_cv_search_fstrm_iothr_init+:} false; then : $as_echo_n "(cached) " >&6 @@ -20410,7 +20412,7 @@ else as_fn_error $? "The fstrm library was not found. Please install fstrm!" "$LINENO" 5 fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing protobuf_c_message_pack" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing protobuf_c_message_pack" >&5 $as_echo_n "checking for library containing protobuf_c_message_pack... " >&6; } if ${ac_cv_search_protobuf_c_message_pack+:} false; then : $as_echo_n "(cached) " >&6 @@ -20472,12 +20474,13 @@ fi $as_echo "#define HAVE_DNSTAP 1" >>confdefs.h - DNSTAP=dnstap - DNSTAPSRCS='${DNSTAPSRCS}' - DNSTAPOBJS='${DNSTAPOBJS}' - DNSTAPTARGETS='${DNSTAPTARGETS}' - DNSTAPMAN='${DNSTAPMAN}' - DNSTAPHTML='${DNSTAPHTML}' + DNSTAP=dnstap + DNSTAPSRCS='${DNSTAPSRCS}' + DNSTAPOBJS='${DNSTAPOBJS}' + DNSTAPTARGETS='${DNSTAPTARGETS}' + DNSTAPMAN='${DNSTAPMAN}' + DNSTAPHTML='${DNSTAPHTML}' + DNSTAP_PB_C_H="dnstap.pb-c.h" fi @@ -20486,6 +20489,7 @@ fi + # # The following sets up how non-blocking i/o is established. # Sunos, cygwin and solaris 2.x (x<5) require special handling. diff --git a/configure.in b/configure.in index a9aa6832682..fc48e474dd8 100644 --- a/configure.in +++ b/configure.in @@ -4099,58 +4099,60 @@ DNSTAPOBJS= DNSTAPTARGETS= DNSTAPMAN= DNSTAPHTML= +DNSTAP_PB_C_H= if test "x$use_dnstap" != "xno"; then - if ! $use_threads; then - AC_MSG_ERROR([Dnstap requires threads.]) - fi - AC_PATH_PROG([PROTOC_C], [protoc-c]) - if test -z "$PROTOC_C"; then - AC_MSG_WARN([The protoc-c program was not found.]) - fi - AC_ARG_WITH([protobuf-c], - AC_HELP_STRING([--with-protobuf-c=path], - [Path where protobuf-c is installed, for dnstap]), [ - # workaround for protobuf-c includes at old dir - # before protobuf-c-1.0.0 - if test -f $withval/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I$withval/include/google" - else - CFLAGS="$CFLAGS -I$withval/include" - fi - LDFLAGS="$LDFLAGS -L$withval/lib" - ], [ - # workaround for protobuf-c includes at old dir - # before protobuf-c-1.0.0 - if test -f /usr/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I/usr/include/google" - else - if test -f /usr/local/include/google/protobuf-c/protobuf-c.h - then - CFLAGS="$CFLAGS -I/usr/local/include/google" - LDFLAGS="$LDFLAGS -L/usr/local/lib" - fi - fi - ]) - AC_ARG_WITH([libfstrm], AC_HELP_STRING([--with-libfstrm=path], - [Path where libfstrm is installed, for dnstap]), [ - CFLAGS="$CFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - ]) - - AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [], - AC_MSG_ERROR([The fstrm library was not found. Please install fstrm!])) - AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [], - AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!])) - - AC_DEFINE(HAVE_DNSTAP, 1, [Define to 1 to enable dnstap support]) - DNSTAP=dnstap - DNSTAPSRCS='${DNSTAPSRCS}' - DNSTAPOBJS='${DNSTAPOBJS}' - DNSTAPTARGETS='${DNSTAPTARGETS}' - DNSTAPMAN='${DNSTAPMAN}' - DNSTAPHTML='${DNSTAPHTML}' + if ! $use_threads; then + AC_MSG_ERROR([Dnstap requires threads.]) + fi + AC_PATH_PROG([PROTOC_C], [protoc-c]) + if test -z "$PROTOC_C"; then + AC_MSG_WARN([The protoc-c program was not found.]) + fi + AC_ARG_WITH([protobuf-c], + AC_HELP_STRING([--with-protobuf-c=path], + [Path where protobuf-c is installed, for dnstap]), [ + # workaround for protobuf-c includes at old dir + # before protobuf-c-1.0.0 + if test -f $withval/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I$withval/include/google" + else + CFLAGS="$CFLAGS -I$withval/include" + fi + LDFLAGS="$LDFLAGS -L$withval/lib" + ], [ + # workaround for protobuf-c includes at old dir + # before protobuf-c-1.0.0 + if test -f /usr/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I/usr/include/google" + else + if test -f /usr/local/include/google/protobuf-c/protobuf-c.h + then + CFLAGS="$CFLAGS -I/usr/local/include/google" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + fi + fi + ]) + AC_ARG_WITH([libfstrm], AC_HELP_STRING([--with-libfstrm=path], + [Path where libfstrm is installed, for dnstap]), [ + CFLAGS="$CFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + ]) + + AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [], + AC_MSG_ERROR([The fstrm library was not found. Please install fstrm!])) + AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [], + AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!])) + + AC_DEFINE(HAVE_DNSTAP, 1, [Define to 1 to enable dnstap support]) + DNSTAP=dnstap + DNSTAPSRCS='${DNSTAPSRCS}' + DNSTAPOBJS='${DNSTAPOBJS}' + DNSTAPTARGETS='${DNSTAPTARGETS}' + DNSTAPMAN='${DNSTAPMAN}' + DNSTAPHTML='${DNSTAPHTML}' + DNSTAP_PB_C_H="dnstap.pb-c.h" fi AC_SUBST(DNSTAP) AC_SUBST(DNSTAPSRCS) @@ -4158,6 +4160,7 @@ AC_SUBST(DNSTAPOBJS) AC_SUBST(DNSTAPTARGETS) AC_SUBST(DNSTAPMAN) AC_SUBST(DNSTAPHTML) +AC_SUBST(DNSTAP_PB_C_H) # # The following sets up how non-blocking i/o is established. diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index b0993c46979..dc65998055d 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -165,6 +165,10 @@ to allow dnstap data to be presented in a human-readable format. + + rndc dnstap-reopen can be used reopen + dnstap output files after renaming them. + For more information on dnstap, see http://dnstap.info. diff --git a/lib/dns/.gitignore b/lib/dns/.gitignore index d6a4772a275..66c95ddd79a 100644 --- a/lib/dns/.gitignore +++ b/lib/dns/.gitignore @@ -5,3 +5,5 @@ enumclass.h enumtype.h rdatastruct.h gen.dSYM +dnstap.pb-c.c +dnstap.pb-c.h \ No newline at end of file diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index 95aae2ccda4..3144ecf5c84 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -83,8 +83,8 @@ DNSOBJS = acache.@O@ acl.@O@ adb.@O@ badcache.@O@ byaddr.@O@ \ version.@O@ view.@O@ xfrin.@O@ zone.@O@ zonekey.@O@ zt.@O@ PORTDNSOBJS = client.@O@ ecdb.@O@ -OBJS= ${DNSOBJS} ${OTHEROBJS} ${DSTOBJS} ${PORTDNSOBJS} \ - @DNSTAPOBJS@ @GEOIPLINKOBJS@ +OBJS= @DNSTAPOBJS@ ${DNSOBJS} ${OTHEROBJS} ${DSTOBJS} \ + ${PORTDNSOBJS} @GEOIPLINKOBJS@ # Alphabetically @@ -168,6 +168,7 @@ clean distclean:: rm -f libdns.@A@ timestamp rm -f gen code.h include/dns/enumtype.h include/dns/enumclass.h rm -f include/dns/rdatastruct.h + rm -f dnstap.pb-c.c dnstap.pb-c.h include/dns/dnstap.pb-c.h newrr:: rm -f code.h include/dns/enumtype.h include/dns/enumclass.h diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index b475174e330..387c6ae8029 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -90,6 +90,20 @@ struct dns_dtmsg { Dnstap__Message m; }; +struct dns_dtenv { + unsigned int magic; + isc_refcount_t refcount; + + isc_mem_t *mctx; + + struct fstrm_iothr *iothr; + struct fstrm_writer *fw; + + isc_region_t identity; + isc_region_t version; + char *path; +}; + #define CHECK(x) do { \ result = (x); \ if (result != ISC_R_SUCCESS) \ @@ -174,6 +188,9 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, memset(env, 0, sizeof(dns_dtenv_t)); CHECK(isc_refcount_init(&env->refcount, 1)); + env->path = isc_mem_strdup(mctx, path); + if (env->path == NULL) + CHECK(ISC_R_NOMEMORY); fwopt = fstrm_writer_options_init(); if (fwopt == NULL) @@ -189,13 +206,14 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, if (mode == dns_dtmode_file) { ffwopt = fstrm_file_options_init(); if (ffwopt != NULL) { - fstrm_file_options_set_file_path(ffwopt, path); + fstrm_file_options_set_file_path(ffwopt, env->path); fw = fstrm_file_writer_init(ffwopt, fwopt); } } else if (mode == dns_dtmode_unix) { fuwopt = fstrm_unix_writer_options_init(); if (fuwopt != NULL) { - fstrm_unix_writer_options_set_socket_path(fuwopt, path); + fstrm_unix_writer_options_set_socket_path(fuwopt, + env->path); fw = fstrm_unix_writer_init(fuwopt, fwopt); } } else @@ -207,11 +225,16 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, fopt = fstrm_iothr_options_init(); fstrm_iothr_options_set_num_input_queues(fopt, workers); + /* + * Remember 'fw' so we can close and reopen it later. + */ + env->fw = fw; env->iothr = fstrm_iothr_init(fopt, &fw); if (env->iothr == NULL) { isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSTAP, DNS_LOGMODULE_DNSTAP, ISC_LOG_WARNING, "unable to initialize dnstap I/O thread"); + env->fw = NULL; fstrm_writer_destroy(&fw); CHECK(ISC_R_FAILURE); } @@ -235,6 +258,8 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, if (env != NULL) { if (env->mctx != NULL) isc_mem_detach(&env->mctx); + if (env->path != NULL) + isc_mem_free(mctx, env->path); isc_mem_put(mctx, env, sizeof(dns_dtenv_t)); } } @@ -242,6 +267,30 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, return (result); } +isc_result_t +dns_dt_reopen(dns_dtenv_t *env) { + isc_result_t result = ISC_R_SUCCESS; + fstrm_res res; + + REQUIRE(VALID_DTENV(env)); + + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSTAP, + DNS_LOGMODULE_DNSTAP, ISC_LOG_INFO, + "reopening dnstap destination '%s'", + env->path); + + if (env->fw != NULL) { + res = fstrm_writer_close(env->fw); + if (res == fstrm_res_success) + fstrm_writer_open(env->fw); + return (ISC_R_SUCCESS); + } + + + + return (result); +} + static isc_result_t toregion(dns_dtenv_t *env, isc_region_t *r, const char *str) { unsigned char *p = NULL; @@ -332,6 +381,8 @@ destroy(dns_dtenv_t *env) { isc_mem_free(env->mctx, env->version.base); env->version.length = 0; } + if (env->path != NULL) + isc_mem_free(env->mctx, env->path); isc_mem_putanddetach(&env->mctx, env, sizeof(*env)); } diff --git a/lib/dns/dnstap.pb-c.c b/lib/dns/dnstap.pb-c.c deleted file mode 100644 index 50000bd6493..00000000000 --- a/lib/dns/dnstap.pb-c.c +++ /dev/null @@ -1,523 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: dnstap.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "dnstap.pb-c.h" -void dnstap__dnstap__init - (Dnstap__Dnstap *message) -{ - static Dnstap__Dnstap init_value = DNSTAP__DNSTAP__INIT; - *message = init_value; -} -size_t dnstap__dnstap__get_packed_size - (const Dnstap__Dnstap *message) -{ - assert(message->base.descriptor == &dnstap__dnstap__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t dnstap__dnstap__pack - (const Dnstap__Dnstap *message, - uint8_t *out) -{ - assert(message->base.descriptor == &dnstap__dnstap__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t dnstap__dnstap__pack_to_buffer - (const Dnstap__Dnstap *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &dnstap__dnstap__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -Dnstap__Dnstap * - dnstap__dnstap__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (Dnstap__Dnstap *) - protobuf_c_message_unpack (&dnstap__dnstap__descriptor, - allocator, len, data); -} -void dnstap__dnstap__free_unpacked - (Dnstap__Dnstap *message, - ProtobufCAllocator *allocator) -{ - assert(message->base.descriptor == &dnstap__dnstap__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void dnstap__message__init - (Dnstap__Message *message) -{ - static Dnstap__Message init_value = DNSTAP__MESSAGE__INIT; - *message = init_value; -} -size_t dnstap__message__get_packed_size - (const Dnstap__Message *message) -{ - assert(message->base.descriptor == &dnstap__message__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t dnstap__message__pack - (const Dnstap__Message *message, - uint8_t *out) -{ - assert(message->base.descriptor == &dnstap__message__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t dnstap__message__pack_to_buffer - (const Dnstap__Message *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &dnstap__message__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -Dnstap__Message * - dnstap__message__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (Dnstap__Message *) - protobuf_c_message_unpack (&dnstap__message__descriptor, - allocator, len, data); -} -void dnstap__message__free_unpacked - (Dnstap__Message *message, - ProtobufCAllocator *allocator) -{ - assert(message->base.descriptor == &dnstap__message__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -static const ProtobufCEnumValue dnstap__dnstap__type__enum_values_by_number[1] = -{ - { "MESSAGE", "DNSTAP__DNSTAP__TYPE__MESSAGE", 1 }, -}; -static const ProtobufCIntRange dnstap__dnstap__type__value_ranges[] = { -{1, 0},{0, 1} -}; -static const ProtobufCEnumValueIndex dnstap__dnstap__type__enum_values_by_name[1] = -{ - { "MESSAGE", 0 }, -}; -const ProtobufCEnumDescriptor dnstap__dnstap__type__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "dnstap.Dnstap.Type", - "Type", - "Dnstap__Dnstap__Type", - "dnstap", - 1, - dnstap__dnstap__type__enum_values_by_number, - 1, - dnstap__dnstap__type__enum_values_by_name, - 1, - dnstap__dnstap__type__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; -static const ProtobufCFieldDescriptor dnstap__dnstap__field_descriptors[5] = -{ - { - "identity", - 1, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Dnstap, has_identity), - offsetof(Dnstap__Dnstap, identity), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "version", - 2, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Dnstap, has_version), - offsetof(Dnstap__Dnstap, version), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "extra", - 3, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Dnstap, has_extra), - offsetof(Dnstap__Dnstap, extra), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "message", - 14, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_MESSAGE, - 0, /* quantifier_offset */ - offsetof(Dnstap__Dnstap, message), - &dnstap__message__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "type", - 15, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(Dnstap__Dnstap, type), - &dnstap__dnstap__type__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned dnstap__dnstap__field_indices_by_name[] = { - 2, /* field[2] = extra */ - 0, /* field[0] = identity */ - 3, /* field[3] = message */ - 4, /* field[4] = type */ - 1, /* field[1] = version */ -}; -static const ProtobufCIntRange dnstap__dnstap__number_ranges[2 + 1] = -{ - { 1, 0 }, - { 14, 3 }, - { 0, 5 } -}; -const ProtobufCMessageDescriptor dnstap__dnstap__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "dnstap.Dnstap", - "Dnstap", - "Dnstap__Dnstap", - "dnstap", - sizeof(Dnstap__Dnstap), - 5, - dnstap__dnstap__field_descriptors, - dnstap__dnstap__field_indices_by_name, - 2, dnstap__dnstap__number_ranges, - (ProtobufCMessageInit) dnstap__dnstap__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue dnstap__message__type__enum_values_by_number[12] = -{ - { "AUTH_QUERY", "DNSTAP__MESSAGE__TYPE__AUTH_QUERY", 1 }, - { "AUTH_RESPONSE", "DNSTAP__MESSAGE__TYPE__AUTH_RESPONSE", 2 }, - { "RESOLVER_QUERY", "DNSTAP__MESSAGE__TYPE__RESOLVER_QUERY", 3 }, - { "RESOLVER_RESPONSE", "DNSTAP__MESSAGE__TYPE__RESOLVER_RESPONSE", 4 }, - { "CLIENT_QUERY", "DNSTAP__MESSAGE__TYPE__CLIENT_QUERY", 5 }, - { "CLIENT_RESPONSE", "DNSTAP__MESSAGE__TYPE__CLIENT_RESPONSE", 6 }, - { "FORWARDER_QUERY", "DNSTAP__MESSAGE__TYPE__FORWARDER_QUERY", 7 }, - { "FORWARDER_RESPONSE", "DNSTAP__MESSAGE__TYPE__FORWARDER_RESPONSE", 8 }, - { "STUB_QUERY", "DNSTAP__MESSAGE__TYPE__STUB_QUERY", 9 }, - { "STUB_RESPONSE", "DNSTAP__MESSAGE__TYPE__STUB_RESPONSE", 10 }, - { "TOOL_QUERY", "DNSTAP__MESSAGE__TYPE__TOOL_QUERY", 11 }, - { "TOOL_RESPONSE", "DNSTAP__MESSAGE__TYPE__TOOL_RESPONSE", 12 }, -}; -static const ProtobufCIntRange dnstap__message__type__value_ranges[] = { -{1, 0},{0, 12} -}; -static const ProtobufCEnumValueIndex dnstap__message__type__enum_values_by_name[12] = -{ - { "AUTH_QUERY", 0 }, - { "AUTH_RESPONSE", 1 }, - { "CLIENT_QUERY", 4 }, - { "CLIENT_RESPONSE", 5 }, - { "FORWARDER_QUERY", 6 }, - { "FORWARDER_RESPONSE", 7 }, - { "RESOLVER_QUERY", 2 }, - { "RESOLVER_RESPONSE", 3 }, - { "STUB_QUERY", 8 }, - { "STUB_RESPONSE", 9 }, - { "TOOL_QUERY", 10 }, - { "TOOL_RESPONSE", 11 }, -}; -const ProtobufCEnumDescriptor dnstap__message__type__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "dnstap.Message.Type", - "Type", - "Dnstap__Message__Type", - "dnstap", - 12, - dnstap__message__type__enum_values_by_number, - 12, - dnstap__message__type__enum_values_by_name, - 1, - dnstap__message__type__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; -static const ProtobufCFieldDescriptor dnstap__message__field_descriptors[14] = -{ - { - "type", - 1, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_ENUM, - 0, /* quantifier_offset */ - offsetof(Dnstap__Message, type), - &dnstap__message__type__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "socket_family", - 2, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_ENUM, - offsetof(Dnstap__Message, has_socket_family), - offsetof(Dnstap__Message, socket_family), - &dnstap__socket_family__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "socket_protocol", - 3, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_ENUM, - offsetof(Dnstap__Message, has_socket_protocol), - offsetof(Dnstap__Message, socket_protocol), - &dnstap__socket_protocol__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_address", - 4, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Message, has_query_address), - offsetof(Dnstap__Message, query_address), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "response_address", - 5, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Message, has_response_address), - offsetof(Dnstap__Message, response_address), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_port", - 6, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT32, - offsetof(Dnstap__Message, has_query_port), - offsetof(Dnstap__Message, query_port), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "response_port", - 7, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT32, - offsetof(Dnstap__Message, has_response_port), - offsetof(Dnstap__Message, response_port), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_time_sec", - 8, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT64, - offsetof(Dnstap__Message, has_query_time_sec), - offsetof(Dnstap__Message, query_time_sec), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_time_nsec", - 9, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_FIXED32, - offsetof(Dnstap__Message, has_query_time_nsec), - offsetof(Dnstap__Message, query_time_nsec), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_message", - 10, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Message, has_query_message), - offsetof(Dnstap__Message, query_message), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "query_zone", - 11, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Message, has_query_zone), - offsetof(Dnstap__Message, query_zone), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "response_time_sec", - 12, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_UINT64, - offsetof(Dnstap__Message, has_response_time_sec), - offsetof(Dnstap__Message, response_time_sec), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "response_time_nsec", - 13, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_FIXED32, - offsetof(Dnstap__Message, has_response_time_nsec), - offsetof(Dnstap__Message, response_time_nsec), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "response_message", - 14, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_BYTES, - offsetof(Dnstap__Message, has_response_message), - offsetof(Dnstap__Message, response_message), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned dnstap__message__field_indices_by_name[] = { - 3, /* field[3] = query_address */ - 9, /* field[9] = query_message */ - 5, /* field[5] = query_port */ - 8, /* field[8] = query_time_nsec */ - 7, /* field[7] = query_time_sec */ - 10, /* field[10] = query_zone */ - 4, /* field[4] = response_address */ - 13, /* field[13] = response_message */ - 6, /* field[6] = response_port */ - 12, /* field[12] = response_time_nsec */ - 11, /* field[11] = response_time_sec */ - 1, /* field[1] = socket_family */ - 2, /* field[2] = socket_protocol */ - 0, /* field[0] = type */ -}; -static const ProtobufCIntRange dnstap__message__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 14 } -}; -const ProtobufCMessageDescriptor dnstap__message__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "dnstap.Message", - "Message", - "Dnstap__Message", - "dnstap", - sizeof(Dnstap__Message), - 14, - dnstap__message__field_descriptors, - dnstap__message__field_indices_by_name, - 1, dnstap__message__number_ranges, - (ProtobufCMessageInit) dnstap__message__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCEnumValue dnstap__socket_family__enum_values_by_number[2] = -{ - { "INET", "DNSTAP__SOCKET_FAMILY__INET", 1 }, - { "INET6", "DNSTAP__SOCKET_FAMILY__INET6", 2 }, -}; -static const ProtobufCIntRange dnstap__socket_family__value_ranges[] = { -{1, 0},{0, 2} -}; -static const ProtobufCEnumValueIndex dnstap__socket_family__enum_values_by_name[2] = -{ - { "INET", 0 }, - { "INET6", 1 }, -}; -const ProtobufCEnumDescriptor dnstap__socket_family__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "dnstap.SocketFamily", - "SocketFamily", - "Dnstap__SocketFamily", - "dnstap", - 2, - dnstap__socket_family__enum_values_by_number, - 2, - dnstap__socket_family__enum_values_by_name, - 1, - dnstap__socket_family__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; -static const ProtobufCEnumValue dnstap__socket_protocol__enum_values_by_number[2] = -{ - { "UDP", "DNSTAP__SOCKET_PROTOCOL__UDP", 1 }, - { "TCP", "DNSTAP__SOCKET_PROTOCOL__TCP", 2 }, -}; -static const ProtobufCIntRange dnstap__socket_protocol__value_ranges[] = { -{1, 0},{0, 2} -}; -static const ProtobufCEnumValueIndex dnstap__socket_protocol__enum_values_by_name[2] = -{ - { "TCP", 1 }, - { "UDP", 0 }, -}; -const ProtobufCEnumDescriptor dnstap__socket_protocol__descriptor = -{ - PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, - "dnstap.SocketProtocol", - "SocketProtocol", - "Dnstap__SocketProtocol", - "dnstap", - 2, - dnstap__socket_protocol__enum_values_by_number, - 2, - dnstap__socket_protocol__enum_values_by_name, - 1, - dnstap__socket_protocol__value_ranges, - NULL,NULL,NULL,NULL /* reserved[1234] */ -}; diff --git a/lib/dns/dnstap.pb-c.h b/lib/dns/dnstap.pb-c.h deleted file mode 100644 index 71fd82919d1..00000000000 --- a/lib/dns/dnstap.pb-c.h +++ /dev/null @@ -1,343 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: dnstap.proto */ - -#ifndef PROTOBUF_C_dnstap_2eproto__INCLUDED -#define PROTOBUF_C_dnstap_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1000000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1001001 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - - -typedef struct _Dnstap__Dnstap Dnstap__Dnstap; -typedef struct _Dnstap__Message Dnstap__Message; - - -/* --- enums --- */ - -/* - * Identifies which field below is filled in. - */ -typedef enum _Dnstap__Dnstap__Type { - DNSTAP__DNSTAP__TYPE__MESSAGE = 1 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__DNSTAP__TYPE) -} Dnstap__Dnstap__Type; -typedef enum _Dnstap__Message__Type { - /* - * AUTH_QUERY is a DNS query message received from a resolver by an - * authoritative name server, from the perspective of the authorative - * name server. - */ - DNSTAP__MESSAGE__TYPE__AUTH_QUERY = 1, - /* - * AUTH_RESPONSE is a DNS response message sent from an authoritative - * name server to a resolver, from the perspective of the authoritative - * name server. - */ - DNSTAP__MESSAGE__TYPE__AUTH_RESPONSE = 2, - /* - * RESOLVER_QUERY is a DNS query message sent from a resolver to an - * authoritative name server, from the perspective of the resolver. - * Resolvers typically clear the RD (recursion desired) bit when - * sending queries. - */ - DNSTAP__MESSAGE__TYPE__RESOLVER_QUERY = 3, - /* - * RESOLVER_RESPONSE is a DNS response message received from an - * authoritative name server by a resolver, from the perspective of - * the resolver. - */ - DNSTAP__MESSAGE__TYPE__RESOLVER_RESPONSE = 4, - /* - * CLIENT_QUERY is a DNS query message sent from a client to a DNS - * server which is expected to perform further recursion, from the - * perspective of the DNS server. The client may be a stub resolver or - * forwarder or some other type of software which typically sets the RD - * (recursion desired) bit when querying the DNS server. The DNS server - * may be a simple forwarding proxy or it may be a full recursive - * resolver. - */ - DNSTAP__MESSAGE__TYPE__CLIENT_QUERY = 5, - /* - * CLIENT_RESPONSE is a DNS response message sent from a DNS server to - * a client, from the perspective of the DNS server. The DNS server - * typically sets the RA (recursion available) bit when responding. - */ - DNSTAP__MESSAGE__TYPE__CLIENT_RESPONSE = 6, - /* - * FORWARDER_QUERY is a DNS query message sent from a downstream DNS - * server to an upstream DNS server which is expected to perform - * further recursion, from the perspective of the downstream DNS - * server. - */ - DNSTAP__MESSAGE__TYPE__FORWARDER_QUERY = 7, - /* - * FORWARDER_RESPONSE is a DNS response message sent from an upstream - * DNS server performing recursion to a downstream DNS server, from the - * perspective of the downstream DNS server. - */ - DNSTAP__MESSAGE__TYPE__FORWARDER_RESPONSE = 8, - /* - * STUB_QUERY is a DNS query message sent from a stub resolver to a DNS - * server, from the perspective of the stub resolver. - */ - DNSTAP__MESSAGE__TYPE__STUB_QUERY = 9, - /* - * STUB_RESPONSE is a DNS response message sent from a DNS server to a - * stub resolver, from the perspective of the stub resolver. - */ - DNSTAP__MESSAGE__TYPE__STUB_RESPONSE = 10, - /* - * TOOL_QUERY is a DNS query message sent from a DNS software tool to a - * DNS server, from the perspective of the tool. - */ - DNSTAP__MESSAGE__TYPE__TOOL_QUERY = 11, - /* - * TOOL_RESPONSE is a DNS response message received by a DNS software - * tool from a DNS server, from the perspective of the tool. - */ - DNSTAP__MESSAGE__TYPE__TOOL_RESPONSE = 12 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__MESSAGE__TYPE) -} Dnstap__Message__Type; -/* - * SocketFamily: the network protocol family of a socket. This specifies how - * to interpret "network address" fields. - */ -typedef enum _Dnstap__SocketFamily { - /* - * IPv4 (RFC 791) - */ - DNSTAP__SOCKET_FAMILY__INET = 1, - /* - * IPv6 (RFC 2460) - */ - DNSTAP__SOCKET_FAMILY__INET6 = 2 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__SOCKET_FAMILY) -} Dnstap__SocketFamily; -/* - * SocketProtocol: the transport protocol of a socket. This specifies how to - * interpret "transport port" fields. - */ -typedef enum _Dnstap__SocketProtocol { - /* - * User Datagram Protocol (RFC 768) - */ - DNSTAP__SOCKET_PROTOCOL__UDP = 1, - /* - * Transmission Control Protocol (RFC 793) - */ - DNSTAP__SOCKET_PROTOCOL__TCP = 2 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__SOCKET_PROTOCOL) -} Dnstap__SocketProtocol; - -/* --- messages --- */ - -/* - * "Dnstap": this is the top-level dnstap type, which is a "union" type that - * contains other kinds of dnstap payloads, although currently only one type - * of dnstap payload is defined. - * See: https://developers.google.com/protocol-buffers/docs/techniques#union - */ -struct _Dnstap__Dnstap -{ - ProtobufCMessage base; - /* - * DNS server identity. - * If enabled, this is the identity string of the DNS server which generated - * this message. Typically this would be the same string as returned by an - * "NSID" (RFC 5001) query. - */ - protobuf_c_boolean has_identity; - ProtobufCBinaryData identity; - /* - * DNS server version. - * If enabled, this is the version string of the DNS server which generated - * this message. Typically this would be the same string as returned by a - * "version.bind" query. - */ - protobuf_c_boolean has_version; - ProtobufCBinaryData version; - /* - * Extra data for this payload. - * This field can be used for adding an arbitrary byte-string annotation to - * the payload. No encoding or interpretation is applied or enforced. - */ - protobuf_c_boolean has_extra; - ProtobufCBinaryData extra; - Dnstap__Dnstap__Type type; - /* - * One of the following will be filled in. - */ - Dnstap__Message *message; -}; -#define DNSTAP__DNSTAP__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&dnstap__dnstap__descriptor) \ - , 0,{0,NULL}, 0,{0,NULL}, 0,{0,NULL}, 0, NULL } - - -/* - * Message: a wire-format (RFC 1035 section 4) DNS message and associated - * metadata. Applications generating "Message" payloads should follow - * certain requirements based on the MessageType, see below. - */ -struct _Dnstap__Message -{ - ProtobufCMessage base; - /* - * One of the Type values described above. - */ - Dnstap__Message__Type type; - /* - * One of the SocketFamily values described above. - */ - protobuf_c_boolean has_socket_family; - Dnstap__SocketFamily socket_family; - /* - * One of the SocketProtocol values described above. - */ - protobuf_c_boolean has_socket_protocol; - Dnstap__SocketProtocol socket_protocol; - /* - * The network address of the message initiator. - * For SocketFamily INET, this field is 4 octets (IPv4 address). - * For SocketFamily INET6, this field is 16 octets (IPv6 address). - */ - protobuf_c_boolean has_query_address; - ProtobufCBinaryData query_address; - /* - * The network address of the message responder. - * For SocketFamily INET, this field is 4 octets (IPv4 address). - * For SocketFamily INET6, this field is 16 octets (IPv6 address). - */ - protobuf_c_boolean has_response_address; - ProtobufCBinaryData response_address; - /* - * The transport port of the message initiator. - * This is a 16-bit UDP or TCP port number, depending on SocketProtocol. - */ - protobuf_c_boolean has_query_port; - uint32_t query_port; - /* - * The transport port of the message responder. - * This is a 16-bit UDP or TCP port number, depending on SocketProtocol. - */ - protobuf_c_boolean has_response_port; - uint32_t response_port; - /* - * The time at which the DNS query message was sent or received, depending - * on whether this is an AUTH_QUERY, RESOLVER_QUERY, or CLIENT_QUERY. - * This is the number of seconds since the UNIX epoch. - */ - protobuf_c_boolean has_query_time_sec; - uint64_t query_time_sec; - /* - * The time at which the DNS query message was sent or received. - * This is the seconds fraction, expressed as a count of nanoseconds. - */ - protobuf_c_boolean has_query_time_nsec; - uint32_t query_time_nsec; - /* - * The initiator's original wire-format DNS query message, verbatim. - */ - protobuf_c_boolean has_query_message; - ProtobufCBinaryData query_message; - /* - * The "zone" or "bailiwick" pertaining to the DNS query message. - * This is a wire-format DNS domain name. - */ - protobuf_c_boolean has_query_zone; - ProtobufCBinaryData query_zone; - /* - * The time at which the DNS response message was sent or received, - * depending on whether this is an AUTH_RESPONSE, RESOLVER_RESPONSE, or - * CLIENT_RESPONSE. - * This is the number of seconds since the UNIX epoch. - */ - protobuf_c_boolean has_response_time_sec; - uint64_t response_time_sec; - /* - * The time at which the DNS response message was sent or received. - * This is the seconds fraction, expressed as a count of nanoseconds. - */ - protobuf_c_boolean has_response_time_nsec; - uint32_t response_time_nsec; - /* - * The responder's original wire-format DNS response message, verbatim. - */ - protobuf_c_boolean has_response_message; - ProtobufCBinaryData response_message; -}; -#define DNSTAP__MESSAGE__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&dnstap__message__descriptor) \ - , 0, 0,0, 0,0, 0,{0,NULL}, 0,{0,NULL}, 0,0, 0,0, 0,0, 0,0, 0,{0,NULL}, 0,{0,NULL}, 0,0, 0,0, 0,{0,NULL} } - - -/* Dnstap__Dnstap methods */ -void dnstap__dnstap__init - (Dnstap__Dnstap *message); -size_t dnstap__dnstap__get_packed_size - (const Dnstap__Dnstap *message); -size_t dnstap__dnstap__pack - (const Dnstap__Dnstap *message, - uint8_t *out); -size_t dnstap__dnstap__pack_to_buffer - (const Dnstap__Dnstap *message, - ProtobufCBuffer *buffer); -Dnstap__Dnstap * - dnstap__dnstap__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void dnstap__dnstap__free_unpacked - (Dnstap__Dnstap *message, - ProtobufCAllocator *allocator); -/* Dnstap__Message methods */ -void dnstap__message__init - (Dnstap__Message *message); -size_t dnstap__message__get_packed_size - (const Dnstap__Message *message); -size_t dnstap__message__pack - (const Dnstap__Message *message, - uint8_t *out); -size_t dnstap__message__pack_to_buffer - (const Dnstap__Message *message, - ProtobufCBuffer *buffer); -Dnstap__Message * - dnstap__message__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void dnstap__message__free_unpacked - (Dnstap__Message *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*Dnstap__Dnstap_Closure) - (const Dnstap__Dnstap *message, - void *closure_data); -typedef void (*Dnstap__Message_Closure) - (const Dnstap__Message *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor dnstap__socket_family__descriptor; -extern const ProtobufCEnumDescriptor dnstap__socket_protocol__descriptor; -extern const ProtobufCMessageDescriptor dnstap__dnstap__descriptor; -extern const ProtobufCEnumDescriptor dnstap__dnstap__type__descriptor; -extern const ProtobufCMessageDescriptor dnstap__message__descriptor; -extern const ProtobufCEnumDescriptor dnstap__message__type__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_dnstap_2eproto__INCLUDED */ diff --git a/lib/dns/include/dns/Makefile.in b/lib/dns/include/dns/Makefile.in index a69f7685ed3..7a6e4337c1f 100644 --- a/lib/dns/include/dns/Makefile.in +++ b/lib/dns/include/dns/Makefile.in @@ -24,7 +24,7 @@ HEADERS = acache.h acl.h adb.h badcache.h bit.h byaddr.h \ client.h clientinfo.h compress.h \ db.h dbiterator.h dbtable.h diff.h dispatch.h \ dlz.h dlz_dlopen.h dns64.h dnssec.h ds.h dsdigest.h \ - dnstap.h dnstap.pb-c.h dyndb.h \ + dnstap.h dyndb.h \ edns.h ecdb.h events.h fixedname.h forward.h geoip.h \ ipkeylist.h iptable.h \ journal.h keydata.h keyflags.h keytable.h keyvalues.h \ @@ -39,7 +39,7 @@ HEADERS = acache.h acl.h adb.h badcache.h bit.h byaddr.h \ update.h validator.h version.h view.h xfrin.h \ zone.h zonekey.h zt.h -GENHEADERS = enumclass.h enumtype.h rdatastruct.h +GENHEADERS = @DNSTAP_PB_C_H@ enumclass.h enumtype.h rdatastruct.h SUBDIRS = TARGETS = diff --git a/lib/dns/include/dns/dnstap.h b/lib/dns/include/dns/dnstap.h index e686b722dd5..e21efa67d11 100644 --- a/lib/dns/include/dns/dnstap.h +++ b/lib/dns/include/dns/dnstap.h @@ -94,18 +94,6 @@ typedef struct dns_dthandle { } dns_dthandle_t; #ifdef HAVE_DNSTAP -struct dns_dtenv { - unsigned int magic; - isc_refcount_t refcount; - - isc_mem_t *mctx; - - struct fstrm_iothr *iothr; - - isc_region_t identity; - isc_region_t version; -}; - struct dns_dtdata { isc_mem_t *mctx; @@ -169,6 +157,15 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, *\li Other errors are possible. */ +isc_result_t +dns_dt_reopen(dns_dtenv_t *env); +/*%< + * Reopens files established by dns_dt_create(). + * + * Requires: + *\li 'env' is a valid dnstap environment. + */ + isc_result_t dns_dt_setidentity(dns_dtenv_t *env, const char *identity); isc_result_t diff --git a/lib/dns/include/dns/dnstap.pb-c.h b/lib/dns/include/dns/dnstap.pb-c.h deleted file mode 100644 index 71fd82919d1..00000000000 --- a/lib/dns/include/dns/dnstap.pb-c.h +++ /dev/null @@ -1,343 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: dnstap.proto */ - -#ifndef PROTOBUF_C_dnstap_2eproto__INCLUDED -#define PROTOBUF_C_dnstap_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1000000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1001001 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - - -typedef struct _Dnstap__Dnstap Dnstap__Dnstap; -typedef struct _Dnstap__Message Dnstap__Message; - - -/* --- enums --- */ - -/* - * Identifies which field below is filled in. - */ -typedef enum _Dnstap__Dnstap__Type { - DNSTAP__DNSTAP__TYPE__MESSAGE = 1 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__DNSTAP__TYPE) -} Dnstap__Dnstap__Type; -typedef enum _Dnstap__Message__Type { - /* - * AUTH_QUERY is a DNS query message received from a resolver by an - * authoritative name server, from the perspective of the authorative - * name server. - */ - DNSTAP__MESSAGE__TYPE__AUTH_QUERY = 1, - /* - * AUTH_RESPONSE is a DNS response message sent from an authoritative - * name server to a resolver, from the perspective of the authoritative - * name server. - */ - DNSTAP__MESSAGE__TYPE__AUTH_RESPONSE = 2, - /* - * RESOLVER_QUERY is a DNS query message sent from a resolver to an - * authoritative name server, from the perspective of the resolver. - * Resolvers typically clear the RD (recursion desired) bit when - * sending queries. - */ - DNSTAP__MESSAGE__TYPE__RESOLVER_QUERY = 3, - /* - * RESOLVER_RESPONSE is a DNS response message received from an - * authoritative name server by a resolver, from the perspective of - * the resolver. - */ - DNSTAP__MESSAGE__TYPE__RESOLVER_RESPONSE = 4, - /* - * CLIENT_QUERY is a DNS query message sent from a client to a DNS - * server which is expected to perform further recursion, from the - * perspective of the DNS server. The client may be a stub resolver or - * forwarder or some other type of software which typically sets the RD - * (recursion desired) bit when querying the DNS server. The DNS server - * may be a simple forwarding proxy or it may be a full recursive - * resolver. - */ - DNSTAP__MESSAGE__TYPE__CLIENT_QUERY = 5, - /* - * CLIENT_RESPONSE is a DNS response message sent from a DNS server to - * a client, from the perspective of the DNS server. The DNS server - * typically sets the RA (recursion available) bit when responding. - */ - DNSTAP__MESSAGE__TYPE__CLIENT_RESPONSE = 6, - /* - * FORWARDER_QUERY is a DNS query message sent from a downstream DNS - * server to an upstream DNS server which is expected to perform - * further recursion, from the perspective of the downstream DNS - * server. - */ - DNSTAP__MESSAGE__TYPE__FORWARDER_QUERY = 7, - /* - * FORWARDER_RESPONSE is a DNS response message sent from an upstream - * DNS server performing recursion to a downstream DNS server, from the - * perspective of the downstream DNS server. - */ - DNSTAP__MESSAGE__TYPE__FORWARDER_RESPONSE = 8, - /* - * STUB_QUERY is a DNS query message sent from a stub resolver to a DNS - * server, from the perspective of the stub resolver. - */ - DNSTAP__MESSAGE__TYPE__STUB_QUERY = 9, - /* - * STUB_RESPONSE is a DNS response message sent from a DNS server to a - * stub resolver, from the perspective of the stub resolver. - */ - DNSTAP__MESSAGE__TYPE__STUB_RESPONSE = 10, - /* - * TOOL_QUERY is a DNS query message sent from a DNS software tool to a - * DNS server, from the perspective of the tool. - */ - DNSTAP__MESSAGE__TYPE__TOOL_QUERY = 11, - /* - * TOOL_RESPONSE is a DNS response message received by a DNS software - * tool from a DNS server, from the perspective of the tool. - */ - DNSTAP__MESSAGE__TYPE__TOOL_RESPONSE = 12 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__MESSAGE__TYPE) -} Dnstap__Message__Type; -/* - * SocketFamily: the network protocol family of a socket. This specifies how - * to interpret "network address" fields. - */ -typedef enum _Dnstap__SocketFamily { - /* - * IPv4 (RFC 791) - */ - DNSTAP__SOCKET_FAMILY__INET = 1, - /* - * IPv6 (RFC 2460) - */ - DNSTAP__SOCKET_FAMILY__INET6 = 2 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__SOCKET_FAMILY) -} Dnstap__SocketFamily; -/* - * SocketProtocol: the transport protocol of a socket. This specifies how to - * interpret "transport port" fields. - */ -typedef enum _Dnstap__SocketProtocol { - /* - * User Datagram Protocol (RFC 768) - */ - DNSTAP__SOCKET_PROTOCOL__UDP = 1, - /* - * Transmission Control Protocol (RFC 793) - */ - DNSTAP__SOCKET_PROTOCOL__TCP = 2 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DNSTAP__SOCKET_PROTOCOL) -} Dnstap__SocketProtocol; - -/* --- messages --- */ - -/* - * "Dnstap": this is the top-level dnstap type, which is a "union" type that - * contains other kinds of dnstap payloads, although currently only one type - * of dnstap payload is defined. - * See: https://developers.google.com/protocol-buffers/docs/techniques#union - */ -struct _Dnstap__Dnstap -{ - ProtobufCMessage base; - /* - * DNS server identity. - * If enabled, this is the identity string of the DNS server which generated - * this message. Typically this would be the same string as returned by an - * "NSID" (RFC 5001) query. - */ - protobuf_c_boolean has_identity; - ProtobufCBinaryData identity; - /* - * DNS server version. - * If enabled, this is the version string of the DNS server which generated - * this message. Typically this would be the same string as returned by a - * "version.bind" query. - */ - protobuf_c_boolean has_version; - ProtobufCBinaryData version; - /* - * Extra data for this payload. - * This field can be used for adding an arbitrary byte-string annotation to - * the payload. No encoding or interpretation is applied or enforced. - */ - protobuf_c_boolean has_extra; - ProtobufCBinaryData extra; - Dnstap__Dnstap__Type type; - /* - * One of the following will be filled in. - */ - Dnstap__Message *message; -}; -#define DNSTAP__DNSTAP__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&dnstap__dnstap__descriptor) \ - , 0,{0,NULL}, 0,{0,NULL}, 0,{0,NULL}, 0, NULL } - - -/* - * Message: a wire-format (RFC 1035 section 4) DNS message and associated - * metadata. Applications generating "Message" payloads should follow - * certain requirements based on the MessageType, see below. - */ -struct _Dnstap__Message -{ - ProtobufCMessage base; - /* - * One of the Type values described above. - */ - Dnstap__Message__Type type; - /* - * One of the SocketFamily values described above. - */ - protobuf_c_boolean has_socket_family; - Dnstap__SocketFamily socket_family; - /* - * One of the SocketProtocol values described above. - */ - protobuf_c_boolean has_socket_protocol; - Dnstap__SocketProtocol socket_protocol; - /* - * The network address of the message initiator. - * For SocketFamily INET, this field is 4 octets (IPv4 address). - * For SocketFamily INET6, this field is 16 octets (IPv6 address). - */ - protobuf_c_boolean has_query_address; - ProtobufCBinaryData query_address; - /* - * The network address of the message responder. - * For SocketFamily INET, this field is 4 octets (IPv4 address). - * For SocketFamily INET6, this field is 16 octets (IPv6 address). - */ - protobuf_c_boolean has_response_address; - ProtobufCBinaryData response_address; - /* - * The transport port of the message initiator. - * This is a 16-bit UDP or TCP port number, depending on SocketProtocol. - */ - protobuf_c_boolean has_query_port; - uint32_t query_port; - /* - * The transport port of the message responder. - * This is a 16-bit UDP or TCP port number, depending on SocketProtocol. - */ - protobuf_c_boolean has_response_port; - uint32_t response_port; - /* - * The time at which the DNS query message was sent or received, depending - * on whether this is an AUTH_QUERY, RESOLVER_QUERY, or CLIENT_QUERY. - * This is the number of seconds since the UNIX epoch. - */ - protobuf_c_boolean has_query_time_sec; - uint64_t query_time_sec; - /* - * The time at which the DNS query message was sent or received. - * This is the seconds fraction, expressed as a count of nanoseconds. - */ - protobuf_c_boolean has_query_time_nsec; - uint32_t query_time_nsec; - /* - * The initiator's original wire-format DNS query message, verbatim. - */ - protobuf_c_boolean has_query_message; - ProtobufCBinaryData query_message; - /* - * The "zone" or "bailiwick" pertaining to the DNS query message. - * This is a wire-format DNS domain name. - */ - protobuf_c_boolean has_query_zone; - ProtobufCBinaryData query_zone; - /* - * The time at which the DNS response message was sent or received, - * depending on whether this is an AUTH_RESPONSE, RESOLVER_RESPONSE, or - * CLIENT_RESPONSE. - * This is the number of seconds since the UNIX epoch. - */ - protobuf_c_boolean has_response_time_sec; - uint64_t response_time_sec; - /* - * The time at which the DNS response message was sent or received. - * This is the seconds fraction, expressed as a count of nanoseconds. - */ - protobuf_c_boolean has_response_time_nsec; - uint32_t response_time_nsec; - /* - * The responder's original wire-format DNS response message, verbatim. - */ - protobuf_c_boolean has_response_message; - ProtobufCBinaryData response_message; -}; -#define DNSTAP__MESSAGE__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&dnstap__message__descriptor) \ - , 0, 0,0, 0,0, 0,{0,NULL}, 0,{0,NULL}, 0,0, 0,0, 0,0, 0,0, 0,{0,NULL}, 0,{0,NULL}, 0,0, 0,0, 0,{0,NULL} } - - -/* Dnstap__Dnstap methods */ -void dnstap__dnstap__init - (Dnstap__Dnstap *message); -size_t dnstap__dnstap__get_packed_size - (const Dnstap__Dnstap *message); -size_t dnstap__dnstap__pack - (const Dnstap__Dnstap *message, - uint8_t *out); -size_t dnstap__dnstap__pack_to_buffer - (const Dnstap__Dnstap *message, - ProtobufCBuffer *buffer); -Dnstap__Dnstap * - dnstap__dnstap__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void dnstap__dnstap__free_unpacked - (Dnstap__Dnstap *message, - ProtobufCAllocator *allocator); -/* Dnstap__Message methods */ -void dnstap__message__init - (Dnstap__Message *message); -size_t dnstap__message__get_packed_size - (const Dnstap__Message *message); -size_t dnstap__message__pack - (const Dnstap__Message *message, - uint8_t *out); -size_t dnstap__message__pack_to_buffer - (const Dnstap__Message *message, - ProtobufCBuffer *buffer); -Dnstap__Message * - dnstap__message__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void dnstap__message__free_unpacked - (Dnstap__Message *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*Dnstap__Dnstap_Closure) - (const Dnstap__Dnstap *message, - void *closure_data); -typedef void (*Dnstap__Message_Closure) - (const Dnstap__Message *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCEnumDescriptor dnstap__socket_family__descriptor; -extern const ProtobufCEnumDescriptor dnstap__socket_protocol__descriptor; -extern const ProtobufCMessageDescriptor dnstap__dnstap__descriptor; -extern const ProtobufCEnumDescriptor dnstap__dnstap__type__descriptor; -extern const ProtobufCMessageDescriptor dnstap__message__descriptor; -extern const ProtobufCEnumDescriptor dnstap__message__type__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_dnstap_2eproto__INCLUDED */