2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

report if sit is good/bad

This commit is contained in:
Mark Andrews 2014-02-20 15:55:09 +11:00
parent 51d6d7eea4
commit f0c00f10a0
3 changed files with 25 additions and 9 deletions

View File

@ -3270,7 +3270,9 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
#ifdef ISC_PLATFORM_USESIT #ifdef ISC_PLATFORM_USESIT
static void 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]; char bb[256];
isc_buffer_t hexbuf; isc_buffer_t hexbuf;
size_t len; 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 (optlen >= len && optlen >= 8U) {
if (memcmp(isc_buffer_current(optbuf), sit, 8) == 0) { if (memcmp(isc_buffer_current(optbuf), sit, 8) == 0) {
if (l->comments) msg->sitok = 1;
printf(";; SIT client cookie part match\n"); } else {
} else
printf(";; Warning: SIT client cookie part mis-match\n"); printf(";; Warning: SIT client cookie part mis-match\n");
} else msg->sitbad = 1;
}
} else {
printf(";; Warning: SIT bad token (too short)\n"); printf(";; Warning: SIT bad token (too short)\n");
msg->sitbad = 1;
}
isc_buffer_forward(optbuf, (unsigned int)optlen); isc_buffer_forward(optbuf, (unsigned int)optlen);
} }
static void 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; dns_rdata_t rdata;
isc_result_t result; isc_result_t result;
isc_buffer_t optbuf; isc_buffer_t optbuf;
isc_uint16_t optcode, optlen; isc_uint16_t optcode, optlen;
dns_rdataset_t *opt = msg->opt;
result = dns_rdataset_first(opt); result = dns_rdataset_first(opt);
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
@ -3317,7 +3323,7 @@ process_opt(dig_lookup_t *l, dns_rdataset_t *opt) {
optlen = isc_buffer_getuint16(&optbuf); optlen = isc_buffer_getuint16(&optbuf);
switch (optcode) { switch (optcode) {
case DNS_OPT_SIT: case DNS_OPT_SIT:
process_sit(l, &optbuf, optlen); process_sit(l, msg, &optbuf, optlen);
break; break;
default: default:
isc_buffer_forward(&optbuf, optlen); isc_buffer_forward(&optbuf, optlen);
@ -3695,9 +3701,9 @@ recv_done(isc_task_t *task, isc_event_t *event) {
if (msg->opt == NULL) if (msg->opt == NULL)
printf(";; expected opt record in response\n"); printf(";; expected opt record in response\n");
else else
process_opt(l, msg->opt); process_opt(l, msg);
} else if (l->sit && msg->opt != NULL) } else if (l->sit && msg->opt != NULL)
process_opt(l, msg->opt); process_opt(l, msg);
#endif #endif
if (!l->doing_xfr || l->xfr_q == query) { if (!l->doing_xfr || l->xfr_q == query) {

View File

@ -218,6 +218,8 @@ struct dns_message {
unsigned int verify_attempted : 1; unsigned int verify_attempted : 1;
unsigned int free_query : 1; unsigned int free_query : 1;
unsigned int free_saved : 1; unsigned int free_saved : 1;
unsigned int sitok : 1;
unsigned int sitbad : 1;
unsigned int opt_reserved; unsigned int opt_reserved;
unsigned int sig_reserved; unsigned int sig_reserved;

View File

@ -437,6 +437,8 @@ msginit(dns_message_t *m) {
m->saved.base = NULL; m->saved.base = NULL;
m->saved.length = 0; m->saved.length = 0;
m->free_saved = 0; m->free_saved = 0;
m->sitok = 0;
m->sitbad = 0;
m->querytsig = NULL; m->querytsig = NULL;
} }
@ -485,6 +487,8 @@ msgresetopt(dns_message_t *msg)
dns_rdataset_disassociate(msg->opt); dns_rdataset_disassociate(msg->opt);
isc_mempool_put(msg->rdspool, msg->opt); isc_mempool_put(msg->rdspool, msg->opt);
msg->opt = NULL; 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); isc_buffer_forward(&optbuf, optlen);
if (optcode == DNS_OPT_SIT) { if (optcode == DNS_OPT_SIT) {
if (msg->sitok)
ADD_STRING(target, " (good)");
if (msg->sitbad)
ADD_STRING(target, " (bad)");
ADD_STRING(target, "\n"); ADD_STRING(target, "\n");
continue; continue;
} }