resolv.h revision 28982
14910Swollman/*- 2139365Srik * Copyright (c) 1983, 1987, 1989, 1993 34910Swollman * The Regents of the University of California. All rights reserved. 4139823Simp * 5139823Simp * Redistribution and use in source and binary forms, with or without 6139365Srik * modification, are permitted provided that the following conditions 725944Sjoerg * are met: 84910Swollman * 1. Redistributions of source code must retain the above copyright 925944Sjoerg * notice, this list of conditions and the following disclaimer. 1088534Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 1125944Sjoerg * notice, this list of conditions and the following disclaimer in the 124910Swollman * documentation and/or other materials provided with the distribution. 134910Swollman * 3. All advertising materials mentioning features or use of this software 144910Swollman * must display the following acknowledgement: 154910Swollman * This product includes software developed by the University of 164910Swollman * California, Berkeley and its contributors. 174910Swollman * 4. Neither the name of the University nor the names of its contributors 184910Swollman * may be used to endorse or promote products derived from this software 1930300Sjoerg * without specific prior written permission. 2016288Sgpalmer * 2150477Speter * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 224910Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 234910Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2440008Sjoerg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2540008Sjoerg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2632350Seivind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2754263Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2831742Seivind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2931742Seivind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 304952Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314952Sbde * SUCH DAMAGE. 3270199Sjhay * 3324204Sbde * - 344910Swollman * Portions Copyright (c) 1993 by Digital Equipment Corporation. 3525706Sjoerg * 3659604Sobrien * Permission to use, copy, modify, and distribute this software for any 3729024Sbde * purpose with or without fee is hereby granted, provided that the above 384910Swollman * copyright notice and this permission notice appear in all copies, and that 3940008Sjoerg * the name of Digital Equipment Corporation not be used in advertising or 4030300Sjoerg * publicity pertaining to distribution of the document or software without 414910Swollman * specific, written prior permission. 424910Swollman * 434910Swollman * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 444910Swollman * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 4542104Sphk * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 46196019Srwatson * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 4788534Sjoerg * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 4888534Sjoerg * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 4988534Sjoerg * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 5088534Sjoerg * SOFTWARE. 514910Swollman * - 5230300Sjoerg * --Copyright-- 5330300Sjoerg * 544910Swollman * @(#)resolv.h 8.1 (Berkeley) 6/2/93 5588705Sjoerg * From Id: resolv.h,v 8.18 1997/06/01 20:34:32 vixie Exp 5688705Sjoerg * $Id: resolv.h,v 1.13 1997/06/27 08:32:38 peter Exp $ 574910Swollman */ 584910Swollman 594910Swollman#ifndef _RESOLV_H_ 604910Swollman#define _RESOLV_H_ 61148385Sume 62148385Sume#include <sys/param.h> 63148385Sume#include <sys/types.h> 64148385Sume#include <sys/cdefs.h> 65182121Simp#include <stdio.h> 6688705Sjoerg 6711819Sjulian/* 6811819Sjulian * Revision information. This is the release date in YYYYMMDD format. 6911819Sjulian * It can change every day so the right thing to do with it is use it 7011819Sjulian * in preprocessor commands such as "#if (__RES > 19931104)". Do not 7111819Sjulian * compare for equality; rather, use it to determine whether your resolver 724910Swollman * is new enough to contain a certain feature. 734910Swollman */ 74182121Simp 754910Swollman#define __RES 19960801 764910Swollman 7725944Sjoerg/* 7825944Sjoerg * Resolver configuration file. 7925944Sjoerg * Normally not present, but may contain the address of the 8025955Sjoerg * inital name server(s) to query and the domain search list. 8125944Sjoerg */ 8225944Sjoerg 8325944Sjoerg#ifndef _PATH_RESCONF 8425955Sjoerg#define _PATH_RESCONF "/etc/resolv.conf" 8525955Sjoerg#endif 8625955Sjoerg 8730300Sjoerg/* 8830300Sjoerg * Global defines and variables for resolver stub. 8930300Sjoerg */ 9030300Sjoerg#define MAXNS 3 /* max # name servers we'll track */ 9130300Sjoerg#define MAXDFLSRCH 3 /* # default domain levels to try */ 9230300Sjoerg#define MAXDNSRCH 6 /* max # domains in search path */ 9330300Sjoerg#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ 9430300Sjoerg 9530300Sjoerg#define RES_TIMEOUT 5 /* min. seconds between retries */ 9625944Sjoerg#define MAXRESOLVSORT 10 /* number of net to sort on */ 9725944Sjoerg#define RES_MAXNDOTS 15 /* should reflect bit field size */ 9825955Sjoerg 9925955Sjoergstruct __res_state { 10045152Sphk int retrans; /* retransmition time interval */ 10125944Sjoerg int retry; /* number of times to retransmit */ 10230300Sjoerg u_long options; /* option flags - see below. */ 10330300Sjoerg int nscount; /* number of name servers */ 10430300Sjoerg struct sockaddr_in 10530300Sjoerg nsaddr_list[MAXNS]; /* address of name server */ 10630300Sjoerg#define nsaddr nsaddr_list[0] /* for backward compatibility */ 10730300Sjoerg u_short id; /* current message id */ 10888534Sjoerg char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ 10988534Sjoerg char defdname[256]; /* default domain (deprecated) */ 11078064Sume u_long pfcode; /* RES_PRF_ flags - see below. */ 11130300Sjoerg unsigned ndots:4; /* threshold for initial abs. query */ 11230300Sjoerg unsigned nsort:4; /* number of elements in sort_list[] */ 11330300Sjoerg char unused[3]; 11430300Sjoerg struct { 11578064Sume struct in_addr addr; 1164910Swollman u_int32_t mask; 11725944Sjoerg } sort_list[MAXRESOLVSORT]; 11825944Sjoerg char pad[72]; /* on an i386 this means 512b total */ 11925944Sjoerg}; 12025944Sjoerg 12125944Sjoerg/* 12225944Sjoerg * Resolver options (keep these in synch with res_debug.c, please) 12325944Sjoerg */ 12425944Sjoerg#define RES_INIT 0x00000001 /* address initialized */ 12525944Sjoerg#define RES_DEBUG 0x00000002 /* print debug messages */ 12625944Sjoerg#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ 12725944Sjoerg#define RES_USEVC 0x00000008 /* use virtual circuit */ 1284910Swollman#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ 12930300Sjoerg#define RES_IGNTC 0x00000020 /* ignore truncation errors */ 13030300Sjoerg#define RES_RECURSE 0x00000040 /* recursion desired */ 13130300Sjoerg#define RES_DEFNAMES 0x00000080 /* use default domain name */ 13230300Sjoerg#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ 13330300Sjoerg#define RES_DNSRCH 0x00000200 /* search up local domain tree */ 13430300Sjoerg#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ 13530300Sjoerg#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ 13630300Sjoerg#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ 1374910Swollman#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ 13825944Sjoerg#define RES_NOTLDQUERY 0x00004000 /* Don't query TLD names */ 13925944Sjoerg 14025944Sjoerg#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) 1414910Swollman 14278064Sume/* 14378064Sume * Resolver "pfcode" values. Used by dig. 14478064Sume */ 14588534Sjoerg#define RES_PRF_STATS 0x00000001 14688534Sjoerg/* 0x00000002 */ 14730300Sjoerg#define RES_PRF_CLASS 0x00000004 14830300Sjoerg#define RES_PRF_CMD 0x00000008 14930300Sjoerg#define RES_PRF_QUES 0x00000010 1504910Swollman#define RES_PRF_ANS 0x00000020 15130300Sjoerg#define RES_PRF_AUTH 0x00000040 15230300Sjoerg#define RES_PRF_ADD 0x00000080 15330300Sjoerg#define RES_PRF_HEAD1 0x00000100 15430300Sjoerg#define RES_PRF_HEAD2 0x00000200 15530300Sjoerg#define RES_PRF_TTLID 0x00000400 15630300Sjoerg#define RES_PRF_HEADX 0x00000800 15730300Sjoerg#define RES_PRF_QUERY 0x00001000 15830300Sjoerg#define RES_PRF_REPLY 0x00002000 15930300Sjoerg#define RES_PRF_INIT 0x00004000 16030300Sjoerg/* 0x00008000 */ 16130300Sjoerg 16230300Sjoerg/* hooks are still experimental as of 4.9.2 */ 16330300Sjoergtypedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } 16430300Sjoerg res_sendhookact; 16525944Sjoerg 16625944Sjoergtypedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns, 16725944Sjoerg const u_char **query, 16825944Sjoerg int *querylen, 16925944Sjoerg u_char *ans, 17025944Sjoerg int anssiz, 17125944Sjoerg int *resplen)); 17225944Sjoerg 17325944Sjoergtypedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns, 17425944Sjoerg const u_char *query, 17525944Sjoerg int querylen, 17625944Sjoerg u_char *ans, 177227293Sed int anssiz, 178147256Sbrooks int *resplen)); 1794910Swollman 18011189Sjkhstruct res_sym { 18111189Sjkh int number; /* Identifying number, like T_MX */ 18211189Sjkh char * name; /* Its symbolic name, like "MX" */ 183103842Salfred char * humanname; /* Its fun name, like "mail exchanger" */ 1844910Swollman}; 1854910Swollman 1864910Swollmanextern struct __res_state _res; 18711189Sjkhextern const struct res_sym __p_class_syms[]; 18811189Sjkhextern const struct res_sym __p_type_syms[]; 18911189Sjkh 190103842Salfred/* Private routines shared between libc/net, named, nslookup and others. */ 1914910Swollman#define res_hnok __res_hnok 1924910Swollman#define res_ownok __res_ownok 1934910Swollman#define res_mailok __res_mailok 19411189Sjkh#define res_dnok __res_dnok 19511189Sjkh#define sym_ston __sym_ston 19611189Sjkh#define sym_ntos __sym_ntos 19711189Sjkh#define sym_ntop __sym_ntop 19811189Sjkh#define b64_ntop __b64_ntop 19911189Sjkh#define b64_pton __b64_pton 200103842Salfred#define loc_ntoa __loc_ntoa 20188704Sjoerg#define loc_aton __loc_aton 2024910Swollman#define dn_skipname __dn_skipname 20325944Sjoerg#define fp_resstat __fp_resstat 20425944Sjoerg#define fp_query __fp_query 20525944Sjoerg#define fp_nquery __fp_nquery 20625944Sjoerg#define hostalias __hostalias 20725944Sjoerg#define putlong __putlong 20825944Sjoerg#define putshort __putshort 20925944Sjoerg#define p_class __p_class 21025944Sjoerg#define p_time __p_time 21125944Sjoerg#define p_type __p_type 21225944Sjoerg#define p_query __p_query 21325944Sjoerg#define p_cdnname __p_cdnname 21425944Sjoerg#define p_cdname __p_cdname 21525944Sjoerg#define p_fqnname __p_fqnname 21625944Sjoerg#define p_fqname __p_fqname 21725944Sjoerg#define p_rr __p_rr 21825944Sjoerg#define p_option __p_option 21925944Sjoerg#define p_secstodate __p_secstodate 22025944Sjoerg#define dn_count_labels __dn_count_labels 22125944Sjoerg#define dn_comp __dn_comp 22225944Sjoerg#define res_randomid __res_randomid 22325944Sjoerg#define res_isourserver __res_isourserver 22425944Sjoerg#define res_nameinquery __res_nameinquery 22525944Sjoerg#define res_queriesmatch __res_queriesmatch 22625944Sjoerg#define res_close __res_close 22725944Sjoerg 22825944Sjoerg#ifdef BIND_RES_POSIX3 22925944Sjoerg#define dn_expand __dn_expand 23025944Sjoerg#define res_init __res_init 23125944Sjoerg#define res_query __res_query 23225944Sjoerg#define res_search __res_search 23325944Sjoerg#define res_querydomain __res_querydomain 23425944Sjoerg#define res_mkquery __res_mkquery 23540008Sjoerg#define res_send __res_send 23640008Sjoerg#endif 23740008Sjoerg 238188668Srwatson__BEGIN_DECLS 239188668Srwatsonint res_hnok __P((const char *)); 240188668Srwatsonint res_ownok __P((const char *)); 241190818Sedint res_mailok __P((const char *)); 242138745Srikint res_dnok __P((const char *)); 24388705Sjoergint sym_ston __P((const struct res_sym *, char *, int *)); 2444910Swollmanconst char * sym_ntos __P((const struct res_sym *, int, int *)); 2454910Swollmanconst char * sym_ntop __P((const struct res_sym *, int, int *)); 2464910Swollmanint b64_ntop __P((u_char const *, size_t, char *, size_t)); 2474910Swollmanint b64_pton __P((char const *, u_char *, size_t)); 2484910Swollmanint loc_aton __P((const char *, u_char *)); 24930300Sjoergconst char * loc_ntoa __P((const u_char *, char *)); 25030300Sjoergint dn_skipname __P((const u_char *, const u_char *)); 2514910Swollmanvoid fp_resstat __P((struct __res_state *, FILE *)); 252126910Srwatsonvoid fp_query __P((const u_char *, FILE *)); 2534910Swollmanvoid fp_nquery __P((const u_char *, int, FILE *)); 2544910Swollmanconst char * hostalias __P((const char *)); 2554910Swollmanvoid putlong __P((u_int32_t, u_char *)); 2564910Swollmanvoid putshort __P((u_int16_t, u_char *)); 25788705Sjoergconst char * p_class __P((int)); 2584910Swollmanconst char * p_time __P((u_int32_t)); 25925944Sjoergconst char * p_type __P((int)); 26025944Sjoergvoid p_query __P((const u_char *)); 261147256Sbrooksconst u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *)); 26225944Sjoergconst u_char * p_cdname __P((const u_char *, const u_char *, FILE *)); 26311189Sjkhconst u_char * p_fqnname __P((const u_char *, const u_char *, 26430300Sjoerg int, char *, int)); 265191148Skmacyconst u_char * p_fqname __P((const u_char *, const u_char *, FILE *)); 2664910Swollmanconst u_char * p_rr __P((const u_char *, const u_char *, FILE *)); 26725944Sjoergconst char * p_option __P((u_long)); 26825944Sjoergchar * p_secstodate __P((u_long)); 26925944Sjoergint dn_count_labels __P((char *)); 27025944Sjoergint dn_comp __P((const char *, u_char *, int, 27125944Sjoerg u_char **, u_char **)); 27225944Sjoergint dn_expand __P((const u_char *, const u_char *, const u_char *, 27325944Sjoerg char *, int)); 27442104Sphkint res_init __P((void)); 27525944Sjoergu_int res_randomid __P((void)); 27625944Sjoergint res_query __P((const char *, int, int, u_char *, int)); 27730300Sjoergint res_search __P((const char *, int, int, u_char *, int)); 27842104Sphkint res_querydomain __P((const char *, const char *, int, int, 27930300Sjoerg u_char *, int)); 28025944Sjoergint res_mkquery __P((int, const char *, int, int, const u_char *, 28125944Sjoerg int, const u_char *, u_char *, int)); 28225944Sjoergint res_send __P((const u_char *, int, u_char *, int)); 28325944Sjoergint res_isourserver __P((const struct sockaddr_in *)); 28425944Sjoergint res_nameinquery __P((const char *, int, int, 28525944Sjoerg const u_char *, const u_char *)); 28625944Sjoergint res_queriesmatch __P((const u_char *, const u_char *, 28730300Sjoerg const u_char *, const u_char *)); 28830300Sjoergvoid res_close __P((void)); 289138745Srik__END_DECLS 290138745Srik 291138745Srik#endif /* !_RESOLV_H_ */ 29225944Sjoerg