From f0c00f10a0b15e551655a309e3bc9252e6bf8cfd Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 20 Feb 2014 15:55:09 +1100 Subject: [PATCH] report if sit is good/bad --- bin/dig/dighost.c | 24 +++++++++++++++--------- lib/dns/include/dns/message.h | 2 ++ lib/dns/message.c | 8 ++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 337bc2936a..9494cb416d 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -3270,7 +3270,9 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg, #ifdef ISC_PLATFORM_USESIT static void -process_sit(dig_lookup_t *l, isc_buffer_t *optbuf, size_t optlen) { +process_sit(dig_lookup_t *l, dns_message_t *msg, + isc_buffer_t *optbuf, size_t optlen) +{ char bb[256]; isc_buffer_t hexbuf; size_t len; @@ -3290,21 +3292,25 @@ process_sit(dig_lookup_t *l, isc_buffer_t *optbuf, size_t optlen) { if (optlen >= len && optlen >= 8U) { if (memcmp(isc_buffer_current(optbuf), sit, 8) == 0) { - if (l->comments) - printf(";; SIT client cookie part match\n"); - } else + msg->sitok = 1; + } else { printf(";; Warning: SIT client cookie part mis-match\n"); - } else + msg->sitbad = 1; + } + } else { printf(";; Warning: SIT bad token (too short)\n"); + msg->sitbad = 1; + } isc_buffer_forward(optbuf, (unsigned int)optlen); } static void -process_opt(dig_lookup_t *l, dns_rdataset_t *opt) { +process_opt(dig_lookup_t *l, dns_message_t *msg) { dns_rdata_t rdata; isc_result_t result; isc_buffer_t optbuf; isc_uint16_t optcode, optlen; + dns_rdataset_t *opt = msg->opt; result = dns_rdataset_first(opt); if (result == ISC_R_SUCCESS) { @@ -3317,7 +3323,7 @@ process_opt(dig_lookup_t *l, dns_rdataset_t *opt) { optlen = isc_buffer_getuint16(&optbuf); switch (optcode) { case DNS_OPT_SIT: - process_sit(l, &optbuf, optlen); + process_sit(l, msg, &optbuf, optlen); break; default: isc_buffer_forward(&optbuf, optlen); @@ -3695,9 +3701,9 @@ recv_done(isc_task_t *task, isc_event_t *event) { if (msg->opt == NULL) printf(";; expected opt record in response\n"); else - process_opt(l, msg->opt); + process_opt(l, msg); } else if (l->sit && msg->opt != NULL) - process_opt(l, msg->opt); + process_opt(l, msg); #endif if (!l->doing_xfr || l->xfr_q == query) { diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 88fb31ae68..013411fcc4 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -218,6 +218,8 @@ struct dns_message { unsigned int verify_attempted : 1; unsigned int free_query : 1; unsigned int free_saved : 1; + unsigned int sitok : 1; + unsigned int sitbad : 1; unsigned int opt_reserved; unsigned int sig_reserved; diff --git a/lib/dns/message.c b/lib/dns/message.c index 3ec7c07942..5137cb11d9 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -437,6 +437,8 @@ msginit(dns_message_t *m) { m->saved.base = NULL; m->saved.length = 0; m->free_saved = 0; + m->sitok = 0; + m->sitbad = 0; m->querytsig = NULL; } @@ -485,6 +487,8 @@ msgresetopt(dns_message_t *msg) dns_rdataset_disassociate(msg->opt); isc_mempool_put(msg->rdspool, msg->opt); msg->opt = NULL; + msg->sitok = 0; + msg->sitbad = 0; } } @@ -3342,6 +3346,10 @@ dns_message_pseudosectiontotext(dns_message_t *msg, isc_buffer_forward(&optbuf, optlen); if (optcode == DNS_OPT_SIT) { + if (msg->sitok) + ADD_STRING(target, " (good)"); + if (msg->sitbad) + ADD_STRING(target, " (bad)"); ADD_STRING(target, "\n"); continue; }