dighost.c revision 4765fc7c3f8fdf565a6e49bb11c1d10efee4cef7
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Copyright (C) 2000-2003 Internet Software Consortium.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Permission to use, copy, modify, and/or distribute this software for any
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * PERFORMANCE OF THIS SOFTWARE.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson/* $Id: dighost.c,v 1.326 2009/09/15 23:48:09 tbox Exp $ */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Notice to programmers: Do not use this code as an example of how to
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * use the ISC library to perform DNS lookups. Dig and Host both operate
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * on the request level, since they allow fine-tuning of output and are
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * intended as debugging tools. As a result, they perform many of the
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * functions which could be better handled using the dns_resolver
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * functions in most applications.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonunsigned int timeout = 0;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstatic void initialize_idn(void);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstatic isc_result_t output_filter(isc_buffer_t *buffer,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstatic idn_result_t append_textname(char *name, const char *origin,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstatic void idn_check_result(idn_result_t r, const char *msg);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson *\li 0 Everything went well, including things like NXDOMAIN
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson *\li 1 Usage error
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson *\li 7 Got too many RR's or Names
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson *\li 8 Couldn't open batch file
7ab0e69f61e61e81d489c95c7ebd981e74e7ef16Andreas Gustafsson *\li 9 No reply from server
7ab0e69f61e61e81d489c95c7ebd981e74e7ef16Andreas Gustafsson *\li 10 Internal error
42a5f9c8f535fb2a6d1cbfaa38533176e1f1667aBob Halleyunsigned int digestbits = 0;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t get_trusted_key(isc_mem_t *mctx);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_rdataset_t * sigchase_scanname(dns_rdatatype_t type,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_rdataset_t * chase_scanname_section(dns_message_t *msg,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t advanced_rrsearch(dns_rdataset_t **rdataset,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t sigchase_verify_sig_key(dns_name_t *name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t sigchase_verify_sig(dns_name_t *name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t sigchase_verify_ds(dns_name_t *name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonvoid print_rdata(dns_rdata_t *rdata, isc_mem_t *mctx);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson dns_rdataset_t *rdataset, isc_mem_t *mctx);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonvoid dup_name(dns_name_t *source, dns_name_t* target,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonvoid free_name(dns_name_t *name, isc_mem_t *mctx);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonvoid dump_database_section(dns_message_t *msg, int section);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_rdataset_t * search_type(dns_name_t *name, dns_rdatatype_t type,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t contains_trusted_key(dns_name_t *name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t prove_nx_domain(dns_message_t * msg,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t prove_nx_type(dns_message_t * msg, dns_name_t *name,
42a5f9c8f535fb2a6d1cbfaa38533176e1f1667aBob Halleyisc_result_t prove_nx(dns_message_t * msg, dns_name_t * name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstatic void nameFromString(const char *str, dns_name_t *p_ret);
2e715dbdc263f859c01b57a9d733c1dfbf28b90eBob Halleyint inf_name(dns_name_t * name1, dns_name_t * name2);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t opentmpkey(isc_mem_t *mctx, const char *file,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t removetmpkey(isc_mem_t *mctx, const char *file);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t getneededrr(dns_message_t *msg);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonvoid sigchase_bottom_up(dns_message_t *msg);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t initialization(dns_name_t *name);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t prepare_lookup(dns_name_t *name);
2e715dbdc263f859c01b57a9d733c1dfbf28b90eBob Halleyisc_result_t grandfather_pb_test(dns_name_t * zone_name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_result_t child_of_zone(dns_name_t *name,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_rdataset_t *chase_sigdsrdataset = NULL;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_rdataset_t *chase_sigkeyrdataset = NULL;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_name_t chase_name; /* the query name */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * the current name is the parent name when we follow delegation
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * the child name is used for delegation (NS DS responses in AUTHORITY section)
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_siglookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_keylookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_sigkeylookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_dslookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_sigdslookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t chase_nslookedup = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t delegation_follow = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonisc_boolean_t have_delegation_ns = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas GustafssonISC_LIST(dig_message_t) chase_message_list;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas GustafssonISC_LIST(dig_message_t) chase_message_list2;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonstruct_tk_list tk_list = { {NULL, NULL, NULL, NULL, NULL}, 0};
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Apply and clear locks at the event level in global task.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Can I get rid of these using shutdown events? XXX
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson debug("lock_lookup %s:%d", __FILE__, __LINE__);\
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson check_result(isc_mutex_lock((&lookup_lock)), "isc_mutex_lock");\
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson debug("unlock_lookup %s:%d", __FILE__, __LINE__);\
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson check_result(isc_mutex_unlock((&lookup_lock)),\
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson "isc_mutex_unlock");\
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonrecv_done(isc_task_t *task, isc_event_t *event);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonconnect_timeout(isc_task_t *task, isc_event_t *event);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonlaunch_next_query(dig_query_t *query, isc_boolean_t include_question);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonmem_free(void *arg, void *mem, size_t size) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonnext_token(char **stringp, const char *delim) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson while (*s != '\0') {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (*s == '.')
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson unsigned int len, i;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (r.base[i] >= '!' && r.base[i] <= '}')
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (r.base[i] >= '!' && r.base[i] <= '}')
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Append 'len' bytes of 'text' at '*p', failing with
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * ISC_R_NOSPACE if that would advance p past 'end'.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonappend(const char *text, int len, char **p, char *end) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonreverse_octets(const char *in, char **p, char *end) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = reverse_octets(dot + 1, p, end);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonget_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson r = inet_pton(AF_INET6, value, &addr.type.in6);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson /* This is a valid IPv6 address. */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson unsigned int options = 0;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = dns_byaddr_createptrname2(&addr, options, name);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Not a valid IPv6 address. Assume IPv4.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * If 'strict' is not set, construct the
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * in-addr.arpa name by blindly reversing
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * octets whether or not they look like integers,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * so that this can be used for RFC2317 names
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (strict && inet_pton(AF_INET, value, &addr.type.in) != 1)
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson /* Append .in-addr.arpa. and a terminating NUL. */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = append(".in-addr.arpa.", 15, &p, end);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssoncheck_result(isc_result_t result, const char *msg) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson fatal("%s: %s", msg, isc_result_totext(result));
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Create a server structure, which is part of the lookup structure.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * This is little more than a linked list of servers to query in hopes
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * of finding the answer the user is looking for
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonmake_server(const char *servname, const char *userarg) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson fatal("memory allocation failure in %s:%d",
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson strncpy(srv->servername, servname, MXNAME);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Create a copy of the server list from the lwres configuration structure.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * The dest list must have already had ISC_LIST_INIT applied.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssoncopy_server_list(lwres_conf_t *confdata, dig_serverlist_t *dest) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson af = addr2af(confdata->nameservers[i].family);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson lwres_net_ntop(af, confdata->nameservers[i].address,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson while (s != NULL) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_sockaddr_t sockaddrs[DIG_MAX_ADDRESSES];
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = bind9_getaddresses(opt, 0, sockaddrs,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson fatal("couldn't get address for '%s': %s",
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson for (i = 0; i < count; i++) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_netaddr_fromsockaddr(&netaddr, &sockaddrs[i]);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_netaddr_format(&netaddr, tmp, sizeof(tmp));
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonadd_nameserver(lwres_conf_t *confdata, const char *addr, int af) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (confdata->nsnext >= LWRES_CONFMAXNAMESERVERS)
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson confdata->nameservers[i].family = LWRES_ADDRTYPE_V4;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson confdata->nameservers[i].length = NS_INADDRSZ;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson confdata->nameservers[i].family = LWRES_ADDRTYPE_V6;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson confdata->nameservers[i].length = NS_IN6ADDRSZ;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (lwres_net_pton(af, addr, &confdata->nameservers[i].address) == 1) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Produce a cloned server list. The dest list must have already had
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * ISC_LIST_INIT applied.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonclone_server_list(dig_serverlist_t src, dig_serverlist_t *dest) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson newsrv = make_server(srv->servername, srv->userarg);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Create an empty lookup structure, which holds all the information needed
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * to get an answer to a user's question. This structure contains two
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * linked lists: the server list (servers to query) and the query list
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * (outstanding queries which have been made to the listed servers).
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson fatal("memory allocation failure in %s:%d",
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->identify_previous_line = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->trace_root_sigchase = ISC_FALSE;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->rdtype_sigchase = dns_rdatatype_any;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->qrdtype_sigchase = dns_rdatatype_any;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->rdclass_sigchase = dns_rdataclass_in;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson looknew->rdclass_sigchaseset = ISC_FALSE;
return (looknew);
#if DIG_SIGCHASE_TD
#ifdef DIG_SIGCHASE
#if DIG_SIGCHASE_TD
if (servers)
return (looknew);
return (looknew);
setup_text_key(void) {
int secretsize;
unsigned char *secretstore;
goto failure;
goto failure;
const char *desc) {
isc_uint32_t n;
return (result);
*uip = n;
return (ISC_R_SUCCESS);
static isc_uint32_t
return (tmp);
int len;
digestbits = 0;
digestbits = 0;
* Get a key from a named.conf format keyfile
static isc_result_t
read_confkey(void) {
const char *keyname;
const char *secretstr;
const char *algorithm;
return (ISC_R_FILENOTFOUND);
goto cleanup;
&file);
goto cleanup;
goto cleanup;
return (result);
setup_file_key(void) {
&dstkey);
goto failure;
case DST_ALG_HMACMD5:
case DST_ALG_HMACSHA1:
case DST_ALG_HMACSHA224:
case DST_ALG_HMACSHA256:
case DST_ALG_HMACSHA384:
case DST_ALG_HMACSHA512:
goto failure;
goto failure;
static dig_searchlist_t *
return (search);
* Setup the system as a whole, reading key information and resolv.conf
setup_system(void) {
unsigned int lwresflags;
if (have_ipv4)
if (have_ipv6)
/* If user doesn't specify server use nameservers from resolv.conf. */
if (have_ipv4) {
if (have_ipv6) {
#ifdef WITH_IDN
if (keyfile[0] != 0)
else if (keysecret[0] != 0)
#ifdef DIG_SIGCHASE
#if DIG_SIGCHASE_TD
#if DIG_SIGCHASE_BU
clear_searchlist(void) {
* Override the search list derived from resolv.conf by 'domain'.
setup_libs(void) {
if (dnssec)
if (nsid) {
* part of dig.c, host.c, or nslookup.c) to either shutdown the system as
check_if_done(void) {
sendcount == 0) {
link);
link);
sockcount--;
static isc_boolean_t
dig_query_t *q;
if (debugging) {
while (q != NULL) {
return (ISC_FALSE);
return (ISC_TRUE);
dig_server_t *s;
void *ptr;
while (s != NULL) {
ptr = s;
start_lookup(void) {
if (cancel_now)
#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;
0, &rdataset);
&rdataset);
unsigned int nlabels;
int order;
if (!horizontal)
if (!bad)
numLookups++;
if (!success) {
isc_uint32_t i, j;
for (i = numLookups; i > 0; i--) {
isc_random_get(&j);
return (numLookups);
static isc_boolean_t
if (!usesearch)
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)
sockcount++;
if (specified_source) {
link);
recvcount++;
sendcount++;
if (!l->tcp_mode)
sockcount--;
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;
goto doexit;
goto next_rdata;
goto doexit;
goto doexit;
goto next_rdata;
goto doexit;
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);
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);
for (i= 0; i < MAX_TRUSTED_KEY; i++) {
char alphnum[] =
int tempnamekeylen;
return (ISC_R_NOMEMORY);
return (result);
int tempnamelen;
int tempnamekeylen;
char *cp;
return (ISC_R_NOMEMORY);
goto cleanup;
cp++;
return (ISC_R_FAILURE);
x = cp--;
x = cp--;
return (ISC_R_NOMEMORY);
return (ISC_R_FAILURE);
*fp = f;
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
filename);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
#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);