Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / bin / dig / include / dig / dig.h
blob3b2d9e6a47abde61aeefbc53bbeebb7f20f183f4
1 /*
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 $ */
20 #ifndef DIG_H
21 #define DIG_H
23 #include <dns/rdatalist.h>
25 #include <dst/dst.h>
27 #include <isc/boolean.h>
28 #include <isc/buffer.h>
29 #include <isc/bufferlist.h>
30 #include <isc/formatcheck.h>
31 #include <isc/lang.h>
32 #include <isc/list.h>
33 #include <isc/mem.h>
34 #include <isc/print.h>
35 #include <isc/sockaddr.h>
36 #include <isc/socket.h>
38 #define MXSERV 6
39 #define MXNAME (DNS_NAME_MAXTEXT+1)
40 #define MXRD 32
41 #define BUFSIZE 512
42 #define COMMSIZE 0xffff
43 #ifndef RESOLV_CONF
44 #define RESOLV_CONF "/etc/resolv.conf"
45 #endif
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
58 #define UDP_TIMEOUT 5
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.
69 #define ROOTNS 1
71 * Set the number of root servers to ask for information when running in
72 * trace mode.
73 * XXXMWS -- trace mode is currently semi-broken, and this number *MUST*
74 * be 1.
77 ISC_LANG_BEGINDECLS
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;
85 struct dig_lookup {
86 isc_boolean_t
87 pending, /* Pending a successful answer */
88 waiting_connect,
89 doing_xfr,
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 */
94 ignore,
95 recurse,
96 aaonly,
97 adflag,
98 cdflag,
99 trace, /* dig +trace */
100 trace_root, /* initial query for either +trace or +nssearch */
101 tcp_mode,
102 ip6_int,
103 comments,
104 stats,
105 section_question,
106 section_answer,
107 section_authority,
108 section_additional,
109 servfail_stops,
110 new_search,
111 besteffort,
112 dnssec;
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;
125 char *sendspace;
126 dns_name_t *name;
127 isc_timer_t *timer;
128 isc_interval_t interval;
129 dns_message_t *sendmsg;
130 dns_name_t *oname;
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;
136 dig_query_t *xfr_q;
137 isc_uint32_t retries;
138 int nsfound;
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;
148 struct dig_query {
149 dig_lookup_t *lookup;
150 isc_boolean_t waiting_connect,
151 first_pass,
152 first_soa_rcvd,
153 second_rr_rcvd,
154 first_repeat_rcvd,
155 recv_made,
156 warn_id;
157 isc_uint32_t first_rr_serial;
158 isc_uint32_t second_rr_serial;
159 isc_uint32_t rr_count;
160 char *servname;
161 isc_bufferlist_t sendlist,
162 recvlist,
163 lengthlist;
164 isc_buffer_t recvbuf,
165 lengthbuf,
166 slbuf;
167 char *recvspace,
168 lengthspace[4],
169 slspace[4];
170 isc_socket_t *sock;
171 ISC_LINK(dig_query_t) link;
172 isc_sockaddr_t sockaddr;
173 isc_time_t time_sent;
176 struct dig_server {
177 char servername[MXNAME];
178 ISC_LINK(dig_server_t) link;
181 struct dig_searchlist {
182 char origin[MXNAME];
183 ISC_LINK(dig_searchlist_t) link;
187 * Routines in dighost.c.
189 void
190 get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
192 isc_result_t
193 get_reverse(char *reverse, char *value, isc_boolean_t ip6int,
194 isc_boolean_t strict);
196 void
197 fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
199 void
200 debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
202 void
203 check_result(isc_result_t result, const char *msg);
205 void
206 setup_lookup(dig_lookup_t *lookup);
208 void
209 do_lookup(dig_lookup_t *lookup);
211 void
212 start_lookup(void);
214 void
215 onrun_callback(isc_task_t *task, isc_event_t *event);
218 dhmain(int argc, char **argv);
220 void
221 setup_libs(void);
223 void
224 setup_system(void);
226 dig_lookup_t *
227 requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
229 dig_lookup_t *
230 make_empty_lookup(void);
232 dig_lookup_t *
233 clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
235 dig_server_t *
236 make_server(const char *servname);
238 void
239 clone_server_list(dig_serverlist_t src,
240 dig_serverlist_t *dest);
242 void
243 cancel_all(void);
245 void
246 destroy_libs(void);
248 void
249 set_search_domain(char *domain);
252 * Routines to be defined in dig.c, host.c, and nslookup.c.
255 isc_result_t
256 printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
258 * Print the final result of the lookup.
261 void
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
266 * output of "dig".
269 void
270 trying(char *frm, dig_lookup_t *lookup);
272 void
273 dighost_shutdown(void);
275 char *
276 next_token(char **stringp, const char *delim);
278 ISC_LANG_ENDDECLS
280 #endif