dig.c File Reference

#include <config.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <isc/app.h>
#include <isc/netaddr.h>
#include <isc/parseint.h>
#include <isc/print.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/util.h>
#include <dns/byaddr.h>
#include <dns/fixedname.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatatype.h>
#include <dns/rdataclass.h>
#include <dns/result.h>
#include <dns/tsig.h>
#include <dig/dig.h>

Go to the source code of this file.

Defines

#define ADD_STRING(b, s)
#define DIG_MAX_ADDRESSES   20
#define FULLCHECK(A)
#define FULLCHECK2(A, B)

Functions

static char * rcode_totext (dns_rcode_t rcode)
 safe rcodetext[]
static void print_usage (FILE *fp)
 print usage
static
ISC_PLATFORM_NORETURN_PRE void 
usage (void)
static void version (void)
 version
static void help (void)
 help
void received (int bytes, isc_sockaddr_t *from, dig_query_t *query)
 Callback from dighost.c to print the received message.
void trying (char *frm, dig_lookup_t *lookup)
static isc_result_t say_message (dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf)
 Internal print routine used to print short form replies.
static isc_result_t short_answer (dns_message_t *msg, dns_messagetextflag_t flags, isc_buffer_t *buf, dig_query_t *query)
 short_form message print handler. Calls above say_message()
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 printgreeting (int argc, char **argv, dig_lookup_t *lookup)
 print the greeting message when the program first starts up.
static void plus_option (char *option, isc_boolean_t is_batchfile, dig_lookup_t *lookup)
 We're not using isc_commandline_parse() here since the command line syntax of dig is quite a bit different from that which can be described by that routine. XXX doc options.
static isc_boolean_t dash_option (char *option, char *next, dig_lookup_t **lookup, isc_boolean_t *open_type_class, isc_boolean_t *need_clone, isc_boolean_t config_only, int argc, char **argv, isc_boolean_t *firstarg)
static void preparse_args (int argc, char **argv)
 Because we may be trying to do memory allocation recording, we're going to need to parse the arguments for the -m *before* we start the main argument parsing routine.
static void parse_args (isc_boolean_t is_batchfile, isc_boolean_t config_only, int argc, char **argv)
void dighost_shutdown (void)
int main (int argc, char **argv)
 Main processing routine for dig.

Variables

dig_lookup_tdefault_lookup = NULL
static char * batchname = NULL
static FILE * batchfp = NULL
static char * argv0
static int addresscount = 0
static char domainopt [DNS_NAME_MAXTEXT]
static isc_boolean_t short_form = ISC_FALSE
static isc_boolean_t printcmd = ISC_TRUE
static isc_boolean_t ip6_int = ISC_FALSE
static isc_boolean_t plusquest = ISC_FALSE
static isc_boolean_t pluscomm = ISC_FALSE
static isc_boolean_t multiline = ISC_FALSE
static isc_boolean_t nottl = ISC_FALSE
static isc_boolean_t noclass = ISC_FALSE
static isc_boolean_t onesoa = ISC_FALSE
static isc_boolean_t rrcomments = ISC_FALSE
static isc_boolean_t use_usec = ISC_FALSE
static isc_boolean_t nocrypto = ISC_FALSE
static isc_boolean_t ttlunits = ISC_FALSE
static isc_uint32_t splitwidth = 0xffffffff
static const char *const opcodetext []
 opcode text
static const char *const rcodetext []
 return code text
static const char * single_dash_opts = "46dhimnuv"
 ISC_TRUE returned if value was used
static const char * dash_opts = "46bcdfhikmnptvyx"


Detailed Description

Definition in file dig.c.


Define Documentation

#define ADD_STRING ( b,
s   ) 

Value:

{                               \
        if (strlen(s) >= isc_buffer_availablelength(b)) \
                return (ISC_R_NOSPACE);                 \
        else                                            \
                isc_buffer_putstr(b, s);                \
}

