2000-04-19 23:23:31 +00:00
|
|
|
/*
|
2000-04-26 18:34:17 +00:00
|
|
|
* Copyright (C) 2000 Internet Software Consortium.
|
2000-04-19 23:23:31 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2000-06-16 18:00:05 +00:00
|
|
|
/* $Id: dig.h,v 1.23 2000/06/16 18:00:05 mws Exp $ */
|
2000-06-06 18:49:06 +00:00
|
|
|
|
2000-04-19 23:23:31 +00:00
|
|
|
#ifndef DIG_H
|
|
|
|
#define DIG_H
|
|
|
|
|
|
|
|
#define SDIG_BUFFER_SIZE 2048
|
|
|
|
#include <isc/lang.h>
|
|
|
|
#include <isc/socket.h>
|
|
|
|
#include <isc/buffer.h>
|
|
|
|
#include <isc/bufferlist.h>
|
|
|
|
#include <isc/sockaddr.h>
|
|
|
|
#include <isc/boolean.h>
|
|
|
|
#include <isc/mem.h>
|
|
|
|
#include <isc/list.h>
|
2000-04-26 19:36:40 +00:00
|
|
|
#include <isc/print.h>
|
2000-06-02 18:45:33 +00:00
|
|
|
#include <dns/rdatalist.h>
|
2000-06-06 22:50:44 +00:00
|
|
|
#include <dst/dst.h>
|
2000-04-19 23:23:31 +00:00
|
|
|
|
|
|
|
#define MXSERV 4
|
|
|
|
#define MXNAME 256
|
|
|
|
#define MXRD 32
|
|
|
|
#define BUFSIZE 512
|
2000-05-08 22:51:08 +00:00
|
|
|
#define COMMSIZE 32767
|
2000-04-19 23:23:31 +00:00
|
|
|
#define RESOLVCONF "/etc/resolv.conf"
|
2000-05-24 19:27:01 +00:00
|
|
|
#define OUTPUTBUF 32767
|
2000-05-06 01:16:07 +00:00
|
|
|
#define LOOKUP_LIMIT 64
|
|
|
|
/* Lookup_limit is just a limiter, keeping too many lookups from being
|
|
|
|
* created. It's job is mainly to prevent the program from running away
|
|
|
|
* in a tight loop of constant lookups. It's value is arbitrary.
|
|
|
|
*/
|
|
|
|
#define ROOTNS 1
|
|
|
|
/* Set the number of root servers to ask for information when running in
|
|
|
|
* trace mode.
|
|
|
|
* XXXMWS -- trace mode is currently semi-broken, and this number *MUST*
|
|
|
|
* be 1.
|
|
|
|
*/
|
2000-04-19 23:23:31 +00:00
|
|
|
|
|
|
|
ISC_LANG_BEGINDECLS
|
|
|
|
|
|
|
|
typedef struct dig_lookup dig_lookup_t;
|
|
|
|
typedef struct dig_query dig_query_t;
|
|
|
|
typedef struct dig_server dig_server_t;
|
2000-05-02 23:23:12 +00:00
|
|
|
typedef struct dig_searchlist dig_searchlist_t;
|
2000-04-19 23:23:31 +00:00
|
|
|
|
|
|
|
struct dig_lookup {
|
2000-05-12 01:02:37 +00:00
|
|
|
isc_boolean_t
|
|
|
|
pending, /* Pending a successful answer */
|
2000-04-20 19:09:11 +00:00
|
|
|
waiting_connect,
|
2000-04-28 21:41:19 +00:00
|
|
|
doing_xfr,
|
|
|
|
ns_search_only,
|
|
|
|
use_my_server_list,
|
2000-05-03 20:27:13 +00:00
|
|
|
identify,
|
2000-05-06 01:16:07 +00:00
|
|
|
recurse,
|
2000-05-08 22:51:08 +00:00
|
|
|
aaonly,
|
2000-06-16 18:00:05 +00:00
|
|
|
adflag,
|
|
|
|
cdflag,
|
2000-05-06 01:16:07 +00:00
|
|
|
trace,
|
2000-05-08 22:51:08 +00:00
|
|
|
trace_root,
|
2000-05-12 01:02:37 +00:00
|
|
|
defname,
|
|
|
|
tcp_mode,
|
|
|
|
comments,
|
|
|
|
stats,
|
|
|
|
section_question,
|
|
|
|
section_answer,
|
|
|
|
section_authority,
|
2000-05-24 19:49:51 +00:00
|
|
|
section_additional,
|
|
|
|
new_search;
|
2000-04-19 23:23:31 +00:00
|
|
|
char textname[MXNAME]; /* Name we're going to be looking up */
|
|
|
|
char rttext[MXRD]; /* rdata type text */
|
|
|
|
char rctext[MXRD]; /* rdata class text */
|
|
|
|
char namespace[BUFSIZE];
|
2000-05-02 23:23:12 +00:00
|
|
|
char onamespace[BUFSIZE];
|
2000-04-19 23:23:31 +00:00
|
|
|
isc_buffer_t namebuf;
|
2000-05-02 23:23:12 +00:00
|
|
|
isc_buffer_t onamebuf;
|
2000-04-19 23:23:31 +00:00
|
|
|
isc_buffer_t sendbuf;
|
|
|
|
char sendspace[COMMSIZE];
|
|
|
|
dns_name_t *name;
|
|
|
|
isc_timer_t *timer;
|
|
|
|
isc_interval_t interval;
|
|
|
|
dns_message_t *sendmsg;
|
2000-05-02 23:23:12 +00:00
|
|
|
dns_name_t *oname;
|
2000-04-19 23:23:31 +00:00
|
|
|
ISC_LINK(dig_lookup_t) link;
|
|
|
|
ISC_LIST(dig_query_t) q;
|
2000-04-28 21:41:19 +00:00
|
|
|
ISC_LIST(dig_server_t) my_server_list;
|
2000-05-02 23:23:12 +00:00
|
|
|
dig_searchlist_t *origin;
|
2000-04-20 19:09:11 +00:00
|
|
|
dig_query_t *xfr_q;
|
2000-05-02 23:23:12 +00:00
|
|
|
int retries;
|
2000-05-06 01:16:07 +00:00
|
|
|
int nsfound;
|
2000-05-08 22:51:08 +00:00
|
|
|
isc_uint16_t udpsize;
|
2000-06-02 18:45:33 +00:00
|
|
|
isc_uint32_t ixfr_serial;
|
|
|
|
isc_buffer_t rdatabuf;
|
|
|
|
char rdatastore[MXNAME];
|
2000-06-06 22:50:44 +00:00
|
|
|
dst_context_t *tsigctx;
|
|
|
|
isc_buffer_t *querysig;
|
2000-06-07 00:13:57 +00:00
|
|
|
isc_uint32_t msgcounter;
|
2000-04-19 23:23:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dig_query {
|
|
|
|
dig_lookup_t *lookup;
|
|
|
|
isc_boolean_t working,
|
|
|
|
waiting_connect,
|
|
|
|
first_pass,
|
2000-06-02 18:45:33 +00:00
|
|
|
first_soa_rcvd,
|
|
|
|
second_rr_rcvd,
|
|
|
|
first_repeat_rcvd;
|
|
|
|
isc_uint32_t first_rr_serial;
|
|
|
|
isc_uint32_t second_rr_serial;
|
2000-05-02 23:23:12 +00:00
|
|
|
int retries;
|
2000-04-19 23:23:31 +00:00
|
|
|
char *servname;
|
|
|
|
isc_bufferlist_t sendlist,
|
|
|
|
recvlist,
|
|
|
|
lengthlist;
|
|
|
|
isc_buffer_t recvbuf,
|
2000-04-20 19:09:11 +00:00
|
|
|
lengthbuf,
|
|
|
|
slbuf;
|
2000-04-19 23:23:31 +00:00
|
|
|
char recvspace[COMMSIZE],
|
2000-04-20 19:09:11 +00:00
|
|
|
lengthspace[4],
|
|
|
|
slspace[4];
|
2000-04-19 23:23:31 +00:00
|
|
|
isc_socket_t *sock;
|
|
|
|
ISC_LINK(dig_query_t) link;
|
|
|
|
isc_sockaddr_t sockaddr;
|
2000-05-02 23:23:12 +00:00
|
|
|
isc_time_t time_sent;
|
2000-04-19 23:23:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dig_server {
|
|
|
|
char servername[MXNAME];
|
|
|
|
ISC_LINK(dig_server_t) link;
|
|
|
|
};
|
|
|
|
|
2000-05-02 23:23:12 +00:00
|
|
|
struct dig_searchlist {
|
|
|
|
char origin[MXNAME];
|
|
|
|
ISC_LINK(dig_searchlist_t) link;
|
|
|
|
};
|
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
/*
|
|
|
|
* Routines in dighost.c.
|
|
|
|
*/
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
2000-05-16 17:53:35 +00:00
|
|
|
get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr);
|
|
|
|
void
|
2000-06-01 18:49:22 +00:00
|
|
|
fatal(const char *format, ...);
|
2000-04-29 00:12:56 +00:00
|
|
|
void
|
2000-06-01 18:49:22 +00:00
|
|
|
debug(const char *format, ...);
|
2000-05-05 18:22:16 +00:00
|
|
|
void
|
2000-06-01 18:49:22 +00:00
|
|
|
check_result(isc_result_t result, const char *msg);
|
2000-04-26 18:34:17 +00:00
|
|
|
isc_boolean_t
|
2000-06-01 18:49:22 +00:00
|
|
|
isclass(char *text);
|
2000-04-26 18:34:17 +00:00
|
|
|
isc_boolean_t
|
2000-06-01 18:49:22 +00:00
|
|
|
istype(char *text);
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
|
|
|
setup_lookup(dig_lookup_t *lookup);
|
|
|
|
void
|
2000-05-12 01:02:37 +00:00
|
|
|
do_lookup(dig_lookup_t *lookup);
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
2000-05-12 01:02:37 +00:00
|
|
|
start_lookup (void);
|
2000-05-02 23:23:12 +00:00
|
|
|
void
|
|
|
|
send_udp(dig_lookup_t *lookup);
|
2000-05-09 18:05:13 +00:00
|
|
|
int
|
|
|
|
dhmain(int argc, char **argv);
|
|
|
|
void
|
|
|
|
setup_libs(void);
|
|
|
|
void
|
|
|
|
setup_system(void);
|
|
|
|
void
|
|
|
|
free_lists(int exitcode);
|
2000-06-01 18:49:22 +00:00
|
|
|
dig_lookup_t *
|
|
|
|
requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers);
|
2000-05-09 18:05:13 +00:00
|
|
|
|
2000-04-26 18:34:17 +00:00
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
/*
|
|
|
|
* Routines needed in dig.c and host.c.
|
|
|
|
*/
|
2000-04-26 18:34:17 +00:00
|
|
|
isc_result_t
|
2000-06-01 18:49:22 +00:00
|
|
|
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
2000-05-02 23:23:12 +00:00
|
|
|
received(int bytes, int frmsize, char *frm, dig_query_t *query);
|
|
|
|
void
|
|
|
|
trying(int frmsize, char *frm, dig_lookup_t *lookup);
|
2000-05-12 01:02:37 +00:00
|
|
|
void
|
|
|
|
dighost_shutdown(void);
|
2000-04-26 18:34:17 +00:00
|
|
|
|
2000-04-19 23:23:31 +00:00
|
|
|
ISC_LANG_ENDDECLS
|
|
|
|
|
|
|
|
#endif
|