edns_cookies extension

This commit is contained in:
Willem Toorop 2015-03-20 21:37:54 +01:00
parent 5da3bf1af2
commit 3aea9da626
3 changed files with 16 additions and 1 deletions

View File

@ -209,6 +209,8 @@ dns_req_new(getdns_context *context, getdns_eventloop *loop,
= is_extension_set(extensions, "dnssec_return_validation_chain");
int dnssec_ok_checking_disabled
= is_extension_set(extensions, "dnssec_ok_checking_disabled");
int edns_cookies
= is_extension_set(extensions, "edns_cookies");
int dnssec_extension_set = dnssec_return_status
|| dnssec_return_only_secure || dnssec_return_validation_chain
@ -281,7 +283,8 @@ dns_req_new(getdns_context *context, getdns_eventloop *loop,
(void) getdns_list_get_length(options, &noptions);
with_opt = edns_do_bit != 0 || edns_maximum_udp_payload_size != 512 ||
edns_extended_rcode != 0 || edns_version != 0 || noptions;
edns_extended_rcode != 0 || edns_version != 0 || noptions ||
edns_cookies;
edns_maximum_udp_payload_size = with_opt &&
( edns_maximum_udp_payload_size == -1 ||
@ -307,6 +310,12 @@ dns_req_new(getdns_context *context, getdns_eventloop *loop,
max_query_sz = ( GLDNS_HEADER_SIZE
+ strlen(name) + 1 + 4 /* dname always smaller then strlen(name) + 1 */
+ 12 + opt_options_size /* space needed for OPT (if needed) */
+ ( !edns_cookies ? 0
: 2 /* EDNS0 Option Code */
+ 2 /* Option length = 8 + 16 = 24 */
+ 8 /* client cookie */
+ 16 /* server cookie */
)
/* TODO: TSIG */
+ 7) / 8 * 8;
}
@ -343,6 +352,7 @@ dns_req_new(getdns_context *context, getdns_eventloop *loop,
result->dnssec_return_status = dnssec_return_status;
result->dnssec_return_only_secure = dnssec_return_only_secure;
result->dnssec_return_validation_chain = dnssec_return_validation_chain;
result->edns_cookies = edns_cookies;
/* will be set by caller */
result->user_pointer = NULL;

View File

@ -46,6 +46,7 @@ struct getdns_context;
struct getdns_upstreams;
struct getdns_upstream;
#define EDNSCOOKIE_OPCODE 65001
/**
* \defgroup strings String Constants
@ -238,6 +239,7 @@ typedef struct getdns_dns_req {
int dnssec_return_status;
int dnssec_return_only_secure;
int dnssec_return_validation_chain;
int edns_cookies;
/* Internally used by return_validation_chain */
int dnssec_ok_checking_disabled;

View File

@ -64,6 +64,9 @@ static getdns_extension_format extformats[] = {
{"dnssec_return_only_secure", t_int},
{"dnssec_return_status", t_int},
{"dnssec_return_validation_chain", t_int},
#ifdef EDNS_COOKIES
{"edns_cookies", t_int},
#endif
{"return_api_information", t_int},
{"return_both_v4_and_v6", t_int},
{"return_call_debugging", t_int},