dighost.c revision 3ab1cd05b892fbe8fcaed812db67b3d5165dca3e
c19f42a378f76af272166f9cababe7bfbc1cf6abTinderbox User * Copyright (C) 2000 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
e1cf6fd20a9f56c6c31581480445dea96fc7ac60Mark Andrews/* $Id: dighost.c,v 1.112 2000/08/03 18:23:16 mws Exp $ */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Notice to programmers: Do not use this code as an example of how to
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * use the ISC library to perform DNS lookups. Dig and Host both operate
f80ea74e1984e0b1dbe48dd86ecdd3a2380393cbBob Halley * on the request level, since they allow fine-tuning of output and are
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt * intended as debugging tools. As a result, they perform many of the
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * functions which could be better handled using the dns_resolver
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * functions in most applications.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson#if (!(defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO)))
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssonunsigned int timeout = 0;
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * 0 Everything went well, including things like NXDOMAIN
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 1 Usage error
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 7 Got too many RR's or Names
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 8 Couldn't open batch file
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 9 No reply from server
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 10 Internal error
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Apply and clear locks at the event level in global task.
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * Can I get rid of these using shutdown events? XXX
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 debug("lock_lookup %s:%d", __FILE__, __LINE__);\
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(isc_mutex_lock((&lookup_lock)), "isc_mutex_lock");\
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 debug("unlock_lookup %s:%d", __FILE__, __LINE__);\
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(isc_mutex_unlock((&lookup_lock)),\
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater "isc_mutex_unlock");\
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉recv_done(isc_task_t *task, isc_event_t *event);
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Huntconnect_timeout(isc_task_t *task, isc_event_t *event);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 while (*s != '\0') {
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson if (*s == '.')
3a34b87c878990c6303358efd22265c2c5980c65Mark Andrews printf("Printing a buffer with length %d\n", r.length);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafssoncheck_result(isc_result_t result, const char *msg) {
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fatal("%s: %s", msg, isc_result_totext(result));
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Create a server structure, which is part of the lookup structure.
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt * This is little more than a linked list of servers to query in hopes
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt * of finding the answer the user is looking for
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 fatal("Memory allocation failure in %s:%d",
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 * Produce a cloned server list. The dest list must have already had
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 * ISC_LIST_INIT applied.
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * Create an empty lookup structure, which holds all the information needed
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt * to get an answer to a user's question. This structure contains two
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * linked lists: the server list (servers to query) and the query list
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * (outstanding queries which have been made to the listed servers).
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Clone a lookup, perhaps copying the server list. This does not clone
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * the query list, since it will be regenerated by the setup_lookup()
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * function, nor does it queue up the new lookup for processing.
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Caution: If you don't clone the servers, you MUST clone the server
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * list seperately from somewhere else, or construct it by hand.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater strncpy(looknew->textname, lookold-> textname, MXNAME);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater looknew->trace_root = lookold->trace_root;
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater looknew->ns_search_only = lookold->ns_search_only;
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater looknew->section_question = lookold->section_question;
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington looknew->section_answer = lookold->section_answer;
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt looknew->section_authority = lookold->section_authority;
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington looknew->section_additional = lookold->section_additional;
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt * Requeue a lookup for further processing, perhaps copying the server
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt * list. The new lookup structure is returned to the caller, and is
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * queued for processing. If servers are not cloned in the requeue, they
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * must be added before allowing the current event to complete, since the
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * completion of the event may result in the next entry on the lookup
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * queue getting run.
ed04318ef686581fc9a20965a5be02abfb4f1bd5Andreas Gustafssonrequeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 looknew = clone_lookup(lookold, servers);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 "-> %p, new@%p -> %p",
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 lookold, lookold->link.next, looknew, looknew->link.next);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 ISC_LIST_PREPEND(lookup_list, looknew, link);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 "%p, new = %p, new -> %p",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater unsigned char *secretstore;
70c7f4fb4fc589b04a68d67479d34eecd99c1991Evan Hunt result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater secretstore = isc_mem_allocate(mctx, secretsize);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fatal("Memory allocation failure in %s:%d",
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington isc_buffer_init(&secretbuf, secretstore, secretsize);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_base64_decodestring(mctx, keysecret,
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 printf(";; Couldn't create key %s: %s\n",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_name_fromtext(&keyname, namebuf,
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson result = dns_tsigkey_create(&keyname, dns_tsig_hmacmd5_name,
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson printf(";; Couldn't create key %s: %s\n",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dst_key_fromnamedfile(keyfile, DST_TYPE_PRIVATE,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fprintf(stderr, "Couldn't read key from %s: %s\n",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Get key size in bits, convert to bytes, rounding up (?)
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater secretlen = (dst_key_size(dstkey) + 7) >> 3;
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater secretstore = isc_mem_allocate(mctx, secretlen);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater isc_buffer_init(&secretbuf, secretstore, secretlen);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dst_key_tobuffer(dstkey, &secretbuf);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fprintf(stderr, "Couldn't read key from %s: %s\n",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater dns_name_clone(dst_key_name(dstkey), &keyname);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_tsigkey_create(&keyname, dns_tsig_hmacmd5_name,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Setup the system as a whole, reading key information and resolv.conf
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater search = isc_mem_allocate(mctx, sizeof(struct dig_server));
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fatal("Memory allocation failure in %s:%d",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater /* XXX Check ordering, with search -vs- domain */
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson ISC_LIST_PREPEND(search_list, search, link);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater get_servers = ISC_TF(server_list.head == NULL);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater /* XXX Use lwres resolv.conf reader */
f0e246e271f84c6fe960a3c36703a56d1067431cBrian Wellington } else if (strcasecmp(ptr, "options") == 0) {
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson } else if (strcasecmp(ptr, "search") == 0){
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater mctx, sizeof(struct
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater "failure in %s:"
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater } else if ((strcasecmp(ptr, "domain") == 0) &&
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater mctx, sizeof(struct
618a5e4923c3d064c1cc0f1866e27e8ddca90700Andreas Gustafsson "failure in %s:"
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson else if (keysecret[0] != 0)
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Setup the ISC and DNS libraries for use by the system.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Warning: This is not particularly good randomness. We'll
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * just use random() now for getting id values, but doing so
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * does NOT insure that id's cann't be guessed.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(result, "isc_net_probeipv4");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_taskmgr_create(mctx, 1, 0, &taskmgr);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_taskmgr_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_task_create(taskmgr, 0, &global_task);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_timermgr_create(mctx, &timermgr);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_timermgr_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_socketmgr_create(mctx, &socketmgr);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_socketmgr_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_entropy_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = isc_mempool_create(mctx, COMMSIZE, &commctx);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_mempool_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * 6 and 2 set as reasonable parameters for 3 or 4 nameserver
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Add EDNS0 option record to a message. Currently, the only supported
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * option is UDP buffer size.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉add_opt(dns_message_t *msg, isc_uint16_t udpsize) {
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 result = dns_message_gettemprdataset(msg, &rdataset);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(result, "dns_message_gettemprdataset");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 result = dns_message_gettemprdatalist(msg, &rdatalist);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(result, "dns_message_gettemprdatalist");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 result = dns_message_gettemprdata(msg, &rdata);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(result, "dns_message_gettemprdata");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater dns_rdatalist_tordataset(rdatalist, rdataset);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_message_setopt(msg, rdataset);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_setopt");
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson * Add a question section to a message, asking for the specified name,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * type, and class.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉add_question(dns_message_t *message, dns_name_t *name,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 dns_rdataclass_t rdclass, dns_rdatatype_t rdtype)
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 result = dns_message_gettemprdataset(message, &rdataset);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 check_result(result, "dns_message_gettemprdataset()");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 dns_rdataset_makequestion(rdataset, rdclass, rdtype);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 ISC_LIST_APPEND(name->list, rdataset, link);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Check if we're done with all the queued lookups, which is true iff
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * all sockets, sends, and recvs are accounted for (counters == 0),
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * and the lookup list is empty.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * If we are done, pass control back out to dighost_shutdown() (which is
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * part of dig.c, host.c, or nslookup.c) to either shutdown the system as
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * a whole or reseed the lookup list.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 debug("list %s", ISC_LIST_EMPTY(lookup_list) ? "empty" : "full");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 if (ISC_LIST_EMPTY(lookup_list) && current_lookup == NULL &&
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Clear out a query when we're done with it. WARNING: This routine
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * WILL invalidate the query pointer.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 if (ISC_LINK_LINKED(&query->recvbuf, link))
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 ISC_LIST_DEQUEUE(query->recvlist, &query->recvbuf,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 if (ISC_LINK_LINKED(&query->lengthbuf, link))
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 ISC_LIST_DEQUEUE(query->lengthlist, &query->lengthbuf,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 isc_mempool_put(commctx, query->recvspace);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 isc_buffer_invalidate(&query->lengthbuf);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Try and clear out a lookup if we're done with it. Return ISC_TRUE if
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * the lookup was successfully cleared. If ISC_TRUE is returned, the
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * lookup pointer has been invalidated.
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater while (q != NULL) {
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * At this point, we know there are no queries on the lookup,
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * so can make it go away also.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 s = ISC_LIST_HEAD(lookup->my_server_list);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 while (s != NULL) {
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 debug("freeing server %p belonging to %p",
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 debug("freeing buffer %p", lookup->querysig);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 isc_mempool_put(commctx, lookup->sendspace);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * If we can, start the next lookup in the queue running.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * This assumes that the lookup on the head of the queue hasn't been
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * started yet. It also removes the lookup from the head of the queue,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * setting the current_lookup pointer pointing to it.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * If there's a current lookup running, we really shouldn't get
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 current_lookup = ISC_LIST_HEAD(lookup_list);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Put the current lookup somewhere so cancel_all can find it
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 ISC_LIST_DEQUEUE(lookup_list, current_lookup, link);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * If we can, clear the current lookup and start the next one running.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * This calls try_clear_lookup, so may invalidate the lookup pointer.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * Create and queue a new lookup as a followup to the current lookup,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * based on the supplied message and section. This is used in trace and
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * name server search modes to start a new lookup using servers from
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * NS records in a reply.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉followup_lookup(dns_message_t *msg, dig_query_t *query,
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 result = dns_message_firstname(msg,section);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 (query->lookup->trace || query->lookup->ns_search_only))
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 followup_lookup(msg, query, DNS_SECTION_AUTHORITY);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 debug("following up %s", query->lookup->textname);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 dns_message_currentname(msg, section, &name);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 for (rdataset = ISC_LIST_HEAD(name->list);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 rdataset = ISC_LIST_NEXT(rdataset, link)) {
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 loopresult = dns_rdataset_first(rdataset);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 "isc_buffer_allocate");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 "dns_rdata_totext");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 /* Initialize lookup if we've not yet */
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_message_nextname(msg, section);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater if ((lookup == NULL) && (section == DNS_SECTION_ANSWER) &&
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater (query->lookup->trace || query->lookup->ns_search_only))
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater followup_lookup(msg, query, DNS_SECTION_AUTHORITY);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Create and queue a new lookup using the next origin from the origin
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * list, read in setup_system().
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updaternext_origin(dns_message_t *msg, dig_query_t *query) {
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater debug("following up %s", query->lookup->textname);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * We're not using a search list, so don't even think
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson * about finding the next entry.
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Then we just did rootorg; there's nothing left.
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater lookup = requeue_lookup(query->lookup, ISC_TRUE);
9a7d202077fae00fbdca610d8a8d90689e30f331Mark Andrews lookup->origin = ISC_LIST_NEXT(query->lookup->origin, link);
ce3c351d815569455892c30dc78d8c2e85ec1076Andreas Gustafsson * Insert an SOA record into the sendmessage in a lookup. Used for
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 * creating IXFR queries.
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 dns_name_clone(lookup->name, &soa.origin);
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 dns_name_clone(lookup->name, &soa.mname);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater isc_buffer_init(&lookup->rdatabuf, lookup->rdatastore,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_message_gettemprdata(lookup->sendmsg, &rdata);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_gettemprdata");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_rdata_fromstruct(rdata, lookup->rdclass,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "isc_rdata_fromstruct");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_message_gettemprdatalist(lookup->sendmsg, &rdatalist);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_gettemprdatalist");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_message_gettemprdataset(lookup->sendmsg, &rdataset);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_gettemprdataset");
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 dns_rdatalist_tordataset(rdatalist, rdataset);
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 result = dns_message_gettempname(lookup->sendmsg, &soaname);
7781f25078c491a9650dec555bdc86cb0ed49861Tatuya JINMEI 神明達哉 check_result(result, "dns_message_gettempname");
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson ISC_LIST_APPEND(soaname->list, rdataset, link);
f951f076f3d321c52b824a866caff28ce4f8e06cAndreas Gustafsson dns_message_addname(lookup->sendmsg, soaname, DNS_SECTION_AUTHORITY);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * Setup the supplied lookup structure, making it ready to start sending
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * queries to servers. Create and initialize the message to be sent as
b239c8294a5653d21876d084e0c5b029f6b9fc5dMichael Graff * well as the query structures and buffer space for the replies. If the
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * server list is empty, clone it from the system default list.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_create");
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater if (ISC_LIST_EMPTY(lookup->my_server_list)) {
ed04318ef686581fc9a20965a5be02abfb4f1bd5Andreas Gustafsson clone_server_list(server_list, &lookup->my_server_list);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater check_result(result, "dns_message_gettempname");
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington isc_buffer_init(&lookup->namebuf, lookup->namespace,
c20ffa38dee7efa0dc01822d4bac5e41729b9b61Brian Wellington isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * If the name has too many dots, force the origin to be NULL
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * (which produces an absolute lookup). Otherwise, take the origin
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * we have if there's one in the struct already. If it's NULL,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * take the first entry in the searchlist iff either usesearch
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater * is TRUE or we got a domain line in the resolv.conf file.
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews /* XXX New search here? */
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews if ((count_dots(lookup->textname) >= ndots) || lookup->defname)
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews else if (lookup->origin == NULL && lookup->new_search &&
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater lookup->origin = ISC_LIST_HEAD(search_list);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater debug("trying origin %s", lookup->origin->origin);
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews result = dns_message_gettempname(lookup->sendmsg,
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews check_result(result, "dns_message_gettempname");
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 /* XXX Helper funct to conv char* to name? */
5c024f787777143031c2c49f9811c39c84bfa259Tatuya JINMEI 神明達哉 isc_buffer_init(&b, lookup->origin->origin, len);
307adf67922dd222bacf84ef0f074a0eb84d3a0aMark Andrews result = dns_name_fromtext(lookup->oname, &b, dns_rootname,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater dns_name_clone(dns_rootname, lookup->name);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_name_fromtext(lookup->name, &b,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater fatal("'%s' is not in legal name syntax (%s)",
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater lookup->textname, dns_result_totext(result));
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater dns_message_puttempname(lookup->sendmsg, &lookup->oname);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater isc_buffer_init(&b, lookup->textname, len);
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater result = dns_name_fromtext(lookup->name, &b,
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater dns_name_clone(dns_rootname, lookup->name);
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt /* XXX Move some of this into function, dns_name_format. */
dd185fb371632b9cf1b7be3097960185c9645a09Mark Andrews lookup->sendmsg->id = (unsigned short)(random() & 0xFFFF);
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt * If this is a trace request, completely disallow recursion, since
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt * it's meaningless for traces.
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt if (lookup->recurse && !lookup->trace && !lookup->ns_search_only) {
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt /* XXX aaflag */
e1cf6fd20a9f56c6c31581480445dea96fc7ac60Mark Andrews dns_message_addname(lookup->sendmsg, lookup->name,
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt * Force TCP mode if we're doing an xfr.
e1cf6fd20a9f56c6c31581480445dea96fc7ac60Mark Andrews * XXX UDP ixfr's would be useful
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt add_question(lookup->sendmsg, lookup->name, lookup->rdclass,
dd185fb371632b9cf1b7be3097960185c9645a09Mark Andrews /* XXX add_soa */
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt /* XXX Insist this? */
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt result = dns_message_settsigkey(lookup->sendmsg, key);
6214c3c93a43dc86f080dc0219e4560b69721f53Mark Andrews isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE);
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf);
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt result = dns_message_rendersection(lookup->sendmsg,
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt check_result(result, "dns_message_rendersection");
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt result = dns_message_rendersection(lookup->sendmsg,
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt check_result(result, "dns_message_rendersection");
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt for (serv = ISC_LIST_HEAD(lookup->my_server_list);
01279934803dd45c007a58b61fe20c2852135b52Evan Hunt query = isc_mem_allocate(mctx, sizeof(dig_query_t));
f172f06ff2e7609dd7d91914a44b4e24cff8bb7aAutomatic Updater debug("create query %p linked to lookup %p",
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt isc_buffer_init(&query->lengthbuf, query->lengthspace, 2);
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt isc_buffer_init(&query->slbuf, query->slspace, 2);
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt /* XXX qrflag, print_query, etc... */
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt printmessage(ISC_LIST_HEAD(lookup->q), lookup->sendmsg,
d640b4a0ab9dec252749793f78a1ed1e8551ea19Evan Hunt * Event handler for send completion. Track send counter, and clear out
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * the query if the send was canceled.
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt REQUIRE(event->ev_type == ISC_SOCKEVENT_SENDDONE);
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * Cancel a lookup, sending isc_socket_cancel() requests to all outstanding
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * IO sockets. The cancel handlers should take care of cleaning up the
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * query and lookup structures
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * Send a UDP packet to the remote nameserver, possible starting the
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * recv action as well. Also make sure that the timer is running and
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * is properly reset.
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Huntsend_udp(dig_lookup_t *lookup, isc_boolean_t make_recv) {
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * If the timer already exists, that means we're calling this
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * a second time (for a retry). Don't need to recreate it,
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt * just reset it.
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt isc_interval_set(&lookup->interval, local_timeout, 0);
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt result = isc_timer_reset(lookup->timer, isc_timertype_once,
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf,
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt debug("recving with lookup=%p, query=%p, sock=%p",
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews ISC_LIST_ENQUEUE(query->sendlist, &lookup->sendbuf,
dd2a0a6d2dec1c23787351e51b434a838dec5603Evan Hunt result = isc_socket_sendtov(query->sock, &query->sendlist,
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews * IO timeout handler, used for both connect and recv timeouts. If
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews * retries are still allowed, either resend the UDP packet or queue a
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews * new TCP lookup. Otherwise, cancel the lookup.
bbf31e6b623af575138669bdd7031232867b9166Mark Andrewsconnect_timeout(isc_task_t *task, isc_event_t *event) {
bbf31e6b623af575138669bdd7031232867b9166Mark Andrews REQUIRE(event->ev_type == ISC_TIMEREVENT_IDLE);
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt printf(";; connection timed out; no servers could be "
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt "reached\n");
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt * Event handler for the TCP recv which gets the length header of TCP
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt * packets. Start the next recv of length bytes.
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunttcp_length_done(isc_task_t *task, isc_event_t *event) {
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt REQUIRE(event->ev_type == ISC_SOCKEVENT_RECVDONE);
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt result = isc_sockaddr_totext(&query->sockaddr, b);
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt ISC_LIST_DEQUEUE(sevent->bufferlist, &query->lengthbuf, link);
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt fatal("Length of %X was longer than I can handle!",
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt * Even though the buffer was already init'ed, we need
feb067b25a8e33db62e2a7bf2e83bbb7f6eee845Evan Hunt * to redo it now, to force the length we want.
recvcount++;
dig_lookup_t *l;
sockcount--;
if (include_question) {
link);
recvcount++;
sendcount++;
dig_lookup_t *l;
isc_region_t r;
isc_buffer_usedregion(b, &r);
sockcount--;
isc_buffer_free(&b);
static isc_boolean_t
isc_buffer_t b;
isc_region_t r;
return (ISC_TRUE);
&name);
return (ISC_TRUE);
goto next_rdata;
&soa,
mctx);
goto doexit;
goto next_rdata;
goto doexit;
goto doexit;
goto next_rdata;
goto doexit;
goto next_rdata;
goto doexit;
if (atlimit) {
isc_buffer_usedregion(&b, &r);
if (atlimit)
return (ISC_TRUE);
return (ISC_FALSE);
isc_region_t r;
dig_lookup_t *n, *l;
unsigned int local_timeout;
recvcount--;
|| cancel_now) {
&msg);
l->sendmsg,
l->querysig);
if (l->msgcounter != 0)
l->msgcounter++;
hex_dump(b);
if (!l->tcp_mode) {
cancel_lookup(l);
l->querysig);
&l->querysig);
l->doing_xfr ) {
if (timeout == 0) {
if (l->tcp_mode)
local_timeout, 0);
NULL,
&l->interval,
if ((l->trace)||
(l->ns_search_only)) {
if (show_details ||
== ISC_R_SUCCESS)) &&
!l->trace_root))
ISC_TRUE);
MXNAME);
&ab);
(char *)r.base,
query);
l->trace_root)
ISC_TRUE);
&ab);
(char *)r.base,
query);
if (show_details) {
l->doing_xfr)
== ISC_R_SUCCESS) &&
l->ns_search_only &&
!l->trace_root ) {
if (l->pending)
if (l->doing_xfr) {
if (docancel) {
cancel_lookup(l);
&ab);
(char *)r.base,
query);
cancel_lookup(l);
sockcount--;
int result;
if (result != 0) {
port);
unsigned int local_timeout;
if (timeout == 0)
sockcount++;
if (specified_source)
sockcount++;
if (specified_source)
start_lookup();
cancel_all(void) {
dig_lookup_t *l, *n;
dig_query_t *q;
if (free_now) {
while (q != NULL) {
q, current_lookup);
while (l != NULL) {
try_clear_lookup(l);
destroy_libs(void) {
void *ptr;
dig_server_t *s;
dig_searchlist_t *o;
while (s != NULL) {
ptr = s;
while (o != NULL) {
ptr = o;
if (is_dst_up) {
if (isc_mem_debugging != 0)