sipxtacklib  Version 3.3
resolv.h
Go to the documentation of this file.
1 /*
2  * ++Copyright++ 1983, 1987, 1989, 1993
3  * -
4  * Copyright (c) 1983, 1987, 1989, 1993
5  * The Regents of the University of California. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  * must display the following acknowledgement:
17  * This product includes software developed by the University of
18  * California, Berkeley and its contributors.
19  * 4. Neither the name of the University nor the names of its contributors
20  * may be used to endorse or promote products derived from this software
21  * without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  * -
35  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
36  *
37  * Permission to use, copy, modify, and distribute this software for any
38  * purpose with or without fee is hereby granted, provided that the above
39  * copyright notice and this permission notice appear in all copies, and that
40  * the name of Digital Equipment Corporation not be used in advertising or
41  * publicity pertaining to distribution of the document or software without
42  * specific, written prior permission.
43  *
44  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
45  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
46  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
47  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
48  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
49  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
50  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
51  * SOFTWARE.
52  * -
53  * --Copyright--
54  */
55 
56 /*
57  * @(#)resolv.h 8.1 (Berkeley) 6/2/93
58  * $Id: resolv.h,v 8.5 1995/12/22 10:20:27 vixie Exp
59  */
60 
61 #ifndef _RESOLV_H_
62 #define _RESOLV_H_
63 
64 #ifdef WINCE
65 # include <types.h>
66 #else
67 # include <sys/types.h>
68 #endif
69 
70 #include <stdio.h>
71 #include <winsock2.h>
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 /*
78  * revision information. this is the release date in YYYYMMDD format.
79  * it can change every day so the right thing to do with it is use it
80  * in preprocessor commands such as "#if (__RES > 19931104)". do not
81  * compare for equality; rather, use it to determine whether your resolver
82  * is new enough to contain a certain feature.
83  */
84 
85 #define __RES 19951031
86 
87 /*
88  * Resolver configuration file.
89  * Normally not present, but may contain the address of the
90  * inital name server(s) to query and the domain search list.
91  */
92 
93 #ifndef _PATH_RESCONF
94 #define _PATH_RESCONF "/etc/resolv.conf"
95 #endif
96 
97 /*
98  * Global defines and variables for resolver stub.
99  */
100 #define MAXNS 3 /* max # name servers we'll track */
101 #define MAXDFLSRCH 3 /* # default domain levels to try */
102 #define MAXDNSRCH 6 /* max # domains in search path */
103 #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
104 #define MAXDNSLUS 4 /* max # of host lookup types */
105 
106 #define RES_TIMEOUT 5 /* min. seconds between retries */
107 #define MAXRESOLVSORT 10 /* number of net to sort on */
108 #define RES_MAXNDOTS 15 /* should reflect bit field size */
109 
110 struct __res_state {
111  int retrans; /* retransmition time interval */
112  int retry; /* number of times to retransmit */
113  u_long options; /* option flags - see below. */
114  int nscount; /* number of name servers */
115  struct sockaddr_in
116  nsaddr_list[MAXNS]; /* address of name server */
117 #define nsaddr nsaddr_list[0] /* for backward compatibility */
118  u_short id; /* current packet id */
119  char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
120  char defdname[MAXDNAME]; /* default domain */
121  u_long pfcode; /* RES_PRF_ flags - see below. */
122  unsigned ndots:4; /* threshold for initial abs. query */
123  unsigned nsort:4; /* number of elements in sort_list[] */
124  char unused[3];
125  struct {
126  struct in_addr addr;
130 };
131 
132 /*
133  * Resolver options (keep these in synch with res_debug.c, please)
134  */
135 #define RES_INIT 0x00000001 /* address initialized */
136 #define RES_DEBUG 0x00000002 /* print debug messages */
137 #define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
138 #define RES_USEVC 0x00000008 /* use virtual circuit */
139 #define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
140 #define RES_IGNTC 0x00000020 /* ignore trucation errors */
141 #define RES_RECURSE 0x00000040 /* recursion desired */
142 #define RES_DEFNAMES 0x00000080 /* use default domain name */
143 #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
144 #define RES_DNSRCH 0x00000200 /* search up local domain tree */
145 #define RES_INSECURE1 0x00000400 /* type 1 security disabled */
146 #define RES_INSECURE2 0x00000800 /* type 2 security disabled */
147 #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
148 #define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
149 #define RES_NOTLDQUERY 0x00000000 /* do not know where to find it */
150 
151 #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
152 
153 /*
154  * Resolver "pfcode" values. Used by dig.
155  */
156 #define RES_PRF_STATS 0x00000001
157 /* 0x00000002 */
158 #define RES_PRF_CLASS 0x00000004
159 #define RES_PRF_CMD 0x00000008
160 #define RES_PRF_QUES 0x00000010
161 #define RES_PRF_ANS 0x00000020
162 #define RES_PRF_AUTH 0x00000040
163 #define RES_PRF_ADD 0x00000080
164 #define RES_PRF_HEAD1 0x00000100
165 #define RES_PRF_HEAD2 0x00000200
166 #define RES_PRF_TTLID 0x00000400
167 #define RES_PRF_HEADX 0x00000800
168 #define RES_PRF_QUERY 0x00001000
169 #define RES_PRF_REPLY 0x00002000
170 #define RES_PRF_INIT 0x00004000
171 /* 0x00008000 */
172 
173 #ifdef __STDC__
174 #define __P(x) x
175 #else
176 #define __P(x) ()
177 #endif
178 
179 /* hooks are still experimental as of 4.9.2 */
182 
183 typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns,
184  const u_char **query,
185  int *querylen,
186  u_char *ans,
187  int anssiz,
188  int *resplen);
189 
190 typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns,
191  const u_char *query,
192  int querylen,
193  u_char *ans,
194  int anssiz,
195  int *resplen);
196 
197 extern struct __res_state _sip_res;
198 
199 /* Private routines shared between libc/net, named, nslookup and others. */
200 #define dn_skipname __dn_skipname
201 #define fp_query __fp_query
202 #define fp_nquery __fp_nquery
203 #define hostalias __hostalias
204 #define putlong __putlong
205 #define putshort __putshort
206 #define p_class __p_class
207 #define p_time __p_time
208 #define p_type __p_type
209 #define p_cdnname __p_cdnname
210 #define p_cdname __p_cdname
211 #define p_fqname __p_fqname
212 #define p_rr __p_rr
213 #define p_option __p_option
214 #define res_randomid __res_randomid
215 #define res_isourserver __res_isourserver
216 #define res_nameinquery __res_nameinquery
217 #define res_queriesmatch __res_queriesmatch
218 
219 int __dn_skipname(const u_char *, const u_char *);
220 void __fp_resstat(struct __res_state *, FILE *);
221 void __fp_query(const u_char *, FILE *);
222 void __fp_nquery(const u_char *, int, FILE *);
223 char *__hostalias(const char *);
224 void __putlong(u_int32, u_char *);
225 void __putshort(u_int16, u_char *);
226 char *__p_time(u_int32);
227 void __p_query(const u_char *);
228 const u_char *__p_cdnname(const u_char *, const u_char *, int, FILE *);
229 const u_char *__p_cdname(const u_char *, const u_char *, FILE *);
230 const u_char *__p_fqname(const u_char *, const u_char *, FILE *);
231 const u_char *__p_rr(const u_char *, const u_char *, FILE *);
232 const char *__p_type(int);
233 const char *__p_class(int);
234 const char *__p_option(u_long option);
235 int dn_comp(const char *, u_char *, int, u_char **, u_char **);
236 int dn_expand(const u_char *, const u_char *, const u_char *,
237  char *, int);
238 int res_init(void);
239 int res_init_ip(const char* szIp);
240 u_int16 res_randomid(void);
241 int res_query(const char *, int, int, u_char *, int);
242 int res_search(const char *, int, int, u_char *, int);
243 int res_local_querydomain(const char *, const char *, int, int,
244  u_char *, int);
245 int res_mkquery(int, const char *, int, int, const u_char *, int,
246  const u_char *, u_char *, int);
247 int res_send(const u_char *, int, u_char *, int);
248 int res_isourserver(const struct sockaddr_in *);
249 int res_nameinquery(const char *, int, int,
250  const u_char *, const u_char *);
251 int res_queriesmatch(const u_char *, const u_char *,
252  const u_char *, const u_char *);
253 /* XXX - these last two don't belong in the resolver */
254 u_int inet_nsap_addr(const char *, u_char *, int maxlen);
255 char *inet_nsap_ntoa(int, const u_char *, char *ascii);
256 
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* !_RESOLV_H_ */
res_sendhookact(* res_send_rhook)(const struct sockaddr_in *ns, const u_char *query, int querylen, u_char *ans, int anssiz, int *resplen)
Definition: resolv.h:190
Definition: resolv.h:180
int __dn_skipname(const u_char *, const u_char *)
void __fp_resstat(struct __res_state *, FILE *)
int res_init_ip(const char *szIp)
char * inet_nsap_ntoa(int, const u_char *, char *ascii)
#define MAXDNSRCH
Definition: resolv.h:102
char unused[3]
Definition: resolv.h:124
const u_char * __p_fqname(const u_char *, const u_char *, FILE *)
int nscount
Definition: resolv.h:114
struct in_addr addr
Definition: resolv.h:126
Definition: resolv.h:180
#define res_randomid
Definition: resolv.h:214
#define MAXNS
Definition: resolv.h:100
u_long options
Definition: resolv.h:113
int res_query(const char *, int, int, u_char *, int)
Definition: resolv.h:180
const char * __p_type(int)
void __fp_nquery(const u_char *, int, FILE *)
int res_search(const char *, int, int, u_char *, int)
void __fp_query(const u_char *, FILE *)
void __putlong(u_int32, u_char *)
const char * __p_option(u_long option)
unsigned ndots
Definition: resolv.h:122
u_int32 mask
Definition: resolv.h:127
char * dnsrch[MAXDNSRCH+1]
Definition: resolv.h:119
int dn_expand(const u_char *, const u_char *, const u_char *, char *, int)
int retrans
Definition: resolv.h:111
#define MAXDNSLUS
Definition: resolv.h:104
int res_mkquery(int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int)
const char * __p_class(int)
void __p_query(const u_char *)
char * __p_time(u_int32)
#define res_nameinquery
Definition: resolv.h:216
unsigned short u_int16
Definition: types.h:57
int retry
Definition: resolv.h:112
#define MAXRESOLVSORT
Definition: resolv.h:107
char * __hostalias(const char *)
#define res_queriesmatch
Definition: resolv.h:217
Definition: resolv.h:110
u_short id
Definition: resolv.h:118
void __putshort(u_int16, u_char *)
unsigned int u_int32
Definition: types.h:56
int res_send(const u_char *, int, u_char *, int)
unsigned nsort
Definition: resolv.h:123
Definition: resolv.h:180
int dn_comp(const char *, u_char *, int, u_char **, u_char **)
const u_char * __p_cdname(const u_char *, const u_char *, FILE *)
int res_local_querydomain(const char *, const char *, int, int, u_char *, int)
char defdname[MAXDNAME]
Definition: resolv.h:120
struct __res_state::@0 sort_list[MAXRESOLVSORT]
struct __res_state _sip_res
struct sockaddr_in nsaddr_list[MAXNS]
Definition: resolv.h:115
u_int inet_nsap_addr(const char *, u_char *, int maxlen)
Definition: resolv.h:180
res_sendhookact(* res_send_qhook)(struct sockaddr_in *const *ns, const u_char **query, int *querylen, u_char *ans, int anssiz, int *resplen)
Definition: resolv.h:183
char lookups[MAXDNSLUS]
Definition: resolv.h:129
#define MAXDNAME
Definition: nameser.h:84
int res_init(void)
#define res_isourserver
Definition: resolv.h:215
const u_char * __p_cdnname(const u_char *, const u_char *, int, FILE *)
res_sendhookact
Definition: resolv.h:180
u_long pfcode
Definition: resolv.h:121
const u_char * __p_rr(const u_char *, const u_char *, FILE *)

sipXtackLib home page