dighost.c File Reference

#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <dns/byaddr.h>
#include <dns/fixedname.h>
#include <dns/log.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/rcode.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
#include <dns/result.h>
#include <dns/tsig.h>
#include <dst/dst.h>
#include <dst/result.h>
#include <isc/app.h>
#include <isc/base64.h>
#include <isc/entropy.h>
#include <isc/file.h>
#include <isc/hex.h>
#include <isc/lang.h>
#include <isc/log.h>
#include <isc/netaddr.h>
#include <isc/netdb.h>
#include <isc/parseint.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/result.h>
#include <isc/serial.h>
#include <isc/sockaddr.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/types.h>
#include <isc/util.h>
#include <isccfg/namedconf.h>
#include <lwres/lwres.h>
#include <lwres/net.h>
#include <bind9/getaddresses.h>
#include <dig/dig.h>

Go to the source code of this file.

Defines

#define NS_INADDRSZ   4
#define NS_IN6ADDRSZ   16
#define DIG_MAX_ADDRESSES   20
#define LOCK_LOOKUP
 Apply and clear locks at the event level in global task. Can I get rid of these using shutdown events? XXX.
#define UNLOCK_LOOKUP
#define EDNSOPTS   100U

Functions

static void cancel_lookup (dig_lookup_t *lookup)
 Cancel a lookup, sending isc_socket_cancel() requests to all outstanding IO sockets. The cancel handlers should take care of cleaning up the query and lookup structures.
static void recv_done (isc_task_t *task, isc_event_t *event)
 Event handler for recv complete. Perform whatever actions are necessary, based on the specifics of the user's request.
static void send_udp (dig_query_t *query)
 Send a UDP packet to the remote nameserver, possible starting the recv action as well. Also make sure that the timer is running and is properly reset.
static void connect_timeout (isc_task_t *task, isc_event_t *event)
 IO timeout handler, used for both connect and recv timeouts. If retries are still allowed, either resend the UDP packet or queue a new TCP lookup. Otherwise, cancel the lookup.
