dighost.c revision f17b62a64bec4690f7ef0263efee1fa727b66fd5
803d8426030e1f40c45d6861e95587189173f368Tinderbox 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
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * Notice to programmers: Do not use this code as an example of how to
d25afd60ee2286cb171c4960a790f3d7041b6f85Bob Halley * use the ISC library to perform DNS lookups. Dig and Host both operate
d25afd60ee2286cb171c4960a790f3d7041b6f85Bob Halley * on the request level, since they allow fine-tuning of output and are
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley * intended as debugging tools. As a result, they perform many of the
364a82f7c25b62967678027043425201a5e5171aBob Halley * functions which could be better handled using the dns_resolver
96754ed7b400ce080279de2f92111ad868105290Bob Halley * functions in most applications.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinisc_boolean_t tcp_mode = ISC_FALSE, have_ipv6 = ISC_FALSE,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein free_now = ISC_FALSE, show_details = ISC_FALSE, usesearch=ISC_TRUE,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein while (*s != 0) {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein if (*s == '.')
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein unsigned int len;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein printf("Printing a buffer with length %d\n", r.length);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews fatal("%s: %s", msg, isc_result_totext(result));
3a6d62c59f73d024d1b2ba2ac94d7600530166ffMark Andrews /* Tests if a field is a class, without needing isc libs
bad93fb90cc5f14e200f23ff67cce3127f45b705Mark Andrews * initialized. This list will have to be manually kept in
bad93fb90cc5f14e200f23ff67cce3127f45b705Mark Andrews * sync with what the libs support.
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt for (i = 0; i < numclasses; i++)
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt /* Tests if a field is a type, without needing isc libs
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt * initialized. This list will have to be manually kept in
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt * sync with what the libs support.
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt const char *typelist[] = {"a", "ns", "md", "mf", "cname",
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt for (i = 0; i < numtypes; i++) {
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt unsigned char bitfield;
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt for (i=0;i<tw;i++) {
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt search = isc_mem_allocate( mctx, sizeof(struct dig_server));
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt * Warning: This is not particularly good randomness. We'll
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt * just use random() now for getting id values, but doing so
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt * does NOT insure that id's cann't be guessed.
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt sizeof(struct dig_server));
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt "allocation "
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt "failure in "
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt mctx, sizeof(struct
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley "allocation "
c50fd34a4e0e6978f8ca5f6f3ad8545549c3cfeeBob Halley "failure in %s:"
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt mctx, sizeof(struct
138a6660fb74d458270511ca0ba24aa19bf375d5Bob Halley "allocation "
25e43e68b7431d5e4ff8b5427108cd7f5f9bcf3eBob Halley "failure in %s:"
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt srv = isc_mem_allocate(mctx, sizeof(dig_server_t));
25e43e68b7431d5e4ff8b5427108cd7f5f9bcf3eBob Halley result = isc_taskmgr_create (mctx, 1, 0, &taskmgr);
fa756a197b059b28c44f24e332bd072178861dc6Mark Andrews result = isc_socketmgr_create (mctx, &socketmgr);
542189f21b3ea9b27b0fbc047d832a34dcaf75bcAndreas Gustafsson check_result(result, "isc_socketmgr_create");
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrewsadd_opt (dns_message_t *msg, isc_uint16_t udpsize) {
25e43e68b7431d5e4ff8b5427108cd7f5f9bcf3eBob Halley result = dns_message_gettemprdataset(msg, &rdataset);
b6309ed962c4988a314d61742c4fbc4935467d68Mark Andrews check_result (result, "dns_message_gettemprdataset");
34b394b43e2207e8f8f3703f0402422121455638David Lawrence result = dns_message_gettemprdatalist(msg, &rdatalist);
34b394b43e2207e8f8f3703f0402422121455638David Lawrence check_result (result, "dns_message_gettemprdatalist");
34b394b43e2207e8f8f3703f0402422121455638David Lawrence result = dns_message_gettemprdata(msg, &rdata);
34b394b43e2207e8f8f3703f0402422121455638David Lawrence check_result (result, "dns_message_gettemprdata");
147fd0bdf83272952521a7f343d88a421e2ff997Brian Wellington ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
04b8111f2137a9cf9b0b71228f76b3e40ffa1173Brian Wellington dns_rdatalist_tordataset(rdatalist, rdataset);
04b8111f2137a9cf9b0b71228f76b3e40ffa1173Brian Wellington check_result (result, "dns_message_setopt");
25e43e68b7431d5e4ff8b5427108cd7f5f9bcf3eBob Halleyadd_type(dns_message_t *message, dns_name_t *name, dns_rdataclass_t rdclass,
isc_region_t r;
int len;
BUFSIZE);
NULL,
isc_buffer_usedregion(b, &r);
(char *)r.base);
if (!success) {
if (lookup_counter >
(mctx,
dig_lookup));
__LINE__);
if (section ==
query->
(long int)query->
(long int)lookup,
(long int)lookup->
link);
(long int)query->
(long int)lookup,
(long int)lookup->
dig_server));
isc_buffer_free (&b);
dig_server_t *s;
while (s != NULL) {
dig_server));
link);
link);
int len;
isc_region_t r;
isc_buffer_t b;
isc_buffer_usedregion (&b, &r);
isc_buffer_usedregion (&b, &r);
#ifdef DEBUG
DNS_SECTION_QUESTION, 0);
ISC_TRUE);
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;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
length);
if (include_question) {
#ifdef TWIDDLE
if (twiddle) {
link);
sendcount++;
isc_region_t r;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
isc_region_t r;
if (free_now) {
sendcount--;
&msg);
hex_dump(b);
ISC_R_SUCCESS) &&
if (show_details) {
== ISC_R_SUCCESS) &&
#ifdef DEBUG
&ab);
&ab);
query);
port);
#ifdef DEBUG
if (tcp_mode)
free_lists(void) {
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) {
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;
#ifdef MEMDEBUG
#ifdef TWIDDLE
#ifdef TWIDDLE
srandom(i);
setup_libs();
setup_system();
if (tcp_mode)
isc_app_run();
free_lists();