PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/include/resolv8_compat.h

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