qusevc = false;
qrandom = true;
key_verified = NULL;
+ ldns_edns_option_list* edns_list = NULL;
ldns_init_random(NULL, 0);
/* global first, query opt next, option with parm's last
* and sorted */ /* "46DITSVQf:i:w:q:achuvxzy:so:p:b:k:" */
- while ((c = getopt(argc, argv, "46ab:c:d:Df:hi:I:k:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) {
+ while ((c = getopt(argc, argv, "46ab:c:d:e:Df:hi:I:k:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) {
switch(c) {
/* global options */
case '4':
case 'c':
resolv_conf_file = optarg;
break;
+ case 'e':
+ if (strstr(optarg, "nsid")) {
+ ldns_edns_option *edns;
+ edns_list = ldns_edns_option_list_new();
+
+ /* create NSID EDNS*/
+ edns = ldns_edns_new_from_data(LDNS_EDNS_NSID, 0, NULL);
+
+ if (edns_list == NULL || edns == NULL) {
+ error("EDNS option could not be allocated");
+ break;
+ }
+
+ // @TODO rethink this error
+ if (!(ldns_edns_option_list_push(edns_list, edns))) {
+ error("EDNS option could not be attached");
+ break;
+ }
+
+ break;
+ }
case 't':
qusevc = true;
break;
}
status = ldns_resolver_prepare_query_pkt(&qpkt, res, qname, type, clas, qflags);
if(status != LDNS_STATUS_OK) {
- error("%s", "making query: %s",
+ error("%s", "making query: %s",
ldns_get_errorstr_by_id(status));
}
dump_hex(qpkt, query_file);
} else {
/* create a packet and set the RD flag on it */
pkt = NULL;
- status = ldns_resolver_query_status(
- &pkt, res, qname,
- type, clas, qflags);
+
+ status = ldns_resolver_prepare_query_pkt(&qpkt,
+ res, qname, type, clas, qflags);
+ if(status != LDNS_STATUS_OK) {
+ error("%s", "making query: %s",
+ ldns_get_errorstr_by_id(status));
+ }
+
+ if (edns_list) {
+ /* attach the structed EDNS options for completeness */
+ ldns_pkt_set_edns_option_list(qpkt, edns_list);
+
+ /* write the structured EDNS data to unstructured data */
+ ldns_pkt_edns_write_option_list_to_edns_data(qpkt, edns_list);
+ }
+
+ status = ldns_resolver_send_pkt(&pkt, res, qpkt);
+
if (status != LDNS_STATUS_OK) {
error("error sending query: %s"
, ldns_get_errorstr_by_id(
}
}
- if (!pkt) {
+ /* now handling the response message/packet */
+ if (!pkt) {
mesg("No packet received");
result = EXIT_FAILURE;
} else {
ldns_rr_list_deep_free(key_list);
ldns_rr_list_deep_free(cmdline_rr_list);
ldns_rdf_deep_free(trace_start_name);
+ ldns_edns_option_list_deep_free(edns_list);
xfree(progname);
xfree(tsig_name);
xfree(tsig_data);