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