]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
report if sit is good/bad
authorMark Andrews <marka@isc.org>
Thu, 20 Feb 2014 04:55:09 +0000 (15:55 +1100)
committerMark Andrews <marka@isc.org>
Thu, 20 Feb 2014 04:55:09 +0000 (15:55 +1100)
bin/dig/dighost.c
lib/dns/include/dns/message.h
lib/dns/message.c

index 337bc2936a76a060b7ce8b8224136394a33df175..9494cb416dd74e5589cb47674be910d375fe225c 100644 (file)
@@ -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) {
index 88fb31ae6831eaa5cd71d312a62e2ba30b6fe29c..013411fcc48cdfa7a6efa7d3d6112e2fcc5b8362 100644 (file)
@@ -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;
index 3ec7c0794209aa48a0179ed83ede57f69c599691..5137cb11d9b7aeaaad78d9e0c97cb5e46cfebe43 100644 (file)
@@ -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;
                                }