Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / bin / dig / include / dig / dig.h
blobbfb3acb37c58ed2f748fe5948468a4722c1f57b8
1 /*
2 * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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.105.130.3 2008/12/16 02:59:46 jinmei Exp $ */
20 #ifndef DIG_H
21 #define DIG_H
23 /*! \file */
25 #include <dns/rdatalist.h>
27 #include <dst/dst.h>
29 #include <isc/boolean.h>
30 #include <isc/buffer.h>
31 #include <isc/bufferlist.h>
32 #include <isc/formatcheck.h>
33 #include <isc/lang.h>
34 #include <isc/list.h>
35 #include <isc/mem.h>
36 #include <isc/print.h>
37 #include <isc/sockaddr.h>
38 #include <isc/socket.h>
40 #define MXSERV 20
41 #define MXNAME (DNS_NAME_MAXTEXT+1)
42 #define MXRD 32
43 /*% Buffer Size */
44 #define BUFSIZE 512
45 #define COMMSIZE 0xffff
46 #ifndef RESOLV_CONF
47 /*% location of resolve.conf */
48 #define RESOLV_CONF "/etc/resolv.conf"
49 #endif
50 /*% output buffer */
51 #define OUTPUTBUF 32767
52 /*% Max RR Limit */
53 #define MAXRRLIMIT 0xffffffff
54 #define MAXTIMEOUT 0xffff
55 /*% Max number of tries */
56 #define MAXTRIES 0xffffffff
57 /*% Max number of dots */
58 #define MAXNDOTS 0xffff
59 /*% Max number of ports */
60 #define MAXPORT 0xffff
61 /*% Max serial number */
62 #define MAXSERIAL 0xffffffff
64 /*% Default TCP Timeout */
65 #define TCP_TIMEOUT 10
66 /*% Default UDP Timeout */
67 #define UDP_TIMEOUT 5
69 #define SERVER_TIMEOUT 1
71 #define LOOKUP_LIMIT 64
72 /*%
73 * Lookup_limit is just a limiter, keeping too many lookups from being
74 * created. It's job is mainly to prevent the program from running away
75 * in a tight loop of constant lookups. It's value is arbitrary.
79 * Defaults for the sigchase suboptions. Consolidated here because
80 * these control the layout of dig_lookup_t (among other things).
82 #ifdef DIG_SIGCHASE
83 #ifndef DIG_SIGCHASE_BU
84 #define DIG_SIGCHASE_BU 1
85 #endif
86 #ifndef DIG_SIGCHASE_TD
87 #define DIG_SIGCHASE_TD 1
88 #endif
89 #endif
91 ISC_LANG_BEGINDECLS
93 typedef struct dig_lookup dig_lookup_t;
94 typedef struct dig_query dig_query_t;
95 typedef struct dig_server dig_server_t;
96 #ifdef DIG_SIGCHASE
97 typedef struct dig_message dig_message_t;
98 #endif
99 typedef ISC_LIST(dig_server_t) dig_serverlist_t;
100 typedef struct dig_searchlist dig_searchlist_t;
102 /*% The dig_lookup structure */
103 struct dig_lookup {
104 isc_boolean_t
105 pending, /*%< Pending a successful answer */
106 waiting_connect,
107 doing_xfr,
108 ns_search_only, /*%< dig +nssearch, host -C */
109 identify, /*%< Append an "on server <foo>" message */
110 identify_previous_line, /*% Prepend a "Nameserver <foo>:"
111 message, with newline and tab */
112 ignore,
113 recurse,
114 aaonly,
115 adflag,
116 cdflag,
117 trace, /*% dig +trace */
118 trace_root, /*% initial query for either +trace or +nssearch */
119 tcp_mode,
120 ip6_int,
121 comments,
122 stats,
123 section_question,
124 section_answer,
125 section_authority,
126 section_additional,
127 servfail_stops,
128 new_search,
129 need_search,
130 done_as_is,
131 besteffort,
132 dnssec,
133 nsid; /*% Name Server ID (RFC 5001) */
134 #ifdef DIG_SIGCHASE
135 isc_boolean_t sigchase;
136 #if DIG_SIGCHASE_TD
137 isc_boolean_t do_topdown,
138 trace_root_sigchase,
139 rdtype_sigchaseset,
140 rdclass_sigchaseset;
141 /* Name we are going to validate RRset */
142 char textnamesigchase[MXNAME];
143 #endif
144 #endif
146 char textname[MXNAME]; /*% Name we're going to be looking up */
147 char cmdline[MXNAME];
148 dns_rdatatype_t rdtype;
149 dns_rdatatype_t qrdtype;
150 #if DIG_SIGCHASE_TD
151 dns_rdatatype_t rdtype_sigchase;
152 dns_rdatatype_t qrdtype_sigchase;
153 dns_rdataclass_t rdclass_sigchase;
154 #endif
155 dns_rdataclass_t rdclass;
156 isc_boolean_t rdtypeset;
157 isc_boolean_t rdclassset;
158 char namespace[BUFSIZE];
159 char onamespace[BUFSIZE];
160 isc_buffer_t namebuf;
161 isc_buffer_t onamebuf;
162 isc_buffer_t renderbuf;
163 char *sendspace;
164 dns_name_t *name;
165 isc_timer_t *timer;
166 isc_interval_t interval;
167 dns_message_t *sendmsg;
168 dns_name_t *oname;
169 ISC_LINK(dig_lookup_t) link;
170 ISC_LIST(dig_query_t) q;
171 dig_query_t *current_query;
172 dig_serverlist_t my_server_list;
173 dig_searchlist_t *origin;
174 dig_query_t *xfr_q;
175 isc_uint32_t retries;
176 int nsfound;
177 isc_uint16_t udpsize;
178 isc_int16_t edns;
179 isc_uint32_t ixfr_serial;
180 isc_buffer_t rdatabuf;
181 char rdatastore[MXNAME];
182 dst_context_t *tsigctx;
183 isc_buffer_t *querysig;
184 isc_uint32_t msgcounter;
185 dns_fixedname_t fdomain;
188 /*% The dig_query structure */
189 struct dig_query {
190 dig_lookup_t *lookup;
191 isc_boolean_t waiting_connect,
192 pending_free,
193 waiting_senddone,
194 first_pass,
195 first_soa_rcvd,
196 second_rr_rcvd,
197 first_repeat_rcvd,
198 recv_made,
199 warn_id;
200 isc_uint32_t first_rr_serial;
201 isc_uint32_t second_rr_serial;
202 isc_uint32_t msg_count;
203 isc_uint32_t rr_count;
204 char *servname;
205 char *userarg;
206 isc_bufferlist_t sendlist,
207 recvlist,
208 lengthlist;
209 isc_buffer_t recvbuf,
210 lengthbuf,
211 slbuf;
212 char *recvspace,
213 lengthspace[4],
214 slspace[4];
215 isc_socket_t *sock;
216 ISC_LINK(dig_query_t) link;
217 isc_sockaddr_t sockaddr;
218 isc_time_t time_sent;
219 isc_uint64_t byte_count;
220 isc_buffer_t sendbuf;
223 struct dig_server {
224 char servername[MXNAME];
225 char userarg[MXNAME];
226 ISC_LINK(dig_server_t) link;
229 struct dig_searchlist {
230 char origin[MXNAME];
231 ISC_LINK(dig_searchlist_t) link;
233 #ifdef DIG_SIGCHASE
234 struct dig_message {
235 dns_message_t *msg;
236 ISC_LINK(dig_message_t) link;
238 #endif
240 typedef ISC_LIST(dig_searchlist_t) dig_searchlistlist_t;
241 typedef ISC_LIST(dig_lookup_t) dig_lookuplist_t;
244 * Externals from dighost.c
247 extern dig_lookuplist_t lookup_list;
248 extern dig_serverlist_t server_list;
249 extern dig_searchlistlist_t search_list;
250 extern unsigned int extrabytes;
252 extern isc_boolean_t check_ra, have_ipv4, have_ipv6, specified_source,
253 usesearch, showsearch, qr;
254 extern in_port_t port;
255 extern unsigned int timeout;
256 extern isc_mem_t *mctx;
257 extern dns_messageid_t id;
258 extern int sendcount;
259 extern int ndots;
260 extern int lookup_counter;
261 extern int exitcode;
262 extern isc_sockaddr_t bind_address;
263 extern char keynametext[MXNAME];
264 extern char keyfile[MXNAME];
265 extern char keysecret[MXNAME];
266 extern dns_name_t *hmacname;
267 extern unsigned int digestbits;
268 #ifdef DIG_SIGCHASE
269 extern char trustedkey[MXNAME];
270 #endif
271 extern dns_tsigkey_t *key;
272 extern isc_boolean_t validated;
273 extern isc_taskmgr_t *taskmgr;
274 extern isc_task_t *global_task;
275 extern isc_boolean_t free_now;
276 extern isc_boolean_t debugging, memdebugging;
278 extern char *progname;
279 extern int tries;
280 extern int fatalexit;
281 #ifdef WITH_IDN
282 extern int idnoptions;
283 #endif
286 * Routines in dighost.c.
288 isc_result_t
289 get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
291 isc_result_t
292 get_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int,
293 isc_boolean_t strict);
295 void
296 fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
298 void
299 debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
301 void
302 check_result(isc_result_t result, const char *msg);
304 void
305 setup_lookup(dig_lookup_t *lookup);
307 void
308 destroy_lookup(dig_lookup_t *lookup);
310 void
311 do_lookup(dig_lookup_t *lookup);
313 void
314 start_lookup(void);
316 void
317 onrun_callback(isc_task_t *task, isc_event_t *event);
320 dhmain(int argc, char **argv);
322 void
323 setup_libs(void);
325 void
326 setup_system(void);
328 dig_lookup_t *
329 requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
331 dig_lookup_t *
332 make_empty_lookup(void);
334 dig_lookup_t *
335 clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
337 dig_server_t *
338 make_server(const char *servname, const char *userarg);
340 void
341 flush_server_list(void);
343 void
344 set_nameserver(char *opt);
346 void
347 clone_server_list(dig_serverlist_t src,
348 dig_serverlist_t *dest);
350 void
351 cancel_all(void);
353 void
354 destroy_libs(void);
356 void
357 set_search_domain(char *domain);
359 #ifdef DIG_SIGCHASE
360 void
361 clean_trustedkey(void);
362 #endif
365 * Routines to be defined in dig.c, host.c, and nslookup.c.
367 #ifdef DIG_SIGCHASE
368 isc_result_t
369 printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
370 isc_buffer_t *target);
371 #endif
373 isc_result_t
374 printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
375 /*%<
376 * Print the final result of the lookup.
379 void
380 received(int bytes, isc_sockaddr_t *from, dig_query_t *query);
381 /*%<
382 * Print a message about where and when the response
383 * was received from, like the final comment in the
384 * output of "dig".
387 void
388 trying(char *frm, dig_lookup_t *lookup);
390 void
391 dighost_shutdown(void);
393 char *
394 next_token(char **stringp, const char *delim);
396 #ifdef DIG_SIGCHASE
397 /* Chasing functions */
398 dns_rdataset_t *
399 chase_scanname(dns_name_t *name, dns_rdatatype_t type, dns_rdatatype_t covers);
400 void
401 chase_sig(dns_message_t *msg);
402 #endif
404 ISC_LANG_ENDDECLS
406 #endif