dighost.c revision 9f35af43612c6ae4951e123911ac5a06d7880dca
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * Copyright (C) 2000 Internet Software Consortium.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * Permission to use, copy, modify, and distribute this software for any
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * purpose with or without fee is hereby granted, provided that the above
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * copyright notice and this permission notice appear in all copies.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence/* $Id: dighost.c,v 1.47 2000/06/08 21:18:24 mws Exp $ */
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * Notice to programmers: Do not use this code as an example of how to
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * use the ISC library to perform DNS lookups. Dig and Host both operate
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * on the request level, since they allow fine-tuning of output and are
6b7257f756eb0530cdf54df9a7fab8d51a5001c3David Lawrence * intended as debugging tools. As a result, they perform many of the
6b7257f756eb0530cdf54df9a7fab8d51a5001c3David Lawrence * functions which could be better handled using the dns_resolver
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * functions in most applications.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrenceisc_boolean_t have_ipv6 = ISC_FALSE, specified_source = ISC_FALSE,
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence free_now = ISC_FALSE, show_details = ISC_FALSE, usesearch=ISC_TRUE,
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence while (*s != 0) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence if (*s == '.')
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence unsigned int len;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence printf("Printing a buffer with length %d\n", r.length);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrencecheck_result(isc_result_t result, const char *msg) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence fatal("%s: %s", msg, isc_result_totext(result));
6e033f89d4f1fcf266e07d91fcabf474af4939a1David Lawrence /* Tests if a field is a class, without needing isc libs
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * initialized. This list will have to be manually kept in
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * sync with what the libs support.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence const char *classlist[] = {"in", "hs", "chaos"};
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence for (i = 0; i < numclasses; i++)
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence /* Tests if a field is a type, without needing isc libs
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * initialized. This list will have to be manually kept in
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * sync with what the libs support.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence const char *typelist[] = {"a", "ns", "md", "mf", "cname",
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence for (i = 0; i < numtypes; i++) {
94b166ffa58ef0ff263563c0550d0b30eb9f7772David Lawrence unsigned char bitfield;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence for (i=0;i<tw;i++) {
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence*requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence strncpy (looknew->textname, lookold-> textname, MXNAME);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence strncpy (looknew->rttext, lookold-> rttext, 32);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence strncpy (looknew->rctext, lookold-> rctext, 32);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence looknew->ns_search_only = lookold->ns_search_only;
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence looknew->section_question = lookold->section_question;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence looknew->section_answer = lookold->section_answer;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence looknew->section_authority = lookold->section_authority;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence looknew->section_additional = lookold->section_additional;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence looknew->use_my_server_list = lookold->use_my_server_list;
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence while (s != NULL) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence ISC_LIST_ENQUEUE(looknew->my_server_list, srv,
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence "-> %lx, new@%lx "
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence ISC_LIST_INSERTAFTER(lookup_list, lookold, looknew, link);
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence "%lx, new = %lx, "
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence unsigned char *secretstore;
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence search = isc_mem_allocate( mctx, sizeof(struct dig_server));
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence strncpy(search->origin, fixeddomain, MXNAME - 1);
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence get_servers = ISC_TF(server_list.head == NULL);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence sizeof(struct dig_server));
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence "allocation "
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence "failure in "
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence } else if (strcasecmp(ptr, "options") == 0) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence mctx, sizeof(struct
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence "allocation "
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence "failure in %s:"
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence } else if ((strcasecmp(ptr, "domain") == 0) &&
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence mctx, sizeof(struct
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence "failure in %s:"
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence srv = isc_mem_allocate(mctx, sizeof(dig_server_t));
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence if (keysecret[0] != 0) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = dns_tsigkeyring_create(mctx, &keyring);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence check_result(result, "dns_tsigkeyring_create");
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
goto SYSSETUP_FAIL;
namebuf);
goto SYSSETUP_FAIL;
setup_libs(void) {
if (free_now)
if (still_working)
isc_region_t r;
int len;
if (free_now)
BUFSIZE);
NULL,
isc_buffer_usedregion(b, &r);
(char *)r.base);
if (!success) {
if (section ==
query->
dig_server));
isc_buffer_free (&b);
if (free_now)
MXNAME);
int len;
isc_region_t r;
isc_buffer_t b;
if (free_now)
lookup_counter = 0;
isc_buffer_usedregion (&b, &r);
isc_buffer_usedregion (&b, &r);
DNS_SECTION_QUESTION, 0);
ISC_TRUE);
sockcount--;
sendcount++;
#ifdef TWIDDLE
if (twiddle) {
isc_region_t r;
q != NULL;
if (q->working) {
if (!free_now) {
isc_buffer_clear(b);
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
isc_region_t r;
if (free_now) {
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
sockcount--;
length);
if (free_now)
sockcount--;
if (include_question) {
#ifdef TWIDDLE
if (twiddle) {
link);
sendcount++;
isc_region_t r;
if (free_now) {
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
isc_buffer_t b;
isc_region_t r;
#ifdef NEVER
&name);
goto NEXT_RDATA;
&soa,
mctx);
goto XFR_DONE;
goto NEXT_RDATA;
goto NEXT_RDATA;
isc_buffer_usedregion(&b, &r);
goto NEXT_RDATA;
goto XFR_DONE;
isc_region_t r;
dig_lookup_t *n;
if (free_now) {
if (free_now) {
sendcount--;
&msg);
hex_dump(b);
if (show_details ||
== ISC_R_SUCCESS) &&
if (show_details) {
== ISC_R_SUCCESS) &&
&ab);
query);
port);
sockcount++;
if (specified_source)
sockcount++;
if (specified_source)
start_lookup(void) {
if (free_now)
void *ptr;
dig_lookup_t *l;
dig_query_t *q;
dig_server_t *s;
dig_searchlist_t *o;
if (free_now)
while (l != NULL) {
q = ISC_LIST_HEAD(l->q);
while (q != NULL) {
sockcount--;
link);
link);
ptr = q;
if (l->use_my_server_list) {
while (s != NULL) {
ptr = s;
ptr = l;
while (s != NULL) {
ptr = s;
while (o != NULL) {
ptr = o;
if (isc_mem_debugging)
if (_exitcode != 0)