2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: dig.h,v 1.71.2.7 2004/03/09 06:09:14 marka Exp $ */
23 #include <dns/rdatalist.h>
27 #include <isc/boolean.h>
28 #include <isc/buffer.h>
29 #include <isc/bufferlist.h>
30 #include <isc/formatcheck.h>
34 #include <isc/print.h>
35 #include <isc/sockaddr.h>
36 #include <isc/socket.h>
39 #define MXNAME (DNS_NAME_MAXTEXT+1)
42 #define COMMSIZE 0xffff
44 #define RESOLV_CONF "/etc/resolv.conf"
46 #define OUTPUTBUF 32767
47 #define MAXRRLIMIT 0xffffffff
48 #define MAXTIMEOUT 0xffff
49 #define MAXTRIES 0xffffffff
50 #define MAXNDOTS 0xffff
51 #define MAXPORT 0xffff
52 #define MAXSERIAL 0xffffffff
55 * Default timeout values
57 #define TCP_TIMEOUT 10
60 #define SERVER_TIMEOUT 1
62 #define LOOKUP_LIMIT 64
64 * Lookup_limit is just a limiter, keeping too many lookups from being
65 * created. It's job is mainly to prevent the program from running away
66 * in a tight loop of constant lookups. It's value is arbitrary.
71 * Set the number of root servers to ask for information when running in
73 * XXXMWS -- trace mode is currently semi-broken, and this number *MUST*
79 typedef struct dig_lookup dig_lookup_t
;
80 typedef struct dig_query dig_query_t
;
81 typedef struct dig_server dig_server_t
;
82 typedef ISC_LIST(dig_server_t
) dig_serverlist_t
;
83 typedef struct dig_searchlist dig_searchlist_t
;
87 pending
, /* Pending a successful answer */
90 ns_search_only
, /* dig +nssearch, host -C */
91 identify
, /* Append an "on server <foo>" message */
92 identify_previous_line
, /* Prepend a "Nameserver <foo>:"
93 message, with newline and tab */
99 trace
, /* dig +trace */
100 trace_root
, /* initial query for either +trace or +nssearch */
113 char textname
[MXNAME
]; /* Name we're going to be looking up */
114 char cmdline
[MXNAME
];
115 dns_rdatatype_t rdtype
;
116 dns_rdatatype_t qrdtype
;
117 dns_rdataclass_t rdclass
;
118 isc_boolean_t rdtypeset
;
119 isc_boolean_t rdclassset
;
120 char namespace[BUFSIZE
];
121 char onamespace
[BUFSIZE
];
122 isc_buffer_t namebuf
;
123 isc_buffer_t onamebuf
;
124 isc_buffer_t sendbuf
;
128 isc_interval_t interval
;
129 dns_message_t
*sendmsg
;
131 ISC_LINK(dig_lookup_t
) link
;
132 ISC_LIST(dig_query_t
) q
;
133 dig_query_t
*current_query
;
134 dig_serverlist_t my_server_list
;
135 dig_searchlist_t
*origin
;
137 isc_uint32_t retries
;
139 isc_uint16_t udpsize
;
140 isc_uint32_t ixfr_serial
;
141 isc_buffer_t rdatabuf
;
142 char rdatastore
[MXNAME
];
143 dst_context_t
*tsigctx
;
144 isc_buffer_t
*querysig
;
145 isc_uint32_t msgcounter
;
149 dig_lookup_t
*lookup
;
150 isc_boolean_t waiting_connect
,
157 isc_uint32_t first_rr_serial
;
158 isc_uint32_t second_rr_serial
;
159 isc_uint32_t rr_count
;
161 isc_bufferlist_t sendlist
,
164 isc_buffer_t recvbuf
,
171 ISC_LINK(dig_query_t
) link
;
172 isc_sockaddr_t sockaddr
;
173 isc_time_t time_sent
;
177 char servername
[MXNAME
];
178 ISC_LINK(dig_server_t
) link
;
181 struct dig_searchlist
{
183 ISC_LINK(dig_searchlist_t
) link
;
187 * Routines in dighost.c.
190 get_address(char *host
, in_port_t port
, isc_sockaddr_t
*sockaddr
);
193 get_reverse(char *reverse
, char *value
, isc_boolean_t ip6int
,
194 isc_boolean_t strict
);
197 fatal(const char *format
, ...) ISC_FORMAT_PRINTF(1, 2);
200 debug(const char *format
, ...) ISC_FORMAT_PRINTF(1, 2);
203 check_result(isc_result_t result
, const char *msg
);
206 setup_lookup(dig_lookup_t
*lookup
);
209 do_lookup(dig_lookup_t
*lookup
);
215 onrun_callback(isc_task_t
*task
, isc_event_t
*event
);
218 dhmain(int argc
, char **argv
);
227 requeue_lookup(dig_lookup_t
*lookold
, isc_boolean_t servers
);
230 make_empty_lookup(void);
233 clone_lookup(dig_lookup_t
*lookold
, isc_boolean_t servers
);
236 make_server(const char *servname
);
239 clone_server_list(dig_serverlist_t src
,
240 dig_serverlist_t
*dest
);
249 set_search_domain(char *domain
);
252 * Routines to be defined in dig.c, host.c, and nslookup.c.
256 printmessage(dig_query_t
*query
, dns_message_t
*msg
, isc_boolean_t headers
);
258 * Print the final result of the lookup.
262 received(int bytes
, isc_sockaddr_t
*from
, dig_query_t
*query
);
264 * Print a message about where and when the response
265 * was received from, like the final comment in the
270 trying(char *frm
, dig_lookup_t
*lookup
);
273 dighost_shutdown(void);
276 next_token(char **stringp
, const char *delim
);