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