dighost.c revision 938aea1dc406d525d0c2bbdd4e71f52a942f97c6
5fa46bc91672ef5737aee6f99763161511566c24Tinderbox User * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 2000-2003 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * purpose with or without fee is hereby granted, provided that the above
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews/* $Id: dighost.c,v 1.345 2011/12/07 17:23:28 each Exp $ */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Notice to programmers: Do not use this code as an example of how to
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * use the ISC library to perform DNS lookups. Dig and Host both operate
f4b4e7c16211137332e50bcad3fef0d15639a4f1Brian Wellington * on the request level, since they allow fine-tuning of output and are
f4b4e7c16211137332e50bcad3fef0d15639a4f1Brian Wellington * intended as debugging tools. As a result, they perform many of the
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * functions which could be better handled using the dns_resolver
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * functions in most applications.
23f64ea0dcd7f5b7094ae6ade2a002fb7dde1466Brian Wellingtonunsigned int timeout = 0;
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonstatic void initialize_idn(void);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonstatic isc_result_t output_filter(isc_buffer_t *buffer,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonstatic idn_result_t append_textname(char *name, const char *origin,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonstatic void idn_check_result(idn_result_t r, const char *msg);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Exit Codes:
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington *\li 0 Everything went well, including things like NXDOMAIN
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington *\li 1 Usage error
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington *\li 7 Got too many RR's or Names
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington *\li 8 Couldn't open batch file
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington *\li 9 No reply from server
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington *\li 10 Internal error
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonunsigned int digestbits = 0;
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonisc_result_t get_trusted_key(isc_mem_t *mctx);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_rdataset_t * sigchase_scanname(dns_rdatatype_t type,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtondns_rdataset_t * chase_scanname_section(dns_message_t *msg,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_result_t advanced_rrsearch(dns_rdataset_t **rdataset,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_result_t sigchase_verify_sig_key(dns_name_t *name,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t sigchase_verify_sig(dns_name_t *name,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_result_t sigchase_verify_ds(dns_name_t *name,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonvoid print_rdata(dns_rdata_t *rdata, isc_mem_t *mctx);
23f64ea0dcd7f5b7094ae6ade2a002fb7dde1466Brian Wellington dns_rdataset_t *rdataset, isc_mem_t *mctx);
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrewsvoid dup_name(dns_name_t *source, dns_name_t* target,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonvoid free_name(dns_name_t *name, isc_mem_t *mctx);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonvoid dump_database_section(dns_message_t *msg, int section);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtondns_rdataset_t * search_type(dns_name_t *name, dns_rdatatype_t type,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t contains_trusted_key(dns_name_t *name,
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrewsisc_result_t prove_nx_domain(dns_message_t * msg,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t prove_nx_type(dns_message_t * msg, dns_name_t *name,
e2fd12f3a020ca8c5de168a44fb72e339cdaa3e9Brian Wellingtonisc_result_t prove_nx(dns_message_t * msg, dns_name_t * name,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonstatic void nameFromString(const char *str, dns_name_t *p_ret);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonint inf_name(dns_name_t * name1, dns_name_t * name2);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t removetmpkey(isc_mem_t *mctx, const char *file);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t insert_trustedkey(void *arg, dns_name_t *name,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t getneededrr(dns_message_t *msg);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonvoid sigchase_bottom_up(dns_message_t *msg);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t initialization(dns_name_t *name);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t prepare_lookup(dns_name_t *name);
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t grandfather_pb_test(dns_name_t * zone_name,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellingtonisc_result_t child_of_zone(dns_name_t *name,
d2aebe24c477c70e79dc33ea0507e8886eb7d626Brian Wellingtondns_rdataset_t *chase_sigkeyrdataset = NULL;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * the current name is the parent name when we follow delegation
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * the child name is used for delegation (NS DS responses in AUTHORITY section)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t chase_siglookedup = ISC_FALSE;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t chase_keylookedup = ISC_FALSE;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t chase_sigkeylookedup = ISC_FALSE;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t chase_sigdslookedup = ISC_FALSE;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t delegation_follow = ISC_FALSE;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonisc_boolean_t have_delegation_ns = ISC_FALSE;
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas GustafssonISC_LIST(dig_message_t) chase_message_list2;
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssonstruct_tk_list tk_list = { {NULL, NULL, NULL, NULL, NULL}, 0};
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * Apply and clear locks at the event level in global task.
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * Can I get rid of these using shutdown events? XXX
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater debug("lock_lookup %s:%d", __FILE__, __LINE__);\
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson check_result(isc_mutex_lock((&lookup_lock)), "isc_mutex_lock");\
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson debug("unlock_lookup %s:%d", __FILE__, __LINE__);\
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson check_result(isc_mutex_unlock((&lookup_lock)),\
daa73eae708d568d453e6082e0890d35886a9e0fMark Andrews "isc_mutex_unlock");\
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssonrecv_done(isc_task_t *task, isc_event_t *event);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssonconnect_timeout(isc_task_t *task, isc_event_t *event);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssonlaunch_next_query(dig_query_t *query, isc_boolean_t include_question);
daa73eae708d568d453e6082e0890d35886a9e0fMark Andrewsstatic void *
a4c351fcef77fb332e3cb20253fb96556a414a17Brian Wellingtonmem_free(void *arg, void *mem, size_t size) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonnext_token(char **stringp, const char *delim) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington while (*s != '\0') {
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson if (*s == '.')
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson unsigned int len, i;
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Append 'len' bytes of 'text' at '*p', failing with
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * ISC_R_NOSPACE if that would advance p past 'end'.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonappend(const char *text, int len, char **p, char *end) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonreverse_octets(const char *in, char **p, char *end) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonget_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington r = inet_pton(AF_INET6, value, &addr.type.in6);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* This is a valid IPv6 address. */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington unsigned int options = 0;
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson result = dns_byaddr_createptrname2(&addr, options, name);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * Not a valid IPv6 address. Assume IPv4.
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * If 'strict' is not set, construct the
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * in-addr.arpa name by blindly reversing
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * octets whether or not they look like integers,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * so that this can be used for RFC2317 names
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson if (strict && inet_pton(AF_INET, value, &addr.type.in) != 1)
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson /* Append .in-addr.arpa. and a terminating NUL. */
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson result = append(".in-addr.arpa.", 15, &p, end);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fprintf(stderr, "%ld.%06ld: ", (long)tv.tv_sec,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtoncheck_result(isc_result_t result, const char *msg) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("%s: %s", msg, isc_result_totext(result));
e2fd12f3a020ca8c5de168a44fb72e339cdaa3e9Brian Wellington * Create a server structure, which is part of the lookup structure.
e2fd12f3a020ca8c5de168a44fb72e339cdaa3e9Brian Wellington * This is little more than a linked list of servers to query in hopes
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * of finding the answer the user is looking for
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonmake_server(const char *servname, const char *userarg) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("memory allocation failure in %s:%d",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strlcpy(srv->servername, servname, MXNAME);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Create a copy of the server list from the lwres configuration structure.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * The dest list must have already had ISC_LIST_INIT applied.
7829fad4093f2c1985b1efb7cea00287ff015d2bckbcopy_server_list(lwres_conf_t *confdata, dig_serverlist_t *dest) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington af = addr2af(confdata->nameservers[i].family);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington lwres_net_ntop(af, confdata->nameservers[i].address,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington while (s != NULL) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = bind9_getaddresses(opt, 0, sockaddrs,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington for (i = 0; i < count; i++) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_netaddr_fromsockaddr(&netaddr, &sockaddrs[i]);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_netaddr_format(&netaddr, tmp, sizeof(tmp));
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonadd_nameserver(lwres_conf_t *confdata, const char *addr, int af) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (confdata->nsnext >= LWRES_CONFMAXNAMESERVERS)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington confdata->nameservers[i].family = LWRES_ADDRTYPE_V4;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington confdata->nameservers[i].length = NS_INADDRSZ;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington confdata->nameservers[i].family = LWRES_ADDRTYPE_V6;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington confdata->nameservers[i].length = NS_IN6ADDRSZ;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (lwres_net_pton(af, addr, &confdata->nameservers[i].address) == 1) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Produce a cloned server list. The dest list must have already had
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * ISC_LIST_INIT applied.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonclone_server_list(dig_serverlist_t src, dig_serverlist_t *dest) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington newsrv = make_server(srv->servername, srv->userarg);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Create an empty lookup structure, which holds all the information needed
5e387b9ce6bafdfadedb5b34e4c33a4404e5d589Brian Wellington * to get an answer to a user's question. This structure contains two
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * linked lists: the server list (servers to query) and the query list
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * (outstanding queries which have been made to the listed servers).
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("memory allocation failure in %s:%d",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Clone a lookup, perhaps copying the server list. This does not clone
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * the query list, since it will be regenerated by the setup_lookup()
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * function, nor does it queue up the new lookup for processing.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Caution: If you don't clone the servers, you MUST clone the server
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater * list separately from somewhere else, or construct it by hand.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonclone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strlcpy(looknew->textname, lookold->textname, MXNAME);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strlcpy(looknew->textnamesigchase, lookold->textnamesigchase, MXNAME);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strlcpy(looknew->cmdline, lookold->cmdline, MXNAME);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->ixfr_serial = lookold->ixfr_serial;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->identify_previous_line = lookold->identify_previous_line;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->servfail_stops = lookold->servfail_stops;
fefe1106d96d3a89b21315f665b36a67cdea3840Mark Andrews looknew->trace_root_sigchase = lookold->trace_root_sigchase;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->rdtype_sigchaseset = lookold->rdtype_sigchaseset;
fefe1106d96d3a89b21315f665b36a67cdea3840Mark Andrews looknew->rdtype_sigchase = lookold->rdtype_sigchase;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->qrdtype_sigchase = lookold->qrdtype_sigchase;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->rdclass_sigchase = lookold->rdclass_sigchase;
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews looknew->rdclass_sigchaseset = lookold->rdclass_sigchaseset;
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews looknew->ns_search_only = lookold->ns_search_only;
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews looknew->section_question = lookold->section_question;
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews looknew->section_answer = lookold->section_answer;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->section_authority = lookold->section_authority;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington looknew->section_additional = lookold->section_additional;
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews * Requeue a lookup for further processing, perhaps copying the server
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews * list. The new lookup structure is returned to the caller, and is
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews * queued for processing. If servers are not cloned in the requeue, they
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews * must be added before allowing the current event to complete, since the
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * completion of the event may result in the next entry on the lookup
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * queue getting run.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonrequeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
0a45f098e446a7f41c2a71d9dd0fd8f459b49c34Brian Wellington debug("before insertion, init@%p -> %p, new@%p -> %p",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington lookold, lookold->link.next, looknew, looknew->link.next);
0a45f098e446a7f41c2a71d9dd0fd8f459b49c34Brian Wellington ISC_LIST_PREPEND(lookup_list, looknew, link);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington debug("after insertion, init -> %p, new = %p, new -> %p",
c302b021cc65cc9a358a9a1cbe48de12364f4cb6Brian Wellington unsigned char *secretstore;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "isc_buffer_allocate");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington secretstore = isc_mem_allocate(mctx, secretsize);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("memory allocation failure in %s:%d",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_buffer_init(&secretbuf, secretstore, secretsize);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_base64_decodestring(keysecret, &secretbuf);
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews secretsize = isc_buffer_usedlength(&secretbuf);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_name_fromtext(&keyname, namebuf, dns_rootname, 0, namebuf);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_tsigkey_create(&keyname, hmacname, secretstore,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonparse_uint(isc_uint32_t *uip, const char *value, isc_uint32_t max,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington const char *desc) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_result_t result = isc_parse_uint32(&n, value, 10);
cfcb0881d12db2b7cb33475b7d20ac6c9015203bMark Andrewsparse_bits(char *arg, const char *desc, isc_uint32_t max) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Parse HMAC algorithm specification
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("unknown key type '%.*s'", len, hmac);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-md5-", 9) == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington digestbits = parse_bits(&buf[9], "digest-bits [0..128]", 128);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strcasecmp(buf, "hmac-sha1") == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-sha1-", 10) == 0) {
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson digestbits = parse_bits(&buf[10], "digest-bits [0..160]", 160);
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson } else if (strcasecmp(buf, "hmac-sha224") == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-sha224-", 12) == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington digestbits = parse_bits(&buf[12], "digest-bits [0..224]", 224);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strcasecmp(buf, "hmac-sha256") == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-sha256-", 12) == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington digestbits = parse_bits(&buf[12], "digest-bits [0..256]", 256);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strcasecmp(buf, "hmac-sha384") == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-sha384-", 12) == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington digestbits = parse_bits(&buf[12], "digest-bits [0..384]", 384);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strcasecmp(buf, "hmac-sha512") == 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington } else if (strncasecmp(buf, "hmac-sha512-", 12) == 0) {
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson digestbits = parse_bits(&buf[12], "digest-bits [0..512]", 512);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Get a key from a named.conf format keyfile
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = cfg_parser_create(mctx, lctx, &pctx);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = cfg_parse_file(pctx, keyfile, &cfg_type_sessionkey,
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington (void) cfg_map_get(key, "secret", &secretobj);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington (void) cfg_map_get(key, "algorithm", &algorithmobj);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington if (secretobj == NULL || algorithmobj == NULL)
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington fatal("key must have algorithm and secret");
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington keyname = cfg_obj_asstring(cfg_map_getname(key));
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington algorithm = cfg_obj_asstring(algorithmobj);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews strlcpy(keynametext, keyname, sizeof(keynametext));
6e2871232f7ede047799480370aff444be1f5a13Automatic Updater strlcpy(keysecret, secretstr, sizeof(keysecret));
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* Try reading the key from a K* pair */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington result = dst_key_fromnamedfile(keyfile, NULL,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* If that didn't work, try reading it as a session.key keyfile */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fprintf(stderr, "Couldn't read key from %s: %s\n",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington printf(";; Couldn't create key %s: bad algorithm\n",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_tsigkey_createfromkey(dst_key_name(dstkey), hmacname,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington search = isc_mem_allocate(mctx, sizeof(*search));
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("memory allocation failure in %s:%d",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington while ((search = ISC_LIST_HEAD(search_list)) != NULL) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LIST_UNLINK(search_list, search, link);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtoncreate_search_list(lwres_conf_t *confdata) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington for (i = 0; i < confdata->searchnxt; i++) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington search = make_searchlist_entry(confdata->search[i]);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LIST_APPEND(search_list, search, link);
f8abaa0fae7f75d9601c10b6a4af8dd907494d45Mark Andrews * Setup the system as a whole, reading key information and resolv.conf
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington lwresult = lwres_context_create(&lwctx, mctx, mem_alloc, mem_free,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington lwresult = lwres_conf_parse(lwctx, RESOLV_CONF);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (lwresult != LWRES_R_SUCCESS && lwresult != LWRES_R_NOTFOUND)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* Make the search list */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington else { /* No search list. Use the domain name if any */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington domain = make_searchlist_entry(lwconf->domainname);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LIST_APPEND(search_list, domain, link);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* If user doesn't specify server use nameservers from resolv.conf. */
4a30ede93d59137009db734661cde17612e8ffbeMark Andrews /* If we don't find a nameserver fall back to localhost */
4a30ede93d59137009db734661cde17612e8ffbeMark Andrews lwresult = add_nameserver(lwconf, "127.0.0.1", AF_INET);
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews lwresult = add_nameserver(lwconf, "::1", AF_INET6);
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt else if (keysecret[0] != 0)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* Setup the list of messages for +sigchase */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_name_init(&chase_authority_name, NULL);
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt * Override the search list derived from resolv.conf by 'domain'.
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * Setup the ISC and DNS libraries for use by the system.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington fatal("can't find either v4 or v6 networking");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_log_create(mctx, &lctx, &logconfig);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "isc_log_usechannel");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_taskmgr_create(mctx, 1, 0, &taskmgr);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "isc_taskmgr_create");
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington result = isc_task_create(taskmgr, 0, &global_task);
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington result = isc_timermgr_create(mctx, &timermgr);
e2fd12f3a020ca8c5de168a44fb72e339cdaa3e9Brian Wellington check_result(result, "isc_timermgr_create");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_socketmgr_create(mctx, &socketmgr);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "isc_socketmgr_create");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "isc_entropy_create");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = isc_mempool_create(mctx, COMMSIZE, &commctx);
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington check_result(result, "isc_mempool_create");
e2fd12f3a020ca8c5de168a44fb72e339cdaa3e9Brian Wellington * 6 and 2 set as reasonable parameters for 3 or 4 nameserver
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Add EDNS0 option record to a message. Currently, the only supported
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * options are UDP buffer size, the DO bit, and NSID request.
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellingtonadd_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_uint16_t edns,
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington result = dns_message_gettemprdataset(msg, &rdataset);
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington check_result(result, "dns_message_gettemprdataset");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_message_gettemprdatalist(msg, &rdatalist);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "dns_message_gettemprdatalist");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_message_gettemprdata(msg, &rdata);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "dns_message_gettemprdata");
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington check_result(result, "isc_buffer_allocate");
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_rdatalist_tordataset(rdatalist, rdataset);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_message_setopt(msg, rdataset);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "dns_message_setopt");
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * Add a question section to a message, asking for the specified name,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * type, and class.
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉add_question(dns_message_t *message, dns_name_t *name,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_rdataclass_t rdclass, dns_rdatatype_t rdtype)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_message_gettemprdataset(message, &rdataset);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington check_result(result, "dns_message_gettemprdataset()");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_rdataset_makequestion(rdataset, rdclass, rdtype);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LIST_APPEND(name->list, rdataset, link);
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington * Check if we're done with all the queued lookups, which is true iff
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington * all sockets, sends, and recvs are accounted for (counters == 0),
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington * and the lookup list is empty.
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington * If we are done, pass control back out to dighost_shutdown() (which is
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * part of dig.c, host.c, or nslookup.c) to either shutdown the system as
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * a whole or reseed the lookup list.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington debug("list %s", ISC_LIST_EMPTY(lookup_list) ? "empty" : "full");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (ISC_LIST_EMPTY(lookup_list) && current_lookup == NULL &&
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Clear out a query when we're done with it. WARNING: This routine
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * WILL invalidate the query pointer.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington ISC_LIST_UNLINK(lookup->connecting, query, clink);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington if (ISC_LINK_LINKED(&query->recvbuf, link))
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington ISC_LIST_DEQUEUE(query->recvlist, &query->recvbuf,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington if (ISC_LINK_LINKED(&query->lengthbuf, link))
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington ISC_LIST_DEQUEUE(query->lengthlist, &query->lengthbuf,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington isc_mempool_put(commctx, query->recvspace);
01dbc4fc00adc933af96e88bfce95c07ef1f3c39Mark Andrews * Try and clear out a lookup if we're done with it. Return ISC_TRUE if
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * the lookup was successfully cleared. If ISC_TRUE is returned, the
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * lookup pointer has been invalidated.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington while (q != NULL) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington debug("query to %s still pending", q->servname);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington while (q != NULL) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * At this point, we know there are no queries on the lookup,
b7cd261f2fca2c7138cdc6ae8ee434e9c0031303Brian Wellington * so can make it go away also.
b7cd261f2fca2c7138cdc6ae8ee434e9c0031303Brian Wellington while (s != NULL) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington debug("freeing server %p belonging to %p", s, lookup);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington debug("freeing buffer %p", lookup->querysig);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_mempool_put(commctx, lookup->sendspace);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If we can, start the next lookup in the queue running.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * This assumes that the lookup on the head of the queue hasn't been
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * started yet. It also removes the lookup from the head of the queue,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * setting the current_lookup pointer pointing to it.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If there's a current lookup running, we really shouldn't get
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington current_lookup = ISC_LIST_HEAD(lookup_list);
#if DIG_SIGCHASE_TD
isc_region_t r;
goto novalidation;
goto novalidation;
ISC_FALSE, b);
isc_buffer_usedregion(b, &r);
MXNAME);
isc_buffer_free(&b);
&chase_name);
start_lookup();
int numLookups = 0;
int num;
0, &rdataset);
&rdataset);
unsigned int nlabels;
int order;
if (!horizontal)
if (!bad)
if (!success) {
isc_uint32_t i, j;
i = numLookups;
INSIST(i > 0);
isc_random_get(&j);
return (numLookups);
static isc_boolean_t
if (!usesearch)
return (ISC_FALSE);
0, NULL);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
int len;
isc_buffer_t b;
#ifdef WITH_IDN
#ifdef WITH_IDN
lookup_counter = 0;
#ifdef WITH_IDN
* is TRUE or we got a domain line in the resolv.conf file.
#ifdef WITH_IDN
#ifdef WITH_IDN
sizeof(utf8_origin));
sizeof(utf8_textname));
#ifdef WITH_IDN
dns_rootname, 0,
dns_rootname, 0,
DNS_SECTION_QUESTION, 0);
extrabytes = 0;
ISC_TRUE);
dig_lookup_t *l;
sendcount--;
b != NULL;
dig_lookup_t *l;
unsigned int local_timeout;
if (timeout == 0)
l, &l->timer);
connect_timeout, l,
sizeof(isc_event_t));
dig_lookup_t *l;
if (specified_source &&
sockcount++;
if (specified_source)
static isc_buffer_t *
return (buffer);
sockcount++;
if (specified_source) {
link);
recvcount++;
sendcount++;
if (!l->tcp_mode)
if (!l->tcp_mode) {
l->retries--;
l->retries);
l->retries--;
cancel_lookup(l);
cancel_lookup(l);
dig_lookup_t *l;
recvcount--;
sizeof(sockstr));
sockcount--;
if (length == 0) {
recvcount++;
dig_lookup_t *l;
sockcount--;
if (include_question) {
recvcount++;
sendcount++;
dig_lookup_t *l;
sockcount--;
sockcount--;
static isc_boolean_t
return (ISC_TRUE);
&name);
return (ISC_TRUE);
goto next_rdata;
goto next_rdata;
serial);
serial)) {
goto doexit;
goto next_rdata;
if (axfr) {
goto doexit;
goto doexit;
serial);
goto next_rdata;
goto next_rdata;
goto doexit;
return (ISC_FALSE);
return (ISC_TRUE);
#ifdef DIG_SIGCHASE
dig_lookup_t *n, *l;
unsigned int parseflags;
unsigned int msgflags;
#ifdef DIG_SIGCHASE
isc_region_t r;
recvcount--;
sockcount--;
if (!l->tcp_mode &&
sizeof(buf1));
sizeof(buf2));
if (l->tcp_mode) {
if (fail) {
if (!match)
goto udp_mismatch;
&l->querysig);
if (l->msgcounter != 0)
l->msgcounter++;
#ifdef DIG_SIGCHASE
if (!l->sigchase) {
parseflags = 0;
if (l->besteffort) {
hex_dump(b);
cancel_lookup(l);
&name);
sizeof(namestr));
sizeof(typebuf));
sizeof(classbuf));
if (!match) {
if (l->tcp_mode) {
goto udp_mismatch;
cancel_lookup(l);
if (l->tcp_mode)
unsigned int local_timeout;
if (timeout == 0) {
if (l->tcp_mode)
NULL,
&l->interval,
#ifdef DIG_SIGCHASE
if (!do_sigchase)
} else if (l->trace) {
if (!l->ns_search_only)
if (!l->trace_root)
} else if (count == 0)
if (l->trace_root) {
#ifdef DIG_SIGCHASE
if (!do_sigchase)
#ifdef DIG_SIGCHASE
if (do_sigchase) {
sizeof(dig_message_t));
link);
isc_buffer_usedregion(b, &r);
sizeof(dig_message_t));
link);
#ifdef DIG_SIGCHASE
if (l->pending)
if (l->doing_xfr) {
if (!docancel)
if (docancel) {
cancel_lookup(l);
#ifdef DIG_SIGCHASE
if (!l->sigchase)
#ifdef DIG_SIGCHASE
if (!do_sigchase)
cancel_lookup(l);
#ifdef DIG_SIGCHASE
if (do_sigchase)
recvcount++;
int count;
return (result);
return (ISC_R_SUCCESS);
int count, i;
for (i = 0; i < count; i++) {
return count;
start_lookup();
cancel_all(void) {
dig_lookup_t *l, *n;
if (free_now) {
while (q != NULL) {
q, current_lookup);
clear_query(q);
q = nq;
while (l != NULL) {
try_clear_lookup(l);
destroy_libs(void) {
#ifdef DIG_SIGCHASE
void * ptr;
#ifdef WITH_IDN
#ifdef WITH_IDN
if (is_dst_up) {
#ifdef DIG_SIGCHASE
#if DIG_SIGCHASE_TD
#if DIG_SIGCHASE_BU
if (memdebugging != 0)
#ifdef WITH_IDN
initialize_idn(void) {
idn_result_t r;
#ifdef HAVE_SETLOCALE
if (r != idn_success)
idn_result_tostring(r));
static isc_result_t
return (ISC_R_SUCCESS);
fromlen++;
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
tolen--;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static idn_result_t
return idn_success;
return idn_buffer_overflow;
return idn_success;
if (r != idn_success) {
#ifdef DIG_SIGCHASE
isc_region_t r;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
dump_database(void) {
== ISC_R_SUCCESS)
== ISC_R_SUCCESS)
== ISC_R_SUCCESS)
return (rdataset);
return (rdataset);
return (rdataset);
return (NULL);
int section)
return (rdataset);
return (NULL);
== ISC_R_SUCCESS)
return (rdataset);
== ISC_R_SUCCESS)
rdataset =
return (rdataset);
== ISC_R_SUCCESS)
rdataset =
return (rdataset);
return (NULL);
isc_region_t r;
return (temp);
return (NULL);
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
return (NULL);
return (NULL);
return (ISC_R_SUCCESS);
isc_buffer_t b;
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
for (i= 0; i < MAX_TRUSTED_KEY; i++) {
char alphnum[] =
int tempnamekeylen;
return (ISC_R_NOMEMORY);
return (result);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
mctx));
#if DIG_SIGCHASE_TD
dig_server_t *s;
void *ptr;
while (s != NULL) {
s, lookup);
ptr = s;
#define __FOLLOW_GLUE__
#ifdef __FOLLOW_GLUE__
isc_region_t r;
#ifdef __FOLLOW_GLUE__
dns_rdatatype_any, &true);
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
dns_rdatatype_any, &true);
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
dns_rdata_reset(&a);
return (ISC_R_SUCCESS);
int orderp;
unsigned int nlabelsp;
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_FAILURE);
dns_rdatatype_any, &true);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
isc_region_t r;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
return (ISC_R_FAILURE);
== ISC_TRUE) {
mctx)
== ISC_R_SUCCESS) {
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (result);
return (ISC_R_NOTFOUND);
return (result);
&newdsrdata) == 0) {
mctx);
return (result);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
if (tmplookedup)
return (ISC_R_FAILURE);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
#if DIG_SIGCHASE_TD
== ISC_R_SUCCESS) {
have_answer = true;
&name);
if (have_answer) {
goto cleanandgo;
goto cleanandgo;
if (!delegation_follow) {
mctx);
mctx);
goto cleanandgo;
if (have_response) {
goto cleanandgo;
goto cleanandgo;
&tmp_name);
if (have_response)
goto finalstep;
if (have_delegation_ns) {
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
goto cleanandgo;
#if DIG_SIGCHASE_BU
!= ISC_R_SUCCESS) {
return (ISC_R_ADDRNOTAVAIL);
dns_rdatatype_any, &true);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
dns_rdatatype_ds, &true);
mctx);
int ret;
#if DIG_SIGCHASE_TD
#if DIG_SIGCHASE_BU
unsigned int nblabel1;
unsigned int nblabel2;
int min_lum_label;
if (ret < 0)
else if (ret > 0)
!= ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
== ISC_R_SUCCESS);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ret);
!= ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
return (ret);
return (ISC_R_SUCCESS);
return (ret);