host.c revision 387a58e8c48434f4dd48cd8566e9979002ed3cbe
/*
* 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.
*/
#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 <isc/commandline.h>
#include <dns/fixedname.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
extern isc_boolean_t tcp_mode,
extern unsigned int timeout;
extern isc_taskmgr_t *taskmgr;
extern isc_task_t *task;
extern isc_timermgr_t *timermgr;
extern isc_socketmgr_t *socketmgr;
extern dns_messageid_t id;
extern dns_name_t rootorg;
extern isc_buffer_t rootbuf;
extern int sendcount;
static char *opcodetext[] = {
"QUERY",
"IQUERY",
"STATUS",
"RESERVED3",
"NOTIFY",
"UPDATE",
"RESERVED6",
"RESERVED7",
"RESERVED8",
"RESERVED9",
"RESERVED10",
"RESERVED11",
"RESERVED12",
"RESERVED13",
"RESERVED14",
"RESERVED15"
};
static char *rcodetext[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
"NXDOMAIN",
"NOTIMPL",
"REFUSED",
"YXDOMAIN",
"YXRRSET",
"NXRRSET",
"NOTAUTH",
"NOTZONE",
"RESERVED11",
"RESERVED12",
"RESERVED13",
"RESERVED14",
"RESERVED15",
"BADVERS"
};
static char *rtypetext[] = {
"zero", /* 0 */
"has address", /* 1 */
"name server", /* 2 */
"MD", /* 3 */
"MF", /* 4 */
"is an alias for", /* 5 */
"SOA", /* 6 */
"MB", /* 7 */
"MG", /* 8 */
"MR", /* 9 */
"NULL", /* 10 */
"has well known services", /* 11 */
"domain name pointer", /* 12 */
"host information", /* 13 */
"MINFO", /* 14 */
"mail is handled by", /* 15 */
"text", /* 16 */
"RP", /* 17 */
"AFSDB", /* 18 */
"x25 address", /* 19 */
"isdn address", /* 20 */
"RT" /* 21 */
"NSAP", /* 22 */
"NSAP_PTR", /* 23 */
"has signature", /* 24 */
"has key", /* 25 */
"PX", /* 26 */
"GPOS", /* 27 */
"has AAAA address", /* 28 */
"LOC", /* 29 */
"has next record", /* 30 */
"has 31 record", /* 31 */
"has 32 record", /* 32 */
"SRV", /* 33 */
"has 34 record", /* 34 */
"NAPTR", /* 35 */
"KX", /* 36 */
"CERT", /* 37 */
"has v6 address", /* 38 */
"DNAME", /* 39 */
"has 40 record", /* 40 */
"has optional information"}; /* 41 */
void
debug("In check_next_lookup");
debug("Still have a worker.");
}
}
if (still_working)
return;
debug ("Shutting Down.");
return;
}
if (tcp_mode)
else
}
static void
show_usage() {
fatal ("Usage.");
}
static void
{
isc_region_t r, r2;
isc_buffer_usedregion(b, &r);
}
printf ("\n");
isc_buffer_free(&b);
}
static isc_result_t
{
isc_region_t r;
char t[4096];
char *rtt;
if (sectionid == DNS_SECTION_QUESTION)
else
if (headers)
if (result == ISC_R_NOMORE)
return (ISC_R_SUCCESS);
else if (result != ISC_R_SUCCESS)
return (result);
for (;;) {
isc_buffer_init(&target, t, sizeof(t));
print_name = name;
if (!short_form) {
&target);
if (result != ISC_R_SUCCESS)
return (result);
#ifdef USEINITALWS
if (first) {
print_name = &empty_name;
}
#endif
} else {
while (loopresult == ISC_R_SUCCESS) {
rtt="unspecified data";
rtt="key";
rtt="signature";
else
rtt="unknown";
rdataset);
}
}
}
if (!short_form) {
isc_buffer_usedregion(&target, &r);
if (no_rdata)
(char *)r.base);
else
}
if (result == ISC_R_NOMORE)
break;
else if (result != ISC_R_SUCCESS)
return (result);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
{
isc_region_t r;
char t[4096];
if (headers)
isc_buffer_init(&target, t, sizeof(t));
&target);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_usedregion(&target, &r);
return (ISC_R_SUCCESS);
}
printf ("Host not found: %d(%s)\n",
return (ISC_R_SUCCESS);
}
if (!short_form) {
printf(";; ->>HEADER<<- opcode: %s, status: %s, id: %u\n",
printf(";; flags: ");
printf("qr");
}
}
}
}
}
}
}
printf("; QUERY: %u, ANSWER: %u, "
"AUTHORITY: %u, ADDITIONAL: %u\n",
printf(";; EDNS: version: %u, udp=%u\n",
printf(";; PSEUDOSECTIONS: TSIG\n");
}
!short_form ) {
printf("\n");
if (result != ISC_R_SUCCESS)
return (result);
}
if (!short_form)
printf("\n");
!short_form, query);
if (result != ISC_R_SUCCESS)
return (result);
}
!short_form ) {
printf("\n");
if (result != ISC_R_SUCCESS)
return (result);
}
!short_form ) {
printf("\n");
if (result != ISC_R_SUCCESS)
return (result);
}
printf("\n");
"PSEUDOSECTION TSIG", ISC_TRUE);
if (result != ISC_R_SUCCESS)
return (result);
}
if (!short_form)
printf("\n");
return (result);
}
void
int c;
switch (c) {
case 'l':
break;
case 'v':
case 'd':
break;
case 'r':
break;
case 't':
break;
case 'c':
break;
case 'a':
break;
case 'w':
/* XXXMWS This should be a system-indep.
thing! */
timeout = 32767;
break;
case 'T':
break;
case 'C':
debug ("Showing all SOA's");
if (querytype[0] == 0)
if (queryclass[0] == 0)
break;
}
}
if (isc_commandline_index >= argc) {
show_usage();
}
fatal ("Memory allocation failure.");
}
if (querytype[0] == 0)
if (queryclass[0] == 0)
sizeof(struct dig_lookup));
fatal ("Memory allocation failure.");
ISC_LIST_INIT(lookup->q);
}