2000-04-26 22:53:56 +00:00
|
|
|
/*
|
2001-01-09 22:01:04 +00:00
|
|
|
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-04-26 22:53:56 +00:00
|
|
|
* 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.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* 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.
|
2000-04-26 22:53:56 +00:00
|
|
|
*/
|
|
|
|
|
2001-01-24 19:28:34 +00:00
|
|
|
/* $Id: host.c,v 1.63 2001/01/24 19:28:32 gson Exp $ */
|
2000-06-06 18:49:06 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <stdlib.h>
|
2000-07-06 01:02:42 +00:00
|
|
|
#include <limits.h>
|
2000-04-26 22:53:56 +00:00
|
|
|
|
|
|
|
extern int h_errno;
|
|
|
|
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <isc/app.h>
|
|
|
|
#include <isc/commandline.h>
|
2000-08-14 19:11:05 +00:00
|
|
|
#include <isc/netaddr.h>
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <isc/string.h>
|
|
|
|
#include <isc/util.h>
|
2000-06-30 14:11:49 +00:00
|
|
|
#include <isc/task.h>
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-08-14 19:11:05 +00:00
|
|
|
#include <dns/byaddr.h>
|
|
|
|
#include <dns/fixedname.h>
|
2000-07-05 19:31:26 +00:00
|
|
|
#include <dns/message.h>
|
|
|
|
#include <dns/name.h>
|
|
|
|
#include <dns/rdata.h>
|
2000-07-18 01:28:20 +00:00
|
|
|
#include <dns/rdataclass.h>
|
2000-07-05 19:31:26 +00:00
|
|
|
#include <dns/rdataset.h>
|
2000-07-18 01:28:20 +00:00
|
|
|
#include <dns/rdatatype.h>
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
#include <dig/dig.h>
|
|
|
|
|
|
|
|
extern ISC_LIST(dig_lookup_t) lookup_list;
|
|
|
|
extern ISC_LIST(dig_server_t) server_list;
|
2000-05-02 23:23:12 +00:00
|
|
|
extern ISC_LIST(dig_searchlist_t) search_list;
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2001-01-18 05:12:44 +00:00
|
|
|
extern isc_boolean_t usesearch;
|
2000-09-27 00:02:02 +00:00
|
|
|
extern isc_boolean_t debugging;
|
2000-04-26 22:53:56 +00:00
|
|
|
extern unsigned int timeout;
|
|
|
|
extern isc_mem_t *mctx;
|
2000-05-02 23:23:12 +00:00
|
|
|
extern int ndots;
|
|
|
|
extern int tries;
|
2000-07-05 23:28:32 +00:00
|
|
|
extern char *progname;
|
2000-07-10 18:02:31 +00:00
|
|
|
extern isc_task_t *global_task;
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-09-11 21:48:11 +00:00
|
|
|
isc_boolean_t short_form = ISC_TRUE, listed_server = ISC_FALSE;
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
static const char *opcodetext[] = {
|
2000-04-26 22:53:56 +00:00
|
|
|
"QUERY",
|
|
|
|
"IQUERY",
|
|
|
|
"STATUS",
|
|
|
|
"RESERVED3",
|
|
|
|
"NOTIFY",
|
|
|
|
"UPDATE",
|
|
|
|
"RESERVED6",
|
|
|
|
"RESERVED7",
|
|
|
|
"RESERVED8",
|
|
|
|
"RESERVED9",
|
|
|
|
"RESERVED10",
|
|
|
|
"RESERVED11",
|
|
|
|
"RESERVED12",
|
|
|
|
"RESERVED13",
|
|
|
|
"RESERVED14",
|
|
|
|
"RESERVED15"
|
|
|
|
};
|
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
static const char *rcodetext[] = {
|
2000-04-26 22:53:56 +00:00
|
|
|
"NOERROR",
|
|
|
|
"FORMERR",
|
|
|
|
"SERVFAIL",
|
|
|
|
"NXDOMAIN",
|
|
|
|
"NOTIMPL",
|
|
|
|
"REFUSED",
|
|
|
|
"YXDOMAIN",
|
|
|
|
"YXRRSET",
|
|
|
|
"NXRRSET",
|
|
|
|
"NOTAUTH",
|
|
|
|
"NOTZONE",
|
|
|
|
"RESERVED11",
|
|
|
|
"RESERVED12",
|
|
|
|
"RESERVED13",
|
|
|
|
"RESERVED14",
|
|
|
|
"RESERVED15",
|
|
|
|
"BADVERS"
|
|
|
|
};
|
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
static const char *rtypetext[] = {
|
2000-04-27 23:20:29 +00:00
|
|
|
"zero", /* 0 */
|
|
|
|
"has address", /* 1 */
|
|
|
|
"name server", /* 2 */
|
|
|
|
"MD", /* 3 */
|
|
|
|
"MF", /* 4 */
|
|
|
|
"is an alias for", /* 5 */
|
2000-04-28 21:41:19 +00:00
|
|
|
"SOA", /* 6 */
|
2000-08-01 01:33:37 +00:00
|
|
|
"MB", /* 7 */
|
2000-04-27 23:20:29 +00:00
|
|
|
"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 */
|
2000-05-24 17:26:01 +00:00
|
|
|
"RT", /* 21 */
|
2000-04-27 23:20:29 +00:00
|
|
|
"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 */
|
2000-05-24 17:26:01 +00:00
|
|
|
"EID", /* 31 */
|
|
|
|
"NIMLOC", /* 32 */
|
2000-04-27 23:20:29 +00:00
|
|
|
"SRV", /* 33 */
|
2000-05-24 17:26:01 +00:00
|
|
|
"ATMA", /* 34 */
|
2000-04-27 23:20:29 +00:00
|
|
|
"NAPTR", /* 35 */
|
|
|
|
"KX", /* 36 */
|
|
|
|
"CERT", /* 37 */
|
|
|
|
"has v6 address", /* 38 */
|
|
|
|
"DNAME", /* 39 */
|
2000-05-24 17:26:01 +00:00
|
|
|
"has optional information", /* 41 */
|
|
|
|
"has 42 record", /* 42 */
|
|
|
|
"has 43 record", /* 43 */
|
|
|
|
"has 44 record", /* 44 */
|
|
|
|
"has 45 record", /* 45 */
|
|
|
|
"has 46 record", /* 46 */
|
|
|
|
"has 47 record", /* 47 */
|
|
|
|
"has 48 record", /* 48 */
|
|
|
|
"has 49 record", /* 49 */
|
|
|
|
"has 50 record", /* 50 */
|
|
|
|
"has 51 record", /* 51 */
|
|
|
|
"has 52 record", /* 52 */
|
|
|
|
"has 53 record", /* 53 */
|
|
|
|
"has 54 record", /* 54 */
|
|
|
|
"has 55 record", /* 55 */
|
|
|
|
"has 56 record", /* 56 */
|
|
|
|
"has 57 record", /* 57 */
|
|
|
|
"has 58 record", /* 58 */
|
|
|
|
"has 59 record", /* 59 */
|
|
|
|
"has 60 record", /* 60 */
|
|
|
|
"has 61 record", /* 61 */
|
|
|
|
"has 62 record", /* 62 */
|
|
|
|
"has 63 record", /* 63 */
|
|
|
|
"has 64 record", /* 64 */
|
|
|
|
"has 65 record", /* 65 */
|
|
|
|
"has 66 record", /* 66 */
|
|
|
|
"has 67 record", /* 67 */
|
|
|
|
"has 68 record", /* 68 */
|
|
|
|
"has 69 record", /* 69 */
|
|
|
|
"has 70 record", /* 70 */
|
|
|
|
"has 71 record", /* 71 */
|
|
|
|
"has 72 record", /* 72 */
|
|
|
|
"has 73 record", /* 73 */
|
|
|
|
"has 74 record", /* 74 */
|
|
|
|
"has 75 record", /* 75 */
|
|
|
|
"has 76 record", /* 76 */
|
|
|
|
"has 77 record", /* 77 */
|
|
|
|
"has 78 record", /* 78 */
|
|
|
|
"has 79 record", /* 79 */
|
|
|
|
"has 80 record", /* 80 */
|
|
|
|
"has 81 record", /* 81 */
|
|
|
|
"has 82 record", /* 82 */
|
|
|
|
"has 83 record", /* 83 */
|
|
|
|
"has 84 record", /* 84 */
|
|
|
|
"has 85 record", /* 85 */
|
|
|
|
"has 86 record", /* 86 */
|
|
|
|
"has 87 record", /* 87 */
|
|
|
|
"has 88 record", /* 88 */
|
|
|
|
"has 89 record", /* 89 */
|
|
|
|
"has 90 record", /* 90 */
|
|
|
|
"has 91 record", /* 91 */
|
|
|
|
"has 92 record", /* 92 */
|
|
|
|
"has 93 record", /* 93 */
|
|
|
|
"has 94 record", /* 94 */
|
|
|
|
"has 95 record", /* 95 */
|
|
|
|
"has 96 record", /* 96 */
|
|
|
|
"has 97 record", /* 97 */
|
|
|
|
"has 98 record", /* 98 */
|
|
|
|
"has 99 record", /* 99 */
|
2000-10-19 23:31:56 +00:00
|
|
|
"UINFO", /* 100 */
|
2000-05-24 17:26:01 +00:00
|
|
|
"UID", /* 101 */
|
|
|
|
"GID", /* 102 */
|
|
|
|
"UNSPEC"}; /* 103 */
|
2000-04-27 23:20:29 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
|
|
|
|
static void
|
2000-05-24 03:12:36 +00:00
|
|
|
show_usage(void) {
|
2000-07-05 19:31:26 +00:00
|
|
|
fputs(
|
2000-08-14 19:11:05 +00:00
|
|
|
"Usage: host [-aCdlrTwv] [-c class] [-n] [-N ndots] [-t type] [-W time]\n"
|
2000-05-02 23:23:12 +00:00
|
|
|
" [-R number] hostname [server]\n"
|
|
|
|
" -a is equivalent to -v -t *\n"
|
|
|
|
" -c specifies query class for non-IN data\n"
|
|
|
|
" -C compares SOA records on authorative nameservers\n"
|
|
|
|
" -d is equivalent to -v\n"
|
|
|
|
" -l lists all hosts in a domain, using AXFR\n"
|
2000-08-14 19:11:05 +00:00
|
|
|
" -n Use the nibble form of IPv6 reverse lookup\n"
|
2000-05-02 23:23:12 +00:00
|
|
|
" -N changes the number of dots allowed before root lookup is done\n"
|
|
|
|
" -r disables recursive processing\n"
|
|
|
|
" -R specifies number of retries for UDP packets\n"
|
|
|
|
" -t specifies the query type\n"
|
|
|
|
" -T enables TCP/IP mode\n"
|
|
|
|
" -v enables verbose output\n"
|
|
|
|
" -w specifies to wait forever for a reply\n"
|
2000-05-03 23:07:30 +00:00
|
|
|
" -W specifies how long to wait for a reply\n", stderr);
|
2000-08-03 17:43:06 +00:00
|
|
|
exit(1);
|
2000-08-01 01:33:37 +00:00
|
|
|
}
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-05-12 01:02:37 +00:00
|
|
|
void
|
|
|
|
dighost_shutdown(void) {
|
|
|
|
isc_app_shutdown();
|
|
|
|
}
|
|
|
|
|
2000-05-02 23:23:12 +00:00
|
|
|
void
|
2001-01-24 19:28:34 +00:00
|
|
|
received(int bytes, isc_sockaddr_t *from, dig_query_t *query)
|
|
|
|
{
|
2000-05-04 21:40:47 +00:00
|
|
|
isc_time_t now;
|
|
|
|
isc_result_t result;
|
|
|
|
int diff;
|
|
|
|
|
2000-09-27 00:02:02 +00:00
|
|
|
if (!short_form) {
|
2001-01-24 19:28:34 +00:00
|
|
|
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
|
|
|
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
|
2000-05-04 21:40:47 +00:00
|
|
|
result = isc_time_now(&now);
|
2000-07-05 19:31:26 +00:00
|
|
|
check_result(result, "isc_time_now");
|
2000-05-04 21:40:47 +00:00
|
|
|
diff = isc_time_microdiff(&now, &query->time_sent);
|
2001-01-24 19:28:34 +00:00
|
|
|
printf("Received %u bytes from %s in %d ms\n",
|
|
|
|
bytes, fromtext, diff/1000);
|
2000-05-04 21:40:47 +00:00
|
|
|
}
|
2000-05-02 23:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
trying(int frmsize, char *frm, dig_lookup_t *lookup) {
|
2000-07-05 19:31:26 +00:00
|
|
|
UNUSED(lookup);
|
2000-05-02 23:23:12 +00:00
|
|
|
|
|
|
|
if (!short_form)
|
2001-01-24 19:28:34 +00:00
|
|
|
printf("Trying \"%.*s\"\n", frmsize, frm);
|
2000-05-02 23:23:12 +00:00
|
|
|
}
|
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
static void
|
2000-06-01 18:49:22 +00:00
|
|
|
say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
2000-04-28 21:41:19 +00:00
|
|
|
dig_query_t *query)
|
|
|
|
{
|
2000-05-24 03:12:36 +00:00
|
|
|
isc_buffer_t *b = NULL, *b2 = NULL;
|
2000-04-27 23:20:29 +00:00
|
|
|
isc_region_t r, r2;
|
2000-04-26 22:53:56 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
2000-04-28 21:41:19 +00:00
|
|
|
result = isc_buffer_allocate(mctx, &b, BUFSIZE);
|
2000-07-05 19:31:26 +00:00
|
|
|
check_result(result, "isc_buffer_allocate");
|
2000-04-28 21:41:19 +00:00
|
|
|
result = isc_buffer_allocate(mctx, &b2, BUFSIZE);
|
2000-07-05 19:31:26 +00:00
|
|
|
check_result(result, "isc_buffer_allocate");
|
2000-04-28 21:41:19 +00:00
|
|
|
result = dns_name_totext(name, ISC_FALSE, b);
|
2000-04-27 23:20:29 +00:00
|
|
|
check_result(result, "dns_name_totext");
|
|
|
|
isc_buffer_usedregion(b, &r);
|
|
|
|
result = dns_rdata_totext(rdata, NULL, b2);
|
2000-04-26 22:53:56 +00:00
|
|
|
check_result(result, "dns_rdata_totext");
|
2000-04-27 23:20:29 +00:00
|
|
|
isc_buffer_usedregion(b2, &r2);
|
2001-01-24 19:28:34 +00:00
|
|
|
printf("%.*s %s %.*s", (int)r.length, (char *)r.base,
|
|
|
|
msg, (int)r2.length, (char *)r2.base);
|
2000-04-28 21:41:19 +00:00
|
|
|
if (query->lookup->identify) {
|
2001-01-24 19:28:34 +00:00
|
|
|
printf(" on server %s", query->servname);
|
2000-04-28 21:41:19 +00:00
|
|
|
}
|
2001-01-24 19:28:34 +00:00
|
|
|
printf("\n");
|
2000-04-27 23:20:29 +00:00
|
|
|
isc_buffer_free(&b);
|
|
|
|
isc_buffer_free(&b2);
|
|
|
|
}
|
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
|
|
|
|
static isc_result_t
|
2000-06-01 18:49:22 +00:00
|
|
|
printsection(dns_message_t *msg, dns_section_t sectionid,
|
|
|
|
const char *section_name, isc_boolean_t headers,
|
|
|
|
dig_query_t *query)
|
2000-04-26 22:53:56 +00:00
|
|
|
{
|
|
|
|
dns_name_t *name, *print_name;
|
|
|
|
dns_rdataset_t *rdataset;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2000-04-26 22:53:56 +00:00
|
|
|
isc_buffer_t target;
|
|
|
|
isc_result_t result, loopresult;
|
|
|
|
isc_region_t r;
|
|
|
|
dns_name_t empty_name;
|
|
|
|
char t[4096];
|
|
|
|
isc_boolean_t first;
|
|
|
|
isc_boolean_t no_rdata;
|
2000-06-01 18:49:22 +00:00
|
|
|
const char *rtt;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
if (sectionid == DNS_SECTION_QUESTION)
|
|
|
|
no_rdata = ISC_TRUE;
|
|
|
|
else
|
|
|
|
no_rdata = ISC_FALSE;
|
|
|
|
|
|
|
|
if (headers)
|
|
|
|
printf(";; %s SECTION:\n", section_name);
|
|
|
|
|
|
|
|
dns_name_init(&empty_name, NULL);
|
|
|
|
|
|
|
|
result = dns_message_firstname(msg, sectionid);
|
|
|
|
if (result == ISC_R_NOMORE)
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
else if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
name = NULL;
|
|
|
|
dns_message_currentname(msg, sectionid, &name);
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&target, t, sizeof(t));
|
2000-04-26 22:53:56 +00:00
|
|
|
first = ISC_TRUE;
|
|
|
|
print_name = name;
|
|
|
|
|
|
|
|
for (rdataset = ISC_LIST_HEAD(name->list);
|
|
|
|
rdataset != NULL;
|
|
|
|
rdataset = ISC_LIST_NEXT(rdataset, link)) {
|
|
|
|
if (!short_form) {
|
|
|
|
result = dns_rdataset_totext(rdataset,
|
|
|
|
print_name,
|
|
|
|
ISC_FALSE,
|
|
|
|
no_rdata,
|
|
|
|
&target);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
#ifdef USEINITALWS
|
|
|
|
if (first) {
|
|
|
|
print_name = &empty_name;
|
|
|
|
first = ISC_FALSE;
|
|
|
|
}
|
2000-05-24 03:12:36 +00:00
|
|
|
#else
|
|
|
|
UNUSED(first); /* Shut up compiler. */
|
2000-04-26 22:53:56 +00:00
|
|
|
#endif
|
2000-08-01 01:33:37 +00:00
|
|
|
} else {
|
2000-04-26 22:53:56 +00:00
|
|
|
loopresult = dns_rdataset_first(rdataset);
|
|
|
|
while (loopresult == ISC_R_SUCCESS) {
|
|
|
|
dns_rdataset_current(rdataset, &rdata);
|
2000-05-24 17:26:01 +00:00
|
|
|
if (rdata.type <= 103)
|
2001-01-24 19:28:34 +00:00
|
|
|
rtt = rtypetext[rdata.type];
|
2000-04-27 23:20:29 +00:00
|
|
|
else if (rdata.type == 249)
|
2000-05-24 03:12:36 +00:00
|
|
|
rtt = "key";
|
2000-04-27 23:20:29 +00:00
|
|
|
else if (rdata.type == 250)
|
2000-05-24 03:12:36 +00:00
|
|
|
rtt = "signature";
|
2000-04-27 23:20:29 +00:00
|
|
|
else
|
2000-06-01 18:49:22 +00:00
|
|
|
rtt = "unknown";
|
2000-05-24 17:26:01 +00:00
|
|
|
say_message(print_name, rtt,
|
2000-04-28 21:41:19 +00:00
|
|
|
&rdata, query);
|
2000-10-31 03:22:05 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2000-06-01 18:49:22 +00:00
|
|
|
loopresult =
|
|
|
|
dns_rdataset_next(rdataset);
|
2000-04-26 22:53:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!short_form) {
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&target, &r);
|
2000-04-26 22:53:56 +00:00
|
|
|
if (no_rdata)
|
|
|
|
printf(";%.*s", (int)r.length,
|
|
|
|
(char *)r.base);
|
|
|
|
else
|
|
|
|
printf("%.*s", (int)r.length, (char *)r.base);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
result = dns_message_nextname(msg, sectionid);
|
|
|
|
if (result == ISC_R_NOMORE)
|
|
|
|
break;
|
|
|
|
else if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
|
2000-06-01 18:49:22 +00:00
|
|
|
const char *set_name, isc_boolean_t headers)
|
2000-04-26 22:53:56 +00:00
|
|
|
{
|
|
|
|
isc_buffer_t target;
|
|
|
|
isc_result_t result;
|
|
|
|
isc_region_t r;
|
|
|
|
char t[4096];
|
|
|
|
|
|
|
|
UNUSED(msg);
|
2000-08-01 01:33:37 +00:00
|
|
|
if (headers)
|
2000-04-26 22:53:56 +00:00
|
|
|
printf(";; %s SECTION:\n", set_name);
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&target, t, sizeof(t));
|
2000-04-26 22:53:56 +00:00
|
|
|
|
|
|
|
result = dns_rdataset_totext(rdataset, owner, ISC_FALSE, ISC_FALSE,
|
|
|
|
&target);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&target, &r);
|
2000-04-26 22:53:56 +00:00
|
|
|
printf("%.*s", (int)r.length, (char *)r.base);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2000-04-28 21:41:19 +00:00
|
|
|
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
2000-04-26 22:53:56 +00:00
|
|
|
isc_boolean_t did_flag = ISC_FALSE;
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
dns_rdataset_t *opt, *tsig = NULL;
|
2000-04-26 22:53:56 +00:00
|
|
|
dns_name_t *tsigname;
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2000-07-03 05:10:14 +00:00
|
|
|
isc_buffer_t *b = NULL;
|
2000-05-04 21:40:47 +00:00
|
|
|
isc_region_t r;
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-07-05 19:31:26 +00:00
|
|
|
UNUSED(headers);
|
2000-04-28 21:53:50 +00:00
|
|
|
|
2000-09-13 00:27:27 +00:00
|
|
|
if (listed_server) {
|
|
|
|
printf("Using domain server:\n");
|
|
|
|
printf("Name: %s\n", query->servname);
|
|
|
|
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
|
|
|
check_result(result, "isc_buffer_allocate");
|
|
|
|
result = isc_sockaddr_totext(&query->sockaddr, b);
|
|
|
|
check_result(result, "isc_sockaddr_totext");
|
|
|
|
printf("Address: %.*s\n",
|
|
|
|
(int)isc_buffer_usedlength(b),
|
|
|
|
(char*)isc_buffer_base(b));
|
|
|
|
isc_buffer_free(&b);
|
|
|
|
printf("Aliases: \n\n");
|
|
|
|
}
|
|
|
|
|
2000-04-27 23:20:29 +00:00
|
|
|
if (msg->rcode != 0) {
|
2000-05-04 21:40:47 +00:00
|
|
|
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
2000-07-05 19:31:26 +00:00
|
|
|
check_result(result, "isc_buffer_allocate");
|
2000-05-04 21:40:47 +00:00
|
|
|
result = dns_name_totext(query->lookup->name, ISC_FALSE,
|
|
|
|
b);
|
2000-07-05 19:31:26 +00:00
|
|
|
check_result(result, "dns_name_totext");
|
|
|
|
isc_buffer_usedregion(b, &r);
|
|
|
|
printf("Host %.*s not found: %d(%s)\n",
|
|
|
|
(int)r.length, (char *)r.base,
|
|
|
|
msg->rcode, rcodetext[msg->rcode]);
|
|
|
|
isc_buffer_free(&b);
|
2000-04-27 23:20:29 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2000-04-26 22:53:56 +00:00
|
|
|
if (!short_form) {
|
|
|
|
printf(";; ->>HEADER<<- opcode: %s, status: %s, id: %u\n",
|
|
|
|
opcodetext[msg->opcode], rcodetext[msg->rcode],
|
|
|
|
msg->id);
|
|
|
|
printf(";; flags: ");
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_QR) != 0) {
|
|
|
|
printf("qr");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_AA) != 0) {
|
|
|
|
printf("%saa", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_TC) != 0) {
|
|
|
|
printf("%stc", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_RD) != 0) {
|
|
|
|
printf("%srd", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_RA) != 0) {
|
|
|
|
printf("%sra", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_AD) != 0) {
|
|
|
|
printf("%sad", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
|
|
|
if ((msg->flags & DNS_MESSAGEFLAG_CD) != 0) {
|
|
|
|
printf("%scd", did_flag ? " " : "");
|
|
|
|
did_flag = ISC_TRUE;
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
printf("; QUERY: %u, ANSWER: %u, "
|
|
|
|
"AUTHORITY: %u, ADDITIONAL: %u\n",
|
2000-04-26 22:53:56 +00:00
|
|
|
msg->counts[DNS_SECTION_QUESTION],
|
|
|
|
msg->counts[DNS_SECTION_ANSWER],
|
|
|
|
msg->counts[DNS_SECTION_AUTHORITY],
|
|
|
|
msg->counts[DNS_SECTION_ADDITIONAL]);
|
|
|
|
opt = dns_message_getopt(msg);
|
|
|
|
if (opt != NULL)
|
|
|
|
printf(";; EDNS: version: %u, udp=%u\n",
|
|
|
|
(unsigned int)((opt->ttl & 0x00ff0000) >> 16),
|
|
|
|
(unsigned int)opt->rdclass);
|
|
|
|
tsigname = NULL;
|
|
|
|
tsig = dns_message_gettsig(msg, &tsigname);
|
|
|
|
if (tsig != NULL)
|
|
|
|
printf(";; PSEUDOSECTIONS: TSIG\n");
|
|
|
|
}
|
|
|
|
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) &&
|
2000-07-05 19:31:26 +00:00
|
|
|
!short_form) {
|
2000-04-26 22:53:56 +00:00
|
|
|
printf("\n");
|
|
|
|
result = printsection(msg, DNS_SECTION_QUESTION, "QUESTION",
|
2000-04-28 21:41:19 +00:00
|
|
|
ISC_TRUE, query);
|
2000-04-26 22:53:56 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) {
|
|
|
|
if (!short_form)
|
|
|
|
printf("\n");
|
|
|
|
result = printsection(msg, DNS_SECTION_ANSWER, "ANSWER",
|
2000-05-24 03:12:36 +00:00
|
|
|
ISC_TF(!short_form), query);
|
2000-04-26 22:53:56 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
2000-09-11 21:48:11 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
|
2000-07-05 19:31:26 +00:00
|
|
|
!short_form) {
|
2000-04-26 22:53:56 +00:00
|
|
|
printf("\n");
|
|
|
|
result = printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY",
|
2000-04-28 21:41:19 +00:00
|
|
|
ISC_TRUE, query);
|
2000-04-26 22:53:56 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) &&
|
2000-07-05 19:31:26 +00:00
|
|
|
!short_form) {
|
2000-04-26 22:53:56 +00:00
|
|
|
printf("\n");
|
|
|
|
result = printsection(msg, DNS_SECTION_ADDITIONAL,
|
2000-04-28 21:41:19 +00:00
|
|
|
"ADDITIONAL", ISC_TRUE, query);
|
2000-04-26 22:53:56 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
if ((tsig != NULL) && !short_form) {
|
|
|
|
printf("\n");
|
|
|
|
result = printrdata(msg, tsig, tsigname,
|
|
|
|
"PSEUDOSECTION TSIG", ISC_TRUE);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
if (!short_form)
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-05-12 01:02:37 +00:00
|
|
|
static void
|
2000-04-26 22:53:56 +00:00
|
|
|
parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
|
|
|
|
char hostname[MXNAME];
|
|
|
|
dig_server_t *srv;
|
|
|
|
dig_lookup_t *lookup;
|
2000-10-23 23:13:21 +00:00
|
|
|
int c;
|
2000-05-08 22:51:08 +00:00
|
|
|
char store[MXNAME];
|
2000-07-18 01:28:20 +00:00
|
|
|
isc_textregion_t tr;
|
|
|
|
isc_result_t result;
|
|
|
|
dns_rdatatype_t rdtype;
|
|
|
|
dns_rdataclass_t rdclass;
|
2000-04-26 22:53:56 +00:00
|
|
|
|
2000-04-28 21:53:50 +00:00
|
|
|
UNUSED(is_batchfile);
|
|
|
|
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup = make_empty_lookup();
|
|
|
|
|
2000-08-14 19:11:05 +00:00
|
|
|
while ((c = isc_commandline_parse(argc, argv, "lvwrdt:c:aTCN:R:W:Dn"))
|
2000-05-02 23:23:12 +00:00
|
|
|
!= EOF) {
|
2000-04-26 22:53:56 +00:00
|
|
|
switch (c) {
|
|
|
|
case 'l':
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->tcp_mode = ISC_TRUE;
|
|
|
|
lookup->rdtype = dns_rdatatype_axfr;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdtypeset = ISC_TRUE;
|
2000-04-26 22:53:56 +00:00
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
case 'd':
|
|
|
|
short_form = ISC_FALSE;
|
|
|
|
break;
|
|
|
|
case 'r':
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->recurse = ISC_FALSE;
|
2000-04-26 22:53:56 +00:00
|
|
|
break;
|
|
|
|
case 't':
|
2000-07-18 01:28:20 +00:00
|
|
|
tr.base = isc_commandline_argument;
|
|
|
|
tr.length = strlen(isc_commandline_argument);
|
|
|
|
result = dns_rdatatype_fromtext(&rdtype,
|
|
|
|
(isc_textregion_t *)&tr);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-07-18 01:28:20 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2001-01-24 19:28:34 +00:00
|
|
|
fprintf(stderr,"Warning: invalid type: %s\n",
|
|
|
|
isc_commandline_argument);
|
2000-12-08 17:06:52 +00:00
|
|
|
else {
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->rdtype = rdtype;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdtypeset = ISC_TRUE;
|
|
|
|
}
|
2000-04-26 22:53:56 +00:00
|
|
|
break;
|
2000-04-27 23:20:29 +00:00
|
|
|
case 'c':
|
2000-07-18 01:28:20 +00:00
|
|
|
tr.base = isc_commandline_argument;
|
|
|
|
tr.length = strlen(isc_commandline_argument);
|
|
|
|
result = dns_rdataclass_fromtext(&rdclass,
|
|
|
|
(isc_textregion_t *)&tr);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-07-18 01:28:20 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2001-01-24 19:28:34 +00:00
|
|
|
fprintf(stderr,"Warning: invalid class: %s\n",
|
|
|
|
isc_commandline_argument);
|
2000-12-08 17:06:52 +00:00
|
|
|
else {
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->rdclass = rdclass;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdclassset = ISC_TRUE;
|
|
|
|
}
|
2000-04-27 23:20:29 +00:00
|
|
|
break;
|
2000-04-26 22:53:56 +00:00
|
|
|
case 'a':
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->rdtype = dns_rdatatype_any;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdtypeset = ISC_TRUE;
|
2000-04-26 22:53:56 +00:00
|
|
|
short_form = ISC_FALSE;
|
|
|
|
break;
|
2000-08-14 19:11:05 +00:00
|
|
|
case 'n':
|
|
|
|
lookup->nibble = ISC_TRUE;
|
|
|
|
break;
|
2000-04-26 22:53:56 +00:00
|
|
|
case 'w':
|
2000-07-05 23:28:32 +00:00
|
|
|
/*
|
|
|
|
* The timer routines are coded such that
|
|
|
|
* timeout==MAXINT doesn't enable the timer
|
|
|
|
*/
|
2000-07-06 01:02:42 +00:00
|
|
|
timeout = INT_MAX;
|
2000-04-26 22:53:56 +00:00
|
|
|
break;
|
2000-05-02 23:23:12 +00:00
|
|
|
case 'W':
|
|
|
|
timeout = atoi(isc_commandline_argument);
|
|
|
|
if (timeout < 1)
|
|
|
|
timeout = 1;
|
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
tries = atoi(isc_commandline_argument);
|
|
|
|
if (tries < 1)
|
|
|
|
tries = 1;
|
|
|
|
break;
|
2000-04-28 21:41:19 +00:00
|
|
|
case 'T':
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->tcp_mode = ISC_TRUE;
|
2000-04-28 21:41:19 +00:00
|
|
|
break;
|
2000-04-27 23:20:29 +00:00
|
|
|
case 'C':
|
2000-07-05 23:28:32 +00:00
|
|
|
debug("showing all SOAs");
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->rdtype = dns_rdatatype_soa;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdtypeset = ISC_TRUE;
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->rdclass = dns_rdataclass_in;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdclassset = ISC_TRUE;
|
2000-07-18 01:28:20 +00:00
|
|
|
lookup->ns_search_only = ISC_TRUE;
|
|
|
|
lookup->trace_root = ISC_TRUE;
|
2000-04-27 23:20:29 +00:00
|
|
|
break;
|
2000-05-02 23:23:12 +00:00
|
|
|
case 'N':
|
2000-08-01 01:33:37 +00:00
|
|
|
debug("setting NDOTS to %s",
|
2000-07-05 19:31:26 +00:00
|
|
|
isc_commandline_argument);
|
2000-05-02 23:23:12 +00:00
|
|
|
ndots = atoi(isc_commandline_argument);
|
|
|
|
break;
|
2000-06-21 01:40:42 +00:00
|
|
|
case 'D':
|
|
|
|
debugging = ISC_TRUE;
|
|
|
|
break;
|
2000-04-26 22:53:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isc_commandline_index >= argc) {
|
|
|
|
show_usage();
|
|
|
|
}
|
2000-10-19 22:49:34 +00:00
|
|
|
strncpy(hostname, argv[isc_commandline_index], sizeof(hostname));
|
|
|
|
hostname[sizeof(hostname)-1]=0;
|
2000-07-05 19:31:26 +00:00
|
|
|
if (argc > isc_commandline_index + 1) {
|
2000-07-14 16:35:30 +00:00
|
|
|
srv = make_server(argv[isc_commandline_index+1]);
|
2000-07-05 23:28:32 +00:00
|
|
|
debug("server is %s", srv->servername);
|
2000-07-05 19:31:26 +00:00
|
|
|
ISC_LIST_APPEND(server_list, srv, link);
|
2000-09-11 21:48:11 +00:00
|
|
|
listed_server = ISC_TRUE;
|
2000-04-26 22:53:56 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-26 22:53:56 +00:00
|
|
|
lookup->pending = ISC_FALSE;
|
2000-10-23 23:13:21 +00:00
|
|
|
if (get_reverse(store, hostname, lookup->nibble) == ISC_R_SUCCESS) {
|
|
|
|
strncpy(lookup->textname, store, sizeof(lookup->textname));
|
|
|
|
lookup->textname[sizeof(lookup->textname)-1] = 0;
|
2000-08-14 19:17:42 +00:00
|
|
|
lookup->rdtype = dns_rdatatype_ptr;
|
2000-12-08 17:06:52 +00:00
|
|
|
lookup->rdtypeset = ISC_TRUE;
|
2000-07-05 19:31:26 +00:00
|
|
|
} else {
|
2000-10-19 22:49:34 +00:00
|
|
|
strncpy(lookup->textname, hostname, sizeof(lookup->textname));
|
|
|
|
lookup->textname[sizeof(lookup->textname)-1]=0;
|
2000-07-05 19:31:26 +00:00
|
|
|
}
|
2000-05-24 19:49:51 +00:00
|
|
|
lookup->new_search = ISC_TRUE;
|
2000-04-26 22:53:56 +00:00
|
|
|
ISC_LIST_APPEND(lookup_list, lookup, link);
|
2000-08-22 17:02:49 +00:00
|
|
|
|
|
|
|
usesearch = ISC_TRUE;
|
2000-04-26 22:53:56 +00:00
|
|
|
}
|
|
|
|
|
2000-05-09 18:05:13 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv) {
|
2000-07-10 18:02:31 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
2000-05-09 18:05:13 +00:00
|
|
|
ISC_LIST_INIT(lookup_list);
|
|
|
|
ISC_LIST_INIT(server_list);
|
|
|
|
ISC_LIST_INIT(search_list);
|
|
|
|
|
2000-07-05 23:28:32 +00:00
|
|
|
debug("main()");
|
|
|
|
progname = argv[0];
|
2000-07-19 17:52:27 +00:00
|
|
|
result = isc_app_start();
|
|
|
|
check_result(result, "isc_app_start");
|
2000-05-09 18:05:13 +00:00
|
|
|
setup_libs();
|
|
|
|
parse_args(ISC_FALSE, argc, argv);
|
|
|
|
setup_system();
|
2000-07-10 18:02:31 +00:00
|
|
|
result = isc_app_onrun(mctx, global_task, onrun_callback, NULL);
|
|
|
|
check_result(result, "isc_app_onrun");
|
2000-05-09 18:05:13 +00:00
|
|
|
isc_app_run();
|
2000-07-14 17:57:27 +00:00
|
|
|
cancel_all();
|
|
|
|
destroy_libs();
|
2000-06-29 05:21:12 +00:00
|
|
|
isc_app_finish();
|
2000-05-09 18:05:13 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|