dighost.c revision 30eee5633cb0378a0ad96645391e9706c35b7765
/*
* Copyright (C) 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#define MEMDEBUG
#include <config.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
extern int h_errno;
#include <isc/assertions.h>
#include <isc/sockaddr.h>
#include <dns/fixedname.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dig/printmsg.h>
unsigned int timeout;
int sendcount=0;
extern isc_boolean_t short_form;
static void
free_lists(void);
static void
hex_dump(isc_buffer_t *b)
{
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
printf("\n");
}
if (len % 16 != 0)
printf("\n");
}
void
free_lists();
isc_mem_destroy (&mctx);
}
exit(1);
}
inline void
if (result != ISC_R_SUCCESS)
}
/* Tests if a field is a class, without needing isc libs
initialized. This list will have to be manually kept in
sync with what the libs support. */
const int numclasses = 3;
int i;
for (i=0;i<numclasses;i++) {
return ISC_TRUE;
}
return ISC_FALSE;
}
/* Tests if a field is a type, without needing isc libs
initialized. This list will have to be manually kept in
sync with what the libs support. */
"soa", "mb", "mg", "mr", "null",
"wks", "ptr", "hinfo", "minfo",
"mx", "txt", "rp", "afsdb",
"x25", "isdn", "rt", "nsap",
"nsap_ptr", "sig", "key", "px",
"gpos", "aaaa", "loc", "nxt",
"srv", "naptr", "kx", "cert",
"a6", "dname", "opt", "unspec",
"tkey", "tsig", "axfr"};
const int numtypes = 41;
int i;
for (i=0;i<numtypes;i++) {
return ISC_TRUE;
}
return ISC_FALSE;
}
static void
setup_system() {
char *ptr;
== 0) {
fatal ("Memory allocation failure.");
}
}
}
}
}
}
fatal ("Memory allocation failure");
}
}
static void
setup_libs() {
isc_buffer_t b;
result = isc_app_start();
result = isc_net_probeipv4();
result = isc_net_probeipv6();
if (result == ISC_R_SUCCESS)
isc_buffer_add (&b, 1);
}
static void
{
}
void
int len;
isc_buffer_t b;
#ifdef DEBUG
#endif
isc_buffer_add (&b, len);
if (result != ISC_R_SUCCESS) {
fatal ("Aborting: %s is not a legal name syntax.",
}
if (recurse)
if (rdtype == dns_rdatatype_axfr) {
/* Force TCP mode if we're doing an xfr */
}
fatal ("Memory allocation failure.");
}
}
static void
isc_event_free (&event);
}
static void
#ifdef DEBUG
#endif
return;
}
}
}
/* connect_timeout is used for both UDP recieves and TCP connects. */
static void
dig_query_t *q=NULL;
isc_buffer_t *b;
isc_region_t r;
for (q = ISC_LIST_HEAD(lookup->q);
q != NULL;
q = ISC_LIST_NEXT(q, link)) {
if (q->working) {
isc_buffer_clear (b);
isc_buffer_used(b, &r);
printf (";; Connection to server %.*s for %s failed: Connection timed out.\n",
}
}
isc_buffer_free (&b);
isc_event_free (&event);
}
static void
static void
isc_buffer_t *b=NULL;
isc_region_t r;
#ifdef DEBUG
#endif
isc_event_free (&event);
return;
}
isc_buffer_used(b, &r);
isc_buffer_free (&b);
isc_event_free (&event);
return;
}
length = isc_buffer_getuint16(b);
fatal ("Length was longer than I can handle!");
/* XXXMWS Fix the above. */
/* Even though the buffer was already init'ed, we need
to redo it now, to force the length we want. */
query);
#ifdef DEBUG
#endif
isc_event_free (&event);
}
static void
#ifdef DEBUG
fputs ("Ignoring launch_next_query because !pending.",
stderr);
#endif
return;
}
if (include_question)
link);
sendcount++;
#ifdef DEBUG
#endif
return;
}
static void
isc_buffer_t *b;
isc_region_t r;
#ifdef DEBUG
#endif
isc_buffer_used(b, &r);
printf (";; Connection to server %.*s for %s failed: %s.\n",
isc_buffer_free(&b);
isc_event_free (&event);
return;
}
isc_event_free (&event);
}
static isc_boolean_t
if (result == ISC_R_SUCCESS) {
#ifdef DEBUG
#endif
return (ISC_TRUE);
} else {
#ifdef DEBUG
#endif
return (ISC_FALSE);
}
}
static void
isc_buffer_t *b=NULL;
isc_region_t r;
sendcount--;
#ifdef DEBUG
#endif
#ifdef DEBUG
#endif
isc_event_free (&event);
return;
}
&msg);
if (result != ISC_R_SUCCESS)
hex_dump (b);
if (query->first_soa_rcvd &&
else
}
#ifdef DEBUG
#endif
if (!query->first_soa_rcvd) {
puts ("; Transfer failed. Didn't start with SOA answer.");
isc_event_free (&event);
return;
}
else {
}
}
else {
isc_event_free (&event);
return;
}
else {
}
}
}
else {
}
isc_buffer_used (&ab, &r);
if (!short_form)
printf ("; Received %u bytes from %s\n",
}
isc_event_free (&event);
return;
}
/* In truth, we should never get into the CANCELED routine, since
the cancel_lookup() routine clears the pending flag. */
isc_event_free (&event);
return;
}
}
static void
else {
fatal("Couldn't look up your server host %s. errno=%d",
port);
}
}
void
#ifdef DEBUG
#endif
}
}
void
#ifdef DEBUG
#endif
sendcount++;
#ifdef DEBUG
#endif
}
}
static void
free_lists(void) {
void *ptr;
dig_lookup_t *l;
dig_query_t *q;
dig_server_t *s;
l = ISC_LIST_HEAD(lookup_list);
while (l != NULL) {
q = ISC_LIST_HEAD(l->q);
while (q != NULL) {
isc_socket_detach (&q->sock);
ISC_LIST_DEQUEUE (q->recvlist,
isc_buffer_invalidate (&q->recvbuf);
isc_buffer_invalidate (&q->lengthbuf);
ptr = q;
q = ISC_LIST_NEXT(q, link);
}
dns_message_destroy (&l->sendmsg);
isc_timer_detach (&l->timer);
ptr = l;
l = ISC_LIST_NEXT(l, link);
}
s = ISC_LIST_HEAD(server_list);
while (s != NULL) {
ptr = s;
s = ISC_LIST_NEXT(s, link);
}
isc_task_detach (&task);
}
int
setup_libs();
port = 53;
timeout = 10;
setup_system();
if (tcp_mode)
else
isc_app_run();
free_lists();
#ifdef MEMDEBUG
#endif
isc_mem_destroy (&mctx);
}
return (0);
}