159deaec5SRodney W. Grimes /*- 259deaec5SRodney W. Grimes * Copyright (c) 1983, 1987, 1989, 1993 359deaec5SRodney W. Grimes * The Regents of the University of California. All rights reserved. 459deaec5SRodney W. Grimes * 559deaec5SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 659deaec5SRodney W. Grimes * modification, are permitted provided that the following conditions 759deaec5SRodney W. Grimes * are met: 859deaec5SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 959deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1059deaec5SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1159deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1259deaec5SRodney W. Grimes * documentation and/or other materials provided with the distribution. 1359deaec5SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 1459deaec5SRodney W. Grimes * must display the following acknowledgement: 1559deaec5SRodney W. Grimes * This product includes software developed by the University of 1659deaec5SRodney W. Grimes * California, Berkeley and its contributors. 1759deaec5SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 1859deaec5SRodney W. Grimes * may be used to endorse or promote products derived from this software 1959deaec5SRodney W. Grimes * without specific prior written permission. 2059deaec5SRodney W. Grimes * 2159deaec5SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2259deaec5SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2359deaec5SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2459deaec5SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2559deaec5SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2659deaec5SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2759deaec5SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2859deaec5SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2959deaec5SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3059deaec5SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3159deaec5SRodney W. Grimes * SUCH DAMAGE. 320160f9c0SPeter Wemm */ 330160f9c0SPeter Wemm 340160f9c0SPeter Wemm /* 350160f9c0SPeter Wemm * Portions Copyright (c) 1996 by Internet Software Consortium. 3659deaec5SRodney W. Grimes * 3759deaec5SRodney W. Grimes * Permission to use, copy, modify, and distribute this software for any 3859deaec5SRodney W. Grimes * purpose with or without fee is hereby granted, provided that the above 390160f9c0SPeter Wemm * copyright notice and this permission notice appear in all copies. 4059deaec5SRodney W. Grimes * 410160f9c0SPeter Wemm * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS 420160f9c0SPeter Wemm * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 430160f9c0SPeter Wemm * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE 440160f9c0SPeter Wemm * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 4559deaec5SRodney W. Grimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 4659deaec5SRodney W. Grimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 4759deaec5SRodney W. Grimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 4859deaec5SRodney W. Grimes * SOFTWARE. 490160f9c0SPeter Wemm */ 500160f9c0SPeter Wemm 510160f9c0SPeter Wemm /* 521363f04cSPaul Traina * @(#)resolv.h 8.1 (Berkeley) 6/2/93 530160f9c0SPeter Wemm * From Id: resolv.h,v 8.12 1998/04/28 19:36:46 halley Exp $ 540160f9c0SPeter Wemm * $Id: resolv.h,v 1.14 1997/09/01 01:19:10 brian Exp $ 5559deaec5SRodney W. Grimes */ 5659deaec5SRodney W. Grimes 5759deaec5SRodney W. Grimes #ifndef _RESOLV_H_ 5859deaec5SRodney W. Grimes #define _RESOLV_H_ 5959deaec5SRodney W. Grimes 601363f04cSPaul Traina #include <sys/param.h> 6159deaec5SRodney W. Grimes #include <sys/types.h> 621363f04cSPaul Traina #include <sys/cdefs.h> 631363f04cSPaul Traina #include <stdio.h> 641363f04cSPaul Traina 651363f04cSPaul Traina /* 66315d6d9cSPeter Wemm * Revision information. This is the release date in YYYYMMDD format. 67315d6d9cSPeter Wemm * It can change every day so the right thing to do with it is use it 68315d6d9cSPeter Wemm * in preprocessor commands such as "#if (__RES > 19931104)". Do not 691363f04cSPaul Traina * compare for equality; rather, use it to determine whether your resolver 701363f04cSPaul Traina * is new enough to contain a certain feature. 711363f04cSPaul Traina */ 721363f04cSPaul Traina 73315d6d9cSPeter Wemm #define __RES 19960801 741363f04cSPaul Traina 7559deaec5SRodney W. Grimes /* 760160f9c0SPeter Wemm * This used to be defined in res_query.c, now it's in herror.c. It was 770160f9c0SPeter Wemm * never extern'd by any *.h file before it was placed here. herror.c is 780160f9c0SPeter Wemm * part of libresolv.a even though it might make more sense in libnetdb.a 790160f9c0SPeter Wemm * or even libnet.a. 800160f9c0SPeter Wemm */ 810160f9c0SPeter Wemm 820160f9c0SPeter Wemm extern int h_errno; 830160f9c0SPeter Wemm 840160f9c0SPeter Wemm /* 8559deaec5SRodney W. Grimes * Resolver configuration file. 8659deaec5SRodney W. Grimes * Normally not present, but may contain the address of the 8759deaec5SRodney W. Grimes * inital name server(s) to query and the domain search list. 8859deaec5SRodney W. Grimes */ 8959deaec5SRodney W. Grimes 9059deaec5SRodney W. Grimes #ifndef _PATH_RESCONF 9159deaec5SRodney W. Grimes #define _PATH_RESCONF "/etc/resolv.conf" 9259deaec5SRodney W. Grimes #endif 9359deaec5SRodney W. Grimes 9459deaec5SRodney W. Grimes /* 9559deaec5SRodney W. Grimes * Global defines and variables for resolver stub. 9659deaec5SRodney W. Grimes */ 9759deaec5SRodney W. Grimes #define MAXNS 3 /* max # name servers we'll track */ 9859deaec5SRodney W. Grimes #define MAXDFLSRCH 3 /* # default domain levels to try */ 9959deaec5SRodney W. Grimes #define MAXDNSRCH 6 /* max # domains in search path */ 10059deaec5SRodney W. Grimes #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ 10159deaec5SRodney W. Grimes 10259deaec5SRodney W. Grimes #define RES_TIMEOUT 5 /* min. seconds between retries */ 1031363f04cSPaul Traina #define MAXRESOLVSORT 10 /* number of net to sort on */ 1041363f04cSPaul Traina #define RES_MAXNDOTS 15 /* should reflect bit field size */ 10559deaec5SRodney W. Grimes 10659deaec5SRodney W. Grimes struct __res_state { 10759deaec5SRodney W. Grimes int retrans; /* retransmition time interval */ 10859deaec5SRodney W. Grimes int retry; /* number of times to retransmit */ 1091363f04cSPaul Traina u_long options; /* option flags - see below. */ 11059deaec5SRodney W. Grimes int nscount; /* number of name servers */ 1111363f04cSPaul Traina struct sockaddr_in 1121363f04cSPaul Traina nsaddr_list[MAXNS]; /* address of name server */ 11359deaec5SRodney W. Grimes #define nsaddr nsaddr_list[0] /* for backward compatibility */ 114315d6d9cSPeter Wemm u_short id; /* current message id */ 11559deaec5SRodney W. Grimes char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ 116315d6d9cSPeter Wemm char defdname[256]; /* default domain (deprecated) */ 1171363f04cSPaul Traina u_long pfcode; /* RES_PRF_ flags - see below. */ 1181363f04cSPaul Traina unsigned ndots:4; /* threshold for initial abs. query */ 1191363f04cSPaul Traina unsigned nsort:4; /* number of elements in sort_list[] */ 1201363f04cSPaul Traina char unused[3]; 1211363f04cSPaul Traina struct { 1221363f04cSPaul Traina struct in_addr addr; 1231363f04cSPaul Traina u_int32_t mask; 1241363f04cSPaul Traina } sort_list[MAXRESOLVSORT]; 125315d6d9cSPeter Wemm char pad[72]; /* on an i386 this means 512b total */ 12659deaec5SRodney W. Grimes }; 12759deaec5SRodney W. Grimes 12859deaec5SRodney W. Grimes /* 12959deaec5SRodney W. Grimes * Resolver options (keep these in synch with res_debug.c, please) 13059deaec5SRodney W. Grimes */ 1311363f04cSPaul Traina #define RES_INIT 0x00000001 /* address initialized */ 1321363f04cSPaul Traina #define RES_DEBUG 0x00000002 /* print debug messages */ 133d58a9efdSPeter Wemm #define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ 1341363f04cSPaul Traina #define RES_USEVC 0x00000008 /* use virtual circuit */ 135d58a9efdSPeter Wemm #define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ 13671d9c781SMike Pritchard #define RES_IGNTC 0x00000020 /* ignore truncation errors */ 1371363f04cSPaul Traina #define RES_RECURSE 0x00000040 /* recursion desired */ 1381363f04cSPaul Traina #define RES_DEFNAMES 0x00000080 /* use default domain name */ 1391363f04cSPaul Traina #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ 1401363f04cSPaul Traina #define RES_DNSRCH 0x00000200 /* search up local domain tree */ 1411363f04cSPaul Traina #define RES_INSECURE1 0x00000400 /* type 1 security disabled */ 1421363f04cSPaul Traina #define RES_INSECURE2 0x00000800 /* type 2 security disabled */ 143d58a9efdSPeter Wemm #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ 14474b3fad6SPeter Wemm #define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ 145a367bd9eSBrian Somers #define RES_NOTLDQUERY 0x00004000 /* Don't query TLD names */ 14659deaec5SRodney W. Grimes 14759deaec5SRodney W. Grimes #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) 14859deaec5SRodney W. Grimes 14959deaec5SRodney W. Grimes /* 15059deaec5SRodney W. Grimes * Resolver "pfcode" values. Used by dig. 15159deaec5SRodney W. Grimes */ 1521363f04cSPaul Traina #define RES_PRF_STATS 0x00000001 1530160f9c0SPeter Wemm #define RES_PRF_UPDATE 0x00000002 1541363f04cSPaul Traina #define RES_PRF_CLASS 0x00000004 1551363f04cSPaul Traina #define RES_PRF_CMD 0x00000008 1561363f04cSPaul Traina #define RES_PRF_QUES 0x00000010 1571363f04cSPaul Traina #define RES_PRF_ANS 0x00000020 1581363f04cSPaul Traina #define RES_PRF_AUTH 0x00000040 1591363f04cSPaul Traina #define RES_PRF_ADD 0x00000080 1601363f04cSPaul Traina #define RES_PRF_HEAD1 0x00000100 1611363f04cSPaul Traina #define RES_PRF_HEAD2 0x00000200 1621363f04cSPaul Traina #define RES_PRF_TTLID 0x00000400 1631363f04cSPaul Traina #define RES_PRF_HEADX 0x00000800 1641363f04cSPaul Traina #define RES_PRF_QUERY 0x00001000 1651363f04cSPaul Traina #define RES_PRF_REPLY 0x00002000 1661363f04cSPaul Traina #define RES_PRF_INIT 0x00004000 1671363f04cSPaul Traina /* 0x00008000 */ 16859deaec5SRodney W. Grimes 1691363f04cSPaul Traina typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } 1701363f04cSPaul Traina res_sendhookact; 1711363f04cSPaul Traina 1721363f04cSPaul Traina typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns, 1731363f04cSPaul Traina const u_char **query, 1741363f04cSPaul Traina int *querylen, 1751363f04cSPaul Traina u_char *ans, 1761363f04cSPaul Traina int anssiz, 1771363f04cSPaul Traina int *resplen)); 1781363f04cSPaul Traina 1791363f04cSPaul Traina typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns, 1801363f04cSPaul Traina const u_char *query, 1811363f04cSPaul Traina int querylen, 1821363f04cSPaul Traina u_char *ans, 1831363f04cSPaul Traina int anssiz, 1841363f04cSPaul Traina int *resplen)); 18559deaec5SRodney W. Grimes 186315d6d9cSPeter Wemm struct res_sym { 187315d6d9cSPeter Wemm int number; /* Identifying number, like T_MX */ 188315d6d9cSPeter Wemm char * name; /* Its symbolic name, like "MX" */ 189315d6d9cSPeter Wemm char * humanname; /* Its fun name, like "mail exchanger" */ 190315d6d9cSPeter Wemm }; 191315d6d9cSPeter Wemm 19259deaec5SRodney W. Grimes extern struct __res_state _res; 193315d6d9cSPeter Wemm extern const struct res_sym __p_class_syms[]; 194315d6d9cSPeter Wemm extern const struct res_sym __p_type_syms[]; 19559deaec5SRodney W. Grimes 19659deaec5SRodney W. Grimes /* Private routines shared between libc/net, named, nslookup and others. */ 19774b3fad6SPeter Wemm #define res_hnok __res_hnok 19874b3fad6SPeter Wemm #define res_ownok __res_ownok 19974b3fad6SPeter Wemm #define res_mailok __res_mailok 20074b3fad6SPeter Wemm #define res_dnok __res_dnok 201315d6d9cSPeter Wemm #define sym_ston __sym_ston 202315d6d9cSPeter Wemm #define sym_ntos __sym_ntos 203315d6d9cSPeter Wemm #define sym_ntop __sym_ntop 204315d6d9cSPeter Wemm #define b64_ntop __b64_ntop 205315d6d9cSPeter Wemm #define b64_pton __b64_pton 20674b3fad6SPeter Wemm #define loc_ntoa __loc_ntoa 20774b3fad6SPeter Wemm #define loc_aton __loc_aton 2080160f9c0SPeter Wemm #define fp_resstat __fp_resstat /* XXX new divert */ 2090160f9c0SPeter Wemm #define p_query __p_query /* XXX new divert */ 21059deaec5SRodney W. Grimes #define dn_skipname __dn_skipname 211315d6d9cSPeter Wemm #define fp_resstat __fp_resstat 21259deaec5SRodney W. Grimes #define fp_query __fp_query 2131363f04cSPaul Traina #define fp_nquery __fp_nquery 21459deaec5SRodney W. Grimes #define hostalias __hostalias 21559deaec5SRodney W. Grimes #define putlong __putlong 21659deaec5SRodney W. Grimes #define putshort __putshort 21759deaec5SRodney W. Grimes #define p_class __p_class 21859deaec5SRodney W. Grimes #define p_time __p_time 21959deaec5SRodney W. Grimes #define p_type __p_type 220315d6d9cSPeter Wemm #define p_query __p_query 2211363f04cSPaul Traina #define p_cdnname __p_cdnname 2220160f9c0SPeter Wemm #define p_section __p_section /* XXX new func in 8.1 */ 2231363f04cSPaul Traina #define p_cdname __p_cdname 224315d6d9cSPeter Wemm #define p_fqnname __p_fqnname 2251363f04cSPaul Traina #define p_fqname __p_fqname 2260160f9c0SPeter Wemm /* XXX p_rr gone */ 2271363f04cSPaul Traina #define p_option __p_option 228315d6d9cSPeter Wemm #define p_secstodate __p_secstodate 229315d6d9cSPeter Wemm #define dn_count_labels __dn_count_labels 230315d6d9cSPeter Wemm #define dn_comp __dn_comp 2310160f9c0SPeter Wemm #define dn_expand __dn_expand /* XXX unmasked */ 2320160f9c0SPeter Wemm #define res_init __res_init /* XXX unmasked */ 233d58a9efdSPeter Wemm #define res_randomid __res_randomid 2340160f9c0SPeter Wemm #define res_query __res_query /* XXX unmasked */ 2350160f9c0SPeter Wemm #define res_search __res_search /* XXX unmasked */ 2360160f9c0SPeter Wemm #define res_querydomain __res_querydomain /* XXX unmasked */ 2370160f9c0SPeter Wemm #define res_mkquery __res_mkquery /* XXX unmasked */ 2380160f9c0SPeter Wemm #define res_send __res_send /* XXX unmasked */ 239d58a9efdSPeter Wemm #define res_isourserver __res_isourserver 240d58a9efdSPeter Wemm #define res_nameinquery __res_nameinquery 241d58a9efdSPeter Wemm #define res_queriesmatch __res_queriesmatch 242315d6d9cSPeter Wemm #define res_close __res_close 2430160f9c0SPeter Wemm #define res_mkupdate __res_mkupdate /* XXX new func in 8.1 */ 2440160f9c0SPeter Wemm #define res_mkupdrec __res_mkupdrec /* XXX new func in 8.1 */ 2450160f9c0SPeter Wemm #define res_freeupdrec __res_freeupdrec /* XXX new func in 8.1 */ 2461363f04cSPaul Traina 24759deaec5SRodney W. Grimes __BEGIN_DECLS 248315d6d9cSPeter Wemm int res_hnok __P((const char *)); 249315d6d9cSPeter Wemm int res_ownok __P((const char *)); 250315d6d9cSPeter Wemm int res_mailok __P((const char *)); 251315d6d9cSPeter Wemm int res_dnok __P((const char *)); 2520160f9c0SPeter Wemm int sym_ston __P((const struct res_sym *, const char *, int *)); 253315d6d9cSPeter Wemm const char * sym_ntos __P((const struct res_sym *, int, int *)); 254315d6d9cSPeter Wemm const char * sym_ntop __P((const struct res_sym *, int, int *)); 255315d6d9cSPeter Wemm int b64_ntop __P((u_char const *, size_t, char *, size_t)); 256315d6d9cSPeter Wemm int b64_pton __P((char const *, u_char *, size_t)); 257315d6d9cSPeter Wemm int loc_aton __P((const char *, u_char *)); 258315d6d9cSPeter Wemm const char * loc_ntoa __P((const u_char *, char *)); 259315d6d9cSPeter Wemm int dn_skipname __P((const u_char *, const u_char *)); 260315d6d9cSPeter Wemm void fp_resstat __P((struct __res_state *, FILE *)); 261315d6d9cSPeter Wemm void fp_query __P((const u_char *, FILE *)); 262315d6d9cSPeter Wemm void fp_nquery __P((const u_char *, int, FILE *)); 263315d6d9cSPeter Wemm const char * hostalias __P((const char *)); 264315d6d9cSPeter Wemm void putlong __P((u_int32_t, u_char *)); 265315d6d9cSPeter Wemm void putshort __P((u_int16_t, u_char *)); 266315d6d9cSPeter Wemm const char * p_class __P((int)); 267315d6d9cSPeter Wemm const char * p_time __P((u_int32_t)); 268315d6d9cSPeter Wemm const char * p_type __P((int)); 269315d6d9cSPeter Wemm void p_query __P((const u_char *)); 270315d6d9cSPeter Wemm const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *)); 271315d6d9cSPeter Wemm const u_char * p_cdname __P((const u_char *, const u_char *, FILE *)); 272315d6d9cSPeter Wemm const u_char * p_fqnname __P((const u_char *, const u_char *, 273315d6d9cSPeter Wemm int, char *, int)); 274315d6d9cSPeter Wemm const u_char * p_fqname __P((const u_char *, const u_char *, FILE *)); 275315d6d9cSPeter Wemm const char * p_option __P((u_long)); 276315d6d9cSPeter Wemm char * p_secstodate __P((u_long)); 2770160f9c0SPeter Wemm int dn_count_labels __P((const char *)); 278315d6d9cSPeter Wemm int dn_comp __P((const char *, u_char *, int, 279315d6d9cSPeter Wemm u_char **, u_char **)); 28059deaec5SRodney W. Grimes int dn_expand __P((const u_char *, const u_char *, const u_char *, 2811363f04cSPaul Traina char *, int)); 28259deaec5SRodney W. Grimes int res_init __P((void)); 283315d6d9cSPeter Wemm u_int res_randomid __P((void)); 2841363f04cSPaul Traina int res_query __P((const char *, int, int, u_char *, int)); 2851363f04cSPaul Traina int res_search __P((const char *, int, int, u_char *, int)); 2861363f04cSPaul Traina int res_querydomain __P((const char *, const char *, int, int, 2871363f04cSPaul Traina u_char *, int)); 288315d6d9cSPeter Wemm int res_mkquery __P((int, const char *, int, int, const u_char *, 289315d6d9cSPeter Wemm int, const u_char *, u_char *, int)); 2901363f04cSPaul Traina int res_send __P((const u_char *, int, u_char *, int)); 291d58a9efdSPeter Wemm int res_isourserver __P((const struct sockaddr_in *)); 292d58a9efdSPeter Wemm int res_nameinquery __P((const char *, int, int, 293d58a9efdSPeter Wemm const u_char *, const u_char *)); 294d58a9efdSPeter Wemm int res_queriesmatch __P((const u_char *, const u_char *, 295d58a9efdSPeter Wemm const u_char *, const u_char *)); 296315d6d9cSPeter Wemm void res_close __P((void)); 2970160f9c0SPeter Wemm const char * p_section __P((int, int)); 2980160f9c0SPeter Wemm int res_update __P((ns_updrec *)); 2990160f9c0SPeter Wemm int res_mkupdate __P((ns_updrec *, u_char *, int)); 3000160f9c0SPeter Wemm ns_updrec * res_mkupdrec __P((int, const char *, u_int, u_int, u_long)); 3010160f9c0SPeter Wemm void res_freeupdrec __P((ns_updrec *)); 30259deaec5SRodney W. Grimes __END_DECLS 30359deaec5SRodney W. Grimes 30459deaec5SRodney W. Grimes #endif /* !_RESOLV_H_ */ 305