static void launch_next_query (dig_query_t *query, isc_boolean_t include_question)
 For transfers that involve multiple recvs (XFR's in particular), launch the next recv.
static void check_next_lookup (dig_lookup_t *lookup)
 If we can, clear the current lookup and start the next one running. This calls try_clear_lookup, so may invalidate the lookup pointer.
static isc_boolean_t next_origin (dig_lookup_t *oldlookup)
 Create and queue a new lookup using the next origin from the search list, read in setup_system().
static void * mem_alloc (void *arg, size_t size)
static void mem_free (void *arg, void *mem, size_t size)
char * next_token (char **stringp, const char *delim)
static int count_dots (char *string)
static void hex_dump (isc_buffer_t *b)
static isc_result_t append (const char *text, int len, char **p, char *end)
 Append 'len' bytes of 'text' at '*p', failing with ISC_R_NOSPACE if that would advance p past 'end'.
static isc_result_t reverse_octets (const char *in, char **p, char *end)
isc_result_t get_reverse (char *reverse, size_t len, char *value, isc_boolean_t ip6_int, isc_boolean_t strict)
void fatal (const char *format,...)
void debug (const char *format,...)
void check_result (isc_result_t result, const char *msg)
dig_server_tmake_server (const char *servname, const char *userarg)
 Create a server structure, which is part of the lookup structure. This is little more than a linked list of servers to query in hopes of finding the answer the user is looking for.
static int addr2af (int lwresaddrtype)
static void copy_server_list (lwres_conf_t *confdata, dig_serverlist_t *dest)
 Create a copy of the server list from the lwres configuration structure. The dest list must have already had ISC_LIST_INIT applied.
void flush_server_list (void)
void set_nameserver (char *opt)
static isc_result_t add_nameserver (lwres_conf_t *confdata, const char *addr, int af)
void clone_server_list (dig_serverlist_t src, dig_serverlist_t *dest)
 Produce a cloned server list. The dest list must have already had ISC_LIST_INIT applied.
dig_lookup_tmake_empty_lookup (void)
 Create an empty lookup structure, which holds all the information needed to get an answer to a user's question. This structure contains two linked lists: the server list (servers to query) and the query list (outstanding queries which have been made to the listed servers).
dig_lookup_tclone_lookup (dig_lookup_t *lookold, isc_boolean_t servers)
 Clone a lookup, perhaps copying the server list. This does not clone the query list, since it will be regenerated by the setup_lookup() function, nor does it queue up the new lookup for processing. Caution: If you don't clone the servers, you MUST clone the server list separately from somewhere else, or construct it by hand.
dig_lookup_trequeue_lookup (dig_lookup_t *lookold, isc_boolean_t servers)
 Requeue a lookup for further processing, perhaps copying the server list. The new lookup structure is returned to the caller, and is queued for processing. If servers are not cloned in the requeue, they must be added before allowing the current event to complete, since the completion of the event may result in the next entry on the lookup queue getting run.
void setup_text_key (void)
static isc_result_t parse_uint_helper (isc_uint32_t *uip, const char *value, isc_uint32_t max, const char *desc, int base)
isc_result_t parse_uint (isc_uint32_t *uip, const char *value, isc_uint32_t max, const char *desc)
isc_result_t parse_xint (isc_uint32_t *uip, const char *value, isc_uint32_t max, const char *desc)
static isc_uint32_t parse_bits (char *arg, const char *desc, isc_uint32_t max)
isc_result_t parse_netprefix (isc_sockaddr_t **sap, const char *value)
void parse_hmac (const char *hmac)
static isc_result_t read_confkey (void)
void setup_file_key (void)
static dig_searchlist_tmake_searchlist_entry (char *domain)
static void clear_searchlist (void)
static void create_search_list (lwres_conf_t *confdata)
void setup_system (void)
 Setup the system as a whole, reading key information and resolv.conf settings.
void set_search_domain (char *domain)
 Override the search list derived from resolv.conf by 'domain'.
void setup_libs (void)
 Setup the ISC and DNS libraries for use by the system.
void save_opt (dig_lookup_t *lookup, char *code, char *value)
static void add_opt (dns_message_t *msg, isc_uint16_t udpsize, isc_uint16_t edns, unsigned int flags, dns_ednsopt_t *opts, size_t count)
 Add EDNS0 option record to a message. Currently, the only supported options are UDP buffer size, the DO bit, and EDNS options (e.g., NSID, SIT, client-subnet).
static void add_question (dns_message_t *message, dns_name_t *name, dns_rdataclass_t rdclass, dns_rdatatype_t rdtype)
 Add a question section to a message, asking for the specified name, type, and class.
static void check_if_done (void)
 Check if we're done with all the queued lookups, which is true iff all sockets, sends, and recvs are accounted for (counters == 0), and the lookup list is empty. If we are done, pass control back out to dighost_shutdown() (which is part of dig.c, host.c, or nslookup.c) to either shutdown the system as a whole or reseed the lookup list.
static void clear_query (dig_query_t *query)
 Clear out a query when we're done with it. WARNING: This routine WILL invalidate the query pointer.
static isc_boolean_t try_clear_lookup (dig_lookup_t *lookup)
 Try and clear out a lookup if we're done with it. Return ISC_TRUE if the lookup was successfully cleared. If ISC_TRUE is returned, the lookup pointer has been invalidated.
void destroy_lookup (dig_lookup_t *lookup)
void start_lookup (void)
 If we can, start the next lookup in the queue running. This assumes that the lookup on the head of the queue hasn't been started yet. It also removes the lookup from the head of the queue, setting the current_lookup pointer pointing to it.
static int followup_lookup (dns_message_t *msg, dig_query_t *query, dns_section_t section)
 Create and queue a new lookup as a followup to the current lookup, based on the supplied message and section. This is used in trace and name server search modes to start a new lookup using servers from NS records in a reply. Returns the number of followup lookups made.
static void insert_soa (dig_lookup_t *lookup)
 Insert an SOA record into the sendmessage in a lookup. Used for creating IXFR queries.
isc_boolean_t setup_lookup (dig_lookup_t *lookup)
 Setup the supplied lookup structure, making it ready to start sending queries to servers. Create and initialize the message to be sent as well as the query structures and buffer space for the replies. If the server list is empty, clone it from the system default list.
static void send_done (isc_task_t *_task, isc_event_t *event)
 Event handler for send completion. Track send counter, and clear out the query if the send was canceled.
static void bringup_timer (dig_query_t *query, unsigned int default_timeout)
static void force_timeout (dig_lookup_t *l, dig_query_t *query)
static void connect_done (isc_task_t *task, isc_event_t *event)
 Event handler for TCP connect complete. Make sure the connection was successful, then pass into launch_next_query to actually send the question.
static void send_tcp_connect (dig_query_t *query)
 Unlike send_udp, this can't be called multiple times with the same query. When we retry TCP, we requeue the whole lookup, which should start anew.
static isc_buffer_tclone_buffer (isc_buffer_t *source)
static void tcp_length_done (isc_task_t *task, isc_event_t *event)
 Event handler for the TCP recv which gets the length header of TCP packets. Start the next recv of length bytes.
static isc_boolean_t check_for_more_data (dig_query_t *query, dns_message_t *msg, isc_socketevent_t *sevent)
 Check if the ongoing XFR needs more data before it's complete, using the semantics of IXFR and AXFR protocols. Much of the complexity of this routine comes from determining when an IXFR is complete. ISC_FALSE means more data is on the way, and the recv has been issued.
static int ednsvers (dns_rdataset_t *opt)
isc_result_t get_address (char *host, in_port_t myport, isc_sockaddr_t *sockaddr)
 Turn a name into an address, using system-supplied routines. This is used in looking up server names, etc... and needs to use system-supplied routines, since they may be using a non-DNS system for these lookups.
int getaddresses (dig_lookup_t *lookup, const char *host, isc_result_t *resultp)
void do_lookup (dig_lookup_t *lookup)
 Initiate either a TCP or UDP lookup.
void onrun_callback (isc_task_t *task, isc_event_t *event)
 Start everything in action upon task startup.
void cancel_all (void)
 Make everything on the lookup queue go away. Mainly used by the SIGINT handler.
void destroy_libs (void)
 Destroy all of the libs we are using, and get everything ready for a clean shutdown.

Variables

static lwres_context_t * lwctx = NULL
static lwres_conf_t * lwconf
dig_lookuplist_t lookup_list
dig_serverlist_t server_list
dig_searchlistlist_t search_list
isc_boolean_t check_ra = ISC_FALSE
isc_boolean_t have_ipv4 = ISC_FALSE
isc_boolean_t have_ipv6 = ISC_FALSE
isc_boolean_t specified_source = ISC_FALSE
isc_boolean_t free_now = ISC_FALSE
isc_boolean_t cancel_now = ISC_FALSE
isc_boolean_t usesearch = ISC_FALSE
isc_boolean_t showsearch = ISC_FALSE
isc_boolean_t qr = ISC_FALSE
isc_boolean_t is_dst_up = ISC_FALSE
isc_boolean_t keep_open = ISC_FALSE
isc_boolean_t verbose = ISC_FALSE
in_port_t port = 53
unsigned int timeout = 0
unsigned int extrabytes
isc_mem_tmctx = NULL
isc_log_tlctx = NULL
isc_taskmgr_ttaskmgr = NULL
isc_task_tglobal_task = NULL
isc_timermgr_ttimermgr = NULL
isc_socketmgr_tsocketmgr = NULL
isc_sockaddr_t bind_address
isc_sockaddr_t bind_any
int sendcount = 0
int recvcount = 0
int sockcount = 0
int ndots = -1
int tries = 3
int lookup_counter = 0
isc_socket_tkeep = NULL
isc_sockaddr_t keepaddr
int exitcode = 0
 Exit Codes:.
int fatalexit = 0
char keynametext [MXNAME]
char keyfile [MXNAME] = ""
char keysecret [MXNAME] = ""
unsigned char cookie_secret [33]
unsigned char cookie [8]
dns_name_thmacname = NULL
unsigned int digestbits = 0
isc_buffer_tnamebuf = NULL
dns_tsigkey_tkey = NULL
isc_boolean_t validated = ISC_TRUE
isc_entropy_tentp = NULL
isc_mempool_tcommctx = NULL
isc_boolean_t debugging = ISC_FALSE
isc_boolean_t debugtiming = ISC_FALSE
isc_boolean_t memdebugging = ISC_FALSE
char * progname = NULL
isc_mutex_t lookup_lock
dig_lookup_tcurrent_lookup = NULL
static dns_ednsopt_t ednsopts [EDNSOPTS]
static unsigned char ednsoptscnt = 0


Detailed Description

Note:
Notice to programmers: Do not use this code as an example of how to use the ISC library to perform DNS lookups. Dig and Host both operate on the request level, since they allow fine-tuning of output and are intended as debugging tools. As a result, they perform many of the functions which could be better handled using the dns_resolver functions in most applications.

Definition in file dighost.c.


Define Documentation

#define NS_INADDRSZ   4

Definition at line 107 of file dighost.c.

#define NS_IN6ADDRSZ   16

Definition at line 111 of file dighost.c.

#define DIG_MAX_ADDRESSES   20

Definition at line 347 of file dighost.c.

#define LOCK_LOOKUP

Value:

{\
        debug("lock_lookup %s:%d", __FILE__, __LINE__);\
        check_result(isc_mutex_lock((&lookup_lock)), "isc_mutex_lock");\
        debug("success");\
}
Apply and clear locks at the event level in global task. Can I get rid of these using shutdown events? XXX.

Definition at line 353 of file dighost.c.

Referenced by cancel_all(), connect_done(), connect_timeout(), destroy_libs(), onrun_callback(), recv_done(), send_done(), and tcp_length_done().

#define UNLOCK_LOOKUP

Value:

{\
        debug("unlock_lookup %s:%d", __FILE__, __LINE__);\
        check_result(isc_mutex_unlock((&lookup_lock)),\
                     "isc_mutex_unlock");\
}

Definition at line 358 of file dighost.c.

Referenced by cancel_all(), connect_done(), connect_timeout(), destroy_libs(), onrun_callback(), recv_done(), send_done(), and tcp_length_done().

#define EDNSOPTS   100U

Definition at line 1532 of file dighost.c.

Referenced by save_opt(), and setup_lookup().


Function Documentation

static void cancel_lookup ( dig_lookup_t lookup  )  [static]

Cancel a lookup, sending isc_socket_cancel() requests to all outstanding IO sockets. The cancel handlers should take care of cleaning up the query and lookup structures.

Definition at line 2708 of file dighost.c.

References check_if_done(), clear_query(), debug, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKCANCEL_ALL, isc_socket_cancel(), isc_timer_detach(), and dig_query::sock.

Referenced by connect_timeout(), followup_lookup(), next_origin(), and recv_done().

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

Event handler for recv complete. Perform whatever actions are necessary, based on the specifics of the user's request.

Definition at line 3507 of file dighost.c.

References isc_socketevent::address, isc_socketevent::bufferlist, cancel_lookup(), cancel_now, check_for_more_data(), check_next_lookup(), check_ra, check_result(), clear_query(), COMMSIZE, dns_message::counts, debug, dns_message_create(), dns_message_currentname(), dns_message_destroy(), dns_message_firstname(), dns_message_getquerytsig(), DNS_MESSAGE_INTENTPARSE, dns_message_nextname(), dns_message_parse(), dns_message_peekheader(), dns_message_setquerytsig(), dns_message_settsigkey(), DNS_MESSAGEFLAG_QR, DNS_MESSAGEFLAG_RA, DNS_MESSAGEFLAG_TC, DNS_MESSAGEPARSE_BESTEFFORT, DNS_MESSAGEPARSE_IGNORETRUNCATION, DNS_MESSAGEPARSE_PRESERVEORDER, dns_name_equal(), dns_name_format(), DNS_NAME_FORMATSIZE, DNS_R_RECOVERABLE, dns_rcode_badvers, dns_rcode_noerror, dns_rcode_nxdomain, dns_rcode_servfail, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_rdatatype_format(), DNS_RDATATYPE_FORMATSIZE, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_tsig_verify(), ednsvers(), extrabytes, fatal(), dig_query::first_soa_rcvd, dns_message::flags, followup_lookup(), free_now, hex_dump(), INSIST, isc_buffer_allocate(), isc_buffer_copyregion(), isc_buffer_free(), isc_buffer_init, isc_buffer_invalidate, isc_buffer_remaininglength, isc_buffer_usedregion, isc_event_free(), ISC_FALSE, isc_interval_set(), ISC_LIST_DEQUEUE, ISC_LIST_EMPTY, ISC_LIST_ENQUEUE, ISC_LIST_HEAD, ISC_LIST_INITANDAPPEND, ISC_LIST_NEXT, isc_mem_allocate, ISC_R_CANCELED, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_any(), isc_sockaddr_any6(), ISC_SOCKADDR_CMPADDR, ISC_SOCKADDR_CMPPORT, ISC_SOCKADDR_CMPSCOPE, ISC_SOCKADDR_CMPSCOPEZERO, isc_sockaddr_compare(), isc_sockaddr_eqaddr(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_sockaddr_getport(), isc_sockaddr_ismulticast(), isc_sockaddr_pf(), isc_socket_detach(), isc_socket_recvv(), ISC_SOCKEVENT_RECVDONE, isc_timer_reset(), isc_timer_touch(), isc_timertype_once, ISC_TRUE, isc_region::length, LOCK_LOOKUP, dig_query::lookup, lookup_list, match(), name, next_origin(), dns_message::opt, printmessage(), process_opt(), dns_message::rcode, dns_rdataset::rdclass, received(), dig_query::recvbuf, recvcount, dig_query::recvlist, dig_query::recvspace, requeue_lookup(), REQUIRE, isc_socketevent::result, send_tcp_connect(), send_udp(), dig_query::servname, showsearch, dig_query::sock, dig_query::sockaddr, sockcount, dns_message::tcp_continuation, TCP_TIMEOUT, TIME_NOW, dig_query::time_recv, timeout, dns_message::tsigctx, dns_rdataset::type, UDP_TIMEOUT, UNLOCK_LOOKUP, UNUSED, isc_buffer::used, usesearch, validated, dig_query::waiting_connect, and dig_query::warn_id.

Referenced by send_udp(), and tcp_length_done().

static void send_udp ( dig_query_t query  )  [static]

Send a UDP packet to the remote nameserver, possible starting the recv action as well. Also make sure that the timer is running and is properly reset.

Definition at line 2901 of file dighost.c.

References bringup_timer(), check_result(), clone_buffer(), debug, force_timeout(), get_address(), INSIST, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_ENQUEUE, ISC_LIST_INIT, ISC_R_SUCCESS, isc_sockaddr_anyofpf(), isc_sockaddr_pf(), isc_socket_bind(), isc_socket_create(), isc_socket_dscp(), isc_socket_recvv(), ISC_SOCKET_REUSEADDRESS, isc_socket_sendtov2(), isc_sockettype_udp, ISC_SOCKFLAG_NORETRY, ISC_TRUE, dig_query::lookup, port, recv_done(), dig_query::recv_made, dig_query::recvbuf, recvcount, dig_query::recvlist, send_done(), dig_query::sendbuf, sendcount, dig_query::sendlist, dig_query::servname, dig_query::sock, dig_query::sockaddr, sockcount, specified_source, TIME_NOW, dig_query::time_sent, UDP_TIMEOUT, dig_query::waiting_connect, and dig_query::waiting_senddone.

Referenced by connect_timeout(), do_lookup(), recv_done(), and send_done().

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

IO timeout handler, used for both connect and recv timeouts. If retries are still allowed, either resend the UDP packet or queue a new TCP lookup. Otherwise, cancel the lookup.

Definition at line 2973 of file dighost.c.

References cancel_lookup(), check_next_lookup(), debug, exitcode, free_now, INSIST, isc_event_free(), ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKCANCEL_ALL, isc_socket_cancel(), ISC_TIMEREVENT_IDLE, ISC_TRUE, LOCK_LOOKUP, dig_query::lookup, requeue_lookup(), REQUIRE, send_tcp_connect(), send_udp(), dig_query::sock, UNLOCK_LOOKUP, and UNUSED.

Referenced by bringup_timer(), and force_timeout().

static void launch_next_query ( dig_query_t query,
isc_boolean_t  include_question 
) [static]

For transfers that involve multiple recvs (XFR's in particular), launch the next recv.

Definition at line 3121 of file dighost.c.

References buffer, check_next_lookup(), check_result(), clear_query(), clone_buffer(), debug, dig_query::first_soa_rcvd, free_now, INSIST, isc_buffer_clear, isc_buffer_putuint16, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_ENQUEUE, ISC_LIST_INIT, isc_socket_detach(), isc_socket_recvv(), isc_socket_sendv(), ISC_TRUE, dig_query::lengthbuf, dig_query::lengthlist, dig_query::lookup, recvcount, send_done(), dig_query::sendbuf, sendcount, dig_query::sendlist, dig_query::slbuf, dig_query::sock, sockcount, tcp_length_done(), TIME_NOW, dig_query::time_sent, isc_buffer::used, dig_query::waiting_connect, and dig_query::waiting_senddone.

Referenced by check_for_more_data(), connect_done(), send_tcp_connect(), and tcp_length_done().

static void check_next_lookup ( dig_lookup_t lookup  )  [static]

If we can, clear the current lookup and start the next one running. This calls try_clear_lookup, so may invalidate the lookup pointer.

Definition at line 1871 of file dighost.c.

References current_lookup, debug, free_now, INSIST, ISC_LIST_HEAD, start_lookup(), and try_clear_lookup().

Referenced by connect_done(), connect_timeout(), launch_next_query(), recv_done(), send_tcp_connect(), start_lookup(), and tcp_length_done().

static isc_boolean_t next_origin ( dig_lookup_t oldlookup  )  [static]

Create and queue a new lookup using the next origin from the search list, read in setup_system().

Return ISC_TRUE iff there was another searchlist entry.

Definition at line 2061 of file dighost.c.

References cancel_lookup(), debug, dns_fixedname_init, dns_fixedname_name, dns_name_countlabels(), dns_name_fromstring2(), dns_name_isabsolute(), fixed, free_now, INSIST, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, ISC_TRUE, name, ndots, requeue_lookup(), search(), search_list, and usesearch.

Referenced by recv_done(), and start_lookup().

static void* mem_alloc ( void *  arg,
size_t  size 
) [static]

Definition at line 386 of file dighost.c.

References isc_mem_get.

Referenced by setup_system().

static void mem_free ( void *  arg,
void *  mem,
size_t  size 
) [static]

Definition at line 391 of file dighost.c.

References isc_mem_put.

Referenced by setup_system().

char* next_token ( char **  stringp,
const char *  delim 
)

Definition at line 396 of file dighost.c.

Referenced by dash_option(), dighost_shutdown(), do_next_command(), ns_server_delzone(), ns_server_dumpdb(), ns_server_dumpsecroots(), ns_server_flushcache(), ns_server_flushnode(), ns_server_mkeys(), ns_server_nta(), ns_server_setdebuglevel(), ns_server_signing(), ns_server_sync(), ns_server_testgen(), ns_server_togglequerylog(), ns_server_tsigdelete(), ns_server_validation(), parse_args(), plus_option(), and zone_from_args().

static int count_dots ( char *  string  )  [static]

Definition at line 408 of file dighost.c.

References s.

Referenced by setup_lookup().

static void hex_dump ( isc_buffer_t b  )  [static]

Definition at line 422 of file dighost.c.

References isc_region::base, isc_buffer_usedregion, isc_region::length, and r.

Referenced by recv_done().

static isc_result_t append ( const char *  text,
int  len,
char **  p,
char *  end 
) [static]

Append 'len' bytes of 'text' at '*p', failing with ISC_R_NOSPACE if that would advance p past 'end'.

Definition at line 461 of file dighost.c.

References ISC_R_NOSPACE, and ISC_R_SUCCESS.

Referenced by dns_diff_subtract(), get_reverse(), printgreeting(), and reverse_octets().

static isc_result_t reverse_octets ( const char *  in,
char **  p,
char *  end 
) [static]

Definition at line 470 of file dighost.c.

References append(), and ISC_R_SUCCESS.

Referenced by get_reverse().

isc_result_t get_reverse ( char *  reverse,
size_t  len,
char *  value,
isc_boolean_t  ip6_int,
isc_boolean_t  strict 
)

Definition at line 489 of file dighost.c.

References AF_INET6, append(), dns_byaddr_createptrname2(), DNS_BYADDROPT_IPV6INT, dns_fixedname_init, dns_fixedname_name, dns_name_format(), DNS_R_BADDOTTEDQUAD, isc_netaddr::family, isc_netaddr::in, isc_netaddr::in6, ISC_R_SUCCESS, name, r, reverse_octets(), and isc_netaddr::type.

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

static void fatal ( const char *  format,
  ... 
)

Definition at line 538 of file dighost.c.

References exitcode, fatalexit, and progname.

Referenced by active_node(), assignwork(), build_final_keylist(), check_keyversion(), check_no_nsec(), check_result(), cleannode(), cleanup_zone(), clone_buffer(), clone_lookup(), dash_option(), db_load_from_stream(), emit(), evaluate_key(), evaluate_local(), evaluate_realm(), evaluate_server(), expecttofindkey(), followup_lookup(), force_timeout(), get_addresses(), get_next_command(), get_soa_ttls(), getaddresses(), hashlist_add(), ISC_LIST(), loadexplicitkeys(), loadkey(), loadset(), loadzone(), loadzonekeys(), main(), make_empty_lookup(), make_searchlist_entry(), make_server(), next_server(), ns_server_create(), nsec3ify(), nsecify(), opendb(), parse_args(), parse_bits(), parse_config(), parse_hmac(), parse_netprefix(), plus_option(), read_confkey(), read_sessionkey(), recv_done(), recvsoa(), remove_records(), requeue_lookup(), rndc_connected(), rndc_recvdone(), rndc_recvnonce(), rndc_senddone(), save_opt(), sendrequest(), set_nameserver(), set_nsec3params(), setup_entropy(), setup_keystr(), setup_libs(), setup_lookup(), setup_system(), setup_text_key(), sign(), signapex(), signname(), signset(), signwithkey(), strtoclass(), strtotime(), strtottl(), time_units(), user_interaction(), verifynode(), verifyzone(), warnifallksk(), and writeset().

void debug ( const char *  format,
  ... 
)

Definition at line 555 of file dighost.c.

References debugging, debugtiming, isc_time_nanoseconds(), isc_time_seconds(), and TIME_NOW.

void check_result ( isc_result_t  result,
const char *  msg 
)

Definition at line 574 of file dighost.c.

Referenced by active_node(), add_ds(), add_opt(), add_question(), addnowildcardhash(), addnsec3(), addnsec3param(), bringup_timer(), build_final_keylist(), chase_cnamechain(), check_for_more_data(), check_no_rrsig(), check_tsig_error(), cleannode(), cleanup_zone(), destroy_libs(), dumpnode(), fetch_callback(), followup_lookup(), get_soa_ttls(), goodsig(), innsec3params(), insert_soa(), is_empty(), isoptout(), launch_next_query(), loadds(), loadkeyset(), loadzone(), main(), make_prereq(), match_nsec3(), nsec3clean(), nsec3ify(), nsecify(), opendb(), parse_name(), parse_rdata(), presign(), printa(), printmessage(), printrdata(), printsoa(), record_found(), recv_done(), recvsoa(), remove_records(), remove_sigs(), reset_system(), rrset_cleanup(), save_opt(), say_message(), send_tcp_connect(), send_udp(), send_update(), sendrequest(), set_nsec3params(), setsoaserial(), setup_keystr(), setup_libs(), setup_logging(), setup_lookup(), setup_system(), setup_text_key(), setzone(), short_answer(), show_message(), show_settings(), signapex(), signname(), signset(), signwithkey(), start_lookup(), start_update(), tcp_length_done(), type_format(), update_addordelete(), update_completed(), verifynode(), verifynsec(), verifynsec3(), verifyset(), verifyzone(), warnifallksk(), and writeset().

dig_server_t* make_server ( const char *  servname,
const char *  userarg 
)

Create a server structure, which is part of the lookup structure. This is little more than a linked list of servers to query in hopes of finding the answer the user is looking for.

Definition at line 586 of file dighost.c.

References debug, fatal(), ISC_LINK_INIT, isc_mem_allocate, MXNAME, REQUIRE, dig_server::servername, and dig_server::userarg.

Referenced by clone_server_list(), copy_server_list(), getaddresses(), and set_nameserver().

static int addr2af ( int  lwresaddrtype  )  [static]

Definition at line 603 of file dighost.c.

References AF_INET6.

Referenced by copy_server_list().

static void copy_server_list ( lwres_conf_t *  confdata,
dig_serverlist_t *  dest 
) [static]

Create a copy of the server list from the lwres configuration structure. The dest list must have already had ISC_LIST_INIT applied.

Definition at line 625 of file dighost.c.

References addr2af(), AF_INET6, debug, have_ipv4, have_ipv6, ISC_LINK_INIT, ISC_LIST_ENQUEUE, and make_server().

Referenced by setup_system().

void flush_server_list ( void   ) 

Definition at line 656 of file dighost.c.

References debug, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_free, s, and server_list.

Referenced by destroy_libs(), and set_nameserver().

void set_nameserver ( char *  opt  ) 

Definition at line 670 of file dighost.c.

References bind9_getaddresses(), DIG_MAX_ADDRESSES, fatal(), flush_server_list(), ISC_LIST_APPEND, isc_netaddr_format(), ISC_NETADDR_FORMATSIZE, isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, isc_result_totext(), make_server(), and server_list.

Referenced by do_next_command(), and parse_args().

static isc_result_t add_nameserver ( lwres_conf_t *  confdata,
const char *  addr,
int  af 
) [static]

Definition at line 700 of file dighost.c.

References AF_INET6, ISC_R_FAILURE, ISC_R_SUCCESS, NS_IN6ADDRSZ, and NS_INADDRSZ.

Referenced by setup_system().

void clone_server_list ( dig_serverlist_t  src,
dig_serverlist_t *  dest 
)

Produce a cloned server list. The dest list must have already had ISC_LIST_INIT applied.

Definition at line 732 of file dighost.c.

References debug, ISC_LINK_INIT, ISC_LIST_ENQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, make_server(), dig_server::servername, and dig_server::userarg.

Referenced by clone_lookup(), and setup_lookup().

dig_lookup_t* make_empty_lookup ( void   ) 

Create an empty lookup structure, which holds all the information needed to get an answer to a user's question. This structure contains two linked lists: the server list (servers to query) and the query list (outstanding queries which have been made to the listed servers).

Definition at line 752 of file dighost.c.

References debug, dns_fixedname_init, fatal(), free_now, INSIST, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_INIT, isc_mem_allocate, ISC_TRUE, and tries.

Referenced by addlookup(), clone_lookup(), and parse_args().

dig_lookup_t* clone_lookup ( dig_lookup_t lookold,
isc_boolean_t  servers 
)

Clone a lookup, perhaps copying the server list. This does not clone the query list, since it will be regenerated by the setup_lookup() function, nor does it queue up the new lookup for processing. Caution: If you don't clone the servers, you MUST clone the server list separately from somewhere else, or construct it by hand.

Definition at line 856 of file dighost.c.

References clone_server_list(), debug, dns_fixedname_name, dns_name_copy(), fatal(), free_now, INSIST, isc_mem_allocate, make_empty_lookup(), and MXNAME.

Referenced by dash_option(), parse_args(), printmessage(), and requeue_lookup().

dig_lookup_t* requeue_lookup ( dig_lookup_t lookold,
isc_boolean_t  servers 
)

Requeue a lookup for further processing, perhaps copying the server list. The new lookup structure is returned to the caller, and is queued for processing. If servers are not cloned in the requeue, they must be added before allowing the current event to complete, since the completion of the event may result in the next entry on the lookup queue getting run.

Definition at line 957 of file dighost.c.

References clone_lookup(), debug, fatal(), INSIST, ISC_LIST_PREPEND, lookup_counter, LOOKUP_LIMIT, and lookup_list.

Referenced by connect_timeout(), followup_lookup(), next_origin(), and recv_done().

void setup_text_key ( void   ) 

Definition at line 979 of file dighost.c.

References check_result(), debug, digestbits, dns_name_fromtext(), dns_name_init(), dns_name_invalidate(), dns_rootname, dns_tsigkey_create(), dst_key_setbits(), DST_R_UNSUPPORTEDALG, fatal(), isc_base64_decodestring(), isc_buffer_allocate(), isc_buffer_free(), isc_buffer_init, isc_buffer_putstr, isc_buffer_usedlength, ISC_FALSE, isc_mem_allocate, isc_mem_free, ISC_R_SUCCESS, isc_result_totext(), dns_tsigkey::key, keynametext, keysecret, and MXNAME.

Referenced by main(), read_confkey(), and setup_system().

static isc_result_t parse_uint_helper ( isc_uint32_t uip,
const char *  value,
isc_uint32_t  max,
const char *  desc,
int  base 
) [static]

Definition at line 1029 of file dighost.c.

References isc_parse_uint32(), ISC_R_RANGE, ISC_R_SUCCESS, and isc_result_totext().

Referenced by parse_uint(), and parse_xint().

isc_result_t parse_uint ( isc_uint32_t uip,
const char *  value,
isc_uint32_t  max,
const char *  desc 
)

Definition at line 1045 of file dighost.c.

References parse_uint_helper().

Referenced by dash_option(), parse_args(), parse_bits(), plus_option(), save_opt(), set_ndots(), set_port(), set_timeout(), and set_tries().

isc_result_t parse_xint ( isc_uint32_t uip,
const char *  value,
isc_uint32_t  max,
const char *  desc 
)

Definition at line 1051 of file dighost.c.

References parse_uint_helper().

Referenced by plus_option().

static isc_uint32_t parse_bits ( char *  arg,
const char *  desc,
isc_uint32_t  max 
) [static]

Definition at line 1057 of file dighost.c.

References fatal(), ISC_R_SUCCESS, and parse_uint().

Referenced by parse_hmac().

isc_result_t parse_netprefix ( isc_sockaddr_t **  sap,
const char *  value 
)

Definition at line 1069 of file dighost.c.

References AF_INET6, fatal(), ISC_FALSE, isc_mem_allocate, isc_parse_uint32(), ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_fromin(), isc_sockaddr_fromin6(), ISC_TRUE, and isc_sockaddr::length.

Referenced by plus_option().

void parse_hmac ( const char *  hmac  ) 

Definition at line 1134 of file dighost.c.

References digestbits, DNS_TSIG_HMACMD5_NAME, DNS_TSIG_HMACSHA1_NAME, DNS_TSIG_HMACSHA224_NAME, DNS_TSIG_HMACSHA256_NAME, DNS_TSIG_HMACSHA384_NAME, DNS_TSIG_HMACSHA512_NAME, fatal(), parse_bits(), and REQUIRE.

Referenced by dash_option(), evaluate_key(), read_confkey(), and setup_keystr().

static isc_result_t read_confkey ( void   )  [static]

Definition at line 1188 of file dighost.c.

References algorithm, cfg_map_get(), cfg_map_getname(), cfg_obj_asstring(), cfg_obj_destroy(), cfg_parse_file(), cfg_parser_create(), cfg_parser_destroy(), cfg_type_sessionkey, cleanup(), fatal(), isc_file_exists(), ISC_R_FILENOTFOUND, ISC_R_SUCCESS, keyfile, keynametext, keysecret, parse_hmac(), and setup_text_key().

Referenced by setup_file_key().

void setup_file_key ( void   ) 

Definition at line 1240 of file dighost.c.

References debug, DNS_TSIG_HMACMD5_NAME, DNS_TSIG_HMACSHA1_NAME, DNS_TSIG_HMACSHA224_NAME, DNS_TSIG_HMACSHA256_NAME, DNS_TSIG_HMACSHA384_NAME, DNS_TSIG_HMACSHA512_NAME, dns_tsigkey_createfromkey(), DST_ALG_HMACMD5, DST_ALG_HMACSHA1, DST_ALG_HMACSHA224, DST_ALG_HMACSHA256, DST_ALG_HMACSHA384, DST_ALG_HMACSHA512, dst_key_alg(), dst_key_free(), dst_key_fromnamedfile(), dst_key_name(), DST_TYPE_KEY, DST_TYPE_PRIVATE, ISC_FALSE, ISC_R_SUCCESS, isc_result_totext(), keyfile, keynametext, and read_confkey().

Referenced by main(), and setup_system().

static dig_searchlist_t* make_searchlist_entry ( char *  domain  )  [static]

Definition at line 1302 of file dighost.c.

References fatal(), ISC_LINK_INIT, isc_mem_allocate, MXNAME, dig_searchlist::origin, and search().

Referenced by create_search_list(), set_search_domain(), and setup_system().

static void clear_searchlist ( void   )  [static]

Definition at line 1315 of file dighost.c.

References ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mem_free, search(), and search_list.

Referenced by create_search_list(), destroy_libs(), and set_search_domain().

static void create_search_list ( lwres_conf_t *  confdata  )  [static]

Definition at line 1324 of file dighost.c.

References clear_searchlist(), debug, ISC_LIST_APPEND, make_searchlist_entry(), search(), and search_list.

Referenced by setup_system().

void setup_system ( void   ) 

Setup the system as a whole, reading key information and resolv.conf settings.

Definition at line 1342 of file dighost.c.

References add_nameserver(), AF_INET6, cookie_secret, copy_server_list(), create_search_list(), debug, dns_name_init(), fatal(), have_ipv4, have_ipv6, isc_entropy_getdata(), ISC_LIST_APPEND, ISC_LIST_EMPTY, ISC_LIST_INIT, ISC_R_SUCCESS, ISC_TRUE, keyfile, keysecret, lwconf, lwctx, make_searchlist_entry(), mem_alloc(), mem_free(), ndots, RESOLV_CONF, search_list, server_list, setup_file_key(), setup_text_key(), timeout, tries, and verbose.

Referenced by main().

void set_search_domain ( char *  domain  ) 

Override the search list derived from resolv.conf by 'domain'.

Definition at line 1449 of file dighost.c.

References clear_searchlist(), ISC_LIST_APPEND, make_searchlist_entry(), search(), and search_list.

Referenced by main(), and setoption().

void setup_libs ( void   ) 

Setup the ISC and DNS libraries for use by the system.

Definition at line 1461 of file dighost.c.

References check_result(), COMMSIZE, debug, dns_log_init(), dns_log_setcontext(), dns_result_register(), dst_lib_init(), fatal(), have_ipv4, have_ipv6, is_dst_up, isc_entropy_create(), isc_log_create(), isc_log_setcontext(), isc_log_setdebuglevel(), isc_log_usechannel(), isc_mem_create(), isc_mem_setname(), isc_mempool_create(), isc_mempool_setfillcount(), isc_mempool_setfreemax(), isc_mempool_setname(), isc_mutex_init, isc_net_probeipv4(), isc_net_probeipv6(), ISC_R_SUCCESS, isc_socketmgr_create(), isc_task_create(), isc_task_setname(), isc_taskmgr_create(), isc_timermgr_create(), ISC_TRUE, lookup_lock, and pk11_result_register().

Referenced by main().

void save_opt ( dig_lookup_t lookup,
char *  code,
char *  value 
)

Definition at line 1537 of file dighost.c.

References check_result(), dns_ednsopt::code, EDNSOPTS, fatal(), isc_buffer_base, isc_buffer_init, isc_buffer_usedlength, isc_hex_decodestring(), isc_mem_allocate, ISC_R_SUCCESS, dns_ednsopt::length, parse_uint(), and dns_ednsopt::value.

Referenced by plus_option().

static void add_opt ( dns_message_t msg,
isc_uint16_t  udpsize,
isc_uint16_t  edns,
unsigned int  flags,
dns_ednsopt_t opts,
size_t  count 
) [static]

Add EDNS0 option record to a message. Currently, the only supported options are UDP buffer size, the DO bit, and EDNS options (e.g., NSID, SIT, client-subnet).

Definition at line 1577 of file dighost.c.

References check_result(), debug, dns_message_buildopt(), and dns_message_setopt().

static void add_question ( dns_message_t message,
dns_name_t name,
dns_rdataclass_t  rdclass,
dns_rdatatype_t  rdtype 
) [static]

Add a question section to a message, asking for the specified name, type, and class.

Definition at line 1596 of file dighost.c.

References check_result(), debug, dns_message_gettemprdataset(), dns_rdataset_init(), dns_rdataset_makequestion(), and ISC_LIST_APPEND.

Referenced by setup_lookup().

static void check_if_done ( void   )  [static]

Check if we're done with all the queued lookups, which is true iff all sockets, sends, and recvs are accounted for (counters == 0), and the lookup list is empty. If we are done, pass control back out to dighost_shutdown() (which is part of dig.c, host.c, or nslookup.c) to either shutdown the system as a whole or reseed the lookup list.

Definition at line 1620 of file dighost.c.

References current_lookup, debug, dighost_shutdown(), INSIST, ISC_LIST_EMPTY, lookup_list, recvcount, sendcount, and sockcount.

Referenced by cancel_lookup(), send_done(), and start_lookup().

static void clear_query ( dig_query_t query  )  [static]

Clear out a query when we're done with it. WARNING: This routine WILL invalidate the query pointer.

Definition at line 1637 of file dighost.c.

References debug, INSIST, isc_buffer_invalidate, ISC_LINK_LINKED, ISC_LIST_DEQUEUE, ISC_LIST_UNLINK, isc_mem_free, isc_mempool_put, isc_socket_detach(), ISC_TRUE, dig_query::lengthbuf, dig_query::lengthlist, dig_query::lookup, dig_query::pending_free, dig_query::recvbuf, dig_query::recvlist, dig_query::recvspace, REQUIRE, dig_query::sock, sockcount, and dig_query::waiting_senddone.

Referenced by cancel_all(), cancel_lookup(), connect_done(), launch_next_query(), recv_done(), send_tcp_connect(), and tcp_length_done().

static isc_boolean_t try_clear_lookup ( dig_lookup_t lookup  )  [static]

Try and clear out a lookup if we're done with it. Return ISC_TRUE if the lookup was successfully cleared. If ISC_TRUE is returned, the lookup pointer has been invalidated.

Definition at line 1681 of file dighost.c.

References debug, debugging, destroy_lookup(), ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_TRUE, REQUIRE, and dig_query::servname.

Referenced by cancel_all(), and check_next_lookup().

void destroy_lookup ( dig_lookup_t lookup  ) 

Definition at line 1717 of file dighost.c.

References debug, dns_message_destroy(), dst_context_destroy(), isc_buffer_free(), ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_free, isc_mempool_put, isc_timer_detach(), and s.

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

void start_lookup ( void   ) 

If we can, start the next lookup in the queue running. This assumes that the lookup on the head of the queue hasn't been started yet. It also removes the lookup from the head of the queue, setting the current_lookup pointer pointing to it.

Definition at line 1758 of file dighost.c.

References isc_region::base, BUFSIZE, cancel_now, check_if_done(), check_next_lookup(), check_result(), current_lookup, debug, dns_name_init(), dns_name_issubdomain(), dns_name_print(), dns_name_totext(), do_lookup(), dst_key_name(), INSIST, isc_buffer_allocate(), isc_buffer_free(), isc_buffer_usedregion, ISC_FALSE, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_R_SUCCESS, ISC_TRUE, isc_region::length, lookup_list, MXNAME, next_origin(), r, and setup_lookup().

Referenced by check_next_lookup(), dighost_shutdown(), getinput(), lookup_done(), ns_lwdclient_processgrbn(), onrun_callback(), and start_lookup().

static int followup_lookup ( dns_message_t msg,
dig_query_t query,
dns_section_t  section 
) [static]

Create and queue a new lookup as a followup to the current lookup, based on the supplied message and section. This is used in trace and name server search modes to start a new lookup using servers from NS records in a reply. Returns the number of followup lookups made.

Definition at line 1894 of file dighost.c.

References cancel_lookup(), check_result(), debug, dns_fixedname_name, dns_message_currentname(), dns_message_findtype(), dns_message_firstname(), dns_message_nextname(), dns_name_copy(), dns_name_format(), DNS_NAME_FORMATSIZE, dns_name_fullcompare(), dns_namereln_equal, dns_namereln_subdomain, dns_rdata_freestruct(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_next(), DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, fatal(), free_now, getaddresses(), INSIST, ISC_FALSE, ISC_LIST_APPEND, ISC_LIST_APPENDLIST, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, ISC_R_SUCCESS, isc_random_get(), isc_result_totext(), ISC_TRUE, dig_query::lookup, lookup_counter, MXSERV, name, and requeue_lookup().

Referenced by recv_done().

static void insert_soa ( dig_lookup_t lookup  )  [static]

Insert an SOA record into the sendmessage in a lookup. Used for creating IXFR queries.

Definition at line 2117 of file dighost.c.

References check_result(), debug, dns_message_addname(), dns_message_gettempname(), dns_message_gettemprdata(), dns_message_gettemprdatalist(), dns_message_gettemprdataset(), dns_name_clone(), dns_name_init(), dns_rdata_fromstruct(), dns_rdatalist_init(), dns_rdatalist_tordataset(), dns_rdataset_init(), dns_rootname, DNS_SECTION_AUTHORITY, isc_buffer_init, ISC_LIST_APPEND, ISC_LIST_INIT, dns_rdatalist::rdclass, dns_rdata::rdclass, and dns_rdatalist::type.

Referenced by setup_lookup().

isc_boolean_t setup_lookup ( dig_lookup_t lookup  ) 

Setup the supplied lookup structure, making it ready to start sending queries to servers. Create and initialize the message to be sent as well as the query structures and buffer space for the replies. If the server list is empty, clone it from the system default list.

Definition at line 2191 of file dighost.c.

References add_opt(), add_question(), dig_query::byte_count, check_result(), clone_server_list(), dns_ednsopt::code, COMMSIZE, cookie, count_dots(), debug, dns_compress_init(), dns_compress_invalidate(), DNS_EDNSOPTIONS, dns_fixedname_init, dns_fixedname_name, dns_message_addname(), dns_message_create(), dns_message_gettempname(), DNS_MESSAGE_INTENTRENDER, dns_message_puttempname(), dns_message_renderbegin(), dns_message_renderend(), dns_message_rendersection(), dns_message_settsigkey(), DNS_MESSAGEEXTFLAG_DO, DNS_MESSAGEFLAG_AA, DNS_MESSAGEFLAG_AD, DNS_MESSAGEFLAG_CD, DNS_MESSAGEFLAG_RD, dns_name_clone(), dns_name_concatenate(), dns_name_copy(), dns_name_format(), dns_name_fromtext(), dns_name_init(), dns_name_isabsolute(), dns_name_settotextfilter(), dns_opcode_query, DNS_OPT_CLIENT_SUBNET, DNS_OPT_EXPIRE, DNS_OPT_NSID, DNS_OPT_SIT, DNS_R_NAMETOOLONG, dns_rootname, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, EDNSOPTS, extrabytes, fatal(), dig_query::first_pass, dig_query::first_repeat_rcvd, dig_query::first_rr_serial, dig_query::first_soa_rcvd, fixed, free_now, insert_soa(), INSIST, isc_buffer_add, isc_buffer_base, isc_buffer_init, isc_buffer_putmem, isc_buffer_putuint16, isc_buffer_putuint8, isc_buffer_usedlength, ISC_FALSE, isc_hex_decodestring(), ISC_LINK_INIT, ISC_LIST_EMPTY, ISC_LIST_ENQUEUE, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, isc_mem_allocate, isc_mempool_get, ISC_R_SUCCESS, isc_random_get(), isc_result_totext(), ISC_TRUE, dig_query::ixfr_axfr, dns_ednsopt::length, dig_query::lengthbuf, dig_query::lengthlist, dig_query::lengthspace, dig_query::lookup, lookup_counter, dig_query::msg_count, MXNAME, name, ndots, dig_query::pending_free, printmessage(), qr, dig_query::recv_made, dig_query::recvbuf, dig_query::recvlist, dig_query::recvspace, REQUIRE, dig_query::rr_count, search_list, dig_query::second_rr_rcvd, dig_query::second_rr_serial, dig_query::sendbuf, server_list, dig_server::servername, dig_query::servname, sockaddr_in6::sin6_addr, dig_query::slbuf, dig_query::slspace, dig_query::sock, trying(), dig_server::userarg, dig_query::userarg, usesearch, dns_ednsopt::value, dig_query::waiting_connect, dig_query::waiting_senddone, and dig_query::warn_id.

Referenced by start_lookup().

static void send_done ( isc_task_t _task,
isc_event_t event 
) [static]

Event handler for send completion. Track send counter, and clear out the query if the send was canceled.

Definition at line 2658 of file dighost.c.

References isc_socketevent::bufferlist, check_if_done(), debug, INSIST, isc_event_free(), ISC_FALSE, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_mem_free, ISC_SOCKEVENT_SENDDONE, LOCK_LOOKUP, dig_query::lookup, dig_query::pending_free, REQUIRE, send_udp(), sendcount, UNLOCK_LOOKUP, UNUSED, and dig_query::waiting_senddone.

Referenced by launch_next_query(), and send_udp().

static void bringup_timer ( dig_query_t query,
unsigned int  default_timeout 
) [static]

Definition at line 2731 of file dighost.c.

References check_result(), connect_timeout(), debug, isc_interval_set(), ISC_LIST_NEXT, isc_timer_create(), isc_timer_detach(), isc_timertype_once, dig_query::lookup, SERVER_TIMEOUT, and timeout.

Referenced by connect_done(), send_tcp_connect(), and send_udp().

static void force_timeout ( dig_lookup_t l,
dig_query_t query 
) [static]

Definition at line 2762 of file dighost.c.

References connect_timeout(), debug, fatal(), isc_event_allocate(), ISC_R_NOMEMORY, isc_result_totext(), isc_task_send(), isc_timer_detach(), and ISC_TIMEREVENT_IDLE.

Referenced by send_tcp_connect(), and send_udp().

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

Event handler for TCP connect complete. Make sure the connection was successful, then pass into launch_next_query to actually send the question.

Definition at line 3188 of file dighost.c.

References bringup_timer(), check_next_lookup(), clear_query(), debug, exitcode, free_now, INSIST, isc_event_free(), ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_NEXT, ISC_R_CANCELED, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_socket_attach(), isc_socket_detach(), ISC_SOCKEVENT_CONNECT, ISC_TRUE, keep_open, launch_next_query(), LOCK_LOOKUP, dig_query::lookup, REQUIRE, isc_socketevent::result, send_tcp_connect(), dig_query::servname, dig_query::sock, dig_query::sockaddr, sockcount, TCP_TIMEOUT, UNLOCK_LOOKUP, UNUSED, and dig_query::waiting_connect.

Referenced by send_tcp_connect().

static void send_tcp_connect ( dig_query_t query  )  [static]

Unlike send_udp, this can't be called multiple times with the same query. When we retry TCP, we requeue the whole lookup, which should start anew.

Definition at line 2795 of file dighost.c.

References bringup_timer(), check_next_lookup(), check_result(), clear_query(), connect_done(), debug, force_timeout(), get_address(), have_ipv4, INSIST, ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_DEQUEUE, ISC_LIST_ENQUEUE, ISC_LIST_NEXT, ISC_R_SUCCESS, isc_sockaddr_any(), isc_sockaddr_any6(), isc_sockaddr_equal(), isc_sockaddr_pf(), isc_socket_attach(), isc_socket_bind(), isc_socket_connect(), isc_socket_create(), isc_socket_dscp(), ISC_SOCKET_REUSEADDRESS, isc_sockettype_tcp, ISC_TRUE, launch_next_query(), dig_query::lookup, port, search(), dig_query::servname, dig_query::sock, dig_query::sockaddr, sockcount, specified_source, TCP_TIMEOUT, and dig_query::waiting_connect.

Referenced by connect_done(), connect_timeout(), do_lookup(), and recv_done().

static isc_buffer_t* clone_buffer ( isc_buffer_t source  )  [static]

Definition at line 2885 of file dighost.c.

References buffer, fatal(), and isc_mem_allocate.

Referenced by launch_next_query(), and send_udp().

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

Event handler for the TCP recv which gets the length header of TCP packets. Start the next recv of length bytes.

Definition at line 3037 of file dighost.c.

References isc_socketevent::bufferlist, check_next_lookup(), check_result(), clear_query(), debug, ENSURE, free_now, INSIST, isc_buffer_getuint16(), isc_buffer_init, isc_buffer_invalidate, isc_event_free(), ISC_FALSE, ISC_LINK_INIT, ISC_LIST_DEQUEUE, ISC_LIST_EMPTY, ISC_LIST_ENQUEUE, ISC_LIST_HEAD, ISC_R_CANCELED, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_socket_detach(), isc_socket_recvv(), ISC_SOCKEVENT_RECVDONE, launch_next_query(), dig_query::lengthbuf, LOCK_LOOKUP, dig_query::lookup, recv_done(), dig_query::recvbuf, recvcount, dig_query::recvlist, dig_query::recvspace, REQUIRE, isc_socketevent::result, dig_query::sock, dig_query::sockaddr, sockcount, UNLOCK_LOOKUP, and UNUSED.

Referenced by launch_next_query().

static isc_boolean_t check_for_more_data ( dig_query_t query,
dns_message_t msg,
isc_socketevent_t sevent 
) [static]

Check if the ongoing XFR needs more data before it's complete, using the semantics of IXFR and AXFR protocols. Much of the complexity of this routine comes from determining when an IXFR is complete. ISC_FALSE means more data is on the way, and the recv has been issued.

Definition at line 3275 of file dighost.c.

References isc_socketevent::address, dig_query::byte_count, check_result(), debug, dns_message_currentname(), dns_message_firstname(), dns_message_nextname(), dns_rdata_freestruct(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_rdataset_next(), DNS_SECTION_ANSWER, dig_query::first_repeat_rcvd, dig_query::first_rr_serial, dig_query::first_soa_rcvd, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, isc_serial_ge(), ISC_TRUE, dig_query::ixfr_axfr, launch_next_query(), dig_query::lookup, dig_query::msg_count, isc_socketevent::n, name, received(), dig_query::rr_count, dig_query::second_rr_rcvd, dig_query::second_rr_serial, serial, and dns_rdata::type.

Referenced by recv_done().

static int ednsvers ( dns_rdataset_t opt  )  [static]

Definition at line 3498 of file dighost.c.

References dns_rdataset::ttl.

Referenced by recv_done().

isc_result_t get_address ( char *  host,
in_port_t  myport,
isc_sockaddr_t sockaddr 
)

Turn a name into an address, using system-supplied routines. This is used in looking up server names, etc... and needs to use system-supplied routines, since they may be using a non-DNS system for these lookups.

Definition at line 4072 of file dighost.c.

References bind9_getaddresses(), INSIST, is_running, isc_app_block(), isc_app_isrunning(), isc_app_unblock(), and ISC_R_SUCCESS.

Referenced by send_tcp_connect(), send_udp(), and show_settings().

int getaddresses ( dig_lookup_t lookup,
const char *  host,
isc_result_t resultp 
)

Definition at line 4092 of file dighost.c.

References bind9_getaddresses(), DIG_MAX_ADDRESSES, fatal(), ISC_LIST_APPEND, isc_netaddr_format(), ISC_NETADDR_FORMATSIZE, isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, isc_result_totext(), and make_server().

Referenced by followup_lookup(), and parse_args().

void do_lookup ( dig_lookup_t lookup  ) 

Initiate either a TCP or UDP lookup.

Definition at line 4125 of file dighost.c.

References debug, ISC_LIST_HEAD, ISC_TRUE, REQUIRE, send_tcp_connect(), and send_udp().

Referenced by start_lookup().

void onrun_callback ( isc_task_t task,
isc_event_t event 
)

Start everything in action upon task startup.

Definition at line 4145 of file dighost.c.

References isc_event_free(), LOCK_LOOKUP, start_lookup(), UNLOCK_LOOKUP, and UNUSED.

Referenced by main().

void cancel_all ( void   ) 

Make everything on the lookup queue go away. Mainly used by the SIGINT handler.

Definition at line 4159 of file dighost.c.

References cancel_now, clear_query(), current_lookup, debug, free_now, ISC_LIST_DEQUEUE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKCANCEL_ALL, isc_socket_cancel(), isc_timer_detach(), ISC_TRUE, LOCK_LOOKUP, lookup_list, dig_query::sock, try_clear_lookup(), and UNLOCK_LOOKUP.

Referenced by main().

void destroy_libs ( void   ) 

Destroy all of the libs we are using, and get everything ready for a clean shutdown.

Definition at line 4216 of file dighost.c.

References check_result(), clear_searchlist(), current_lookup, debug, DESTROYLOCK, dns_message_destroy(), dns_name_destroy(), dns_name_dynamic(), dns_name_settotextfilter(), dns_tsigkey_detach(), dst_lib_destroy(), flush_server_list(), free_now, INSIST, is_dst_up, isc_buffer_free(), isc_entropy_detach(), ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_log_destroy(), isc_mem_destroy(), isc_mem_free, isc_mem_stats(), isc_mempool_destroy(), isc_socket_detach(), isc_socketmgr_destroy(), isc_task_detach(), isc_taskmgr_destroy(), isc_timermgr_destroy(), ISC_TRUE, LOCK_LOOKUP, lookup_list, lookup_lock, lwctx, memdebugging, recvcount, REQUIRE, sendcount, sockcount, and UNLOCK_LOOKUP.

Referenced by main().


Variable Documentation

lwres_context_t* lwctx = NULL [static]

Definition at line 114 of file dighost.c.

Referenced by destroy_libs(), doshutdown(), ns_lwresd_parseeresolvconf(), and setup_system().

lwres_conf_t* lwconf [static]

Definition at line 115 of file dighost.c.

Referenced by setup_system().

dig_lookuplist_t lookup_list

Definition at line 117 of file dighost.c.

Referenced by addlookup(), cancel_all(), check_if_done(), dash_option(), destroy_libs(), flush_lookup_list(), getinput(), main(), parse_args(), printmessage(), recv_done(), requeue_lookup(), and start_lookup().

dig_serverlist_t server_list

Definition at line 118 of file dighost.c.

Referenced by flush_server_list(), main(), set_nameserver(), setup_lookup(), setup_system(), and show_settings().

dig_searchlistlist_t search_list

Definition at line 119 of file dighost.c.

Referenced by clear_searchlist(), create_search_list(), main(), next_origin(), set_search_domain(), setup_lookup(), setup_system(), and show_settings().

isc_boolean_t check_ra = ISC_FALSE

Definition at line 122 of file dighost.c.

Referenced by do_next_command(), main(), parse_args(), and recv_done().

isc_boolean_t have_ipv4 = ISC_FALSE

Definition at line 123 of file dighost.c.

Referenced by bind9_getaddresses(), copy_server_list(), dash_option(), doshutdown(), evaluate_local(), parse_args(), send_tcp_connect(), setup_libs(), and setup_system().

isc_boolean_t have_ipv6 = ISC_FALSE

Definition at line 124 of file dighost.c.

Referenced by bind9_getaddresses(), copy_server_list(), dash_option(), doshutdown(), evaluate_local(), parse_args(), setup_libs(), and setup_system().

isc_boolean_t specified_source = ISC_FALSE

Definition at line 125 of file dighost.c.

Referenced by dash_option(), send_tcp_connect(), and send_udp().

isc_boolean_t free_now = ISC_FALSE

Definition at line 126 of file dighost.c.

Referenced by cancel_all(), check_next_lookup(), clone_lookup(), connect_done(), connect_timeout(), destroy_libs(), dns_zone_detach(), dns_zonemgr_detach(), dns_zonemgr_releasezone(), followup_lookup(), isc_ratelimiter_detach(), launch_next_query(), make_empty_lookup(), next_origin(), recv_done(), setup_lookup(), and tcp_length_done().

isc_boolean_t cancel_now = ISC_FALSE

Definition at line 127 of file dighost.c.

Referenced by cancel_all(), recv_done(), and start_lookup().

isc_boolean_t usesearch = ISC_FALSE

Definition at line 128 of file dighost.c.

Referenced by main(), next_origin(), parse_args(), plus_option(), recv_done(), setoption(), setup_lookup(), and show_settings().

isc_boolean_t showsearch = ISC_FALSE

Definition at line 129 of file dighost.c.

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

isc_boolean_t qr = ISC_FALSE

Definition at line 130 of file dighost.c.

Referenced by plus_option(), and setup_lookup().

isc_boolean_t is_dst_up = ISC_FALSE

Definition at line 131 of file dighost.c.

Referenced by destroy_libs(), doshutdown(), setup_libs(), and setup_system().

isc_boolean_t keep_open = ISC_FALSE

Definition at line 132 of file dighost.c.

Referenced by connect_done(), and plus_option().

isc_boolean_t verbose = ISC_FALSE

Definition at line 133 of file dighost.c.

Referenced by addnowildcardhash(), hashlist_add_dns_name(), key_collision(), loadkey(), main(), notify(), parse_args(), setup_logging(), setup_system(), and vbprintf().

in_port_t port = 53

Definition at line 134 of file dighost.c.

Referenced by cfg_print_sockaddr(), configure_alternates(), configure_forward(), configure_view(), dash_option(), dns_adb_findaddrinfo(), evaluate_local(), evaluate_server(), fromtext_in_wks(), isc_sockaddr_getport(), listener_bind(), ns_add_reserved_dispatch(), ns_config_getipandkeylist(), ns_config_getiplist(), ns_listenelt_fromconfig(), ns_lwresd_configure(), parse_command_line(), parse_querysource(), parse_sockaddrsub(), portset_fromconf(), send_tcp_connect(), send_udp(), set_port(), and show_settings().

unsigned int timeout = 0

Definition at line 135 of file dighost.c.

Referenced by bringup_timer(), isc__socketmgr_waitevents(), notify_send_toaddr(), ns_query(), parse_args(), plus_option(), recv_done(), send_update(), set_timeout(), setup_system(), show_settings(), soa_query(), and update_done().

unsigned int extrabytes

Definition at line 136 of file dighost.c.

Referenced by printmessage(), recv_done(), and setup_lookup().

isc_mem_t* mctx = NULL

Definition at line 137 of file dighost.c.

isc_log_t* lctx = NULL

Definition at line 138 of file dighost.c.

isc_taskmgr_t* taskmgr = NULL

Definition at line 139 of file dighost.c.

isc_task_t* global_task = NULL

Definition at line 140 of file dighost.c.

Referenced by dighost_shutdown(), and main().

isc_timermgr_t* timermgr = NULL

Definition at line 141 of file dighost.c.

isc_socketmgr_t* socketmgr = NULL

Definition at line 142 of file dighost.c.

isc_sockaddr_t bind_address

Definition at line 143 of file dighost.c.

Referenced by dash_option().

isc_sockaddr_t bind_any

Definition at line 144 of file dighost.c.

Referenced by create_tcp_dispatch(), and setup_system().

int sendcount = 0

Definition at line 145 of file dighost.c.

Referenced by check_if_done(), destroy_libs(), launch_next_query(), send_done(), and send_udp().

int recvcount = 0

Definition at line 146 of file dighost.c.

Referenced by check_if_done(), destroy_libs(), launch_next_query(), recv_done(), send_udp(), and tcp_length_done().

int sockcount = 0

Definition at line 147 of file dighost.c.

Referenced by check_if_done(), clear_query(), connect_done(), destroy_libs(), launch_next_query(), recv_done(), send_tcp_connect(), send_udp(), and tcp_length_done().

int ndots = -1

Definition at line 148 of file dighost.c.

Referenced by next_origin(), parse_args(), plus_option(), set_ndots(), setup_lookup(), setup_system(), and show_settings().

int tries = 3

Definition at line 149 of file dighost.c.

Referenced by addlookup(), getname(), getrdata(), hash_divisor(), main(), make_empty_lookup(), parse_args(), printmessage(), set_tries(), setup_system(), and show_settings().

int lookup_counter = 0

Definition at line 150 of file dighost.c.

Referenced by flush_lookup_list(), followup_lookup(), requeue_lookup(), and setup_lookup().

isc_socket_t* keep = NULL

Definition at line 169 of file dighost.c.

Referenced by signset().

isc_sockaddr_t keepaddr

Definition at line 170 of file dighost.c.

int exitcode = 0

Exit Codes:.

Definition at line 182 of file dighost.c.

Referenced by connect_done(), connect_timeout(), fatal(), main(), and parse_args().

int fatalexit = 0

Definition at line 183 of file dighost.c.

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

char keynametext[MXNAME]

Definition at line 184 of file dighost.c.

Referenced by dash_option(), read_confkey(), setup_file_key(), and setup_text_key().

char keyfile[MXNAME] = ""

Definition at line 185 of file dighost.c.

Referenced by configure_session_key(), dash_option(), destroy(), dns_view_restorekeyring(), main(), parse_args(), read_confkey(), read_sessionkey(), setup_file_key(), setup_keyfile(), and setup_system().

char keysecret[MXNAME] = ""

Definition at line 186 of file dighost.c.

Referenced by dash_option(), main(), read_confkey(), received(), setup_system(), and setup_text_key().

unsigned char cookie_secret[33]

Definition at line 187 of file dighost.c.

Referenced by setup_system().

unsigned char cookie[8]

Definition at line 188 of file dighost.c.

Referenced by process_opt(), and setup_lookup().

dns_name_t* hmacname = NULL

Definition at line 189 of file dighost.c.

Referenced by dash_option(), evaluate_key(), setup_keyfile(), and setup_keystr().

unsigned int digestbits = 0

Definition at line 190 of file dighost.c.

Referenced by bind9_check_key(), dash_option(), dns_tsig_sign(), dns_tsig_verify(), evaluate_key(), parse_hmac(), setup_keystr(), and setup_text_key().

isc_buffer_t* namebuf = NULL

Definition at line 191 of file dighost.c.

Referenced by add_bad(), add_cidr(), addnsec3(), ATF_TC_BODY(), badname(), cache_name(), check_keylist(), check_mx(), check_no_nsec(), check_no_rrsig(), check_servers(), check_wildcard(), check_zoneconf(), checkmx(), checkns(), checkqueryacl(), checksrv(), checkupdateacl(), checkwildcard(), client_request(), commit(), configure_forward(), configure_view(), copy_name(), create_empty_zone(), del_name(), detailsection(), diff_apply(), dlvfetched(), dns_adb_createfind2(), dns_badcache_print(), dns_dnssec_findmatchingkeys(), dns_dnssec_findzonekeys2(), dns_dnssec_keylistfromrdataset(), dns_dnssec_verify3(), dns_nsec3_noexistnodata(), dns_root_checkhints(), dns_rpz_find_name(), dns_zone_setclass(), dns_zone_setorigin(), dns_zone_settype(), dns_zone_setview(), dst_gssapi_acceptctx(), dst_gssapi_acquirecred(), dst_gssapi_initctx(), dstkey_fromconfig(), finddlvsep(), findname(), findnsec3proofs(), fix_triggers(), generate(), insert_nodes(), integrity_checks(), is_answeraddress_allowed(), keyfetch_done(), load_raw(), load_secroots(), load_text(), log_fetch(), log_lame(), log_ns_ttl(), log_query(), log_queryerror(), match_nsec3(), mustbesecure(), ns_client_aclmsg(), ns_client_dumprecursing(), ns_lwdclient_processgabn(), ns_lwdclient_processgrbn(), ns_lwdmanager_create(), ns_notify_start(), ns_query(), ns_server_zonestatus(), parse_name(), printsection(), printsoa(), proveunsecure(), query_find(), recvsoa(), report(), resquery_response(), same_question(), send_forward_event(), signname(), soa_query(), startfinddlvsep(), totext_key(), trim_ns_ttl(), update_addordelete(), update_log(), validatezonekey(), validator_logv(), verifynsec(), verifynsec3(), verifyset(), verifyzone(), view_find(), warn_badname(), writeset(), xfrout_logv(), zone_check_glue(), zone_check_mx(), zone_check_ns(), zone_check_srv(), zone_postload(), and zone_xfrdone().

dns_tsigkey_t* key = NULL

Definition at line 192 of file dighost.c.

static void validated = ISC_TRUE

Definition at line 193 of file dighost.c.

Referenced by received(), recv_done(), and valcreate().

isc_entropy_t* entp = NULL

Definition at line 194 of file dighost.c.

isc_mempool_t* commctx = NULL

Definition at line 195 of file dighost.c.

isc_boolean_t debugging = ISC_FALSE

Definition at line 196 of file dighost.c.

Referenced by dash_option(), debug(), do_next_command(), parse_args(), pre_parse_args(), recvsoa(), send_update(), setoption(), show_settings(), try_clear_lookup(), and update_completed().

isc_boolean_t debugtiming = ISC_FALSE

Definition at line 197 of file dighost.c.

Referenced by debug(), and pre_parse_args().

isc_boolean_t memdebugging = ISC_FALSE

Definition at line 198 of file dighost.c.

Referenced by cleanup(), destroy_libs(), pre_parse_args(), and preparse_args().

char* progname = NULL

Definition at line 199 of file dighost.c.

Referenced by fatal(), main(), rndc_recvdone(), and usage().

isc_mutex_t lookup_lock

Definition at line 200 of file dighost.c.

Referenced by destroy_libs(), and setup_libs().

dig_lookup_t* current_lookup = NULL

Definition at line 201 of file dighost.c.

Referenced by cancel_all(), check_if_done(), check_next_lookup(), destroy_libs(), and start_lookup().

dns_ednsopt_t ednsopts[EDNSOPTS] [static]

Definition at line 1533 of file dighost.c.

Referenced by add_opt(), ns_client_addopt(), and resquery_send().

unsigned char ednsoptscnt = 0 [static]

Definition at line 1534 of file dighost.c.


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