source: trunk/athena/lib/ares/ares_private.h @ 22567

Revision 22567, 3.3 KB checked in by ghudson, 18 years ago (diff)
Fix a bunch of signed/unsigned char conflicts. This requires changing the argument type of ares_free_string to a void *. Hopefully that doesn't create any compatibility issues.
Line 
1/* $Id: ares_private.h,v 1.6 2006-11-27 20:42:31 ghudson Exp $ */
2
3/* Copyright 1998, 2002 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
35struct send_request {
36  /* Remaining data to send */
37  const unsigned char *data;
38  int len;
39
40  /* Next request in queue */
41  struct send_request *next;
42};
43
44struct 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  /* Readable/writable flags for ares_process() */
63  int udp_readable;
64  int tcp_readable;
65  int tcp_writable;
66};
67
68struct query {
69  /* Query ID from qbuf, for faster lookup, and current timeout */
70  unsigned short qid;
71  time_t timeout;
72
73  /* Query buf with length at beginning, for TCP transmission */
74  unsigned char *tcpbuf;
75  int tcplen;
76
77  /* Arguments passed to ares_send() (qbuf points into tcpbuf) */
78  const unsigned char *qbuf;
79  int qlen;
80  ares_callback callback;
81  void *arg;
82
83  /* Query status */
84  int try;
85  int server;
86  int *skip_server;
87  int using_tcp;
88  int error_status;
89
90  /* Next query in chain */
91  struct query *next;
92};
93
94/* An IP address pattern; matches an IP address X if X & mask == addr */
95struct apattern {
96  struct in_addr addr;
97  struct in_addr mask;
98};
99
100struct ares_channeldata {
101  /* Configuration data */
102  int flags;
103  int timeout;
104  int tries;
105  int ndots;
106  int udp_port;
107  int tcp_port;
108  char **domains;
109  int ndomains;
110  struct apattern *sortlist;
111  int nsort;
112  char *lookups;
113
114  /* Server addresses and communications state */
115  struct server_state *servers;
116  int nservers;
117
118  /* ID to use for next query */
119  unsigned short next_id;
120
121  /* Active queries */
122  struct query *queries;
123};
124
125void ares__send_query(ares_channel channel, struct query *query, time_t now);
126void ares__close_sockets(struct server_state *server);
127int ares__get_hostent(FILE *fp, struct hostent **host);
128int ares__read_line(FILE *fp, char **buf, int *bufsize);
129void ares__free_questions(struct ares_dns_question *questions, int count);
130void ares__free_question(struct ares_dns_question *question);
131void ares__free_section(struct ares_dns_section *section);
132void ares__free_rr(struct ares_dns_rr *rr);
Note: See TracBrowser for help on using the repository browser.