1 #ifndef __ARES_PRIVATE_H
2 #define __ARES_PRIVATE_H
6 /* Copyright 1998 by the Massachusetts Institute of Technology.
8 * Permission to use, copy, modify, and distribute this
9 * software and its documentation for any purpose and without
10 * fee is hereby granted, provided that the above copyright
11 * notice appear in all copies and that both that copyright
12 * notice and this permission notice appear in supporting
13 * documentation, and that the name of M.I.T. not be used in
14 * advertising or publicity pertaining to distribution of the
15 * software without specific, written prior permission.
16 * M.I.T. makes no representations about the suitability of
17 * this software for any purpose. It is provided "as is"
18 * without express or implied warranty.
22 #include <sys/types.h>
24 #if !defined(WIN32) || defined(WATT32)
25 #include <netinet/in.h>
26 /* We define closesocket() here so that we can use this function all over
27 the source code for closing sockets. */
28 #define closesocket(x) close(x)
33 #include <sys/ioctl.h>
35 #define closesocket(s) close_s(s)
36 #define writev(s,v,c) writev_s(s,v,c)
43 #define DEFAULT_TIMEOUT 5
44 #define DEFAULT_TRIES 4
46 #define INADDR_NONE 0xffffffff
49 #if defined(WIN32) && !defined(WATT32)
51 #define IS_NT() ((int)GetVersion() > 0)
52 #define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
53 #define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
54 #define NAMESERVER "NameServer"
55 #define DHCPNAMESERVER "DhcpNameServer"
56 #define DATABASEPATH "DatabasePath"
57 #define WIN_PATH_HOSTS "\\hosts"
61 #define PATH_RESOLV_CONF "/dev/ENV/etc/resolv.conf"
63 #elif defined(NETWARE)
65 #define PATH_RESOLV_CONF "sys:/etc/resolv.cfg"
66 #define PATH_HOSTS "sys:/etc/hosts"
68 #elif defined(__riscos__)
70 #define PATH_HOSTS "InetDBase:Hosts"
74 #define PATH_RESOLV_CONF "/etc/resolv.conf"
76 #define PATH_HOSTS "/etc/inet/hosts"
78 #define PATH_HOSTS "/etc/hosts"
83 #include "ares_ipv6.h"
86 /* Remaining data to send */
87 const unsigned char *data;
90 /* Next request in queue */
91 struct send_request *next;
96 ares_socket_t udp_socket;
97 ares_socket_t tcp_socket;
99 /* Mini-buffer for reading the length word */
100 unsigned char tcp_lenbuf[2];
104 /* Buffer for reading actual TCP data */
105 unsigned char *tcp_buffer;
108 /* TCP output queue */
109 struct send_request *qhead;
110 struct send_request *qtail;
114 /* Query ID from qbuf, for faster lookup, and current timeout */
118 /* Query buf with length at beginning, for TCP transmission */
119 unsigned char *tcpbuf;
122 /* Arguments passed to ares_send() (qbuf points into tcpbuf) */
123 const unsigned char *qbuf;
125 ares_callback callback;
135 /* Next query in chain */
139 /* An IP address pattern; matches an IP address X if X & mask == addr */
140 #define PATTERN_MASK 0x1
141 #define PATTERN_CIDR 0x2
144 struct in_addr addr4;
145 struct in6_addr addr6;
149 union ares_addr addr;
152 union ares_addr addr;
159 struct ares_channeldata {
160 /* Configuration data */
169 struct apattern *sortlist;
173 /* Server addresses and communications state */
174 struct server_state *servers;
177 /* ID to use for next query */
178 unsigned short next_id;
181 struct query *queries;
183 ares_sock_state_cb sock_state_cb;
184 void *sock_state_cb_data;
187 void ares__send_query(ares_channel channel, struct query *query, time_t now);
188 void ares__close_sockets(ares_channel channel, struct server_state *server);
189 int ares__get_hostent(FILE *fp, int family, struct hostent **host);
190 int ares__read_line(FILE *fp, char **buf, int *bufsize);
192 #define SOCK_STATE_CALLBACK(c, s, r, w) \
194 if ((c)->sock_state_cb) \
195 (c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \
199 /* This is low-level hard-hacking memory leak tracking and similar. Using the
200 libcurl lowlevel code from within library is ugly and only works when
201 c-ares is built and linked with a similarly debug-build libcurl, but we do
202 this anyway for convenience. */
203 #include "../lib/memdebug.h"
206 #endif /* __ARES_PRIVATE_H */