resolv.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1983, 1987, 1989, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the University of
00016  *      California, Berkeley and its contributors.
00017  * 4. Neither the name of the University nor the names of its contributors
00018  *    may be used to endorse or promote products derived from this software
00019  *    without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  */
00033 
00034 /*
00035  * Portions Copyright (c) 1996 by Internet Software Consortium.
00036  *
00037  * Permission to use, copy, modify, and distribute this software for any
00038  * purpose with or without fee is hereby granted, provided that the above
00039  * copyright notice and this permission notice appear in all copies.
00040  *
00041  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
00042  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
00043  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
00044  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
00045  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00046  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00047  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00048  * SOFTWARE.
00049  * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
00050  */
00051 
00052 /*
00053  *      @(#)resolv.h    8.1 (Berkeley) 6/2/93
00054  *      From Id: resolv.h,v 8.12 1998/04/28 19:36:46 halley Exp $
00055  * $FreeBSD: src/include/resolv.h,v 1.26 2004/09/09 17:39:47 yar Exp $
00056  */
00057 
00058 #ifndef _RESOLV_H_
00059 #define _RESOLV_H_
00060 
00061 #include <sys/param.h>
00062 #include <sys/types.h>
00063 #include <sys/cdefs.h>
00064 #include <sys/socket.h>
00065 #include <stdio.h>
00066 
00067 /*
00068  * Revision information.  This is the release date in YYYYMMDD format.
00069  * It can change every day so the right thing to do with it is use it
00070  * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
00071  * compare for equality; rather, use it to determine whether your resolver
00072  * is new enough to contain a certain feature.
00073  */
00074 
00075 #define __RES   19960801
00076 
00077 /*
00078  * Resolver configuration file.
00079  * Normally not present, but may contain the address of the
00080  * inital name server(s) to query and the domain search list.
00081  */
00082 
00083 #ifndef _PATH_RESCONF
00084 #define _PATH_RESCONF        "/etc/resolv.conf"
00085 #endif
00086 
00087 /*
00088  * Global defines and variables for resolver stub.
00089  */
00090 #define MAXNS                   3       /* max # name servers we'll track */
00091 #define MAXDFLSRCH              3       /* # default domain levels to try */
00092 #define MAXDNSRCH               6       /* max # domains in search path */
00093 #define LOCALDOMAINPARTS        2       /* min levels in name that is "local" */
00094 
00095 #define RES_TIMEOUT             5       /* min. seconds between retries */
00096 #define RES_DFLRETRY            4       /* retries per each name server */
00097 #define MAXRESOLVSORT           10      /* number of net to sort on */
00098 #define RES_MAXNDOTS            15      /* should reflect bit field size */
00099 #define RES_MAXRETRANS          30      /* only for resolv.conf/RES_OPTIONS */
00100 #define RES_MAXRETRY            5       /* only for resolv.conf/RES_OPTIONS */
00101 
00102 struct __res_state {
00103         int     retrans;                /* retransmition time interval */
00104         int     retry;                  /* number of times to retransmit */
00105         u_long  options;                /* option flags - see below. */
00106         int     nscount;                /* number of name servers */
00107         struct sockaddr_in
00108                 nsaddr_list[MAXNS];     /* address of name server */
00109 #define nsaddr  nsaddr_list[0]          /* for backward compatibility */
00110         u_short id;                     /* current message id */
00111         char    *dnsrch[MAXDNSRCH+1];   /* components of domain to search */
00112         char    defdname[256];          /* default domain (deprecated) */
00113         u_long  pfcode;                 /* RES_PRF_ flags - see below. */
00114         unsigned ndots:4;               /* threshold for initial abs. query */
00115         unsigned nsort:4;               /* number of elements in sort_list[] */
00116         char    unused[3];
00117         struct {
00118                 struct in_addr  addr;
00119                 u_int32_t       mask;
00120         } sort_list[MAXRESOLVSORT];
00121         char    pad[72];                /* on an i386 this means 512b total */
00122 };
00123 
00124 /* for INET6 */
00125 /*
00126  * replacement of __res_state, separated to keep binary compatibility.
00127  */
00128 struct __res_state_ext {
00129         struct sockaddr_storage nsaddr_list[MAXNS];
00130         struct {
00131                 int     af;             /* address family for addr, mask */
00132                 union {
00133                         struct  in_addr ina;
00134                         struct  in6_addr in6a;
00135                 } addr, mask;
00136         } sort_list[MAXRESOLVSORT];
00137 };
00138 
00139 /*
00140  * Resolver options (keep these in synch with res_debug.c, please)
00141  */
00142 #define RES_INIT        0x00000001      /* address initialized */
00143 #define RES_DEBUG       0x00000002      /* print debug messages */
00144 #define RES_AAONLY      0x00000004      /* authoritative answers only (!IMPL)*/
00145 #define RES_USEVC       0x00000008      /* use virtual circuit */
00146 #define RES_PRIMARY     0x00000010      /* query primary server only (!IMPL) */
00147 #define RES_IGNTC       0x00000020      /* ignore truncation errors */
00148 #define RES_RECURSE     0x00000040      /* recursion desired */
00149 #define RES_DEFNAMES    0x00000080      /* use default domain name */
00150 #define RES_STAYOPEN    0x00000100      /* Keep TCP socket open */
00151 #define RES_DNSRCH      0x00000200      /* search up local domain tree */
00152 #define RES_INSECURE1   0x00000400      /* type 1 security disabled */
00153 #define RES_INSECURE2   0x00000800      /* type 2 security disabled */
00154 #define RES_NOALIASES   0x00001000      /* shuts off HOSTALIASES feature */
00155 #define RES_USE_INET6   0x00002000      /* use/map IPv6 in gethostbyname() */
00156 #define RES_NOTLDQUERY  0x00004000      /* Don't query TLD names */
00157 /* KAME extensions: use higher bit to avoid conflict with ISC use */
00158 #define RES_USE_EDNS0   0x40000000      /* use EDNS0 */
00159 
00160 #define RES_DEFAULT     (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
00161 
00162 /*
00163  * Resolver "pfcode" values.  Used by dig.
00164  */
00165 #define RES_PRF_STATS   0x00000001
00166 #define RES_PRF_UPDATE  0x00000002
00167 #define RES_PRF_CLASS   0x00000004
00168 #define RES_PRF_CMD     0x00000008
00169 #define RES_PRF_QUES    0x00000010
00170 #define RES_PRF_ANS     0x00000020
00171 #define RES_PRF_AUTH    0x00000040
00172 #define RES_PRF_ADD     0x00000080
00173 #define RES_PRF_HEAD1   0x00000100
00174 #define RES_PRF_HEAD2   0x00000200
00175 #define RES_PRF_TTLID   0x00000400
00176 #define RES_PRF_HEADX   0x00000800
00177 #define RES_PRF_QUERY   0x00001000
00178 #define RES_PRF_REPLY   0x00002000
00179 #define RES_PRF_INIT    0x00004000
00180 /*                      0x00008000      */
00181 
00182 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
00183         res_sendhookact;
00184 
00185 typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *ns,
00186                                           const u_char **query,
00187                                           int *querylen,
00188                                           u_char *ans,
00189                                           int anssiz,
00190                                           int *resplen);
00191 
00192 typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *ns,
00193                                           const u_char *query,
00194                                           int querylen,
00195                                           u_char *ans,
00196                                           int anssiz,
00197                                           int *resplen);
00198 
00199 struct res_sym {
00200         int     number;         /* Identifying number, like T_MX */
00201         char *  name;           /* Its symbolic name, like "MX" */
00202         char *  humanname;      /* Its fun name, like "mail exchanger" */
00203 };
00204 
00205 __BEGIN_DECLS
00206 extern struct __res_state *___res(void);
00207 extern struct __res_state_ext *___res_ext(void);
00208 __END_DECLS
00209 #define _res            (*___res())
00210 #define _res_ext        (*___res_ext())
00211 /* for INET6 */
00212 extern struct __res_state_ext _res_ext;
00213 
00214 extern const struct res_sym __p_class_syms[];
00215 extern const struct res_sym __p_type_syms[];
00216 
00217 /* Private routines shared between libc/net, named, nslookup and others. */
00218 #define res_hnok        __res_hnok
00219 #define res_ownok       __res_ownok
00220 #define res_mailok      __res_mailok
00221 #define res_dnok        __res_dnok
00222 #define sym_ston        __sym_ston
00223 #define sym_ntos        __sym_ntos
00224 #define sym_ntop        __sym_ntop
00225 #define b64_ntop        __b64_ntop
00226 #define b64_pton        __b64_pton
00227 #define loc_ntoa        __loc_ntoa
00228 #define loc_aton        __loc_aton
00229 #define fp_resstat      __fp_resstat
00230 #define p_query         __p_query
00231 #define dn_skipname     __dn_skipname
00232 #define fp_resstat      __fp_resstat
00233 #define fp_query        __fp_query
00234 #define fp_nquery       __fp_nquery
00235 #define hostalias       __hostalias
00236 #define putlong         __putlong
00237 #define putshort        __putshort
00238 #define p_class         __p_class
00239 #define p_time          __p_time
00240 #define p_type          __p_type
00241 #define p_query         __p_query
00242 #define p_cdnname       __p_cdnname
00243 #define p_section       __p_section
00244 #define p_cdname        __p_cdname
00245 #define p_fqnname       __p_fqnname
00246 #define p_fqname        __p_fqname
00247 #define p_option        __p_option
00248 #define p_secstodate    __p_secstodate
00249 #define dn_count_labels __dn_count_labels
00250 #define dn_comp         __dn_comp
00251 #define dn_expand       __dn_expand
00252 #define res_init        __res_init
00253 #define res_randomid    __res_randomid
00254 #define res_query       __res_query
00255 #define res_search      __res_search
00256 #define res_querydomain __res_querydomain
00257 #define res_mkquery     __res_mkquery
00258 #define res_send        __res_send
00259 #define res_isourserver __res_isourserver
00260 #define res_nameinquery __res_nameinquery
00261 #define res_queriesmatch __res_queriesmatch
00262 #define res_close       __res_close
00263 #define res_opt         __res_opt
00264 #define res_mkupdate    __res_mkupdate
00265 #define res_mkupdrec    __res_mkupdrec
00266 #define res_freeupdrec  __res_freeupdrec
00267 
00268 
00269 #endif /* !_RESOLV_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top