[7f2036aa] | 1 | /* |
---|
| 2 | * Copyright (c) 1983, 1987, 1989 |
---|
| 3 | * The Regents of the University of California. All rights reserved. |
---|
| 4 | * |
---|
[39e6e65a] | 5 | * Redistribution and use in source and binary forms, with or without |
---|
| 6 | * modification, are permitted provided that the following conditions |
---|
| 7 | * are met: |
---|
| 8 | * 1. Redistributions of source code must retain the above copyright |
---|
| 9 | * notice, this list of conditions and the following disclaimer. |
---|
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
| 11 | * notice, this list of conditions and the following disclaimer in the |
---|
| 12 | * documentation and/or other materials provided with the distribution. |
---|
[7f2036aa] | 13 | * 3. Neither the name of the University nor the names of its contributors |
---|
[39e6e65a] | 14 | * may be used to endorse or promote products derived from this software |
---|
| 15 | * without specific prior written permission. |
---|
| 16 | * |
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
---|
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
---|
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
| 27 | * SUCH DAMAGE. |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | /* |
---|
[7f2036aa] | 31 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
---|
| 32 | * Portions Copyright (c) 1996-1999 by Internet Software Consortium. |
---|
[39e6e65a] | 33 | * |
---|
| 34 | * Permission to use, copy, modify, and distribute this software for any |
---|
| 35 | * purpose with or without fee is hereby granted, provided that the above |
---|
| 36 | * copyright notice and this permission notice appear in all copies. |
---|
| 37 | * |
---|
[7f2036aa] | 38 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
---|
| 39 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
| 40 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
---|
| 41 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
| 42 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
| 43 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
---|
| 44 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
[39e6e65a] | 45 | */ |
---|
| 46 | |
---|
[7f2036aa] | 47 | /*% |
---|
[39e6e65a] | 48 | * @(#)resolv.h 8.1 (Berkeley) 6/2/93 |
---|
[7f2036aa] | 49 | * $FreeBSD: release/9.0.0/include/resolv.h 203964 2010-02-16 19:39:50Z imp $ |
---|
[39e6e65a] | 50 | */ |
---|
| 51 | |
---|
| 52 | #ifndef _RESOLV_H_ |
---|
| 53 | #define _RESOLV_H_ |
---|
| 54 | |
---|
| 55 | #include <sys/param.h> |
---|
| 56 | #include <sys/types.h> |
---|
[ee613aa] | 57 | #include <sys/cdefs.h> |
---|
[39e6e65a] | 58 | #include <stdio.h> |
---|
[7e1d1e4] | 59 | #include <netinet/in.h> /* struct in_addr */ |
---|
[39e6e65a] | 60 | |
---|
[7f2036aa] | 61 | /*% |
---|
[39e6e65a] | 62 | * Revision information. This is the release date in YYYYMMDD format. |
---|
| 63 | * It can change every day so the right thing to do with it is use it |
---|
| 64 | * in preprocessor commands such as "#if (__RES > 19931104)". Do not |
---|
| 65 | * compare for equality; rather, use it to determine whether your resolver |
---|
| 66 | * is new enough to contain a certain feature. |
---|
| 67 | */ |
---|
| 68 | |
---|
| 69 | #define __RES 19960801 |
---|
| 70 | |
---|
[7f2036aa] | 71 | /*% |
---|
[39e6e65a] | 72 | * Resolver configuration file. |
---|
| 73 | * Normally not present, but may contain the address of the |
---|
[f692e004] | 74 | * initial name server(s) to query and the domain search list. |
---|
[39e6e65a] | 75 | */ |
---|
| 76 | |
---|
| 77 | #ifndef _PATH_RESCONF |
---|
| 78 | #define _PATH_RESCONF "/etc/resolv.conf" |
---|
| 79 | #endif |
---|
| 80 | |
---|
[7f2036aa] | 81 | typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } |
---|
| 82 | res_sendhookact; |
---|
| 83 | |
---|
| 84 | typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns, |
---|
| 85 | const u_char **query, |
---|
| 86 | int *querylen, |
---|
| 87 | u_char *ans, |
---|
| 88 | int anssiz, |
---|
| 89 | int *resplen); |
---|
| 90 | |
---|
| 91 | typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns, |
---|
| 92 | const u_char *query, |
---|
| 93 | int querylen, |
---|
| 94 | u_char *ans, |
---|
| 95 | int anssiz, |
---|
| 96 | int *resplen); |
---|
| 97 | |
---|
| 98 | struct res_sym { |
---|
| 99 | int number; /*%< Identifying number, like T_MX */ |
---|
| 100 | const char * name; /*%< Its symbolic name, like "MX" */ |
---|
| 101 | const char * humanname; /*%< Its fun name, like "mail exchanger" */ |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | /*% |
---|
[39e6e65a] | 105 | * Global defines and variables for resolver stub. |
---|
| 106 | */ |
---|
[7f2036aa] | 107 | #define MAXNS 3 /*%< max # name servers we'll track */ |
---|
| 108 | #define MAXDFLSRCH 3 /*%< # default domain levels to try */ |
---|
| 109 | #define MAXDNSRCH 6 /*%< max # domains in search path */ |
---|
| 110 | #define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */ |
---|
| 111 | #define RES_TIMEOUT 5 /*%< min. seconds between retries */ |
---|
| 112 | #define MAXRESOLVSORT 10 /*%< number of net to sort on */ |
---|
| 113 | #define RES_MAXNDOTS 15 /*%< should reflect bit field size */ |
---|
[39e6e65a] | 114 | |
---|
| 115 | struct __res_state { |
---|
[7f2036aa] | 116 | int retrans; /*%< retransmission time interval */ |
---|
| 117 | int retry; /*%< number of times to retransmit */ |
---|
| 118 | u_long options; /*%< option flags - see below. */ |
---|
| 119 | int nscount; /*%< number of name servers */ |
---|
[39e6e65a] | 120 | struct sockaddr_in |
---|
[7f2036aa] | 121 | nsaddr_list[MAXNS]; /*%< address of name server */ |
---|
| 122 | #define nsaddr nsaddr_list[0] /*%< for backward compatibility */ |
---|
| 123 | u_short id; /*%< current message id */ |
---|
| 124 | char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */ |
---|
| 125 | char defdname[256]; /*%< default domain (deprecated) */ |
---|
| 126 | u_long pfcode; /*%< RES_PRF_ flags - see below. */ |
---|
| 127 | unsigned ndots:4; /*%< threshold for initial abs. query */ |
---|
| 128 | unsigned nsort:4; /*%< number of elements in sort_list[] */ |
---|
[39e6e65a] | 129 | char unused[3]; |
---|
| 130 | struct { |
---|
| 131 | struct in_addr addr; |
---|
| 132 | u_int32_t mask; |
---|
| 133 | } sort_list[MAXRESOLVSORT]; |
---|
| 134 | char pad[72]; /* on an i386 this means 512b total */ |
---|
| 135 | }; |
---|
| 136 | |
---|
[7f2036aa] | 137 | typedef struct __res_state *res_state; |
---|
| 138 | |
---|
| 139 | /*% |
---|
[39e6e65a] | 140 | * Resolver options (keep these in synch with res_debug.c, please) |
---|
| 141 | */ |
---|
[7f2036aa] | 142 | #define RES_INIT 0x00000001 /*%< address initialized */ |
---|
| 143 | #define RES_DEBUG 0x00000002 /*%< print debug messages */ |
---|
| 144 | #define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/ |
---|
| 145 | #define RES_USEVC 0x00000008 /*%< use virtual circuit */ |
---|
| 146 | #define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */ |
---|
| 147 | #define RES_IGNTC 0x00000020 /*%< ignore truncation errors */ |
---|
| 148 | #define RES_RECURSE 0x00000040 /*%< recursion desired */ |
---|
| 149 | #define RES_DEFNAMES 0x00000080 /*%< use default domain name */ |
---|
| 150 | #define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */ |
---|
| 151 | #define RES_DNSRCH 0x00000200 /*%< search up local domain tree */ |
---|
| 152 | #define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */ |
---|
| 153 | #define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */ |
---|
| 154 | #define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */ |
---|
| 155 | #define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */ |
---|
| 156 | #define RES_NOTLDQUERY 0x00004000 /*%< Don't query TLD names */ |
---|
[39e6e65a] | 157 | |
---|
[7f2036aa] | 158 | #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \ |
---|
| 159 | RES_DNSRCH) |
---|
[39e6e65a] | 160 | |
---|
[7f2036aa] | 161 | /*% |
---|
[39e6e65a] | 162 | * Resolver "pfcode" values. Used by dig. |
---|
| 163 | */ |
---|
| 164 | #define RES_PRF_STATS 0x00000001 |
---|
| 165 | #define RES_PRF_UPDATE 0x00000002 |
---|
| 166 | #define RES_PRF_CLASS 0x00000004 |
---|
| 167 | #define RES_PRF_CMD 0x00000008 |
---|
| 168 | #define RES_PRF_QUES 0x00000010 |
---|
| 169 | #define RES_PRF_ANS 0x00000020 |
---|
| 170 | #define RES_PRF_AUTH 0x00000040 |
---|
| 171 | #define RES_PRF_ADD 0x00000080 |
---|
| 172 | #define RES_PRF_HEAD1 0x00000100 |
---|
| 173 | #define RES_PRF_HEAD2 0x00000200 |
---|
| 174 | #define RES_PRF_TTLID 0x00000400 |
---|
| 175 | #define RES_PRF_HEADX 0x00000800 |
---|
| 176 | #define RES_PRF_QUERY 0x00001000 |
---|
| 177 | #define RES_PRF_REPLY 0x00002000 |
---|
[7f2036aa] | 178 | #define RES_PRF_INIT 0x00004000 |
---|
[39e6e65a] | 179 | /* 0x00008000 */ |
---|
| 180 | |
---|
[7f2036aa] | 181 | #define fp_nquery __fp_nquery |
---|
| 182 | #define fp_query __fp_query |
---|
| 183 | #define hostalias __hostalias |
---|
| 184 | #define p_query __p_query |
---|
| 185 | #define res_close __res_close |
---|
| 186 | #define res_init __res_init |
---|
| 187 | #define res_isourserver __res_isourserver |
---|
| 188 | #define res_mkquery __res_mkquery |
---|
| 189 | #define res_query __res_query |
---|
| 190 | #define res_querydomain __res_querydomain |
---|
| 191 | #define res_search __res_search |
---|
| 192 | #define res_send __res_send |
---|
[39e6e65a] | 193 | |
---|
[7f2036aa] | 194 | __BEGIN_DECLS |
---|
| 195 | void fp_nquery(const u_char *, int, FILE *); |
---|
| 196 | void fp_query(const u_char *, FILE *); |
---|
| 197 | const char * hostalias(const char *); |
---|
| 198 | void p_query(const u_char *); |
---|
| 199 | void res_close(void); |
---|
| 200 | int res_init(void); |
---|
| 201 | int res_isourserver(const struct sockaddr_in *); |
---|
| 202 | int res_mkquery(int, const char *, int, int, const u_char *, |
---|
| 203 | int, const u_char *, u_char *, int); |
---|
| 204 | int res_query(const char *, int, int, u_char *, int); |
---|
| 205 | int res_querydomain(const char *, const char *, int, int, |
---|
| 206 | u_char *, int); |
---|
| 207 | int res_search(const char *, int, int, u_char *, int); |
---|
| 208 | int res_send(const u_char *, int, u_char *, int); |
---|
| 209 | __END_DECLS |
---|
[39e6e65a] | 210 | |
---|
[7f2036aa] | 211 | extern struct __res_state _res; |
---|
[39e6e65a] | 212 | |
---|
| 213 | |
---|
| 214 | extern const struct res_sym __p_class_syms[]; |
---|
| 215 | extern const struct res_sym __p_type_syms[]; |
---|
| 216 | |
---|
| 217 | /* Private routines shared between libc/net, named, nslookup and others. */ |
---|
[7f2036aa] | 218 | #define b64_ntop __b64_ntop |
---|
| 219 | #define b64_pton __b64_pton |
---|
| 220 | #define dn_comp __dn_comp |
---|
| 221 | #define dn_count_labels __dn_count_labels |
---|
| 222 | #define dn_expand __dn_expand |
---|
| 223 | #define dn_skipname __dn_skipname |
---|
| 224 | #define fp_resstat __fp_resstat |
---|
| 225 | #define loc_aton __loc_aton |
---|
| 226 | #define loc_ntoa __loc_ntoa |
---|
| 227 | #define p_cdname __p_cdname |
---|
| 228 | #define p_cdnname __p_cdnname |
---|
| 229 | #define fp_resstat __fp_resstat |
---|
| 230 | #define p_class __p_class |
---|
| 231 | #define p_fqname __p_fqname |
---|
| 232 | #define p_fqnname __p_fqnname |
---|
| 233 | #define p_option __p_option |
---|
| 234 | #define p_secstodate __p_secstodate |
---|
| 235 | #define p_section __p_section |
---|
| 236 | #define p_time __p_time |
---|
| 237 | #define p_type __p_type |
---|
| 238 | #define putlong __putlong |
---|
| 239 | #define putshort __putshort |
---|
| 240 | #define res_dnok __res_dnok |
---|
| 241 | #define res_hnok __res_hnok |
---|
| 242 | #define res_mailok __res_mailok |
---|
| 243 | #define res_nameinquery __res_nameinquery |
---|
| 244 | #define res_ownok __res_ownok |
---|
| 245 | #define res_queriesmatch __res_queriesmatch |
---|
| 246 | #define res_randomid __res_randomid |
---|
| 247 | #define sym_ntop __sym_ntop |
---|
| 248 | #define sym_ntos __sym_ntos |
---|
| 249 | #define sym_ston __sym_ston |
---|
| 250 | #define res_send_setqhook __res_send_setqhook |
---|
| 251 | #define res_send_setrhook __res_send_setrhook |
---|
| 252 | #define res_mkupdate __res_mkupdate |
---|
| 253 | #define res_mkupdrec __res_mkupdrec |
---|
| 254 | #define res_freeupdrec __res_freeupdrec |
---|
[39e6e65a] | 255 | |
---|
| 256 | __BEGIN_DECLS |
---|
[7f2036aa] | 257 | int res_hnok(const char *); |
---|
| 258 | int res_ownok(const char *); |
---|
| 259 | int res_mailok(const char *); |
---|
| 260 | int res_dnok(const char *); |
---|
| 261 | int sym_ston(const struct res_sym *, const char *, int *); |
---|
| 262 | const char * sym_ntos(const struct res_sym *, int, int *); |
---|
| 263 | const char * sym_ntop(const struct res_sym *, int, int *); |
---|
| 264 | int b64_ntop(u_char const *, size_t, char *, size_t); |
---|
| 265 | int b64_pton(char const *, u_char *, size_t); |
---|
| 266 | int loc_aton(const char *, u_char *); |
---|
| 267 | const char * loc_ntoa(const u_char *, char *); |
---|
| 268 | int dn_skipname(const u_char *, const u_char *); |
---|
| 269 | void fp_resstat(struct __res_state *, FILE *); |
---|
| 270 | void putlong(u_int32_t, u_char *); |
---|
| 271 | void putshort(u_int16_t, u_char *); |
---|
| 272 | const char * p_class(int); |
---|
| 273 | const char * p_time(u_int32_t); |
---|
| 274 | const char * p_type(int); |
---|
| 275 | const u_char * p_cdnname(const u_char *, const u_char *, int, FILE *); |
---|
| 276 | const u_char * p_cdname(const u_char *, const u_char *, FILE *); |
---|
| 277 | const u_char * p_fqnname(const u_char *, const u_char *, int, char *, int); |
---|
| 278 | const u_char * p_fqname(const u_char *, const u_char *, FILE *); |
---|
| 279 | const char * p_option(u_long); |
---|
| 280 | char * p_secstodate(u_long); |
---|
| 281 | int dn_count_labels(const char *); |
---|
| 282 | int dn_comp(const char *, u_char *, int, u_char **, u_char **); |
---|
| 283 | int dn_expand(const u_char *, const u_char *, const u_char *, |
---|
| 284 | char *, int); |
---|
| 285 | u_int res_randomid(void); |
---|
| 286 | int res_nameinquery(const char *, int, int, const u_char *, |
---|
| 287 | const u_char *); |
---|
| 288 | int res_queriesmatch(const u_char *, const u_char *, |
---|
| 289 | const u_char *, const u_char *); |
---|
| 290 | const char * p_section(int, int); |
---|
| 291 | void res_send_setqhook(res_send_qhook); |
---|
| 292 | void res_send_setrhook(res_send_rhook); |
---|
| 293 | |
---|
[39e6e65a] | 294 | /* XXX The following depend on the ns_updrec typedef in arpa/nameser.h */ |
---|
| 295 | #ifdef _ARPA_NAMESER_H_ |
---|
[f692e004] | 296 | int res_update (ns_updrec *); |
---|
| 297 | int res_mkupdate (ns_updrec *, u_char *, int); |
---|
| 298 | ns_updrec * res_mkupdrec (int, const char *, u_int, u_int, u_long); |
---|
| 299 | void res_freeupdrec (ns_updrec *); |
---|
[39e6e65a] | 300 | #endif |
---|
| 301 | __END_DECLS |
---|
| 302 | |
---|
| 303 | #endif /* !_RESOLV_H_ */ |
---|