resolv.h revision 17902
11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1983, 1987, 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 131539Srgrimes * 3. All advertising materials mentioning features or use of this software 141539Srgrimes * must display the following acknowledgement: 151539Srgrimes * This product includes software developed by the University of 161539Srgrimes * California, Berkeley and its contributors. 171539Srgrimes * 4. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 331539Srgrimes * - 341539Srgrimes * Portions Copyright (c) 1993 by Digital Equipment Corporation. 358858Srgrimes * 361539Srgrimes * Permission to use, copy, modify, and distribute this software for any 371539Srgrimes * purpose with or without fee is hereby granted, provided that the above 381539Srgrimes * copyright notice and this permission notice appear in all copies, and that 391539Srgrimes * the name of Digital Equipment Corporation not be used in advertising or 401539Srgrimes * publicity pertaining to distribution of the document or software without 411539Srgrimes * specific, written prior permission. 428858Srgrimes * 431539Srgrimes * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 441539Srgrimes * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 451539Srgrimes * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 461539Srgrimes * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 471539Srgrimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 481539Srgrimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 491539Srgrimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 501539Srgrimes * SOFTWARE. 511539Srgrimes * - 521539Srgrimes * --Copyright-- 533070Spst * 543070Spst * @(#)resolv.h 8.1 (Berkeley) 6/2/93 553070Spst * From Id: resolv.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp 5617902Speter * $Id: resolv.h,v 1.6 1996/01/30 23:30:34 mpp Exp $ 571539Srgrimes */ 581539Srgrimes 591539Srgrimes#ifndef _RESOLV_H_ 601539Srgrimes#define _RESOLV_H_ 611539Srgrimes 623070Spst#include <sys/param.h> 631539Srgrimes#include <sys/types.h> 643070Spst#include <sys/cdefs.h> 653070Spst#include <stdio.h> 663070Spst 671539Srgrimes/* 683070Spst * revision information. this is the release date in YYYYMMDD format. 693070Spst * it can change every day so the right thing to do with it is use it 703070Spst * in preprocessor commands such as "#if (__RES > 19931104)". do not 713070Spst * compare for equality; rather, use it to determine whether your resolver 723070Spst * is new enough to contain a certain feature. 733070Spst */ 743070Spst 7517902Speter#define __RES 19960229 763070Spst 773070Spst/* 781539Srgrimes * Resolver configuration file. 791539Srgrimes * Normally not present, but may contain the address of the 801539Srgrimes * inital name server(s) to query and the domain search list. 811539Srgrimes */ 821539Srgrimes 831539Srgrimes#ifndef _PATH_RESCONF 843070Spst#define _PATH_RESCONF "/etc/resolv.conf" 851539Srgrimes#endif 861539Srgrimes 871539Srgrimes/* 881539Srgrimes * Global defines and variables for resolver stub. 891539Srgrimes */ 901539Srgrimes#define MAXNS 3 /* max # name servers we'll track */ 911539Srgrimes#define MAXDFLSRCH 3 /* # default domain levels to try */ 921539Srgrimes#define MAXDNSRCH 6 /* max # domains in search path */ 931539Srgrimes#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ 941539Srgrimes 951539Srgrimes#define RES_TIMEOUT 5 /* min. seconds between retries */ 963070Spst#define MAXRESOLVSORT 10 /* number of net to sort on */ 973070Spst#define RES_MAXNDOTS 15 /* should reflect bit field size */ 981539Srgrimes 991539Srgrimesstruct __res_state { 1001539Srgrimes int retrans; /* retransmition time interval */ 1011539Srgrimes int retry; /* number of times to retransmit */ 1023070Spst u_long options; /* option flags - see below. */ 1031539Srgrimes int nscount; /* number of name servers */ 1043070Spst struct sockaddr_in 1053070Spst nsaddr_list[MAXNS]; /* address of name server */ 1061539Srgrimes#define nsaddr nsaddr_list[0] /* for backward compatibility */ 1071539Srgrimes u_short id; /* current packet id */ 1081539Srgrimes char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ 1091539Srgrimes char defdname[MAXDNAME]; /* default domain */ 1103070Spst u_long pfcode; /* RES_PRF_ flags - see below. */ 1113070Spst unsigned ndots:4; /* threshold for initial abs. query */ 1123070Spst unsigned nsort:4; /* number of elements in sort_list[] */ 1133070Spst char unused[3]; 1143070Spst struct { 1153070Spst struct in_addr addr; 1163070Spst u_int32_t mask; 1173070Spst } sort_list[MAXRESOLVSORT]; 11813297Speter char pad[72]; /* On an i386 this means 512b total. */ 1191539Srgrimes}; 1201539Srgrimes 1211539Srgrimes/* 1221539Srgrimes * Resolver options (keep these in synch with res_debug.c, please) 1231539Srgrimes */ 12410132Speter#define RES_INIT 0x00000001 /* address initialized */ 12510132Speter#define RES_DEBUG 0x00000002 /* print debug messages */ 12610132Speter#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ 12710132Speter#define RES_USEVC 0x00000008 /* use virtual circuit */ 12810132Speter#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ 12913771Smpp#define RES_IGNTC 0x00000020 /* ignore truncation errors */ 13010132Speter#define RES_RECURSE 0x00000040 /* recursion desired */ 13110132Speter#define RES_DEFNAMES 0x00000080 /* use default domain name */ 13210132Speter#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ 13310132Speter#define RES_DNSRCH 0x00000200 /* search up local domain tree */ 1343070Spst#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ 1353070Spst#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ 13610132Speter#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ 13717902Speter#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ 1381539Srgrimes 13910132Speter#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) 1401539Srgrimes 1411539Srgrimes/* 1421539Srgrimes * Resolver "pfcode" values. Used by dig. 1431539Srgrimes */ 1443070Spst#define RES_PRF_STATS 0x00000001 1453070Spst/* 0x00000002 */ 1463070Spst#define RES_PRF_CLASS 0x00000004 1473070Spst#define RES_PRF_CMD 0x00000008 1483070Spst#define RES_PRF_QUES 0x00000010 1493070Spst#define RES_PRF_ANS 0x00000020 1503070Spst#define RES_PRF_AUTH 0x00000040 1513070Spst#define RES_PRF_ADD 0x00000080 1523070Spst#define RES_PRF_HEAD1 0x00000100 1533070Spst#define RES_PRF_HEAD2 0x00000200 1543070Spst#define RES_PRF_TTLID 0x00000400 1553070Spst#define RES_PRF_HEADX 0x00000800 1563070Spst#define RES_PRF_QUERY 0x00001000 1573070Spst#define RES_PRF_REPLY 0x00002000 1583070Spst#define RES_PRF_INIT 0x00004000 1593070Spst/* 0x00008000 */ 1601539Srgrimes 1613070Spst/* hooks are still experimental as of 4.9.2 */ 1623070Spsttypedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } 1633070Spst res_sendhookact; 1641539Srgrimes 1653070Spsttypedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns, 1663070Spst const u_char **query, 1673070Spst int *querylen, 1683070Spst u_char *ans, 1693070Spst int anssiz, 1703070Spst int *resplen)); 1713070Spst 1723070Spsttypedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns, 1733070Spst const u_char *query, 1743070Spst int querylen, 1753070Spst u_char *ans, 1763070Spst int anssiz, 1773070Spst int *resplen)); 1783070Spst 1791539Srgrimesextern struct __res_state _res; 1801539Srgrimes 1811539Srgrimes/* Private routines shared between libc/net, named, nslookup and others. */ 18217902Speter#define res_hnok __res_hnok 18317902Speter#define res_ownok __res_ownok 18417902Speter#define res_mailok __res_mailok 18517902Speter#define res_dnok __res_dnok 18617902Speter#define loc_ntoa __loc_ntoa 18717902Speter#define loc_aton __loc_aton 1881539Srgrimes#define dn_skipname __dn_skipname 1891539Srgrimes#define fp_query __fp_query 1903070Spst#define fp_nquery __fp_nquery 1911539Srgrimes#define hostalias __hostalias 1921539Srgrimes#define putlong __putlong 1931539Srgrimes#define putshort __putshort 1943070Spst#define p_class __p_class 1953070Spst#define p_time __p_time 1963070Spst#define p_type __p_type 1973070Spst#define p_cdnname __p_cdnname 1983070Spst#define p_cdname __p_cdname 1993070Spst#define p_fqname __p_fqname 2003070Spst#define p_rr __p_rr 2013070Spst#define p_option __p_option 20210132Speter#define res_randomid __res_randomid 20310132Speter#define res_isourserver __res_isourserver 20410132Speter#define res_nameinquery __res_nameinquery 20510132Speter#define res_queriesmatch __res_queriesmatch 2063070Spst 2071539Srgrimes__BEGIN_DECLS 20817902Speterint __res_hnok __P((const char *)); 20917902Speterint __res_ownok __P((const char *)); 21017902Speterint __res_mailok __P((const char *)); 21117902Speterint __res_dnok __P((const char *)); 21217902Speterint __loc_aton __P((const char *ascii, u_char *binary)); 21317902Speterchar * __loc_ntoa __P((const u_char *binary, char *ascii)); 2141539Srgrimesint __dn_skipname __P((const u_char *, const u_char *)); 2151539Srgrimesvoid __fp_resstat __P((struct __res_state *, FILE *)); 2163070Spstvoid __fp_query __P((const u_char *, FILE *)); 2173070Spstvoid __fp_nquery __P((const u_char *, int, FILE *)); 2181539Srgrimeschar *__hostalias __P((const char *)); 2191539Srgrimesvoid __putlong __P((u_int32_t, u_char *)); 2203070Spstvoid __putshort __P((u_int16_t, u_char *)); 2211539Srgrimeschar *__p_time __P((u_int32_t)); 2223070Spstvoid __p_query __P((const u_char *)); 2233070Spstconst u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *)); 2243070Spstconst u_char *__p_cdname __P((const u_char *, const u_char *, FILE *)); 2253070Spstconst u_char *__p_fqname __P((const u_char *, const u_char *, FILE *)); 2263070Spstconst u_char *__p_rr __P((const u_char *, const u_char *, FILE *)); 2273070Spstconst char *__p_type __P((int)); 2283070Spstconst char *__p_class __P((int)); 2293070Spstconst char *__p_option __P((u_long option)); 2303070Spstint dn_comp __P((const char *, u_char *, int, u_char **, u_char **)); 2311539Srgrimesint dn_expand __P((const u_char *, const u_char *, const u_char *, 2323070Spst char *, int)); 2331539Srgrimesint res_init __P((void)); 23410132Speteru_int16_t res_randomid __P((void)); 2353070Spstint res_query __P((const char *, int, int, u_char *, int)); 2363070Spstint res_search __P((const char *, int, int, u_char *, int)); 2373070Spstint res_querydomain __P((const char *, const char *, int, int, 2383070Spst u_char *, int)); 2393070Spstint res_mkquery __P((int, const char *, int, int, const u_char *, int, 2403070Spst const u_char *, u_char *, int)); 2413070Spstint res_send __P((const u_char *, int, u_char *, int)); 24210132Speterint res_isourserver __P((const struct sockaddr_in *)); 24310132Speterint res_nameinquery __P((const char *, int, int, 24410132Speter const u_char *, const u_char *)); 24510132Speterint res_queriesmatch __P((const u_char *, const u_char *, 24610132Speter const u_char *, const u_char *)); 2471539Srgrimes__END_DECLS 2481539Srgrimes 2491539Srgrimes#endif /* !_RESOLV_H_ */ 250