Definition at line 47 of file dig.c.

#define DIG_MAX_ADDRESSES   20

Definition at line 54 of file dig.c.

Referenced by getaddresses(), and set_nameserver().

#define FULLCHECK (  ) 

Value:

do { \
                size_t _l = strlen(cmd); \
                if (_l >= sizeof(A) || strncasecmp(cmd, A, _l) != 0) \
                        goto invalid_option; \
        } while (0)

Referenced by dash_option(), and plus_option().

#define FULLCHECK2 ( A,
 ) 

Value:

do { \
                size_t _l = strlen(cmd); \
                if ((_l >= sizeof(A) || strncasecmp(cmd, A, _l) != 0) && \
                    (_l >= sizeof(B) || strncasecmp(cmd, B, _l) != 0)) \
                        goto invalid_option; \
        } while (0)

Referenced by plus_option().


Function Documentation

static char* rcode_totext ( dns_rcode_t  rcode  )  [static]

safe rcodetext[]

Definition at line 118 of file dig.c.

References rcodetext.

Referenced by printmessage().

static void print_usage ( FILE *  fp  )  [static]

print usage

Definition at line 136 of file dig.c.

Referenced by help(), and usage().

static ISC_PLATFORM_NORETURN_PRE void usage ( void   )  [static]

Definition at line 144 of file dig.c.

References print_usage().

static void version ( void   )  [static]

version

Definition at line 156 of file dig.c.

References VERSION.

static void help ( void   )  [static]

help

Definition at line 162 of file dig.c.

References print_usage().

Referenced by dash_option().

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

Callback from dighost.c to print the received message.

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

Definition at line 262 of file dig.c.

Referenced by check_for_more_data(), and recv_done().

void trying ( char *  frm,
dig_lookup_t lookup 
)

Definition at line 325 of file dig.c.

Referenced by setup_lookup().

static isc_result_t say_message ( dns_rdata_t rdata,
dig_query_t query,
isc_buffer_t buf 
) [static]

Internal print routine used to print short form replies.

Definition at line 334 of file dig.c.

References ADD_STRING, check_result(), dns_rdata_tofmttext(), dns_rdatatype_totext(), DNS_STYLEFLAG_NOCRYPTO, DNS_STYLEFLAG_RRCOMMENT, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_time_microdiff(), dig_query::lookup, nocrypto, rrcomments, dig_query::servname, splitwidth, dig_query::time_recv, dig_query::time_sent, dns_rdata::type, and use_usec.

Referenced by printsection(), and short_answer().

static isc_result_t short_answer ( dns_message_t msg,
dns_messagetextflag_t  flags,
isc_buffer_t buf,
dig_query_t query 
) [static]

short_form message print handler. Calls above say_message()

Definition at line 374 of file dig.c.

References check_result(), dns_message_currentname(), dns_message_firstname(), dns_message_nextname(), dns_name_init(), 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_NOSPACE, ISC_R_SUCCESS, name, say_message(), and UNUSED.

Referenced by printmessage().

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 481 of file dig.c.

Referenced by recv_done(), and setup_lookup().

static void printgreeting ( int  argc,
char **  argv,
dig_lookup_t lookup 
) [static]

print the greeting message when the program first starts up.

Definition at line 710 of file dig.c.

References addresscount, append(), ISC_FALSE, ISC_TRUE, MXNAME, printcmd, short_form, and VERSION.

Referenced by dash_option(), and parse_args().

static void plus_option ( char *  option,
isc_boolean_t  is_batchfile,
dig_lookup_t lookup 
) [static]

We're not using isc_commandline_parse() here since the command line syntax of dig is quite a bit different from that which can be described by that routine. XXX doc options.

Definition at line 761 of file dig.c.

