| 1 | /* Modified for EMX by hv 1994,1996
|
|---|
| 2 | * Modified for gcc by bird 2003
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
|
|---|
| 5 | * 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 | * from: @(#)resolv.h 5.15 (Berkeley) 4/3/91
|
|---|
| 36 | * resolv.h,v 1.4 2003/07/11 11:39:47 bird Exp
|
|---|
| 37 | */
|
|---|
| 38 |
|
|---|
| 39 | #ifndef _RESOLV_H_
|
|---|
| 40 | #define _RESOLV_H_
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | #if defined (__cplusplus)
|
|---|
| 44 | extern "C" {
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | /* toolkit includes a bunch of headers */
|
|---|
| 48 | #ifndef TCPV40HDRS
|
|---|
| 49 | #include <sys/param.h>
|
|---|
| 50 | #include <types.h>
|
|---|
| 51 | #include <sys/cdefs.h>
|
|---|
| 52 | #include <stdio.h>
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | /*
|
|---|
| 56 | * Revision information. This is the release date in YYYYMMDD format.
|
|---|
| 57 | * It can change every day so the right thing to do with it is use it
|
|---|
| 58 | * in preprocessor commands such as "#if (__RES > 19931104)". Do not
|
|---|
| 59 | * compare for equality; rather, use it to determine whether your resolver
|
|---|
| 60 | * is new enough to contain a certain feature.
|
|---|
| 61 | */
|
|---|
| 62 |
|
|---|
| 63 | #define __RES 19960801
|
|---|
| 64 |
|
|---|
| 65 | /*
|
|---|
| 66 | * Resolver configuration file.
|
|---|
| 67 | * Normally not present, but may contain the address of the
|
|---|
| 68 | * inital name server(s) to query and the domain search list.
|
|---|
| 69 | */
|
|---|
| 70 |
|
|---|
| 71 | #ifndef _PATH_RESCONF
|
|---|
| 72 | #define _PATH_RESCONF "/mptn/etc/resolv.conf"
|
|---|
| 73 | #endif
|
|---|
| 74 | #endif /* TCPV40HDRS */
|
|---|
| 75 |
|
|---|
| 76 | /*
|
|---|
| 77 | * Global defines and variables for resolver stub.
|
|---|
| 78 | */
|
|---|
| 79 | #define MAXNS 3 /* max # name servers we'll track */
|
|---|
| 80 | #define MAXDFLSRCH 3 /* # default domain levels to try */
|
|---|
| 81 | #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
|
|---|
| 82 | #define RES_TIMEOUT 4 /* min. seconds between retries */
|
|---|
| 83 | #ifdef TCPV40HDRS
|
|---|
| 84 | #define MAXDNSRCH 3 /* max # domains in search path */
|
|---|
| 85 | #else
|
|---|
| 86 | #define MAXDNSRCH 6 /* max # domains in search path */
|
|---|
| 87 | #define MAXRESOLVSORT 10 /* number of net to sort on */
|
|---|
| 88 | #define RES_MAXNDOTS 15 /* should reflect bit field size */
|
|---|
| 89 | #endif
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | #ifdef TCPV40HDRS
|
|---|
| 93 |
|
|---|
| 94 | #pragma pack(4)
|
|---|
| 95 | struct state {
|
|---|
| 96 | int retrans; /* retransmition time interval */
|
|---|
| 97 | int retry; /* number of times to retransmit */
|
|---|
| 98 | long options; /* option flags - see below. */
|
|---|
| 99 | int nscount; /* number of name servers */
|
|---|
| 100 | struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
|
|---|
| 101 | #define nsaddr nsaddr_list[0] /* for backward compatibility */
|
|---|
| 102 | u_short id; /* current packet id */
|
|---|
| 103 | char defdname[MAXDNAME]; /* default domain */
|
|---|
| 104 | char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
|
|---|
| 105 | };
|
|---|
| 106 | #pragma pack()
|
|---|
| 107 |
|
|---|
| 108 | #else
|
|---|
| 109 |
|
|---|
| 110 | #pragma pack(4)
|
|---|
| 111 | struct __res_state {
|
|---|
| 112 | int retrans; /* retransmition time interval */
|
|---|
| 113 | int retry; /* number of times to retransmit */
|
|---|
| 114 | u_long options; /* option flags - see below. */
|
|---|
| 115 | int nscount; /* number of name servers */
|
|---|
| 116 | struct sockaddr_in
|
|---|
| 117 | nsaddr_list[MAXNS]; /* address of name server */
|
|---|
| 118 | #define nsaddr nsaddr_list[0] /* for backward compatibility */
|
|---|
| 119 | u_short id; /* current message id */
|
|---|
| 120 | char defdname[256]; /* default domain (deprecated) */
|
|---|
| 121 | char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
|
|---|
| 122 | u_long pfcode; /* RES_PRF_ flags - see below. */
|
|---|
| 123 | unsigned ndots:4; /* threshold for initial abs. query */
|
|---|
| 124 | unsigned nsort:4; /* number of elements in sort_list[] */
|
|---|
| 125 | char unused[3];
|
|---|
| 126 | struct {
|
|---|
| 127 | struct in_addr addr;
|
|---|
| 128 | u_int32_t mask;
|
|---|
| 129 | } sort_list[MAXRESOLVSORT];
|
|---|
| 130 | char pad[72]; /* on an i386 this means 512b total */
|
|---|
| 131 | };
|
|---|
| 132 | #pragma pack()
|
|---|
| 133 |
|
|---|
| 134 | #endif
|
|---|
| 135 |
|
|---|
| 136 | /*
|
|---|
| 137 | * Resolver options
|
|---|
| 138 | */
|
|---|
| 139 | #define RES_INIT 0x0001 /* address initialized */
|
|---|
| 140 | #define RES_DEBUG 0x0002 /* print debug messages */
|
|---|
| 141 | #define RES_AAONLY 0x0004 /* authoritative answers only */
|
|---|
| 142 | #define RES_USEVC 0x0008 /* use virtual circuit */
|
|---|
| 143 | #define RES_PRIMARY 0x0010 /* query primary server only */
|
|---|
| 144 | #define RES_IGNTC 0x0020 /* ignore trucation errors */
|
|---|
| 145 | #define RES_RECURSE 0x0040 /* recursion desired */
|
|---|
| 146 | #define RES_DEFNAMES 0x0080 /* use default domain name */
|
|---|
| 147 | #define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
|
|---|
| 148 | #define RES_DNSRCH 0x0200 /* search up local domain tree */
|
|---|
| 149 | #ifndef TCPV40HDRS
|
|---|
| 150 | #define RES_INSECURE1 0x00000400 /* type 1 security disabled */
|
|---|
| 151 | #define RES_INSECURE2 0x00000800 /* type 2 security disabled */
|
|---|
| 152 | #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
|
|---|
| 153 | #define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
|
|---|
| 154 | #endif
|
|---|
| 155 |
|
|---|
| 156 | #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | #ifdef TCPV40HDRS
|
|---|
| 161 |
|
|---|
| 162 | extern struct state _res;
|
|---|
| 163 |
|
|---|
| 164 | #else /* !TCPV40HDRS: */
|
|---|
| 165 |
|
|---|
| 166 | /*
|
|---|
| 167 | * Resolver "pfcode" values. Used by dig.
|
|---|
| 168 | */
|
|---|
| 169 | #define RES_PRF_STATS 0x00000001
|
|---|
| 170 | /* 0x00000002 */
|
|---|
| 171 | #define RES_PRF_CLASS 0x00000004
|
|---|
| 172 | #define RES_PRF_CMD 0x00000008
|
|---|
| 173 | #define RES_PRF_QUES 0x00000010
|
|---|
| 174 | #define RES_PRF_ANS 0x00000020
|
|---|
| 175 | #define RES_PRF_AUTH 0x00000040
|
|---|
| 176 | #define RES_PRF_ADD 0x00000080
|
|---|
| 177 | #define RES_PRF_HEAD1 0x00000100
|
|---|
| 178 | #define RES_PRF_HEAD2 0x00000200
|
|---|
| 179 | #define RES_PRF_TTLID 0x00000400
|
|---|
| 180 | #define RES_PRF_HEADX 0x00000800
|
|---|
| 181 | #define RES_PRF_QUERY 0x00001000
|
|---|
| 182 | #define RES_PRF_REPLY 0x00002000
|
|---|
| 183 | #define RES_PRF_INIT 0x00004000
|
|---|
| 184 | /* 0x00008000 */
|
|---|
| 185 |
|
|---|
| 186 | /* hooks are still experimental as of 4.9.2 */
|
|---|
| 187 | typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
|
|---|
| 188 | res_sendhookact;
|
|---|
| 189 |
|
|---|
| 190 | #ifndef TCPCALL
|
|---|
| 191 | #define TCPCALL _System
|
|---|
| 192 | #endif
|
|---|
| 193 |
|
|---|
| 194 | typedef res_sendhookact (* TCPCALL res_send_qhook)(struct sockaddr_in * const *ns,
|
|---|
| 195 | const u_char **query,
|
|---|
| 196 | int *querylen,
|
|---|
| 197 | u_char *ans,
|
|---|
| 198 | int anssiz,
|
|---|
| 199 | int *resplen);
|
|---|
| 200 |
|
|---|
| 201 | typedef res_sendhookact (* TCPCALL res_send_rhook)(const struct sockaddr_in *ns,
|
|---|
| 202 | const u_char *query,
|
|---|
| 203 | int querylen,
|
|---|
| 204 | u_char *ans,
|
|---|
| 205 | int anssiz,
|
|---|
| 206 | int *resplen);
|
|---|
| 207 |
|
|---|
| 208 | #pragma pack(4)
|
|---|
| 209 | struct res_sym {
|
|---|
| 210 | int number; /* Identifying number, like T_MX */
|
|---|
| 211 | char * name; /* Its symbolic name, like "MX" */
|
|---|
| 212 | char * humanname; /* Its fun name, like "mail exchanger" */
|
|---|
| 213 | };
|
|---|
| 214 | #pragma pack()
|
|---|
| 215 |
|
|---|
| 216 | extern struct __res_state _ress[2];
|
|---|
| 217 | extern const struct res_sym __p_class_syms[];
|
|---|
| 218 | extern const struct res_sym __p_type_syms[];
|
|---|
| 219 | #define _res (_ress[0])
|
|---|
| 220 |
|
|---|
| 221 | /* Private routines shared between libc/net, named, nslookup and others. */
|
|---|
| 222 | #define res_hnok __res_hnok
|
|---|
| 223 | #define res_ownok __res_ownok
|
|---|
| 224 | #define res_mailok __res_mailok
|
|---|
| 225 | #define res_dnok __res_dnok
|
|---|
| 226 | #define sym_ston __sym_ston
|
|---|
| 227 | #define sym_ntos __sym_ntos
|
|---|
| 228 | #define sym_ntop __sym_ntop
|
|---|
| 229 | #define b64_ntop __b64_ntop
|
|---|
| 230 | #define b64_pton __b64_pton
|
|---|
| 231 | #define loc_ntoa __loc_ntoa
|
|---|
| 232 | #define loc_aton __loc_aton
|
|---|
| 233 | #define dn_skipname __dn_skipname
|
|---|
| 234 | #define fp_resstat __fp_resstat
|
|---|
| 235 | #define fp_query __fp_query
|
|---|
| 236 | #define fp_nquery __fp_nquery
|
|---|
| 237 | #define hostalias __hostalias
|
|---|
| 238 | #define putlong __putlong
|
|---|
| 239 | #define putshort __putshort
|
|---|
| 240 | #define p_class __p_class
|
|---|
| 241 | #define p_time __p_time
|
|---|
| 242 | #define p_type __p_type
|
|---|
| 243 | #define p_query __p_query
|
|---|
| 244 | #define p_cdnname __p_cdnname
|
|---|
| 245 | #define p_cdname __p_cdname
|
|---|
| 246 | #define p_fqnname __p_fqnname
|
|---|
| 247 | #define p_fqname __p_fqname
|
|---|
| 248 | #define p_rr __p_rr
|
|---|
| 249 | #define p_option __p_option
|
|---|
| 250 | #define p_secstodate __p_secstodate
|
|---|
| 251 | #define dn_count_labels __dn_count_labels
|
|---|
| 252 | #define dn_comp __dn_comp
|
|---|
| 253 | #define dn_expand __dn_expand
|
|---|
| 254 | #define res_init __res_init
|
|---|
| 255 | #define res_randomid __res_randomid
|
|---|
| 256 | #define res_query __res_query
|
|---|
| 257 | #define res_search __res_search
|
|---|
| 258 | #define res_querydomain __res_querydomain
|
|---|
| 259 | #define res_mkquery __res_mkquery
|
|---|
| 260 | #define res_send __res_send
|
|---|
| 261 | #define res_isourserver __res_isourserver
|
|---|
| 262 | #define res_nameinquery __res_nameinquery
|
|---|
| 263 | #define res_queriesmatch __res_queriesmatch
|
|---|
| 264 | #define res_close __res_close
|
|---|
| 265 |
|
|---|
| 266 | int TCPCALL res_hnok(const char *);
|
|---|
| 267 | int TCPCALL res_ownok(const char *);
|
|---|
| 268 | int TCPCALL res_mailok(const char *);
|
|---|
| 269 | int TCPCALL res_dnok(const char *);
|
|---|
| 270 | int TCPCALL sym_ston(const struct res_sym *, char *, int *);
|
|---|
| 271 | const char * TCPCALL sym_ntos(const struct res_sym *, int, int *);
|
|---|
| 272 | const char * TCPCALL sym_ntop(const struct res_sym *, int, int *);
|
|---|
| 273 | int TCPCALL b64_ntop(u_char const *, size_t, char *, size_t);
|
|---|
| 274 | int TCPCALL b64_pton(char const *, u_char *, size_t);
|
|---|
| 275 | int TCPCALL loc_aton(const char *, u_char *);
|
|---|
| 276 | const char * TCPCALL loc_ntoa(const u_char *, char *);
|
|---|
| 277 | int TCPCALL dn_skipname(const u_char *, const u_char *);
|
|---|
| 278 | void TCPCALL fp_resstat(struct __res_state *, int);
|
|---|
| 279 | void TCPCALL fp_query(const u_char *, int);
|
|---|
| 280 | void TCPCALL fp_nquery(const u_char *, int, int);
|
|---|
| 281 | const char * TCPCALL hostalias(const char *);
|
|---|
| 282 | void TCPCALL putlong(u_int32_t, u_char *);
|
|---|
| 283 | void TCPCALL putshort(u_int16_t, u_char *);
|
|---|
| 284 | const char * TCPCALL p_class(int);
|
|---|
| 285 | const char * TCPCALL p_time(u_int32_t);
|
|---|
| 286 | const char * TCPCALL p_type(int);
|
|---|
| 287 | void TCPCALL p_query(const u_char *);
|
|---|
| 288 | const u_char * TCPCALL p_cdnname(const u_char *, const u_char *, int, int);
|
|---|
| 289 | const u_char * TCPCALL p_cdname(const u_char *, const u_char *, int);
|
|---|
| 290 | const u_char * TCPCALL p_fqnname(const u_char *cp, const u_char *msg,
|
|---|
| 291 | int, char *, int);
|
|---|
| 292 | const u_char * TCPCALL p_fqname(const u_char *, const u_char *, int);
|
|---|
| 293 | const u_char * TCPCALL p_rr(const u_char *, const u_char *, int);
|
|---|
| 294 | const char * TCPCALL p_option(u_long option);
|
|---|
| 295 | char * TCPCALL p_secstodate(u_long);
|
|---|
| 296 | int TCPCALL dn_count_labels(char *);
|
|---|
| 297 | int TCPCALL dn_comp(const char *, u_char *, int,
|
|---|
| 298 | u_char **, u_char **);
|
|---|
| 299 | int TCPCALL dn_expand(const u_char *, const u_char *, const u_char *,
|
|---|
| 300 | char *, int);
|
|---|
| 301 | int TCPCALL res_init(void);
|
|---|
| 302 | u_int TCPCALL res_randomid(void);
|
|---|
| 303 | int TCPCALL res_query(const char *, int, int, u_char *, int);
|
|---|
| 304 | int TCPCALL res_search(const char *, int, int, u_char *, int);
|
|---|
| 305 | int TCPCALL res_querydomain(const char *, const char *, int, int, u_char *, int);
|
|---|
| 306 | int TCPCALL res_mkquery(int, const char *, int, int, const u_char *, int,
|
|---|
| 307 | const u_char *, u_char *, int);
|
|---|
| 308 | int TCPCALL res_send(const u_char *, int, u_char *, int);
|
|---|
| 309 | int TCPCALL res_isourserver(const struct sockaddr_in *);
|
|---|
| 310 | int TCPCALL res_nameinquery(const char *, int, int,
|
|---|
| 311 | const u_char *, const u_char *);
|
|---|
| 312 | int TCPCALL res_queriesmatch(const u_char *, const u_char *,
|
|---|
| 313 | const u_char *, const u_char *);
|
|---|
| 314 | void TCPCALL res_close(void);
|
|---|
| 315 | int TCPCALL dn_find(u_char *exp_dn, u_char *msg,
|
|---|
| 316 | u_char **dnptrs, u_char **lastdnptr);
|
|---|
| 317 | #endif /* !TCPV40HDRS */
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 | #if defined (__cplusplus)
|
|---|
| 321 | }
|
|---|
| 322 | #endif
|
|---|
| 323 |
|
|---|
| 324 | #endif /* !_RESOLV_H_ */
|
|---|