]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - libares/ares_private.h
need automake as a build-dep, even though we don't use most of it
[1ts-debian.git] / libares / ares_private.h
1 /* $Id: ares_private.h,v 1.3 1998/09/22 01:46:11 ghudson Exp $ */
2
3 /* Copyright 1998 by the Massachusetts Institute of Technology.
4  *
5  * Permission to use, copy, modify, and distribute this
6  * software and its documentation for any purpose and without
7  * fee is hereby granted, provided that the above copyright
8  * notice appear in all copies and that both that copyright
9  * notice and this permission notice appear in supporting
10  * documentation, and that the name of M.I.T. not be used in
11  * advertising or publicity pertaining to distribution of the
12  * software without specific, written prior permission.
13  * M.I.T. makes no representations about the suitability of
14  * this software for any purpose.  It is provided "as is"
15  * without express or implied warranty.
16  */
17
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include <netinet/in.h>
21
22 #define DEFAULT_TIMEOUT         5
23 #define DEFAULT_TRIES           4
24 #ifndef INADDR_NONE
25 #define INADDR_NONE 0xffffffff
26 #endif
27
28 #define PATH_RESOLV_CONF        "/etc/resolv.conf"
29 #ifdef ETC_INET
30 #define PATH_HOSTS              "/etc/inet/hosts"
31 #else
32 #define PATH_HOSTS              "/etc/hosts"
33 #endif
34
35 struct send_request {
36   /* Remaining data to send */
37   const char *data;
38   int len;
39
40   /* Next request in queue */
41   struct send_request *next;
42 };
43
44 struct server_state {
45   struct in_addr addr;
46   int udp_socket;
47   int tcp_socket;
48
49   /* Mini-buffer for reading the length word */
50   unsigned char tcp_lenbuf[2];
51   int tcp_lenbuf_pos;
52   int tcp_length;
53
54   /* Buffer for reading actual TCP data */
55   unsigned char *tcp_buffer;
56   int tcp_buffer_pos;
57
58   /* TCP output queue */
59   struct send_request *qhead;
60   struct send_request *qtail;
61 };
62
63 struct query {
64   /* Query ID from qbuf, for faster lookup, and current timeout */
65   unsigned short qid;
66   time_t timeout;
67
68   /* Query buf with length at beginning, for TCP transmission */
69   char *tcpbuf;
70   int tcplen;
71
72   /* Arguments passed to ares_send() (qbuf points into tcpbuf) */
73   const char *qbuf;
74   int qlen;
75   ares_callback callback;
76   void *arg;
77
78   /* Query status */
79   int try;
80   int server;
81   int *skip_server;
82   int using_tcp;
83   int error_status;
84
85   /* Next query in chain */
86   struct query *next;
87 };
88
89 /* An IP address pattern; matches an IP address X if X & mask == addr */
90 struct apattern {
91   struct in_addr addr;
92   struct in_addr mask;
93 };
94
95 struct ares_channeldata {
96   /* Configuration data */
97   int flags;
98   int timeout;
99   int tries;
100   int ndots;
101   int udp_port;
102   int tcp_port;
103   char **domains;
104   int ndomains;
105   struct apattern *sortlist;
106   int nsort;
107   char *lookups;
108
109   /* Server addresses and communications state */
110   struct server_state *servers;
111   int nservers;
112
113   /* ID to use for next query */
114   unsigned short next_id;
115
116   /* Active queries */
117   struct query *queries;
118 };
119
120 void ares__send_query(ares_channel channel, struct query *query, time_t now);
121 void ares__close_sockets(struct server_state *server);
122 int ares__get_hostent(FILE *fp, struct hostent **host);
123 int ares__read_line(FILE *fp, char **buf, int *bufsize);