From: W.C.A. Wijngaards Date: Tue, 21 Jan 2020 08:56:28 +0000 (+0100) Subject: dnstap test program prints identity and version. X-Git-Tag: 1.11.0rc1~120^2~110 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7bddf97450fe4695fb310e7ff1ff53ba624f83da;p=thirdparty%2Funbound.git dnstap test program prints identity and version. --- diff --git a/dnstap/unbound-dnstap-socket.c b/dnstap/unbound-dnstap-socket.c index 4b8ef1dad..3b01506c3 100644 --- a/dnstap/unbound-dnstap-socket.c +++ b/dnstap/unbound-dnstap-socket.c @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef HAVE_SYS_UN_H #include #endif @@ -214,6 +215,37 @@ static char* q_of_msg(ProtobufCBinaryData message) return NULL; } +/** convert possible string or hex data to string. malloced or NULL */ +static char* possible_str(ProtobufCBinaryData str) +{ + int is_str = 1; + size_t i; + for(i=0; i>4]; + res[i*2+1] = hex[str.data[i]&0x0f]; + } + res[str.len*2] = 0; + return res; + } + } + return NULL; +} + /** log data frame contents */ static void log_data_frame(uint8_t* pkt, size_t len) { @@ -255,10 +287,18 @@ static void log_data_frame(uint8_t* pkt, size_t len) free(qinf); if(longformat) { + char* id=NULL, *vs=NULL; if(d->has_identity) { + id=possible_str(d->identity); } if(d->has_version) { + vs=possible_str(d->version); } + if(id || vs) + printf("identity: %s%s%s\n", (id?id:""), + (id&&vs?" ":""), (vs?vs:"")); + free(id); + free(vs); } dnstap__dnstap__free_unpacked(d, NULL); }