References COMMSIZE, default_lookup, domainopt, fatal(), FULLCHECK, FULLCHECK2, ISC_FALSE, isc_mem_free, ISC_R_SUCCESS, ISC_TF, ISC_TRUE, keep_open, MAXNDOTS, MAXTIMEOUT, MAXTRIES, mctx, multiline, ndots, next_token(), noclass, nocrypto, nottl, onesoa, parse_netprefix(), parse_uint(), parse_xint(), pluscomm, plusquest, printcmd, qr, rrcomments, save_opt(), short_form, showsearch, splitwidth, timeout, ttlunits, usage(), and usesearch.

Referenced by parse_args().

static isc_boolean_t dash_option ( char *  option,
char *  next,
dig_lookup_t **  lookup,
isc_boolean_t open_type_class,
isc_boolean_t need_clone,
isc_boolean_t  config_only,
int  argc,
char **  argv,
isc_boolean_t firstarg 
) [static]

Definition at line 1407 of file dig.c.

References AF_INET6, isc_textregion::base, batchname, bind_address, clone_lookup(), debug, debugging, default_lookup, digestbits, DNS_R_UNKNOWN, dns_rdataclass_fromtext(), dns_rdatatype_fromtext(), DNS_TSIG_HMACMD5_NAME, fatal(), FULLCHECK, get_reverse(), hash, have_ipv4, have_ipv6, help(), hmacname, ip6_int, ISC_FALSE, ISC_LIST_APPEND, isc_net_disableipv4(), isc_net_disableipv6(), ISC_R_SUCCESS, isc_sockaddr_fromin(), isc_sockaddr_fromin6(), ISC_TF, ISC_TRUE, keyfile, keynametext, keysecret, isc_textregion::length, lookup_list, MAXPORT, MAXSERIAL, MXNAME, next_token(), parse_hmac(), parse_uint(), pluscomm, plusquest, port, printgreeting(), rdclass, serial, specified_source, usage(), use_usec, and version.

Referenced by parse_args().

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

Because we may be trying to do memory allocation recording, we're going to need to parse the arguments for the -m *before* we start the main argument parsing routine.

I'd prefer not to have to do this, but I am not quite sure how else to fix the problem. Argument parsing in dig involves memory allocation by its nature, so it can't be done in the main argument parser.

Definition at line 1693 of file dig.c.

References isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_MEM_DEBUGTRACE, ISC_TRUE, and memdebugging.

Referenced by main().

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

Definition at line 1717 of file dig.c.

References addresscount, argv0, isc_textregion::base, batchfp, batchname, clone_lookup(), dash_option(), debug, default_lookup, destroy_lookup(), dns_rdataclass_fromtext(), dns_rdatatype_fromtext(), exitcode, fatal(), getaddresses(), input, INSIST, ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_APPEND, ISC_LIST_DEQUEUE, ISC_R_SUCCESS, isc_result_totext(), ISC_TF, ISC_TRUE, isc_textregion::length, lookup_list, make_empty_lookup(), MAXSERIAL, MXNAME, next_token(), parse_uint(), plus_option(), pluscomm, plusquest, printgreeting(), rdclass, and serial.

Referenced by dighost_shutdown(), and main().

void dighost_shutdown ( void   ) 

Definition at line 2014 of file dig.c.

Referenced by check_if_done().

int main ( int  argc,
char **  argv 
)

Main processing routine for dig.

Definition at line 2062 of file dig.c.

References batchfp, batchname, cancel_all(), check_result(), debug, default_lookup, destroy_libs(), destroy_lookup(), domainopt, exitcode, global_task, isc_app_finish(), isc_app_onrun(), isc_app_run(), isc_app_start(), ISC_FALSE, ISC_LIST_INIT, ISC_TRUE, keyfile, keysecret, lookup_list, mctx, onrun_callback(), parse_args(), preparse_args(), progname, search_list, server_list, set_search_domain(), setup_file_key(), setup_libs(), setup_system(), setup_text_key(), and usesearch.


Variable Documentation

dig_lookup_t* default_lookup = NULL

Definition at line 56 of file dig.c.

