dighost.c revision 77365675e9db53de6ef728c98fc696ce86e88e63
67a1122d50d24747976844db61a2c994a9b8b1e4Tinderbox User * Copyright (C) 2000 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * 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.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
3761c433912beabe43abeed2c3513b6201c59f64Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff/* $Id: dighost.c,v 1.80 2000/07/13 01:49:44 mws Exp $ */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * Notice to programmers: Do not use this code as an example of how to
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * use the ISC library to perform DNS lookups. Dig and Host both operate
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * on the request level, since they allow fine-tuning of output and are
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman * intended as debugging tools. As a result, they perform many of the
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * functions which could be better handled using the dns_resolver
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington * functions in most applications.
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews#if (!(defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO)))
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellingtonunsigned int timeout = 0;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews while (*s != '\0') {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews if (*s == '.')
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff unsigned int len;
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman printf("Printing a buffer with length %d\n", r.length);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrewscheck_result(isc_result_t result, const char *msg) {
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff fatal("%s: %s", msg, isc_result_totext(result));
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * Tests if a field is a class, without needing isc libs
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff * initialized. This list will have to be manually kept in
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * sync with what the libs support.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff const char *classlist[] = { "in", "hs", "chaos" };
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley for (i = 0; i < numclasses; i++)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews * Tests if a field is a type, without needing isc libs
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews * initialized. This list will have to be manually kept in
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews * sync with what the libs support.
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews const char *typelist[] = {"a", "ns", "md", "mf", "cname",
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews for (i = 0; i < numtypes; i++) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsrequeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews strncpy(looknew->textname, lookold-> textname, MXNAME);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews strncpy(looknew->rttext, lookold-> rttext, 32);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews strncpy(looknew->rctext, lookold-> rctext, 32);
if (servers) {
while (s != NULL) {
sizeof(struct dig_server));
MXNAME);
link);
return (looknew);
setup_system(void) {
char *ptr;
dig_lookup_t *l;
int secretsize;
unsigned char *secretstore;
if (fixeddomain[0] != 0) {
if (get_servers &&
sizeof(struct dig_server));
__LINE__);
ptr,
ndots);
&& usesearch){
!= NULL) {
mctx, sizeof(struct
dig_server));
__LINE__);
ptr,
link);
(fixeddomain[0] == 0 )){
!= NULL) {
mctx, sizeof(struct
dig_server));
__LINE__);
ptr,
link);
l != NULL;
if (keysecret[0] != 0) {
goto SYSSETUP_FAIL;
namebuf);
goto SYSSETUP_FAIL;
setup_libs(void) {
check_if_done(void) {
link);
link);
static isc_boolean_t
dig_server_t *s;
void *ptr;
return (ISC_FALSE);
while (s != NULL) {
s, lookup);
ptr = s;
return (ISC_TRUE);
begin_next_lookup(void) {
if (still_working)
isc_region_t r;
int len;
BUFSIZE);
NULL,
isc_buffer_usedregion(b, &r);
(char *)r.base);
if (!success) {
if (section ==
query->
query->
sizeof(struct dig_server));
isc_buffer_free(&b);
MXNAME);
int len;
isc_region_t r;
isc_buffer_t b;
lookup_counter = 0;
isc_buffer_usedregion(&b, &r);
isc_buffer_usedregion(&b, &r);
DNS_SECTION_QUESTION, 0);
ISC_TRUE);
sendcount--;
sockcount--;
unsigned int local_timeout;
if (timeout == 0) {
recvcount++;
sendcount++;
isc_region_t r;
q != NULL;
if (q->working) {
isc_buffer_clear(b);
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
isc_region_t r;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
sockcount--;
length);
recvcount++;
sockcount--;
if (include_question) {
link);
recvcount++;
sendcount++;
isc_region_t r;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
static isc_boolean_t
isc_buffer_t b;
isc_region_t r;
return (ISC_TRUE);
#ifdef NEVER
&name);
return (ISC_TRUE);
goto next_rdata;
&soa,
mctx);
goto xfr_done;
goto next_rdata;
goto next_rdata;
isc_buffer_usedregion(&b, &r);
return (ISC_TRUE);
goto next_rdata;
goto xfr_done;
return (ISC_FALSE);
isc_region_t r;
dig_lookup_t *n, *l;
unsigned int local_timeout;
recvcount--;
&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);
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)) {
l->trace_root)
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);
== ISC_R_SUCCESS) ||
(char *)r.base,
query);
cancel_lookup(l);
int result;
if (result != 0) {
port);
unsigned int local_timeout;
if (timeout == 0) {
sockcount++;
if (specified_source)
sockcount++;
if (specified_source)
start_lookup(void) {
start_lookup();
cancel_all(void) {
dig_lookup_t *l;
dig_query_t *q;
while (l != NULL) {
q = ISC_LIST_HEAD(l->q);
while (q != NULL) {
sockcount--;
free_lists(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) {