| 1 | /* |
| 2 | * Copyright (c) 1983, 1987, 1989 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 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. |
| 13 | * 4. Neither the name of the University nor the names of its contributors |
| 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 | /* |
| 31 | * Portions Copyright (c) 1996-1999 by Internet Software Consortium. |
| 32 | * |
| 33 | * Permission to use, copy, modify, and distribute this software for any |
| 34 | * purpose with or without fee is hereby granted, provided that the above |
| 35 | * copyright notice and this permission notice appear in all copies. |
| 36 | * |
| 37 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS |
| 38 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES |
| 39 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE |
| 40 | * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 41 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 42 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
| 43 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 44 | * SOFTWARE. |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | *	@(#)resolv.h	8.1 (Berkeley) 6/2/93 |
| 49 | *	$BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $ |
| 50 | */ |
| 51 | |
| 52 | #ifndef _RESOLV_H_ |
| 53 | #define _RESOLV_H_ |
| 54 | |
| 55 | #include <sys/cdefs.h> |
| 56 | #include <sys/param.h> |
| 57 | #include <sys/types.h> |
| 58 | #include <stdio.h> |
| 59 | #include <netinet/in.h> |
| 60 | #include <arpa/nameser.h> |
| 61 | #include <bits/types/res_state.h> |
| 62 | |
| 63 | /* |
| 64 | * Global defines and variables for resolver stub. |
| 65 | */ |
| 66 | #define LOCALDOMAINPARTS	2	/* min levels in name that is "local" */ |
| 67 | |
| 68 | #define RES_TIMEOUT		5	/* min. seconds between retries */ |
| 69 | #define RES_MAXNDOTS		15	/* should reflect bit field size */ |
| 70 | #define RES_MAXRETRANS		30	/* only for resolv.conf/RES_OPTIONS */ |
| 71 | #define RES_MAXRETRY		5	/* only for resolv.conf/RES_OPTIONS */ |
| 72 | #define RES_DFLRETRY		2	/* Default #/tries. */ |
| 73 | #define RES_MAXTIME		65535	/* Infinity, in milliseconds. */ |
| 74 | |
| 75 | #define nsaddr	nsaddr_list[0]		/* for backward compatibility */ |
| 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	19991006 |
| 86 | |
| 87 | /* |
| 88 | * Resolver configuration file. |
| 89 | * Normally not present, but may contain the address of the |
| 90 | * initial 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 | struct res_sym { |
| 98 | 	int	number;		/* Identifying number, like T_MX */ |
| 99 | 	char *	name;		/* Its symbolic name, like "MX" */ |
| 100 | 	char *	humanname;	/* Its fun name, like "mail exchanger" */ |
| 101 | }; |
| 102 | |
| 103 | /* |
| 104 | * Resolver options (keep these in synch with res_debug.c, please) |
| 105 | */ |
| 106 | #define RES_INIT	0x00000001	/* address initialized */ |
| 107 | #define RES_DEBUG	0x00000002	/* print debug messages */ |
| 108 | #define RES_AAONLY \ |
| 109 | __glibc_macro_warning ("RES_AAONLY is deprecated") 0x00000004 |
| 110 | #define RES_USEVC	0x00000008	/* use virtual circuit */ |
| 111 | #define RES_PRIMARY \ |
| 112 | __glibc_macro_warning ("RES_PRIMARY is deprecated") 0x00000010 |
| 113 | #define RES_IGNTC	0x00000020	/* ignore trucation errors */ |
| 114 | #define RES_RECURSE	0x00000040	/* recursion desired */ |
| 115 | #define RES_DEFNAMES	0x00000080	/* use default domain name */ |
| 116 | #define RES_STAYOPEN	0x00000100	/* Keep TCP socket open */ |
| 117 | #define RES_DNSRCH	0x00000200	/* search up local domain tree */ |
| 118 | #define	RES_NOALIASES	0x00001000	/* shuts off HOSTALIASES feature */ |
| 119 | #define RES_ROTATE	0x00004000	/* rotate ns list after each query */ |
| 120 | #define	RES_NOCHECKNAME \ |
| 121 | __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000 |
| 122 | #define	RES_KEEPTSIG \ |
| 123 | __glibc_macro_warning ("RES_KEEPTSIG is deprecated") 0x00010000 |
| 124 | #define	RES_BLAST \ |
| 125 | __glibc_macro_warning ("RES_BLAST is deprecated") 0x00020000 |
| 126 | #define RES_USE_EDNS0	0x00100000	/* Use EDNS0. */ |
| 127 | #define RES_SNGLKUP	0x00200000	/* one outstanding request at a time */ |
| 128 | #define RES_SNGLKUPREOP	0x00400000	/* -"-, but open new socket for each |
| 129 | 					 request */ |
| 130 | #define RES_USE_DNSSEC	0x00800000	/* use DNSSEC using OK bit in OPT */ |
| 131 | #define RES_NOTLDQUERY	0x01000000	/* Do not look up unqualified name |
| 132 | 					 as a TLD. */ |
| 133 | #define RES_NORELOAD 0x02000000 /* No automatic configuration reload. */ |
| 134 | #define RES_TRUSTAD 0x04000000 /* Request AD bit, keep it in responses. */ |
| 135 | #define RES_NOAAAA 0x08000000 /* Suppress AAAA queries. */ |
| 136 | #define RES_STRICTERR 0x10000000 /* Report more DNS errors as errors. */ |
| 137 | |
| 138 | #define RES_DEFAULT	(RES_RECURSE|RES_DEFNAMES|RES_DNSRCH) |
| 139 | |
| 140 | /* |
| 141 | * Resolver "pfcode" values. Used by dig. |
| 142 | */ |
| 143 | #define RES_PRF_STATS	0x00000001 |
| 144 | #define RES_PRF_UPDATE	0x00000002 |
| 145 | #define RES_PRF_CLASS 0x00000004 |
| 146 | #define RES_PRF_CMD	0x00000008 |
| 147 | #define RES_PRF_QUES	0x00000010 |
| 148 | #define RES_PRF_ANS	0x00000020 |
| 149 | #define RES_PRF_AUTH	0x00000040 |
| 150 | #define RES_PRF_ADD	0x00000080 |
| 151 | #define RES_PRF_HEAD1	0x00000100 |
| 152 | #define RES_PRF_HEAD2	0x00000200 |
| 153 | #define RES_PRF_TTLID	0x00000400 |
| 154 | #define RES_PRF_HEADX	0x00000800 |
| 155 | #define RES_PRF_QUERY	0x00001000 |
| 156 | #define RES_PRF_REPLY	0x00002000 |
| 157 | #define RES_PRF_INIT	0x00004000 |
| 158 | /*			0x00008000	*/ |
| 159 | |
| 160 | /* Things involving an internal (static) resolver context. */ |
| 161 | __BEGIN_DECLS |
| 162 | extern struct __res_state *__res_state(void) __attribute__ ((__const__)); |
| 163 | __END_DECLS |
| 164 | #define _res (*__res_state()) |
| 165 | |
| 166 | #define fp_nquery		__fp_nquery |
| 167 | #define fp_query		__fp_query |
| 168 | #define hostalias		__hostalias |
| 169 | #define p_query			__p_query |
| 170 | #define res_close		__res_close |
| 171 | #define res_init		__res_init |
| 172 | #define res_isourserver		__res_isourserver |
| 173 | |
| 174 | /* zig patch: In glibc 2.33 and earlier res_search, res_nsearch, res_query, res_nquery, |
| 175 | * res_querydomain, res_nquerydomain, dn_skipname, dn_comp, dn_expand were |
| 176 | * #define'd to __res_search, __res_nsearch, etc. glibc 2.34 onwards removes |
| 177 | * the macros and exposes the symbols directly. New glibc exposes compat |
| 178 | * symbols with underscores for backwards compatibility. Applications linked to |
| 179 | * glibc 2.34+ are expected to use the non-underscored symbols. |
| 180 | * |
| 181 | * It is enough to bring the macros back when compiling against the older glibc |
| 182 | * versions. |
| 183 | * |
| 184 | * See glibc commits: |
| 185 | * - ea9878ec271c791880fcbbe519d70c42f8113750 res_* |
| 186 | * - 391e02236b931132c0e8b5ba4c3b087c2aaa1044 dn_skipname |
| 187 | * - fd8a87c0c1932de591e7ad108ff6288a4b6b18c9 dn_comp |
| 188 | * - 640bbdf71c6f10ac26252ac67a22902e26657bd8 dn_expand |
| 189 | */ |
| 190 | #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34) |
| 191 | #define res_search __res_search |
| 192 | #define res_nsearch __res_nsearch |
| 193 | #define res_query __res_query |
| 194 | #define res_nquery __res_nquery |
| 195 | #define res_querydomain __res_querydomain |
| 196 | #define res_nquerydomain __res_nquerydomain |
| 197 | #define dn_skipname __dn_skipname |
| 198 | #define dn_comp __dn_comp |
| 199 | #define dn_expand __dn_expand |
| 200 | #endif |
| 201 | /* end glibc compat hacks */ |
| 202 | |
| 203 | #ifdef _LIBC |
| 204 | # define __RESOLV_DEPRECATED |
| 205 | # define __RESOLV_DEPRECATED_MSG(msg) |
| 206 | #else |
| 207 | # define __RESOLV_DEPRECATED __attribute_deprecated__ |
| 208 | # define __RESOLV_DEPRECATED_MSG(msg) __attribute_deprecated_msg__ (msg) |
| 209 | #endif |
| 210 | |
| 211 | __BEGIN_DECLS |
| 212 | void		fp_nquery (const unsigned char *, int, FILE *) __THROW |
| 213 | __RESOLV_DEPRECATED; |
| 214 | void		fp_query (const unsigned char *, FILE *) __THROW |
| 215 | __RESOLV_DEPRECATED; |
| 216 | const char *	hostalias (const char *) __THROW |
| 217 | __RESOLV_DEPRECATED_MSG ("use getaddrinfo instead"); |
| 218 | void		p_query (const unsigned char *) __THROW |
| 219 | __RESOLV_DEPRECATED; |
| 220 | void		res_close (void) __THROW; |
| 221 | int		res_init (void) __THROW; |
| 222 | int		res_isourserver (const struct sockaddr_in *) __THROW |
| 223 | __RESOLV_DEPRECATED; |
| 224 | int		res_mkquery (int, const char *, int, int, |
| 225 | 			 const unsigned char *, int, const unsigned char *, |
| 226 | 			 unsigned char *, int) __THROW; |
| 227 | int		res_query (const char *, int, int, unsigned char *, int) |
| 228 | __THROW; |
| 229 | int		res_querydomain (const char *, const char *, int, int, |
| 230 | 				 unsigned char *, int) __THROW; |
| 231 | int		res_search (const char *, int, int, unsigned char *, int) |
| 232 | __THROW; |
| 233 | int		res_send (const unsigned char *, int, unsigned char *, int) |
| 234 | __THROW; |
| 235 | __END_DECLS |
| 236 | |
| 237 | #define b64_ntop		__b64_ntop |
| 238 | #define b64_pton		__b64_pton |
| 239 | #define dn_count_labels		__dn_count_labels |
| 240 | #define fp_resstat		__fp_resstat |
| 241 | #define loc_aton		__loc_aton |
| 242 | #define loc_ntoa		__loc_ntoa |
| 243 | #define p_cdname		__p_cdname |
| 244 | #define p_cdnname		__p_cdnname |
| 245 | #define p_class			__p_class |
| 246 | #define p_fqname		__p_fqname |
| 247 | #define p_fqnname		__p_fqnname |
| 248 | #define p_option		__p_option |
| 249 | #define p_time			__p_time |
| 250 | #define p_type			__p_type |
| 251 | #define p_rcode			__p_rcode |
| 252 | #define putlong			__putlong |
| 253 | #define putshort		__putshort |
| 254 | #define res_hostalias		__res_hostalias |
| 255 | #define res_nameinquery		__res_nameinquery |
| 256 | #define res_nclose		__res_nclose |
| 257 | #define res_ninit		__res_ninit |
| 258 | #define res_queriesmatch	__res_queriesmatch |
| 259 | #define res_randomid		__res_randomid |
| 260 | #define sym_ntop		__sym_ntop |
| 261 | #define sym_ntos		__sym_ntos |
| 262 | #define sym_ston		__sym_ston |
| 263 | __BEGIN_DECLS |
| 264 | int		res_hnok (const char *) __THROW; |
| 265 | int		res_ownok (const char *) __THROW; |
| 266 | int		res_mailok (const char *) __THROW; |
| 267 | int		res_dnok (const char *) __THROW; |
| 268 | int		sym_ston (const struct res_sym *, const char *, int *) __THROW |
| 269 | __RESOLV_DEPRECATED; |
| 270 | const char *	sym_ntos (const struct res_sym *, int, int *) __THROW |
| 271 | __RESOLV_DEPRECATED; |
| 272 | const char *	sym_ntop (const struct res_sym *, int, int *) __THROW |
| 273 | __RESOLV_DEPRECATED; |
| 274 | int		b64_ntop (const unsigned char *, size_t, char *, size_t) |
| 275 | __THROW; |
| 276 | int		b64_pton (char const *, unsigned char *, size_t) __THROW; |
| 277 | int		loc_aton (const char *__ascii, unsigned char *__binary) __THROW |
| 278 | __RESOLV_DEPRECATED; |
| 279 | const char *	loc_ntoa (const unsigned char *__binary, char *__ascii) __THROW |
| 280 | __RESOLV_DEPRECATED; |
| 281 | int		dn_skipname (const unsigned char *, const unsigned char *) |
| 282 | __THROW; |
| 283 | void		putlong (uint32_t, unsigned char *) __THROW |
| 284 | __RESOLV_DEPRECATED_MSG ("use NS_PUT16 instead"); |
| 285 | void		putshort (uint16_t, unsigned char *) __THROW |
| 286 | __RESOLV_DEPRECATED_MSG ("use NS_PUT32 instead"); |
| 287 | const char *	p_class (int) __THROW __RESOLV_DEPRECATED; |
| 288 | const char *	p_time (uint32_t) __THROW __RESOLV_DEPRECATED; |
| 289 | const char *	p_type (int) __THROW __RESOLV_DEPRECATED; |
| 290 | const char *	p_rcode (int) __THROW __RESOLV_DEPRECATED; |
| 291 | const unsigned char * p_cdnname (const unsigned char *, const unsigned char *, |
| 292 | 				 int, FILE *) __THROW __RESOLV_DEPRECATED; |
| 293 | const unsigned char * p_cdname (const unsigned char *, const unsigned char *, |
| 294 | 				FILE *) __THROW __RESOLV_DEPRECATED; |
| 295 | const unsigned char * p_fqnname (const unsigned char *__cp, |
| 296 | 				 const unsigned char *__msg, |
| 297 | 				 int, char *, int) __THROW __RESOLV_DEPRECATED; |
| 298 | const unsigned char * p_fqname (const unsigned char *, const unsigned char *, |
| 299 | 				FILE *) __THROW __RESOLV_DEPRECATED; |
| 300 | const char *	p_option (unsigned long __option) __THROW __RESOLV_DEPRECATED; |
| 301 | int		dn_count_labels (const char *) __THROW __RESOLV_DEPRECATED; |
| 302 | int		dn_comp (const char *, unsigned char *, int, unsigned char **, |
| 303 | 			 unsigned char **) __THROW; |
| 304 | int		dn_expand (const unsigned char *, const unsigned char *, |
| 305 | 			 const unsigned char *, char *, int) __THROW; |
| 306 | unsigned int	res_randomid (void) __THROW |
| 307 | __RESOLV_DEPRECATED_MSG ("use getentropy instead"); |
| 308 | int		res_nameinquery (const char *, int, int, |
| 309 | 				 const unsigned char *, |
| 310 | 				 const unsigned char *) __THROW |
| 311 | __RESOLV_DEPRECATED; |
| 312 | int		res_queriesmatch (const unsigned char *, |
| 313 | 				 const unsigned char *, |
| 314 | 				 const unsigned char *, |
| 315 | 				 const unsigned char *) __THROW |
| 316 | __RESOLV_DEPRECATED; |
| 317 | /* Things involving a resolver context. */ |
| 318 | int		res_ninit (res_state) __THROW; |
| 319 | void		fp_resstat (const res_state, FILE *) __THROW |
| 320 | __RESOLV_DEPRECATED; |
| 321 | const char *	res_hostalias (const res_state, const char *, char *, size_t) |
| 322 | __THROW __RESOLV_DEPRECATED_MSG ("use getaddrinfo instead"); |
| 323 | int		res_nquery (res_state, const char *, int, int, |
| 324 | 			 unsigned char *, int) __THROW; |
| 325 | int		res_nsearch (res_state, const char *, int, int, |
| 326 | 			 unsigned char *, int) __THROW; |
| 327 | int		res_nquerydomain (res_state, const char *, const char *, int, |
| 328 | 				 int, unsigned char *, int) __THROW; |
| 329 | int		res_nmkquery (res_state, int, const char *, int, int, |
| 330 | 			 const unsigned char *, int, |
| 331 | 			 const unsigned char *, unsigned char *, int) |
| 332 | __THROW; |
| 333 | int		res_nsend (res_state, const unsigned char *, int, |
| 334 | 			 unsigned char *, int) __THROW; |
| 335 | void		res_nclose (res_state) __THROW; |
| 336 | |
| 337 | __END_DECLS |
| 338 | |
| 339 | #endif /* !_RESOLV_H_ */ |