dighost.c revision 499b34cea04a46823d003d4c0520c8b03e8513cb
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Copyright (C) 2000, 2001 Internet Software Consortium.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
d58e33bfabfee19a035031dac633d36659738d56Evan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
47d837a49967a6a1b290024f5efb0669276013b1Mukund Sivaraman * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
/* $Id: dighost.c,v 1.182 2001/01/09 21:39:15 bwelling Exp $ */
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <limits.h>
extern int h_errno;
#ifdef DNS_OPT_NEWCODES
unsigned int timeout = 0;
int sendcount = 0;
int recvcount = 0;
int sockcount = 0;
int lookup_counter = 0;
int exitcode = 0;
#define LOCK_LOOKUP {\
#define UNLOCK_LOOKUP {\
char *res;
return (res);
s = string;
unsigned int len;
isc_region_t r;
isc_buffer_usedregion(b, &r);
reverse[0] = 0;
return (DNS_R_BADDOTTEDQUAD);
adrs[i]);
isc_buffer_t b;
return (DNS_R_BADDOTTEDQUAD);
name);
return (result);
isc_buffer_putuint8(&b, 0);
return (result);
if (debugging) {
return (srv);
make_empty_lookup(void) {
#ifdef DNS_OPT_NEWCODES_LIVE
return (looknew);
#ifdef DNS_OPT_NEWCODES_LIVE
if (servers)
return (looknew);
return (looknew);
setup_text_key(void) {
int secretsize;
unsigned char *secretstore;
&secretbuf);
goto failure;
namebuf);
goto failure;
setup_file_key(void) {
int secretlen;
goto failure;
goto failure;
* Setup the system as a whole, reading key information and resolv.conf
setup_system(void) {
char *ptr;
char *input;
/* XXX Use lwres resolv.conf reader */
if (get_servers &&
ndots);
!= NULL) {
ptr);
__LINE__);
ptr,
MXNAME);
link);
(fixeddomain[0] == 0 )){
!= NULL) {
__LINE__);
ptr,
link);
if (keyfile[0] != 0)
else if (keysecret[0] != 0)
setup_libs(void) {
#ifdef DNS_OPT_NEWCODES_LIVE
#ifdef DNS_OPT_NEWCODES_LIVE
unsigned int i, optsize = 0;
if (dnssec)
#ifdef DNS_OPT_NEWCODES_LIVE
* 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_server_t *s;
dig_query_t *q;
void *ptr;
if (debugging) {
while (q != NULL) {
q->servname);
return (ISC_FALSE);
while (s != NULL) {
s, lookup);
ptr = s;
return (ISC_TRUE);
start_lookup(void) {
if (cancel_now)
start_lookup();
isc_region_t r;
int len;
BUFSIZE);
NULL,
isc_buffer_usedregion(b, &r);
(char *)r.base);
if (!success) {
if (section ==
query->
query->
isc_buffer_free(&b);
static isc_boolean_t
return (ISC_FALSE);
if (!usesearch)
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
int len;
isc_region_t r;
isc_buffer_t b;
lookup_counter = 0;
* is TRUE or we got a domain line in the resolv.conf file.
if (fixeddomain[0] != 0) {
sizeof(*fixedsearch));
isc_buffer_usedregion(&b, &r);
#ifndef DNS_OPT_NEWCODES_LIVE
#ifdef DNS_OPT_NEWCODES_LIVE
NULL);
MXNAME);
wirebuf);
optlist);
DNS_SECTION_QUESTION, 0);
ISC_TRUE);
sendcount--;
dig_lookup_t *l;
unsigned int local_timeout;
if (timeout == 0) {
NULL,
&l->interval,
l, &l->timer);
dig_lookup_t *l;
if (specified_source &&
sockcount++;
if (specified_source)
if (l->ns_search_only) {
sockcount++;
if (specified_source) {
link);
query);
recvcount++;
link);
sendcount++;
if (l->ns_search_only) {
if (!l->tcp_mode)
if (!l->tcp_mode) {
l->retries--;
l->retries);
cancel_lookup(l);
l->retries--;
cancel_lookup(l);
isc_region_t r;
dig_lookup_t *l;
recvcount--;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
sockcount--;
length);
recvcount++;
dig_lookup_t *l;
sockcount--;
if (include_question) {
link);
recvcount++;
sendcount++;
dig_lookup_t *l;
isc_region_t r;
sockcount--;
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++;
if (l->besteffort)
hex_dump(b);
cancel_lookup(l);
cancel_lookup(l);
l->servfail_stops) {
if (l->tcp_mode)
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)) {
ISC_TRUE);
MXNAME);
&ab);
(char *)r.base,
query);
l->trace_root)
ISC_TRUE);
&ab);
(char *)r.base,
query);
== 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);
start_lookup();
cancel_all(void) {
dig_lookup_t *l, *n;
if (is_blocking) {
if (free_now) {
while (q != NULL) {
q, current_lookup);
clear_query (q);
q = nq;
while (l != NULL) {
try_clear_lookup(l);
destroy_libs(void) {
void *ptr;
dig_server_t *s;
dig_searchlist_t *o;
if (is_blocking) {
while (s != NULL) {
ptr = s;
while (o != NULL) {
ptr = o;
if (is_dst_up) {
if (memdebugging != 0)