Changeset View
Changeset View
Standalone View
Standalone View
contrib/ldns/drill/drill.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | #endif /*HAVE_SSL*/ | ||||
fprintf(stream, "\t-q file\t\twrite query packet to file\n"); | fprintf(stream, "\t-q file\t\twrite query packet to file\n"); | ||||
fprintf(stream, "\t-h\t\tshow this help\n"); | fprintf(stream, "\t-h\t\tshow this help\n"); | ||||
fprintf(stream, "\t-v\t\tshow version\n"); | fprintf(stream, "\t-v\t\tshow version\n"); | ||||
fprintf(stream, "\n Query options:\n"); | fprintf(stream, "\n Query options:\n"); | ||||
fprintf(stream, "\t-4\t\tstay on ip4\n"); | fprintf(stream, "\t-4\t\tstay on ip4\n"); | ||||
fprintf(stream, "\t-6\t\tstay on ip6\n"); | fprintf(stream, "\t-6\t\tstay on ip6\n"); | ||||
fprintf(stream, "\t-a\t\tfallback to EDNS0 and TCP if the answer is truncated\n"); | fprintf(stream, "\t-a\t\tfallback to EDNS0 and TCP if the answer is truncated\n"); | ||||
fprintf(stream, "\t-b <bufsize>\tuse <bufsize> as the buffer size (defaults to 512 b)\n"); | fprintf(stream, "\t-b <bufsize>\tuse <bufsize> as the buffer size (defaults to 512 b)\n"); | ||||
fprintf(stream, "\t-c <file>\tuse file for rescursive nameserver configuration" | fprintf(stream, "\t-c <file>\tuse file for recursive nameserver configuration" | ||||
"\n\t\t\t(/etc/resolv.conf)\n"); | "\n\t\t\t(/etc/resolv.conf)\n"); | ||||
fprintf(stream, "\t-k <file>\tspecify a file that contains a trusted DNSSEC key [**]\n"); | fprintf(stream, "\t-k <file>\tspecify a file that contains a trusted DNSSEC key [**]\n"); | ||||
fprintf(stream, "\t\t\tUsed to verify any signatures in the current answer.\n"); | fprintf(stream, "\t\t\tUsed to verify any signatures in the current answer.\n"); | ||||
fprintf(stream, "\t\t\tWhen DNSSEC enabled tracing (-TD) or signature\n" | fprintf(stream, "\t\t\tWhen DNSSEC enabled tracing (-TD) or signature\n" | ||||
"\t\t\tchasing (-S) and no key files are given, keys are read\n" | "\t\t\tchasing (-S) and no key files are given, keys are read\n" | ||||
"\t\t\tfrom: %s\n", | "\t\t\tfrom: %s\n", | ||||
LDNS_TRUST_ANCHOR_FILE); | LDNS_TRUST_ANCHOR_FILE); | ||||
fprintf(stream, "\t-o <mnemonic>\tset flags to:" | fprintf(stream, "\t-o <mnemonic>\tset flags to:" | ||||
Show All 35 Lines | |||||
*/ | */ | ||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
ldns_resolver *res = NULL; | ldns_resolver *res = NULL; | ||||
ldns_resolver *cmdline_res = NULL; /* only used to resolv @name names */ | ldns_resolver *cmdline_res = NULL; /* only used to resolv @name names */ | ||||
ldns_rr_list *cmdline_rr_list = NULL; | ldns_rr_list *cmdline_rr_list = NULL; | ||||
ldns_rdf *cmdline_dname = NULL; | ldns_rdf *cmdline_dname = NULL; | ||||
ldns_rdf *qname, *qname_tmp; | ldns_rdf *qname; | ||||
ldns_pkt *pkt; | ldns_pkt *pkt; | ||||
ldns_pkt *qpkt; | ldns_pkt *qpkt; | ||||
char *serv; | char *serv; | ||||
char *src = NULL; | char *src = NULL; | ||||
const char *name; | const char *name; | ||||
char *progname; | char *progname; | ||||
char *query_file = NULL; | char *query_file = NULL; | ||||
char *answer_file = NULL; | char *answer_file = NULL; | ||||
Show All 28 Lines | #endif | ||||
uint16_t qbuf; | uint16_t qbuf; | ||||
uint16_t qport; | uint16_t qport; | ||||
uint8_t qfamily; | uint8_t qfamily; | ||||
bool qdnssec; | bool qdnssec; | ||||
bool qfallback; | bool qfallback; | ||||
bool qds; | bool qds; | ||||
bool qusevc; | bool qusevc; | ||||
bool qrandom; | bool qrandom; | ||||
bool drill_reverse = false; | |||||
char *resolv_conf_file = NULL; | char *resolv_conf_file = NULL; | ||||
ldns_rdf *trace_start_name = NULL; | ldns_rdf *trace_start_name = NULL; | ||||
int result = 0; | int result = 0; | ||||
uint8_t s6addr[16]; | uint8_t s6addr[16]; | ||||
char ip6_arpa_str[74]; | char ip6_arpa_str[74]; | ||||
uint8_t s4addr[4]; | |||||
char in_addr_arpa_str[40]; | |||||
#ifdef USE_WINSOCK | #ifdef USE_WINSOCK | ||||
int r; | int r; | ||||
WSADATA wsa_data; | WSADATA wsa_data; | ||||
#endif | #endif | ||||
ldns_output_format_storage fmt_storage; | |||||
ldns_output_format* fmt = ldns_output_format_init(&fmt_storage); | |||||
int_type = -1; serv = NULL; type = 0; | int_type = -1; serv = NULL; type = 0; | ||||
int_clas = -1; name = NULL; clas = 0; | int_clas = -1; name = NULL; clas = 0; | ||||
qname = NULL; src = NULL; | qname = NULL; src = NULL; | ||||
progname = strdup(argv[0]); | progname = strdup(argv[0]); | ||||
#ifdef USE_WINSOCK | #ifdef USE_WINSOCK | ||||
r = WSAStartup(MAKEWORD(2,2), &wsa_data); | r = WSAStartup(MAKEWORD(2,2), &wsa_data); | ||||
Show All 12 Lines | #endif /* USE_WINSOCK */ | ||||
qdnssec = false; | qdnssec = false; | ||||
qfamily = LDNS_RESOLV_INETANY; | qfamily = LDNS_RESOLV_INETANY; | ||||
qfallback = false; | qfallback = false; | ||||
qds = false; | qds = false; | ||||
qbuf = 0; | qbuf = 0; | ||||
qusevc = false; | qusevc = false; | ||||
qrandom = true; | qrandom = true; | ||||
key_verified = NULL; | key_verified = NULL; | ||||
ldns_edns_option_list* edns_list = NULL; | |||||
ldns_init_random(NULL, 0); | ldns_init_random(NULL, 0); | ||||
/* string from orig drill: "i:w:I46Sk:TNp:b:DsvhVcuaq:f:xr" */ | /* string from orig drill: "i:w:I46Sk:TNp:b:DsvhVcuaq:f:xr" */ | ||||
/* global first, query opt next, option with parm's last | /* global first, query opt next, option with parm's last | ||||
* and sorted */ /* "46DITSVQf:i:w:q:achuvxzy:so:p:b:k:" */ | * 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:Df:hi:I:k:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) { | ||||
Show All 30 Lines | #endif /* HAVE_SSL */ | ||||
case 'V': | case 'V': | ||||
if (strtok(optarg, "0123456789") != NULL) { | if (strtok(optarg, "0123456789") != NULL) { | ||||
fprintf(stderr, "-V expects an number as an argument.\n"); | fprintf(stderr, "-V expects an number as an argument.\n"); | ||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
verbosity = atoi(optarg); | verbosity = atoi(optarg); | ||||
break; | break; | ||||
case 'Q': | case 'Q': | ||||
fmt->flags |= LDNS_FMT_SHORT; | |||||
verbosity = -1; | verbosity = -1; | ||||
break; | break; | ||||
case 'f': | case 'f': | ||||
query_file = optarg; | query_file = optarg; | ||||
break; | break; | ||||
case 'i': | case 'i': | ||||
answer_file = optarg; | answer_file = optarg; | ||||
PURPOSE = DRILL_AFROMFILE; | PURPOSE = DRILL_AFROMFILE; | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | #endif /* HAVE_SSL */ | ||||
case 'u': | case 'u': | ||||
qusevc = false; | qusevc = false; | ||||
break; | break; | ||||
case 'v': | case 'v': | ||||
version(stdout, progname); | version(stdout, progname); | ||||
result = EXIT_SUCCESS; | result = EXIT_SUCCESS; | ||||
goto exit; | goto exit; | ||||
case 'x': | case 'x': | ||||
PURPOSE = DRILL_REVERSE; | drill_reverse = true; | ||||
break; | break; | ||||
case 'y': | case 'y': | ||||
#ifdef HAVE_SSL | #ifdef HAVE_SSL | ||||
if (strchr(optarg, ':')) { | if (strchr(optarg, ':')) { | ||||
tsig_separator = (size_t) (strchr(optarg, ':') - optarg); | tsig_separator = (size_t) (strchr(optarg, ':') - optarg); | ||||
if (tsig_algorithm) { | |||||
free(tsig_algorithm); | |||||
tsig_algorithm = NULL; | |||||
} | |||||
if (strchr(optarg + tsig_separator + 1, ':')) { | if (strchr(optarg + tsig_separator + 1, ':')) { | ||||
tsig_separator2 = (size_t) (strchr(optarg + tsig_separator + 1, ':') - optarg); | tsig_separator2 = (size_t) (strchr(optarg + tsig_separator + 1, ':') - optarg); | ||||
tsig_algorithm = xmalloc(strlen(optarg) - tsig_separator2); | tsig_algorithm = xmalloc(strlen(optarg) - tsig_separator2); | ||||
strncpy(tsig_algorithm, optarg + tsig_separator2 + 1, strlen(optarg) - tsig_separator2); | strncpy(tsig_algorithm, optarg + tsig_separator2 + 1, strlen(optarg) - tsig_separator2); | ||||
tsig_algorithm[strlen(optarg) - tsig_separator2 - 1] = '\0'; | tsig_algorithm[strlen(optarg) - tsig_separator2 - 1] = '\0'; | ||||
} else { | } else { | ||||
tsig_separator2 = strlen(optarg); | tsig_separator2 = strlen(optarg); | ||||
tsig_algorithm = strdup("hmac-md5.sig-alg.reg.int"); | tsig_algorithm = strdup("hmac-md5.sig-alg.reg.int"); | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | for(i = 0; i < argc; i++) { | ||||
if (argv[i][0] == '@') { | if (argv[i][0] == '@') { | ||||
if (strlen(argv[i]) == 1) { | if (strlen(argv[i]) == 1) { | ||||
warning("%s", "No nameserver given"); | warning("%s", "No nameserver given"); | ||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
serv = argv[i] + 1; | serv = argv[i] + 1; | ||||
continue; | continue; | ||||
} | } | ||||
/* if ^+ then it's an EDNS option */ | |||||
if (argv[i][0] == '+') { | |||||
if (!strcmp(argv[i]+1, "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; | |||||
} | |||||
if (!(ldns_edns_option_list_push(edns_list, edns))) { | |||||
error("EDNS option NSID could not be attached"); | |||||
break; | |||||
} | |||||
continue; | |||||
} | |||||
else { | |||||
error("Unsupported argument after '+'"); | |||||
break; | |||||
} | |||||
} | |||||
/* if has a dot, it's a name */ | /* if has a dot, it's a name */ | ||||
if (strchr(argv[i], '.')) { | if (strchr(argv[i], '.')) { | ||||
name = argv[i]; | name = argv[i]; | ||||
continue; | continue; | ||||
} | } | ||||
/* if it matches a type, it's a type */ | /* if it matches a type, it's a type */ | ||||
if (int_type == -1) { | if (int_type == -1) { | ||||
type = ldns_get_rr_type_by_name(argv[i]); | type = ldns_get_rr_type_by_name(argv[i]); | ||||
Show All 24 Lines | if (!name) { | ||||
type = LDNS_RR_TYPE_NS; | type = LDNS_RR_TYPE_NS; | ||||
} | } | ||||
/* defaults if not given */ | /* defaults if not given */ | ||||
if (int_clas == -1) { | if (int_clas == -1) { | ||||
clas = LDNS_RR_CLASS_IN; | clas = LDNS_RR_CLASS_IN; | ||||
} | } | ||||
if (int_type == -1) { | if (int_type == -1) { | ||||
if (PURPOSE != DRILL_REVERSE) { | if (!drill_reverse) { | ||||
type = LDNS_RR_TYPE_A; | type = LDNS_RR_TYPE_A; | ||||
} else { | } else { | ||||
type = LDNS_RR_TYPE_PTR; | type = LDNS_RR_TYPE_PTR; | ||||
} | } | ||||
} | } | ||||
if (!drill_reverse) | |||||
; /* pass */ | |||||
else if (strchr(name, ':')) { /* ipv4 or ipv6 addr? */ | |||||
if (!inet_pton(AF_INET6, name, &s6addr)) { | |||||
error("Syntax error: cannot parse IPv6 address\n"); | |||||
} | |||||
(void) snprintf(ip6_arpa_str, sizeof(ip6_arpa_str), | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa.", | |||||
(unsigned int)(s6addr[15] & 0x0F), | |||||
(unsigned int)(s6addr[15] >> 4), | |||||
(unsigned int)(s6addr[14] & 0x0F), | |||||
(unsigned int)(s6addr[14] >> 4), | |||||
(unsigned int)(s6addr[13] & 0x0F), | |||||
(unsigned int)(s6addr[13] >> 4), | |||||
(unsigned int)(s6addr[12] & 0x0F), | |||||
(unsigned int)(s6addr[12] >> 4), | |||||
(unsigned int)(s6addr[11] & 0x0F), | |||||
(unsigned int)(s6addr[11] >> 4), | |||||
(unsigned int)(s6addr[10] & 0x0F), | |||||
(unsigned int)(s6addr[10] >> 4), | |||||
(unsigned int)(s6addr[9] & 0x0F), | |||||
(unsigned int)(s6addr[9] >> 4), | |||||
(unsigned int)(s6addr[8] & 0x0F), | |||||
(unsigned int)(s6addr[8] >> 4), | |||||
(unsigned int)(s6addr[7] & 0x0F), | |||||
(unsigned int)(s6addr[7] >> 4), | |||||
(unsigned int)(s6addr[6] & 0x0F), | |||||
(unsigned int)(s6addr[6] >> 4), | |||||
(unsigned int)(s6addr[5] & 0x0F), | |||||
(unsigned int)(s6addr[5] >> 4), | |||||
(unsigned int)(s6addr[4] & 0x0F), | |||||
(unsigned int)(s6addr[4] >> 4), | |||||
(unsigned int)(s6addr[3] & 0x0F), | |||||
(unsigned int)(s6addr[3] >> 4), | |||||
(unsigned int)(s6addr[2] & 0x0F), | |||||
(unsigned int)(s6addr[2] >> 4), | |||||
(unsigned int)(s6addr[1] & 0x0F), | |||||
(unsigned int)(s6addr[1] >> 4), | |||||
(unsigned int)(s6addr[0] & 0x0F), | |||||
(unsigned int)(s6addr[0] >> 4)); | |||||
name = ip6_arpa_str; | |||||
} else if (!inet_pton(AF_INET, name, &s4addr)) { | |||||
error("Syntax error: cannot parse IPv4 address\n"); | |||||
} else { | |||||
(void) snprintf(in_addr_arpa_str, sizeof(in_addr_arpa_str), | |||||
"%d.%d.%d.%d.in-addr.arpa.", (int)s4addr[3], | |||||
(int)s4addr[2], (int)s4addr[1], (int)s4addr[0]); | |||||
name = in_addr_arpa_str; | |||||
} | |||||
if (src) { | if (src) { | ||||
src_rdf = ldns_rdf_new_addr_frm_str(src); | src_rdf = ldns_rdf_new_addr_frm_str(src); | ||||
if(!src_rdf) { | if(!src_rdf) { | ||||
fprintf(stderr, "-I must be a valid IP[v6] address.\n"); | fprintf(stderr, "-I must be a valid IP[v6] address.\n"); | ||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
} | } | ||||
if (ldns_rdf_size(src_rdf) == 4) { | if (ldns_rdf_size(src_rdf) == 4) { | ||||
qfamily = LDNS_RESOLV_INET; | qfamily = LDNS_RESOLV_INET; | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | case DRILL_AFROMFILE: | ||||
break; | break; | ||||
case DRILL_QTOFILE: | case DRILL_QTOFILE: | ||||
qname = ldns_dname_new_frm_str(name); | qname = ldns_dname_new_frm_str(name); | ||||
if (!qname) { | if (!qname) { | ||||
error("%s", "making qname"); | error("%s", "making qname"); | ||||
} | } | ||||
status = ldns_resolver_prepare_query_pkt(&qpkt, res, qname, type, clas, qflags); | status = ldns_resolver_prepare_query_pkt(&qpkt, res, qname, type, clas, qflags); | ||||
if(status != LDNS_STATUS_OK) { | if(status != LDNS_STATUS_OK) { | ||||
error("%s", "making query: %s", | error("%s", "making query: %s", | ||||
ldns_get_errorstr_by_id(status)); | ldns_get_errorstr_by_id(status)); | ||||
} | } | ||||
dump_hex(qpkt, query_file); | dump_hex(qpkt, query_file); | ||||
ldns_pkt_free(qpkt); | ldns_pkt_free(qpkt); | ||||
break; | break; | ||||
case DRILL_NSEC: | case DRILL_NSEC: | ||||
break; | break; | ||||
case DRILL_REVERSE: | |||||
/* ipv4 or ipv6 addr? */ | |||||
if (strchr(name, ':')) { | |||||
if (!inet_pton(AF_INET6, name, &s6addr)) { | |||||
error("Syntax error: cannot parse IPv6 address\n"); | |||||
} | |||||
(void) snprintf(ip6_arpa_str, sizeof(ip6_arpa_str), | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x." | |||||
"%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa.", | |||||
(unsigned int)(s6addr[15] & 0x0F), | |||||
(unsigned int)(s6addr[15] >> 4), | |||||
(unsigned int)(s6addr[14] & 0x0F), | |||||
(unsigned int)(s6addr[14] >> 4), | |||||
(unsigned int)(s6addr[13] & 0x0F), | |||||
(unsigned int)(s6addr[13] >> 4), | |||||
(unsigned int)(s6addr[12] & 0x0F), | |||||
(unsigned int)(s6addr[12] >> 4), | |||||
(unsigned int)(s6addr[11] & 0x0F), | |||||
(unsigned int)(s6addr[11] >> 4), | |||||
(unsigned int)(s6addr[10] & 0x0F), | |||||
(unsigned int)(s6addr[10] >> 4), | |||||
(unsigned int)(s6addr[9] & 0x0F), | |||||
(unsigned int)(s6addr[9] >> 4), | |||||
(unsigned int)(s6addr[8] & 0x0F), | |||||
(unsigned int)(s6addr[8] >> 4), | |||||
(unsigned int)(s6addr[7] & 0x0F), | |||||
(unsigned int)(s6addr[7] >> 4), | |||||
(unsigned int)(s6addr[6] & 0x0F), | |||||
(unsigned int)(s6addr[6] >> 4), | |||||
(unsigned int)(s6addr[5] & 0x0F), | |||||
(unsigned int)(s6addr[5] >> 4), | |||||
(unsigned int)(s6addr[4] & 0x0F), | |||||
(unsigned int)(s6addr[4] >> 4), | |||||
(unsigned int)(s6addr[3] & 0x0F), | |||||
(unsigned int)(s6addr[3] >> 4), | |||||
(unsigned int)(s6addr[2] & 0x0F), | |||||
(unsigned int)(s6addr[2] >> 4), | |||||
(unsigned int)(s6addr[1] & 0x0F), | |||||
(unsigned int)(s6addr[1] >> 4), | |||||
(unsigned int)(s6addr[0] & 0x0F), | |||||
(unsigned int)(s6addr[0] >> 4)); | |||||
qname = ldns_dname_new_frm_str(ip6_arpa_str); | |||||
} else { | |||||
qname = ldns_dname_new_frm_str(name); | |||||
if (qname) { | |||||
qname_tmp = ldns_dname_reverse(qname); | |||||
ldns_rdf_deep_free(qname); | |||||
qname = qname_tmp; | |||||
qname_tmp = ldns_dname_new_frm_str("in-addr.arpa."); | |||||
status = ldns_dname_cat(qname, qname_tmp); | |||||
if (status != LDNS_STATUS_OK) { | |||||
error("%s", "could not create reverse address for ip4: %s\n", ldns_get_errorstr_by_id(status)); | |||||
} | |||||
ldns_rdf_deep_free(qname_tmp); | |||||
} | |||||
} | |||||
if (!qname) { | |||||
error("%s", "-x implies an ip address"); | |||||
} | |||||
/* create a packet and set the RD flag on it */ | |||||
pkt = NULL; | |||||
status = ldns_resolver_query_status( | |||||
&pkt, res, qname, type, clas, qflags); | |||||
if (status != LDNS_STATUS_OK) { | |||||
error("error sending query: %s", | |||||
ldns_get_errorstr_by_id(status)); | |||||
} | |||||
if (!pkt) { | |||||
if (status == LDNS_STATUS_OK) { | |||||
error("%s", "pkt sending"); | |||||
} | |||||
result = EXIT_FAILURE; | |||||
} else { | |||||
if (verbosity != -1) { | |||||
ldns_pkt_print(stdout, pkt); | |||||
} | |||||
ldns_pkt_free(pkt); | |||||
} | |||||
break; | |||||
case DRILL_QUERY: | case DRILL_QUERY: | ||||
default: | default: | ||||
if (query_file) { | if (query_file) { | ||||
/* this old way, the query packet needed | /* this old way, the query packet needed | ||||
to be parseable, but we want to be able | to be parseable, but we want to be able | ||||
to send mangled packets, so we need | to send mangled packets, so we need | ||||
to do it directly */ | to do it directly */ | ||||
#if 0 | #if 0 | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | default: | ||||
ldns_rr_free(axfr_rr); | ldns_rr_free(axfr_rr); | ||||
axfr_rr = ldns_axfr_next(res); | axfr_rr = ldns_axfr_next(res); | ||||
} | } | ||||
goto exit; | goto exit; | ||||
} else { | } else { | ||||
/* create a packet and set the RD flag on it */ | /* create a packet and set the RD flag on it */ | ||||
pkt = NULL; | pkt = NULL; | ||||
status = ldns_resolver_query_status( | |||||
&pkt, res, qname, | status = ldns_resolver_prepare_query_pkt(&qpkt, | ||||
type, clas, qflags); | res, qname, type, clas, qflags); | ||||
if (status != LDNS_STATUS_OK) { | if(status != LDNS_STATUS_OK) { | ||||
error("%s", "making query: %s", | |||||
ldns_get_errorstr_by_id(status)); | |||||
} | |||||
if (edns_list) { | |||||
/* attach the structed EDNS options */ | |||||
ldns_pkt_set_edns_option_list(qpkt, edns_list); | |||||
} | |||||
status = ldns_resolver_send_pkt(&pkt, res, qpkt); | |||||
ldns_pkt_free(qpkt); | |||||
if (status != LDNS_STATUS_OK) { | |||||
error("error sending query: %s" | error("error sending query: %s" | ||||
, ldns_get_errorstr_by_id( | , ldns_get_errorstr_by_id( | ||||
status)); | status)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* now handling the response message/packet */ | |||||
if (!pkt) { | if (!pkt) { | ||||
mesg("No packet received"); | mesg("No packet received"); | ||||
result = EXIT_FAILURE; | result = EXIT_FAILURE; | ||||
} else { | } else { | ||||
ldns_pkt_print_fmt(stdout, fmt, pkt); | |||||
if (verbosity != -1) { | if (verbosity != -1) { | ||||
ldns_pkt_print(stdout, pkt); | |||||
if (ldns_pkt_tc(pkt)) { | if (ldns_pkt_tc(pkt)) { | ||||
fprintf(stdout, | fprintf(stdout, | ||||
"\n;; WARNING: The answer packet was truncated; you might want to\n"); | "\n;; WARNING: The answer packet was truncated; you might want to\n"); | ||||
fprintf(stdout, | fprintf(stdout, | ||||
";; query again with TCP (-t argument), or EDNS0 (-b for buffer size)\n"); | ";; query again with TCP (-t argument), or EDNS0 (-b for buffer size)\n"); | ||||
} | } | ||||
} | } | ||||
if (qds) { | if (qds) { | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | #endif /* HAVE_SSL */ | ||||
ldns_rr_list_deep_free(cmdline_rr_list); | ldns_rr_list_deep_free(cmdline_rr_list); | ||||
ldns_rdf_deep_free(trace_start_name); | ldns_rdf_deep_free(trace_start_name); | ||||
xfree(progname); | xfree(progname); | ||||
xfree(tsig_name); | xfree(tsig_name); | ||||
xfree(tsig_data); | xfree(tsig_data); | ||||
xfree(tsig_algorithm); | xfree(tsig_algorithm); | ||||
#ifdef HAVE_SSL | #ifdef HAVE_SSL | ||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(HAVE_LIBRESSL) | |||||
#ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA | |||||
CRYPTO_cleanup_all_ex_data(); | CRYPTO_cleanup_all_ex_data (); | ||||
#endif | |||||
#ifdef HAVE_ERR_FREE_STRINGS | |||||
ERR_free_strings(); | ERR_free_strings (); | ||||
#endif | |||||
#ifdef HAVE_EVP_CLEANUP | |||||
EVP_cleanup(); | EVP_cleanup (); | ||||
#endif | |||||
#endif | |||||
#endif | #endif | ||||
#ifdef USE_WINSOCK | #ifdef USE_WINSOCK | ||||
WSACleanup(); | WSACleanup(); | ||||
#endif | #endif | ||||
return result; | return result; | ||||
} | } |