]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Simple EDE example
authorWillem Toorop <willem@nlnetlabs.nl>
Thu, 24 Jun 2021 10:55:46 +0000 (12:55 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Thu, 24 Jun 2021 10:55:46 +0000 (12:55 +0200)
daemon/worker.c
sldns/rrdef.h
util/data/msgreply.h

index e9e163a0448b438e3d3cb8c9d808707bffd095e7..03d131245cb8e354dbe88ff52a10cc6e66d93e2b 100644 (file)
@@ -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,
index 8fd51f0288757678147b8d9948a970a5c4adff87..f022f93cf9dda7d05b7cf6c9af528da2c748e98c 100644 (file)
@@ -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. */
index c6b220ed8d719951ea55dcaabaf70ff31b37d114..715f1cf64cd8eca5be51f2201cb5c78a064000dc 100644 (file)
@@ -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.