resolv.h revision 1.7
1/* 2 * Copyright (c) 1983, 1987, 1989 The Regents of the University of California. 3 * 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 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * from: @(#)resolv.h 5.15 (Berkeley) 4/3/91 34 * $Id: resolv.h,v 1.7 1994/10/19 03:46:42 cgd Exp $ 35 */ 36 37#ifndef _RESOLV_H_ 38#define _RESOLV_H_ 39 40/* 41 * revision information. this is the release date in YYYYMMDD format. 42 * it can change every day so the right thing to do with it is use it 43 * in preprocessor commands such as "#if (__RES > 19931104)". do not 44 * compare for equality; rather, use it to determine whether your resolver 45 * is new enough to contain a certain feature. 46 */ 47 48#define __RES 19931104 49 50/* 51 * Resolver configuration file. 52 * Normally not present, but may contain the address of the 53 * inital name server(s) to query and the domain search list. 54 */ 55 56#ifndef _PATH_RESCONF 57#define _PATH_RESCONF "/etc/resolv.conf" 58#endif 59 60/* 61 * Global defines and variables for resolver stub. 62 */ 63#define MAXNS 3 /* max # name servers we'll track */ 64#define MAXDFLSRCH 3 /* # default domain levels to try */ 65#define MAXDNSRCH 6 /* max # domains in search path */ 66#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ 67#define MAXDNSLUS 4 /* max # of host lookup types */ 68 69#define RES_TIMEOUT 5 /* min. seconds between retries */ 70#define MAXRESOLVSORT 10 /* number of net to sort on */ 71#define RES_MAXNDOTS 15 /* should reflect bit field size */ 72 73struct __res_state { 74 int retrans; /* retransmition time interval */ 75 int retry; /* number of times to retransmit */ 76 long options; /* option flags - see below. */ 77 int nscount; /* number of name servers */ 78 struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ 79#define nsaddr nsaddr_list[0] /* for backward compatibility */ 80 u_short id; /* current packet id */ 81 char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ 82 char defdname[MAXDNAME]; /* default domain */ 83 long pfcode; /* RES_PRF_ flags - see below. */ 84 u_char ndots:4; /* threshold for initial abs. query */ 85 u_char nsort:4; /* number of elements in sort_list[] */ 86 char unused[3]; 87 struct { 88 struct in_addr addr; 89 u_int32_t mask; 90 } sort_list[MAXRESOLVSORT]; 91 char lookups[MAXDNSLUS]; 92}; 93 94/* 95 * Resolver options 96 */ 97#define RES_INIT 0x0001 /* address initialized */ 98#define RES_DEBUG 0x0002 /* print debug messages */ 99#define RES_AAONLY 0x0004 /* authoritative answers only */ 100#define RES_USEVC 0x0008 /* use virtual circuit */ 101#define RES_PRIMARY 0x0010 /* query primary server only */ 102#define RES_IGNTC 0x0020 /* ignore trucation errors */ 103#define RES_RECURSE 0x0040 /* recursion desired */ 104#define RES_DEFNAMES 0x0080 /* use default domain name */ 105#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */ 106#define RES_DNSRCH 0x0200 /* search up local domain tree */ 107 108#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) 109 110/* 111 * Resolver "pfcode" values. Used by dig. 112 */ 113#define RES_PRF_STATS 0x0001 114/* 0x0002 */ 115#define RES_PRF_CLASS 0x0004 116#define RES_PRF_CMD 0x0008 117#define RES_PRF_QUES 0x0010 118#define RES_PRF_ANS 0x0020 119#define RES_PRF_AUTH 0x0040 120#define RES_PRF_ADD 0x0080 121#define RES_PRF_HEAD1 0x0100 122#define RES_PRF_HEAD2 0x0200 123#define RES_PRF_TTLID 0x0400 124#define RES_PRF_HEADX 0x0800 125#define RES_PRF_QUERY 0x1000 126#define RES_PRF_REPLY 0x2000 127#define RES_PRF_INIT 0x4000 128/* 0x8000 */ 129 130extern struct __res_state _res; 131 132#include <sys/cdefs.h> 133#include <stdio.h> 134 135/* Private routines shared between libc/net, named, nslookup and others. */ 136#define dn_skipname __dn_skipname 137#define fp_query __fp_query 138#define hostalias __hostalias 139#define putlong __putlong 140#define putshort __putshort 141#define p_class __p_class 142#define p_time __p_time 143#define p_type __p_type 144__BEGIN_DECLS 145int __dn_skipname __P((const u_char *, const u_char *)); 146void __fp_query __P((char *, FILE *)); 147char *__hostalias __P((const char *)); 148void __putlong __P((u_int32_t, u_char *)); 149void __putshort __P((u_int16_t, u_char *)); 150char *__p_class __P((int)); 151char *__p_time __P((u_int32_t)); 152char *__p_type __P((int)); 153 154int dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **)); 155int dn_expand __P((const u_char *, const u_char *, const u_char *, 156 u_char *, int)); 157int res_init __P((void)); 158int res_query __P((char *, int, int, u_char *, int)); 159int res_search __P((const char *, int, int, u_char *, int)); 160int res_mkquery __P((int, const char *, int, int, const char *, int, 161 const char *, char *, int)); 162int res_send __P((const char *, int, char *, int)); 163__END_DECLS 164 165#endif /* !_RESOLV_H_ */ 166