nslookup.c File Reference

#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/event.h>
#include <isc/parseint.h>
#include <isc/print.h>
#include <isc/string.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <isc/task.h>
#include <isc/netaddr.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/fixedname.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
#include <dns/byaddr.h>
#include <dig/dig.h>

Go to the source code of this file.

Defines

#define N_KNOWN_RRTYPES   (sizeof(rtypetext) / sizeof(rtypetext[0]))

Functions

static void flush_lookup_list (void)
static void getinput (isc_task_t *task, isc_event_t *event)
static char * rcode_totext (dns_rcode_t rcode)
void dighost_shutdown (void)
static void printsoa (dns_rdata_t *rdata)
static void printa (dns_rdata_t *rdata)
static void printrdata (dns_rdata_t *rdata)
static isc_result_t printsection (dig_query_t *query, dns_message_t *msg, isc_boolean_t headers, dns_section_t section)
static isc_result_t detailsection (dig_query_t *query, dns_message_t *msg, isc_boolean_t headers, dns_section_t section)
void received (int bytes, isc_sockaddr_t *from, dig_query_t *query)
 Print a message about where and when the response was received from, like the final comment in the output of "dig".
void trying (char *frm, dig_lookup_t *lookup)
isc_result_t printmessage (dig_query_t *query, dns_message_t *msg, isc_boolean_t headers)
 Print the final result of the lookup.
static void show_settings (isc_boolean_t full, isc_boolean_t serv_only)
static isc_boolean_t testtype (char *typetext)
static isc_boolean_t testclass (char *typetext)
static void set_port (const char *value)
static void set_timeout (const char *value)
static void set_tries (const char *value)
static void set_ndots (const char *value)
static void version (void)
static void setoption (char *opt)
static void addlookup (char *opt)
static void do_next_command (char *input)
static void get_next_command (void)
static void parse_args (int argc, char **argv)
int main (int argc, char **argv)

Variables

static isc_boolean_t short_form = ISC_TRUE
static isc_boolean_t tcpmode = ISC_FALSE
static isc_boolean_t identify = ISC_FALSE
static isc_boolean_t stats = ISC_TRUE
static isc_boolean_t comments = ISC_TRUE
static isc_boolean_t section_question = ISC_TRUE
static isc_boolean_t section_answer = ISC_TRUE
static isc_boolean_t section_authority = ISC_TRUE
static isc_boolean_t section_additional = ISC_TRUE
static isc_boolean_t recurse = ISC_TRUE
static isc_boolean_t aaonly = ISC_FALSE
static isc_boolean_t nofail = ISC_TRUE
static isc_boolean_t interactive
static isc_boolean_t in_use = ISC_FALSE
static char defclass [MXRD] = "IN"
static char deftype [MXRD] = "A"
static isc_event_tglobal_event = NULL
static int query_error = 1
static int print_error = 0
static char domainopt [DNS_NAME_MAXTEXT]
static const char * rcodetext []
static const char * rtypetext []


Define Documentation

#define N_KNOWN_RRTYPES   (sizeof(rtypetext) / sizeof(rtypetext[0]))

Definition at line 135 of file nslookup.c.

Referenced by printrdata().


Function Documentation

static void flush_lookup_list ( void   )  [static]

Definition at line 830 of file nslookup.c.

References dns_message_destroy(), isc_buffer_invalidate, ISC_LINK_LINKED, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_free, ISC_SOCKCANCEL_ALL, isc_socket_cancel(), isc_socket_detach(), isc_timer_detach(), dig_query::lengthbuf, dig_query::lengthlist, lookup_counter, lookup_list, mctx, dig_query::recvbuf, dig_query::recvlist, s, and dig_query::sock.

Referenced by dighost_shutdown().

static void getinput ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 878 of file nslookup.c.

References get_next_command(), in_use, isc_app_shutdown(), ISC_LIST_HEAD, lookup_list, start_lookup(), and UNUSED.

Referenced by main().

static char* rcode_totext ( dns_rcode_t  rcode  )  [static]

Definition at line 141 of file nslookup.c.

References rcodetext.

void dighost_shutdown ( void   ) 

Definition at line 158 of file nslookup.c.

References argv0, batchfp, batchname, debug, flush_lookup_list(), global_task, in_use, input, isc_app_shutdown(), ISC_FALSE, isc_task_send(), ISC_TRUE, MXNAME, next_token(), parse_args(), and start_lookup().

