"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "query.c" between
nsd-4.3.6.tar.gz and nsd-4.3.7.tar.gz

About: NSD is an authoritative only, high performance, simple name server daemon.

query.c  (nsd-4.3.6):query.c  (nsd-4.3.7)
skipping to change at line 1489 skipping to change at line 1489
/* CD flag must be cleared for auth answers */ /* CD flag must be cleared for auth answers */
flags |= 0x8000U; /* Set the QR flag. */ flags |= 0x8000U; /* Set the QR flag. */
FLAGS_SET(q->packet, flags); FLAGS_SET(q->packet, flags);
} }
/* /*
* Processes the query. * Processes the query.
* *
*/ */
query_state_type query_state_type
query_process(query_type *q, nsd_type *nsd) query_process(query_type *q, nsd_type *nsd, uint32_t *now_p)
{ {
/* The query... */ /* The query... */
nsd_rc_type rc; nsd_rc_type rc;
query_state_type query_state; query_state_type query_state;
uint16_t arcount; uint16_t arcount;
/* Sanity checks */ /* Sanity checks */
if (buffer_limit(q->packet) < QHEADERSZ) { if (buffer_limit(q->packet) < QHEADERSZ) {
/* packet too small to contain DNS header. /* packet too small to contain DNS header.
Now packet investigation macros will work without problems. */ Now packet investigation macros will work without problems. */
skipping to change at line 1549 skipping to change at line 1549
if(QDCOUNT(q->packet) == 0 && ANCOUNT(q->packet) == 0 && if(QDCOUNT(q->packet) == 0 && ANCOUNT(q->packet) == 0 &&
NSCOUNT(q->packet) == 0 && ARCOUNT(q->packet) == 1 && NSCOUNT(q->packet) == 0 && ARCOUNT(q->packet) == 1 &&
buffer_limit(q->packet) >= QHEADERSZ+OPT_LEN+ buffer_limit(q->packet) >= QHEADERSZ+OPT_LEN+
OPT_RDATA) { OPT_RDATA) {
/* add edns section to answer */ /* add edns section to answer */
buffer_set_position(q->packet, QHEADERSZ); buffer_set_position(q->packet, QHEADERSZ);
if (edns_parse_record(&q->edns, q->packet, q, nsd)) { if (edns_parse_record(&q->edns, q->packet, q, nsd)) {
if(process_edns(nsd, q) == NSD_RC_OK) { if(process_edns(nsd, q) == NSD_RC_OK) {
int opcode = OPCODE(q->packet); int opcode = OPCODE(q->packet);
(void)query_error(q, NSD_RC_FORMAT); (void)query_error(q, NSD_RC_FORMAT);
query_add_optional(q, nsd); query_add_optional(q, nsd, now_p);
FLAGS_SET(q->packet, FLAGS(q->packet) & 0 x0100U); FLAGS_SET(q->packet, FLAGS(q->packet) & 0 x0100U);
/* Preserve the RD flag. Clear th e rest. */ /* Preserve the RD flag. Clear th e rest. */
OPCODE_SET(q->packet, opcode); OPCODE_SET(q->packet, opcode);
QR_SET(q->packet); QR_SET(q->packet);
return QUERY_PROCESSED; return QUERY_PROCESSED;
} }
} }
} }
FLAGS_SET(q->packet, 0); FLAGS_SET(q->packet, 0);
return query_formerr(q, nsd); return query_formerr(q, nsd);
skipping to change at line 1646 skipping to change at line 1646
QHEADERSZ + 4 + q->qname->name_size); QHEADERSZ + 4 + q->qname->name_size);
QR_SET(q->packet); QR_SET(q->packet);
AD_CLR(q->packet); AD_CLR(q->packet);
QDCOUNT_SET(q->packet, 1); QDCOUNT_SET(q->packet, 1);
ANCOUNT_SET(q->packet, 0); ANCOUNT_SET(q->packet, 0);
NSCOUNT_SET(q->packet, 0); NSCOUNT_SET(q->packet, 0);
ARCOUNT_SET(q->packet, 0); ARCOUNT_SET(q->packet, 0);
return QUERY_PROCESSED; return QUERY_PROCESSED;
} }
if (q->edns.cookie_status == COOKIE_UNVERIFIED)
cookie_verify(q, nsd, now_p);
query_prepare_response(q); query_prepare_response(q);
if (q->qclass != CLASS_IN && q->qclass != CLASS_ANY) { if (q->qclass != CLASS_IN && q->qclass != CLASS_ANY) {
if (q->qclass == CLASS_CH) { if (q->qclass == CLASS_CH) {
return answer_chaos(nsd, q); return answer_chaos(nsd, q);
} else { } else {
/* RFC8914 - Extended DNS Errors /* RFC8914 - Extended DNS Errors
* 4.22. Extended DNS Error Code 21 - Not Supported */ * 4.22. Extended DNS Error Code 21 - Not Supported */
q->edns.ede = EDE_NOT_SUPPORTED; q->edns.ede = EDE_NOT_SUPPORTED;
return query_error(q, RCODE_REFUSE); return query_error(q, RCODE_REFUSE);
skipping to change at line 1673 skipping to change at line 1676
TC_SET(q->packet); TC_SET(q->packet);
return query_error(q, NSD_RC_OK); return query_error(q, NSD_RC_OK);
} }
answer_query(nsd, q); answer_query(nsd, q);
return QUERY_PROCESSED; return QUERY_PROCESSED;
} }
void void
query_add_optional(query_type *q, nsd_type *nsd) query_add_optional(query_type *q, nsd_type *nsd, uint32_t *now_p)
{ {
struct edns_data *edns = &nsd->edns_ipv4; struct edns_data *edns = &nsd->edns_ipv4;
#if defined(INET6) #if defined(INET6)
if (q->addr.ss_family == AF_INET6) { if (q->addr.ss_family == AF_INET6) {
edns = &nsd->edns_ipv6; edns = &nsd->edns_ipv6;
} }
#endif #endif
if (RCODE(q->packet) == RCODE_FORMAT) { if (RCODE(q->packet) == RCODE_FORMAT) {
return; return;
} }
skipping to change at line 1713 skipping to change at line 1716
} else { } else {
/* rdata length */ /* rdata length */
buffer_write_u16(q->packet, q->edns.opt_reserved_space); buffer_write_u16(q->packet, q->edns.opt_reserved_space);
/* edns options */ /* edns options */
if(q->edns.nsid) { if(q->edns.nsid) {
/* nsid opt header */ /* nsid opt header */
buffer_write(q->packet, edns->nsid, OPT_HDR); buffer_write(q->packet, edns->nsid, OPT_HDR);
/* nsid payload */ /* nsid payload */
buffer_write(q->packet, nsd->nsid, nsd->nsid_len) ; buffer_write(q->packet, nsd->nsid, nsd->nsid_len) ;
} }
if(q->edns.cookie_status != COOKIE_NOT_PRESENT) {
/* cookie opt header */
buffer_write(q->packet, edns->cookie, OPT_HDR);
/* cookie payload */
cookie_create(q, nsd, now_p);
buffer_write(q->packet, q->edns.cookie, 24);
}
/* Append Extended DNS Error (RFC8914) option if needed * / /* Append Extended DNS Error (RFC8914) option if needed * /
if (q->edns.ede >= 0) { /* < 0 means no EDE */ if (q->edns.ede >= 0) { /* < 0 means no EDE */
/* OPTION-CODE */ /* OPTION-CODE */
buffer_write_u16(q->packet, EDE_CODE); buffer_write_u16(q->packet, EDE_CODE);
/* OPTION-LENGTH */ /* OPTION-LENGTH */
buffer_write_u16(q->packet, buffer_write_u16(q->packet,
2 + ( q->edns.ede_text_len 2 + ( q->edns.ede_text_len
? q->edns.ede_text_len : 0)); ? q->edns.ede_text_len : 0));
/* INFO-CODE */ /* INFO-CODE */
buffer_write_u16(q->packet, q->edns.ede); buffer_write_u16(q->packet, q->edns.ede);
 End of changes. 5 change blocks. 
3 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)