dig.c revision 31d95f1095c5bf7794c487ecb6fe62b53a802e96
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 2000-2003 Internet Software Consortium.
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer * Permission to use, copy, modify, and/or distribute this software for any
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PERFORMANCE OF THIS SOFTWARE.
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson/* $Id: dig.c,v 1.245 2011/12/07 17:23:28 each Exp $ */
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer#define ADD_STRING(b, s) { \
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer if (strlen(s) >= isc_buffer_availablelength(b)) \
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellingtonstatic isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
38cf6e52ce4b33795713388824b69d78e430b115Michael Sawyer ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer onesoa = ISC_FALSE, rrcomments = ISC_FALSE, use_usec = ISC_FALSE;
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer/*% opcode text */
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyerstatic const char * const opcodetext[] = {
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington "RESERVED10",
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer "RESERVED11",
a5ed46c9fd270775c39770bfd0250a52d374ebf2Michael Sawyer "RESERVED12",
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer "RESERVED13",
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer "RESERVED14",
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer/*% return code text */
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyerstatic const char * const rcodetext[] = {
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer "RESERVED11",
a5ed46c9fd270775c39770bfd0250a52d374ebf2Michael Sawyer "RESERVED12",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "RESERVED13",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "RESERVED14",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "RESERVED15",
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington/*% safe rcodetext[] */
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer if (rcode >= (sizeof(rcodetext)/sizeof(rcodetext[0]))) {
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer/*% print usage */
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington"Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}\n"
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington" {global-d-opt} host [@local-server] {local-d-opt}\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" [ host [@local-server] {local-d-opt} [...]]\n", fp);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer fputs("\nUse \"dig -h\" (or \"dig -h | more\") "
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington/*% version */
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington"Where: domain is in the Domain Name System\n"
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington" q-class is one of (in,hs,ch,...) [default: in]\n"
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington" q-type is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) [default:a]\n"
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington" (Use ixfr=version for type ixfr)\n"
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington" q-opt is one of:\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -x dot-notation (shortcut for reverse lookups)\n"
cc48bb397fa6ba889f25157840492e68114dec8fBrian Wellington" -i (use IP6.INT for IPv6 reverse lookups)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -f filename (batch mode)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -b address[#port] (bind to source address/port)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -p port (specify port number)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -q name (specify query name)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -t type (specify query type)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -c class (specify query class)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -u (display times in usec instead of msec)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -k keyfile (specify tsig key file)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -y [hmac:]name:key (specify named base64 tsig key)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" -4 (use IPv4 query transport only)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -6 (use IPv6 query transport only)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" -m (enable memory usage debugging)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" d-opt is of the form +keyword[=value], where keyword is:\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]vc (TCP mode)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]tcp (TCP mode, alternate syntax)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +time=### (Set query timeout) [5]\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +tries=### (Set number of UDP attempts) [3]\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +retry=### (Set number of UDP retries) [2]\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +domain=### (Set default domainname)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +bufsize=### (Set EDNS0 Max UDP packet size)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +ndots=### (Set NDOTS value)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]edns[=###] (Set EDNS version) [0]\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]search (Set whether to use searchlist)\n"
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews" +[no]showsearch (Search with intermediate results)\n"
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson" +[no]defname (Ditto)\n"
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson" +[no]recurse (Recursive mode)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]ignore (Don't revert to TCP for TC responses.)"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" +[no]fail (Don't try next server on SERVFAIL)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]besteffort (Try to parse even illegal messages)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]aaonly (Set AA flag in query (+[no]aaflag))\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]adflag (Set AD flag in query)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]cdflag (Set CD flag in query)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]cl (Control display of class in records)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]cmd (Control display of command line)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]comments (Control display of comment lines)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]rrcomments (Control display of per-record "
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "comments)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]question (Control display of question)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]answer (Control display of answer)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]authority (Control display of authority)\n"
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence" +[no]additional (Control display of additional)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]stats (Control display of statistics)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]short (Disable everything except short\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" form of answer)\n"
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer" +[no]ttlid (Control display of ttls in records)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]all (Set or clear all display flags)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]qr (Print question before sending)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" +[no]nssearch (Search all authoritative nameservers)\n"
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson" +[no]identify (ID responders in short answers)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]trace (Trace delegation down from root [+dnssec])\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]dnssec (Request DNSSEC records)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]nsid (Request Name Server ID)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]sigchase (Chase DNSSEC signatures)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +trusted-key=#### (Trusted Key when chasing DNSSEC sigs)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]topdown (Do DNSSEC validation top down mode)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]split=## (Split hex/base64 fields into chunks)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]multiline (Print records in an expanded format)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" +[no]onesoa (AXFR prints only one soa record)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" global d-opts and servers (before host name) affect all queries.\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" local d-opts and servers (after host name) affect only that lookup.\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" -h (print help and exit)\n"
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer" -v (print version and exit)\n",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer * Callback from dighost.c to print the received message.
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyerreceived(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson isc_sockaddr_format(from, fromtext, sizeof(fromtext));
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson if (query->lookup->stats && !short_form) {
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson diff = isc_time_microdiff(&now, &query->time_sent);
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson printf(";; Query time: %ld usec\n", (long) diff);
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson printf(";; Query time: %ld msec\n", (long) diff / 1000);
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson printf(";; SERVER: %s(%s)\n", fromtext, query->servname);
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson printf(";; XFR size: %u records (messages %u, "
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "be validated");
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson if ((key == NULL) && (keysecret[0] != 0)) {
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer puts(";; WARNING -- TSIG key was not used.");
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer } else if (query->lookup->identify && !short_form) {
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson diff = isc_time_microdiff(&now, &query->time_sent);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "from %s(%s) in %ld us\n\n",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "from %s(%s) in %ld ms\n\n",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer fromtext, query->userarg, (long) diff / 1000);
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer * Callback from dighost.c to print that it is trying a server.
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer * Not used in dig.
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer * XXX print_trying
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer * Internal print routine used to print short form replies.
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyersay_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafsson if (query->lookup->trace || query->lookup->ns_search_only) {
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = dns_rdatatype_totext(rdata->type, buf);
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson check_result(result, "dns_rdata_totext");
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson diff = isc_time_microdiff(&now, &query->time_sent);
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer snprintf(store, 19, " in %ld us.", (long) diff);
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson snprintf(store, 19, " in %ld ms.", (long) diff / 1000);
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer * short_form message print handler. Calls above say_message()
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyershort_answer(dns_message_t *msg, dns_messagetextflag_t flags,
ee4429e13e08f30c366cdc5d10585388b8a9f212Michael Sawyer result = dns_message_firstname(msg, DNS_SECTION_ANSWER);
ee4429e13e08f30c366cdc5d10585388b8a9f212Michael Sawyer dns_message_currentname(msg, DNS_SECTION_ANSWER, &name);
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = dns_message_nextname(msg, DNS_SECTION_ANSWER);
7ddb4c86a95ab721a70d406821352ce7b730a1bdAndreas Gustafssonprintrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer unsigned int styleflags = 0;
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer if (rdataset == NULL || owner_name == NULL || target == NULL)
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = dns_master_stylecreate2(&style, styleflags,
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = dns_master_stylecreate2(&style, styleflags,
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = dns_master_stylecreate2(&style, styleflags,
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer check_result(result, "dns_master_stylecreate");
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer result = dns_master_rdatasettotext(owner_name, rdataset, style, target);
3291587f23b940c986f41cf37b2e531f618ec2bdMichael Sawyer * Callback from dighost.c to print the reply from a server
3291587f23b940c986f41cf37b2e531f618ec2bdMichael Sawyerprintmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer unsigned int styleflags = 0;
7804502532d6e2eee80083431a22eb5d957f52a0Michael Sawyer result = dns_master_stylecreate2(&style, styleflags,
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer result = dns_master_stylecreate2(&style, styleflags,
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer result = dns_master_stylecreate2(&style, styleflags,
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer check_result(result, "dns_master_stylecreate");
cefd68008fbba3488a077052ae62aa12b6de502bMichael Sawyer debug("printmessage(%s %s %s)", headers ? "headers" : "noheaders",
f900be21902d02418c2c71ffed754fb3f9f54cffMichael Sawyer query->lookup->comments ? "comments" : "nocomments",
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer if (onesoa && query->lookup->rdtype == dns_rdatatype_axfr)
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer flags |= (query->msg_count == 0) ? DNS_MESSAGETEXTFLAG_ONESOA :
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer result = isc_buffer_allocate(mctx, &buf, len);
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson check_result(result, "isc_buffer_allocate");
844eaa56d6d647b38b2a5cf08f7ea5ab7b752690Michael Sawyer if (query->lookup->comments && !short_form) {
37e6e0ca1337351642798b1a6aa24ae40bf86399Andreas Gustafsson printf(";; ->>HEADER<<- opcode: %s, status: %s, "
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer "AUTHORITY: %u, ADDITIONAL: %u\n",
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer "but not available\n");
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer query->lookup->edns != -1 && msg->opt == NULL &&
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer printf("\n;; WARNING: EDNS query returned status "
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer "%s - retry with '+noedns'\n",
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer if (msg != query->lookup->sendmsg && extrabytes != 0U)
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer printf(";; WARNING: Message has %u extra byte%s at "
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer "end\n", extrabytes, extrabytes != 0 ? "s" : "");
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer if (query->lookup->comments && headers && !short_form) {
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer result = dns_message_pseudosectiontotext(msg,
d7a2e0511222811b96f2e8757272ee383ec7b5e6Michael Sawyer result = isc_buffer_allocate(mctx, &buf, len);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "dns_message_pseudosectiontotext");
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer if (query->lookup->section_question && headers) {
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer check_result(result, "dns_message_sectiontotext");
d7a2e0511222811b96f2e8757272ee383ec7b5e6Michael Sawyer check_result(result, "dns_message_sectiontotext");
d7a2e0511222811b96f2e8757272ee383ec7b5e6Michael Sawyer result = short_answer(msg, flags, buf, query);
ee4429e13e08f30c366cdc5d10585388b8a9f212Michael Sawyer check_result(result, "dns_message_sectiontotext");
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer check_result(result, "dns_message_sectiontotext");
8e61de2efdc23d1248cff0abf4cadec3325a929cMichael Sawyer * Only print the signature on the first record.
d821f1cd7e97552401296e880e7518c98c9ebea1Michael Sawyer "dns_message_pseudosectiontotext");
48674819ebf9176b5d5582ae851e485c324c1159Michael Sawyer "dns_message_pseudosectiontotext");
869f65bea49f8d65ab9bb14c4551215529bd7419David Lawrence if (headers && query->lookup->comments && !short_form)
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer printf("%.*s", (int)isc_buffer_usedlength(buf),
32e783c745299f838dd7cf8ffe2032775a80f1d0Andreas Gustafsson * print the greeting message when the program first starts up.
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyerprintgreeting(int argc, char **argv, dig_lookup_t *lookup) {
aa6054ec74819f754bcf19442ca9b39d948171adMichael Sawyer lookup->cmdline[sizeof(lookup->cmdline) - 1] = 0;
5d20773abcdf9ff3afe14a349413174f94594188Michael Sawyer snprintf(lookup->cmdline, sizeof(lookup->cmdline),
55bf97a1b4b7f78b669b1179df1422cb9789c484Michael Sawyer while (i < argc) {
5d20773abcdf9ff3afe14a349413174f94594188Michael Sawyer snprintf(append, sizeof(append), " %s", argv[i++]);
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "; (%d server%s found)\n",
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer ";; global options:%s%s\n",
cd720113a2fc8a781d4e33350b8a2b62857b31d8David Lawrence * We're not using isc_commandline_parse() here since the command line
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer * syntax of dig is quite a bit different from that which can be described
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer * by that routine.
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington * XXX doc options
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyerplus_option(char *option, isc_boolean_t is_batchfile,
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer strncpy(option_store, option, sizeof(option_store));
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer printf(";; Invalid option %s\n", option_store);
07a926724c0a91d85b85a94441938d0094e88cffMark Andrews if (_l >= sizeof(A) || strncasecmp(cmd, A, _l) != 0) \
07a926724c0a91d85b85a94441938d0094e88cffMark Andrews#define FULLCHECK2(A, B) \
d7a2e0511222811b96f2e8757272ee383ec7b5e6Michael Sawyer if ((_l >= sizeof(A) || strncasecmp(cmd, A, _l) != 0) && \
07a926724c0a91d85b85a94441938d0094e88cffMark Andrews (_l >= sizeof(B) || strncasecmp(cmd, B, _l) != 0)) \
07a926724c0a91d85b85a94441938d0094e88cffMark Andrews switch (cmd[0]) {
6e3a8e17fdf108f47bbba17474fd3d120d356b2fBrian Wellington case '\0': /* +ad is a synonym for +adflag */
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer "buffer size");
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer case '\0': /* +cd is a synonym for +cdflag */
e42c402595802edceafbd3e5338dda011fbbcdb6Michael Sawyer strncpy(domainopt, value, sizeof(domainopt));
6fe03d6c83ec02d4494edc870f5e892d419b6885Michael Sawyer result = parse_uint(&num, value, 255, "edns");
b266f8fc42702debc6bd89365273223fa89cd8ddBrian Wellington default: /* Inherits default for compatibility */
goto need_value;
if (!state)
goto invalid_option;
if (state) {
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto invalid_option;
if (state) {
goto invalid_option;
#ifdef DIG_SIGCHASE
goto invalid_option;
if (!state) {
splitwidth = 0;
if (splitwidth)
goto invalid_option;
if (!is_batchfile)
goto need_value;
if (!state)
goto invalid_option;
if (timeout == 0)
#if DIG_SIGCHASE_TD
if (state) {
goto need_value;
if (!state)
goto invalid_option;
#ifdef DIG_SIGCHASE
goto need_value;
if (!state)
goto invalid_option;
sizeof(trustedkey));
if (n >= sizeof(trustedkey))
goto invalid_option;
goto invalid_option;
if (!is_batchfile)
option);
usage();
static isc_boolean_t
switch (opt) {
if (have_ipv4) {
return (ISC_FALSE);
if (have_ipv6) {
return (ISC_FALSE);
return (ISC_FALSE);
help();
exit(0);
version();
exit(0);
return (ISC_FALSE);
goto invalid_option;
switch (opt) {
srcport = 0;
return (value_from_next);
value);
return (value_from_next);
return (value_from_next);
return (value_from_next);
return (value_from_next);
if (!config_only) {
if (*need_clone)
ISC_TRUE);
if (*firstarg) {
return (value_from_next);
value);
return (value_from_next);
usage();
usage();
digestbits = 0;
return (value_from_next);
if (*need_clone)
if (*firstarg) {
return (value_from_next);
usage();
return (ISC_FALSE);
int rc;
char **rv;
char *option;
int bargc;
int rc;
char **rv;
#ifndef NOPOSIX
char *homedir;
char *input;
if (!is_batchfile) {
#ifndef NOPOSIX
homedir);
if (n < sizeof(rcfile))
batchfp) != 0) {
bargc++;
for(i = 0; i < bargc; i++)
i, bargv[i]);
(char **)bargv);
lookup);
rc--;
rv++;
rc--;
rv++;
if (open_type_class) {
if (rdtype ==
if (!config_only) {
if (need_clone)
ISC_TRUE);
if (firstarg) {
goto next_line;
bargc++;
for(i = 0; i < bargc; i++)
if (need_clone)
if (firstarg) {
if (!need_clone)
* Callback from dighost.c to allow program-specific shutdown code.
dighost_shutdown(void) {
int bargc;
char *input;
bargc++;
for(i = 0; i < bargc; i++)
start_lookup();
setup_libs();
setup_system();
isc_app_run();
#ifdef DIG_SIGCHASE
cancel_all();
destroy_libs();
return (exitcode);