static void printsoa ( dns_rdata_t rdata  )  [static]

Definition at line 173 of file nslookup.c.

References check_result(), dns_name_format(), DNS_NAME_FORMATSIZE, dns_rdata_freestruct(), dns_rdata_tostruct(), and namebuf.

Referenced by detailsection(), and printsection().

static void printa ( dns_rdata_t rdata  )  [static]

Definition at line 194 of file nslookup.c.

References check_result(), dns_rdata_totext(), isc_buffer_base, isc_buffer_init, isc_buffer_usedlength, and text.

Referenced by printsection().

static void printrdata ( dns_rdata_t rdata  )  [static]

Definition at line 217 of file nslookup.c.

References check_result(), dns_rdata_totext(), isc_buffer_allocate(), isc_buffer_base, isc_buffer_free(), isc_buffer_usedlength, ISC_FALSE, ISC_R_NOSPACE, ISC_R_SUCCESS, ISC_TRUE, mctx, N_KNOWN_RRTYPES, rtypetext, and dns_rdata::type.

static isc_result_t printsection ( dig_query_t query,
dns_message_t msg,
isc_boolean_t  headers,
dns_section_t  section 
) [static]

Definition at line 245 of file nslookup.c.

References debug, dns_message_currentname(), dns_message_firstname(), dns_message_nextname(), dns_name_format(), DNS_NAME_FORMATSIZE, DNS_RDATA_INIT, dns_rdata_reset(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_next(), DNS_SECTION_ANSWER, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOMORE, ISC_R_SUCCESS, name, namebuf, printa(), printrdata(), printsoa(), dns_rdata::type, and UNUSED.

static isc_result_t detailsection ( dig_query_t query,
dns_message_t msg,
isc_boolean_t  headers,
dns_section_t  section 
) [static]

Definition at line 311 of file nslookup.c.

References debug, dns_message_currentname(), dns_message_firstname(), dns_message_nextname(), dns_name_format(), DNS_NAME_FORMATSIZE, DNS_RDATA_INIT, dns_rdata_reset(), dns_rdataclass_format(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_next(), dns_rdatatype_format(), DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOMORE, ISC_R_SUCCESS, name, namebuf, printrdata(), printsoa(), dns_rdataset::rdclass, dns_rdataset::ttl, dns_rdata::type, dns_rdataset::type, and UNUSED.

Referenced by printmessage().

void received ( int  bytes,
isc_sockaddr_t from,
dig_query_t query 
)

Print a message about where and when the response was received from, like the final comment in the output of "dig".

Definition at line 397 of file nslookup.c.

References dig_query::byte_count, ISC_PRINT_QUADFORMAT, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_time_microdiff(), key, keysecret, dig_query::lookup, dig_query::msg_count, dig_query::rr_count, dig_query::servname, short_form, dig_query::time_recv, dig_query::time_sent, UNUSED, use_usec, dig_query::userarg, and validated.

void trying ( char *  frm,
dig_lookup_t lookup 
)

Definition at line 405 of file nslookup.c.

References UNUSED.

isc_result_t printmessage ( dig_query_t query,
dns_message_t msg,
isc_boolean_t  headers 
)

Print the final result of the lookup.

Definition at line 412 of file nslookup.c.

References check_result(), cleanup(), dns_message::counts, debug, detailsection(), dns_master_stylecreate2(), dns_master_styledestroy(), dns_message_pseudosectiontotext(), dns_message_sectiontotext(), DNS_MESSAGEFLAG_AA, DNS_MESSAGEFLAG_AD, DNS_MESSAGEFLAG_CD, DNS_MESSAGEFLAG_QR, DNS_MESSAGEFLAG_RA, DNS_MESSAGEFLAG_RD, DNS_MESSAGEFLAG_TC, DNS_MESSAGETEXTFLAG_NOCOMMENTS, DNS_MESSAGETEXTFLAG_NOHEADERS, DNS_MESSAGETEXTFLAG_OMITSOA, DNS_MESSAGETEXTFLAG_ONESOA, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_PSEUDOSECTION_OPT, DNS_PSEUDOSECTION_SIG0, DNS_PSEUDOSECTION_TSIG, dns_rcode_formerr, dns_rcode_notimp, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, DNS_STYLEFLAG_COMMENT, DNS_STYLEFLAG_MULTILINE, DNS_STYLEFLAG_NO_CLASS, DNS_STYLEFLAG_NO_TTL, DNS_STYLEFLAG_NOCRYPTO, DNS_STYLEFLAG_OMIT_CLASS, DNS_STYLEFLAG_OMIT_OWNER, DNS_STYLEFLAG_OMIT_TTL, DNS_STYLEFLAG_REL_DATA, DNS_STYLEFLAG_REL_OWNER, DNS_STYLEFLAG_RRCOMMENT, DNS_STYLEFLAG_TTL, DNS_STYLEFLAG_TTL_UNITS, extrabytes, dns_message::flags, dns_message::id, isc_buffer_allocate(), isc_buffer_base, isc_buffer_free(), isc_buffer_usedlength, ISC_LIST_EMPTY, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, ISC_TRUE, dig_query::lookup, mctx, dig_query::msg_count, multiline, noclass, nocrypto, nottl, onesoa, dns_message::opcode, opcodetext, dns_message::opt, OUTPUTBUF, print_error, printsection(), query_error, dns_message::rcode, rcode_totext(), rrcomments, dns_message::sections, short_answer(), short_form, dig_query::sockaddr, splitwidth, ttlunits, and dig_query::userarg.

static void show_settings ( isc_boolean_t  full,
isc_boolean_t  serv_only 
) [static]

Definition at line 469 of file nslookup.c.

References check_result(), debugging, defclass, deftype, get_address(), ISC_LIST_HEAD, ISC_LIST_NEXT, isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, ndots, dig_searchlist::origin, port, recurse, search_list, server_list, dig_server::servername, short_form, tcpmode, timeout, tries, dig_server::userarg, and usesearch.

Referenced by do_next_command(), and setoption().

static isc_boolean_t testtype ( char *  typetext  )  [static]

Definition at line 515 of file nslookup.c.

References isc_textregion::base, dns_rdatatype_fromtext(), ISC_FALSE, ISC_R_SUCCESS, ISC_TRUE, and isc_textregion::length.

Referenced by setoption().

static isc_boolean_t testclass ( char *  typetext  )  [static]

Definition at line 532 of file nslookup.c.

References isc_textregion::base, dns_rdataclass_fromtext(), ISC_FALSE, ISC_R_SUCCESS, ISC_TRUE, isc_textregion::length, and rdclass.

Referenced by setoption().

static void set_port ( const char *  value  )  [static]

Definition at line 549 of file nslookup.c.

References ISC_R_SUCCESS, parse_uint(), and port.

Referenced by setoption().

static void set_timeout ( const char *  value  )  [static]

Definition at line 557 of file nslookup.c.

References ISC_R_SUCCESS, parse_uint(), and timeout.

Referenced by setoption().

static void set_tries ( const char *  value  )  [static]

Definition at line 565 of file nslookup.c.

References ISC_R_SUCCESS, parse_uint(), and tries.

Referenced by setoption().

static void set_ndots ( const char *  value  )  [static]

Definition at line 573 of file nslookup.c.

References ISC_R_SUCCESS, ndots, and parse_uint().

Referenced by setoption().

static void version ( void   )  [static]

Definition at line 581 of file nslookup.c.

References VERSION.

static void setoption ( char *  opt  )  [static]

Definition at line 586 of file nslookup.c.

References debugging, defclass, deftype, domainopt, ISC_FALSE, ISC_TRUE, nofail, recurse, set_ndots(), set_port(), set_search_domain(), set_timeout(), set_tries(), short_form, show_settings(), showsearch, tcpmode, testclass(), testtype(), and usesearch.

Referenced by do_next_command(), and parse_args().

static void addlookup ( char *  opt  )  [static]

Definition at line 673 of file nslookup.c.

References aaonly, isc_textregion::base, comments, debug, defclass, deftype, dns_rdataclass_fromtext(), dns_rdatatype_fromtext(), get_reverse(), identify, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_INIT, ISC_R_SUCCESS, ISC_TRUE, isc_textregion::length, lookup_list, make_empty_lookup(), MXNAME, nofail, rdclass, recurse, section_additional, section_answer, section_authority, section_question, tcpmode, and tries.

Referenced by do_next_command(), and parse_args().

static void do_next_command ( char *  input  )  [static]

Definition at line 736 of file nslookup.c.

References addlookup(), arg, check_ra, in_use, isc_app_block(), isc_app_unblock(), ISC_FALSE, ISC_TRUE, next_token(), set_nameserver(), setoption(), and show_settings().

Referenced by get_next_command().

static void get_next_command ( void   )  [static]

Definition at line 768 of file nslookup.c.

References COMMSIZE, do_next_command(), fatal(), free(), in_use, interactive, isc_app_block(), isc_app_unblock(), ISC_FALSE, isc_mem_allocate, isc_mem_free, and mctx.

Referenced by getinput(), and user_interaction().

static void parse_args ( int  argc,
char **  argv 
) [static]

Definition at line 802 of file nslookup.c.

References addlookup(), check_ra, debug, in_use, ISC_FALSE, ISC_TRUE, set_nameserver(), setoption(), usesearch, and version.

int main ( int  argc,
char **  argv 
)

Definition at line 893 of file nslookup.c.

References cancel_all(), check_ra, check_result(), debug, destroy_libs(), domainopt, getinput(), global_task, in_use, interactive, isc_app_finish(), isc_app_onrun(), isc_app_run(), isc_app_start(), isc_event_free(), ISC_LIST_INIT, ISC_TF, ISC_TRUE, keyfile, keysecret, lookup_list, mctx, onrun_callback(), parse_args(), print_error, progname, query_error, search_list, server_list, set_search_domain(), setup_file_key(), setup_libs(), setup_system(), and setup_text_key().


Variable Documentation

isc_boolean_t short_form = ISC_TRUE [static]

Definition at line 52 of file nslookup.c.

isc_boolean_t tcpmode = ISC_FALSE [static]

Definition at line 53 of file nslookup.c.

Referenced by addlookup(), setoption(), and show_settings().

isc_boolean_t identify = ISC_FALSE [static]

Definition at line 54 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t stats = ISC_TRUE [static]

Definition at line 54 of file nslookup.c.

isc_boolean_t comments = ISC_TRUE [static]

Definition at line 55 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t section_question = ISC_TRUE [static]

Definition at line 55 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t section_answer = ISC_TRUE [static]

Definition at line 56 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t section_authority = ISC_TRUE [static]

Definition at line 56 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t section_additional = ISC_TRUE [static]

Definition at line 57 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t recurse = ISC_TRUE [static]

Definition at line 57 of file nslookup.c.

Referenced by addlookup(), setoption(), and show_settings().

isc_boolean_t aaonly = ISC_FALSE [static]

Definition at line 58 of file nslookup.c.

Referenced by addlookup().

isc_boolean_t nofail = ISC_TRUE [static]

Definition at line 58 of file nslookup.c.

Referenced by addlookup(), and setoption().

isc_boolean_t interactive [static]

Definition at line 60 of file nslookup.c.

Referenced by get_next_command(), main(), parse_args(), and user_interaction().

isc_boolean_t in_use = ISC_FALSE [static]

Definition at line 62 of file nslookup.c.

Referenced by dighost_shutdown(), do_next_command(), get_next_command(), getinput(), main(), and parse_args().

char defclass[MXRD] = "IN" [static]

Definition at line 63 of file nslookup.c.

Referenced by addlookup(), setoption(), and show_settings().

char deftype[MXRD] = "A" [static]

Definition at line 64 of file nslookup.c.

Referenced by addlookup(), setoption(), and show_settings().

isc_event_t* global_event = NULL [static]

Definition at line 65 of file nslookup.c.

int query_error = 1 [static]

Definition at line 66 of file nslookup.c.

Referenced by main(), ns_query_start(), printmessage(), query_find(), and query_resume().

int print_error = 0 [static]

Definition at line 66 of file nslookup.c.

Referenced by main(), and printmessage().

char domainopt[DNS_NAME_MAXTEXT] [static]

Definition at line 68 of file nslookup.c.

const char* rcodetext[] [static]

Initial value:

 {
        "NOERROR",
        "FORMERR",
        "SERVFAIL",
        "NXDOMAIN",
        "NOTIMP",
        "REFUSED",
        "YXDOMAIN",
        "YXRRSET",
        "NXRRSET",
        "NOTAUTH",
        "NOTZONE",
        "RESERVED11",
        "RESERVED12",
        "RESERVED13",
        "RESERVED14",
        "RESERVED15",
        "BADVERS"
}

Definition at line 70 of file nslookup.c.

const char* rtypetext[] [static]

Definition at line 90 of file nslookup.c.

Referenced by printrdata().


Generated on Tue Apr 28 17:41:06 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha