From: Willem Toorop Date: Thu, 24 Jun 2021 10:55:46 +0000 (+0200) Subject: Simple EDE example X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8d78b2083a18d2d49a6e074617142322c269169;p=thirdparty%2Funbound.git Simple EDE example --- diff --git a/daemon/worker.c b/daemon/worker.c index e9e163a04..03d131245 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1290,6 +1290,8 @@ worker_handle_request(struct comm_point* c, void* arg, int error, edns.udp_size = EDNS_ADVERTISED_SIZE; edns.bits &= EDNS_DO; edns.opt_list = NULL; + EDNS_OPT_APPEND_EDE(&edns, worker->scratchpad, + LDNS_EDNS_EDE, "query with bad edns keepalive."); verbose(VERB_ALGO, "query with bad edns keepalive."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); error_encode(c->buffer, LDNS_RCODE_FORMERR, &qinfo, diff --git a/sldns/rrdef.h b/sldns/rrdef.h index 8fd51f028..f022f93cf 100644 --- a/sldns/rrdef.h +++ b/sldns/rrdef.h @@ -433,6 +433,14 @@ enum sldns_enum_edns_option }; typedef enum sldns_enum_edns_option sldns_edns_option; +enum sldns_enum_ede_code +{ + LDNS_EDE_OTHER = 0, + LDNS_EDE_UNSUPPORTED_DNSKEY_ALG = 1, + LDNS_EDE_UNSUPPORTED_DS_DIGEST = 2 +}; +typedef enum sldns_enum_ede_code sldns_ede_code; + #define LDNS_EDNS_MASK_DO_BIT 0x8000 /** TSIG and TKEY extended rcodes (16bit), 0-15 are the normal rcodes. */ diff --git a/util/data/msgreply.h b/util/data/msgreply.h index c6b220ed8..715f1cf64 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -515,6 +515,24 @@ void log_query_info(enum verbosity_value v, const char* str, int edns_opt_append(struct edns_data* edns, struct regional* region, uint16_t code, size_t len, uint8_t* data); +/** + * Append edns EDE option to edns options list + * @param EDNS: the edns data structure to append the edns option to. + * @param REGION: region to allocate the new edns option. + * @param CODE: the EDE code. + * @param TXT: Additional text for the option + */ +#define EDNS_OPT_APPEND_EDE(EDNS, REGION, CODE, TXT) \ + do { \ + struct { \ + uint16_t code; \ + char text[sizeof(TXT) - 1]; \ + } ede = { htons(CODE), TXT }; \ + edns_opt_append((EDNS), (REGION), LDNS_EDNS_EDE, \ + sizeof(uint16_t) + sizeof(TXT) - 1, \ + (void *)&ede); \ + } while(0); + /** * Append edns option to edns option list * @param list: the edns option list to append the edns option to.