host.c revision 0819ae2ca51571d205df061b52d8468889f3a0df
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2000 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
cffe50abf66495ee08084f8e1081278a9b589985Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* $Id: host.c,v 1.36 2000/07/06 01:02:42 mws Exp $ */
15c7a1bf207173deb2bff1d610d5f784b6629875Tinderbox Userextern ISC_LIST(dig_searchlist_t) search_list;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinextern isc_boolean_t have_ipv6, show_details, debugging;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinextern unsigned int timeout;
15c7a1bf207173deb2bff1d610d5f784b6629875Tinderbox Userstatic const char *opcodetext[] = {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED3",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED6",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED8",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED9",
15c7a1bf207173deb2bff1d610d5f784b6629875Tinderbox User "RESERVED10",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED11",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED12",
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "RESERVED13",
cffe50abf66495ee08084f8e1081278a9b589985Brian Wellington "RESERVED14",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellingtonstatic const char *rcodetext[] = {
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington "RESERVED11",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington "RESERVED12",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington "RESERVED13",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington "RESERVED14",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington "RESERVED15",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellingtonstatic const char *rtypetext[] = {
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington"Usage: host [-aCdlrTwv] [-c class] [-N ndots] [-t type] [-W time]\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" [-R number] hostname [server]\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -a is equivalent to -v -t *\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -c specifies query class for non-IN data\n"
f00075e753b20ece0b4daf68b29044e44c898d89Andreas Gustafsson" -C compares SOA records on authorative nameservers\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -d is equivalent to -v\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -l lists all hosts in a domain, using AXFR\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -N changes the number of dots allowed before root lookup is done\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -r disables recursive processing\n"
e851ea826066ac5a5b01c2c23218faa0273a12e8Evan Hunt" -R specifies number of retries for UDP packets\n"
e851ea826066ac5a5b01c2c23218faa0273a12e8Evan Hunt" -t specifies the query type\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -T enables TCP/IP mode\n"
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington" -v enables verbose output\n"
f00075e753b20ece0b4daf68b29044e44c898d89Andreas Gustafsson" -w specifies to wait forever for a reply\n"
f00075e753b20ece0b4daf68b29044e44c898d89Andreas Gustafsson" -W specifies how long to wait for a reply\n", stderr);
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellingtonreceived(int bytes, int frmsize, char *frm, dig_query_t *query) {
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington diff = isc_time_microdiff(&now, &query->time_sent);
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington printf("Received %u bytes from %.*s in %d ms\n",
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellingtontrying(int frmsize, char *frm, dig_lookup_t *lookup) {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austeinsay_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
611dc8876869036ab5e981e53ae7a446145d9354Mark Andrews result = isc_buffer_allocate(mctx, &b, BUFSIZE);
611dc8876869036ab5e981e53ae7a446145d9354Mark Andrews result = isc_buffer_allocate(mctx, &b2, BUFSIZE);
668728fed845b9db9c1423946df03d5fc69f4eeeBrian Wellington result = dns_name_totext(name, ISC_FALSE, b);
611dc8876869036ab5e981e53ae7a446145d9354Mark Andrews printf ( "%.*s %s %.*s", (int)r.length, (char *)r.base,
isc_buffer_free(&b);
static isc_result_t
isc_region_t r;
const char *rtt;
if (headers)
return (ISC_R_SUCCESS);
return (result);
if (!short_form) {
&target);
return (result);
#ifdef USEINITALWS
if (first) {
if (!short_form) {
if (no_rdata)
(char *)r.base);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
isc_region_t r;
if (headers)
&target);
return (result);
return (ISC_R_SUCCESS);
isc_region_t r;
exitcode = 0;
isc_buffer_usedregion(b, &r);
isc_buffer_free(&b);
return (ISC_R_SUCCESS);
if (!short_form) {
!short_form) {
return (result);
if (!short_form)
return (result);
!short_form) {
return (result);
!short_form) {
return (result);
return (result);
if (!short_form)
return (result);
!= EOF) {
if (querytype[0] == 0)
if (queryclass[0] == 0)
show_usage();
show_usage();
adrs[i]);
if (querytype[0] == 0)
if (querytype[0] == 0)
if (queryclass[0] == 0)
setup_libs();
setup_system();
start_lookup();
isc_app_run();
if (isc_mem_debugging)