From ffe87138c5005927d371438cff61e501827e04f2 Mon Sep 17 00:00:00 2001 From: John Dickinson Date: Wed, 21 May 2014 14:50:01 +0000 Subject: [PATCH] Added support for specify_class --- src/request-internal.c | 12 ++++++++++-- src/util-internal.h | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/request-internal.c b/src/request-internal.c index f32761c7..f450c731 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -115,6 +115,9 @@ dns_req_new(struct getdns_context *context, getdns_dns_req *result = NULL; getdns_network_req *req = NULL; + getdns_return_t r; + uint32_t klass; + result = GETDNS_MALLOC(context->mf, getdns_dns_req); if (result == NULL) { return NULL; @@ -135,9 +138,14 @@ dns_req_new(struct getdns_context *context, result->user_callback = NULL; result->local_timeout_id = 0; + /* check the specify_class extension */ + if ((r = getdns_dict_get_int(extensions, "specify_class", &klass)) + != GETDNS_RETURN_GOOD) { + klass = LDNS_RR_CLASS_IN; + } + /* create the requests */ - req = network_req_new(result, - request_type, LDNS_RR_CLASS_IN, extensions); + req = network_req_new(result, request_type, klass, extensions); if (!req) { dns_req_free(result); return NULL; diff --git a/src/util-internal.h b/src/util-internal.h index 31da3c09..1d6d1628 100644 --- a/src/util-internal.h +++ b/src/util-internal.h @@ -126,6 +126,14 @@ getdns_return_t validate_extensions(struct getdns_dict * extensions); struct getdns_list * create_list_from_rr_list(struct getdns_context *context, ldns_rr_list * rr_list); +/** + * helper to check if an extension is set. + * Should only be called for "boolean" type extensions that have a value of + * GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE + * @param extensions dictionary + * @param name of extension to check + * @return int with value 1 if set to GETDNS_EXTENSION_TRUE and 0 otherwise + */ int is_extension_set(struct getdns_dict *extensions, const char *extension); /* util-internal.h */