Referenced by dash_option(), main(), parse_args(), and plus_option().

char* batchname = NULL [static]

Definition at line 58 of file dig.c.

Referenced by dash_option(), dighost_shutdown(), main(), and parse_args().

FILE* batchfp = NULL [static]

Definition at line 59 of file dig.c.

Referenced by dighost_shutdown(), main(), and parse_args().

char* argv0 [static]

Definition at line 60 of file dig.c.

Referenced by dighost_shutdown(), and parse_args().

int addresscount = 0 [static]

Definition at line 61 of file dig.c.

Referenced by parse_args(), and printgreeting().

char domainopt[DNS_NAME_MAXTEXT] [static]

Definition at line 63 of file dig.c.

Referenced by main(), plus_option(), and setoption().

isc_boolean_t short_form = ISC_FALSE [static]

Definition at line 68 of file dig.c.

Referenced by parse_args(), plus_option(), printgreeting(), printmessage(), printsection(), received(), setoption(), show_settings(), and trying().

isc_boolean_t printcmd = ISC_TRUE [static]

Definition at line 68 of file dig.c.

Referenced by plus_option(), and printgreeting().

isc_boolean_t ip6_int = ISC_FALSE [static]

Definition at line 69 of file dig.c.

isc_boolean_t plusquest = ISC_FALSE [static]

Definition at line 69 of file dig.c.

Referenced by dash_option(), parse_args(), and plus_option().

isc_boolean_t pluscomm = ISC_FALSE [static]

Definition at line 69 of file dig.c.

Referenced by dash_option(), parse_args(), and plus_option().

isc_boolean_t multiline = ISC_FALSE [static]

Definition at line 70 of file dig.c.

Referenced by plus_option(), printmessage(), and totext_soa().

isc_boolean_t nottl = ISC_FALSE [static]

Definition at line 70 of file dig.c.

Referenced by ATF_TP_ADD_TCS(), plus_option(), and printmessage().

isc_boolean_t noclass = ISC_FALSE [static]

Definition at line 70 of file dig.c.

Referenced by plus_option(), and printmessage().

isc_boolean_t onesoa = ISC_FALSE [static]

Definition at line 71 of file dig.c.

Referenced by plus_option(), and printmessage().

isc_boolean_t rrcomments = ISC_FALSE [static]

Definition at line 71 of file dig.c.

Referenced by plus_option(), printmessage(), and say_message().

isc_boolean_t use_usec = ISC_FALSE [static]

Definition at line 71 of file dig.c.

Referenced by dash_option(), received(), and say_message().

isc_boolean_t nocrypto = ISC_FALSE [static]

Definition at line 72 of file dig.c.

Referenced by plus_option(), printmessage(), and say_message().

isc_boolean_t ttlunits = ISC_FALSE [static]

Definition at line 72 of file dig.c.

Referenced by plus_option(), and printmessage().

isc_uint32_t splitwidth = 0xffffffff [static]

Definition at line 73 of file dig.c.

Referenced by plus_option(), printmessage(), and say_message().

const char* const opcodetext[] [static]

Initial value:

 {
        "QUERY",
        "IQUERY",
        "STATUS",
        "RESERVED3",
        "NOTIFY",
        "UPDATE",
        "RESERVED6",
        "RESERVED7",
        "RESERVED8",
        "RESERVED9",
        "RESERVED10",
        "RESERVED11",
        "RESERVED12",
        "RESERVED13",
        "RESERVED14",
        "RESERVED15"
}
opcode text

Definition at line 76 of file dig.c.

const char* const rcodetext[] [static]

Initial value:

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

Definition at line 96 of file dig.c.

const char* single_dash_opts = "46dhimnuv" [static]

ISC_TRUE returned if value was used

Definition at line 1404 of file dig.c.

const char* dash_opts = "46bcdfhikmnptvyx" [static]

Definition at line 1405 of file dig.c.


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