source: rtems/cpukit/libnetworking/resolv.h @ 1e039fb3

Last change on this file since 1e039fb3 was 232d6fec, checked in by Christian Mauderer <Christian.Mauderer@…>, on May 2, 2016 at 12:49:32 PM

libnetworking: Import current <netdb.h>

Import the <netdb.h> from current FreeBSD. This allows to build some
current software (e.g. libressl).

Add h_errno().

Update gethostent_r() API. Linux and FreeBSD use a common API now.
Adapt the RTEMS one to provide the same one.

Match gethostbyname_r() with prototype.

  • Property mode set to 100644
File size: 11.2 KB
Line 
1/*
2 * Copyright (c) 1983, 1987, 1989
3 *    The Regents of the University of California.  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. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/*
31 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
32 * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
33 *
34 * Permission to use, copy, modify, and distribute this software for any
35 * purpose with or without fee is hereby granted, provided that the above
36 * copyright notice and this permission notice appear in all copies.
37 *
38 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
39 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
40 * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
41 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
42 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
43 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
44 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
45 */
46
47/*%
48 *      @(#)resolv.h    8.1 (Berkeley) 6/2/93
49 * $FreeBSD: release/9.0.0/include/resolv.h 203964 2010-02-16 19:39:50Z imp $
50 */
51
52#ifndef _RESOLV_H_
53#define _RESOLV_H_
54
55#include <sys/param.h>
56#include <sys/types.h>
57#include <sys/cdefs.h>
58#include <stdio.h>
59#include <netinet/in.h> /* struct in_addr */
60
61/*%
62 * Revision information.  This is the release date in YYYYMMDD format.
63 * It can change every day so the right thing to do with it is use it
64 * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
65 * compare for equality; rather, use it to determine whether your resolver
66 * is new enough to contain a certain feature.
67 */
68
69#define __RES   19960801
70
71/*%
72 * Resolver configuration file.
73 * Normally not present, but may contain the address of the
74 * initial name server(s) to query and the domain search list.
75 */
76
77#ifndef _PATH_RESCONF
78#define _PATH_RESCONF        "/etc/resolv.conf"
79#endif
80
81typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
82        res_sendhookact;
83
84typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns,
85                                              const u_char **query,
86                                              int *querylen,
87                                              u_char *ans,
88                                              int anssiz,
89                                              int *resplen);
90
91typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns,
92                                              const u_char *query,
93                                              int querylen,
94                                              u_char *ans,
95                                              int anssiz,
96                                              int *resplen);
97
98struct res_sym {
99        int             number;    /*%< Identifying number, like T_MX */
100        const char *    name;      /*%< Its symbolic name, like "MX" */
101        const char *    humanname; /*%< Its fun name, like "mail exchanger" */
102};
103
104/*%
105 * Global defines and variables for resolver stub.
106 */
107#define MAXNS                   3       /*%< max # name servers we'll track */
108#define MAXDFLSRCH              3       /*%< # default domain levels to try */
109#define MAXDNSRCH               6       /*%< max # domains in search path */
110#define LOCALDOMAINPARTS        2       /*%< min levels in name that is "local" */
111#define RES_TIMEOUT             5       /*%< min. seconds between retries */
112#define MAXRESOLVSORT           10      /*%< number of net to sort on */
113#define RES_MAXNDOTS            15      /*%< should reflect bit field size */
114
115struct __res_state {
116        int     retrans;                /*%< retransmission time interval */
117        int     retry;                  /*%< number of times to retransmit */
118        u_long  options;                /*%< option flags - see below. */
119        int     nscount;                /*%< number of name servers */
120        struct sockaddr_in
121                nsaddr_list[MAXNS];     /*%< address of name server */
122#define nsaddr  nsaddr_list[0]          /*%< for backward compatibility */
123        u_short id;                     /*%< current message id */
124        char    *dnsrch[MAXDNSRCH+1];   /*%< components of domain to search */
125        char    defdname[256];          /*%< default domain (deprecated) */
126        u_long  pfcode;                 /*%< RES_PRF_ flags - see below. */
127        unsigned ndots:4;               /*%< threshold for initial abs. query */
128        unsigned nsort:4;               /*%< number of elements in sort_list[] */
129        char    unused[3];
130        struct {
131                struct in_addr  addr;
132                u_int32_t       mask;
133        } sort_list[MAXRESOLVSORT];
134        char    pad[72];                /* on an i386 this means 512b total */
135};
136
137typedef struct __res_state *res_state;
138
139/*%
140 * Resolver options (keep these in synch with res_debug.c, please)
141 */
142#define RES_INIT        0x00000001      /*%< address initialized */
143#define RES_DEBUG       0x00000002      /*%< print debug messages */
144#define RES_AAONLY      0x00000004      /*%< authoritative answers only (!IMPL)*/
145#define RES_USEVC       0x00000008      /*%< use virtual circuit */
146#define RES_PRIMARY     0x00000010      /*%< query primary server only (!IMPL) */
147#define RES_IGNTC       0x00000020      /*%< ignore truncation errors */
148#define RES_RECURSE     0x00000040      /*%< recursion desired */
149#define RES_DEFNAMES    0x00000080      /*%< use default domain name */
150#define RES_STAYOPEN    0x00000100      /*%< Keep TCP socket open */
151#define RES_DNSRCH      0x00000200      /*%< search up local domain tree */
152#define RES_INSECURE1   0x00000400      /*%< type 1 security disabled */
153#define RES_INSECURE2   0x00000800      /*%< type 2 security disabled */
154#define RES_NOALIASES   0x00001000      /*%< shuts off HOSTALIASES feature */
155#define RES_USE_INET6   0x00002000      /*%< use/map IPv6 in gethostbyname() */
156#define RES_NOTLDQUERY  0x00004000      /*%< Don't query TLD names */
157
158#define RES_DEFAULT     (RES_RECURSE | RES_DEFNAMES | \
159                         RES_DNSRCH)
160
161/*%
162 * Resolver "pfcode" values.  Used by dig.
163 */
164#define RES_PRF_STATS   0x00000001
165#define RES_PRF_UPDATE  0x00000002
166#define RES_PRF_CLASS   0x00000004
167#define RES_PRF_CMD     0x00000008
168#define RES_PRF_QUES    0x00000010
169#define RES_PRF_ANS     0x00000020
170#define RES_PRF_AUTH    0x00000040
171#define RES_PRF_ADD     0x00000080
172#define RES_PRF_HEAD1   0x00000100
173#define RES_PRF_HEAD2   0x00000200
174#define RES_PRF_TTLID   0x00000400
175#define RES_PRF_HEADX   0x00000800
176#define RES_PRF_QUERY   0x00001000
177#define RES_PRF_REPLY   0x00002000
178#define RES_PRF_INIT    0x00004000
179/*                      0x00008000      */
180
181#define fp_nquery               __fp_nquery
182#define fp_query                __fp_query
183#define hostalias               __hostalias
184#define p_query                 __p_query
185#define res_close               __res_close
186#define res_init                __res_init
187#define res_isourserver         __res_isourserver
188#define res_mkquery             __res_mkquery
189#define res_query               __res_query
190#define res_querydomain         __res_querydomain
191#define res_search              __res_search
192#define res_send                __res_send
193
194__BEGIN_DECLS
195void            fp_nquery(const u_char *, int, FILE *);
196void            fp_query(const u_char *, FILE *);
197const char *    hostalias(const char *);
198void            p_query(const u_char *);
199void            res_close(void);
200int             res_init(void);
201int             res_isourserver(const struct sockaddr_in *);
202int             res_mkquery(int, const char *, int, int, const u_char *,
203                                 int, const u_char *, u_char *, int);
204int             res_query(const char *, int, int, u_char *, int);
205int             res_querydomain(const char *, const char *, int, int,
206                                     u_char *, int);
207int             res_search(const char *, int, int, u_char *, int);
208int             res_send(const u_char *, int, u_char *, int);
209__END_DECLS
210
211extern struct __res_state _res;
212
213
214extern const struct res_sym __p_class_syms[];
215extern const struct res_sym __p_type_syms[];
216
217/* Private routines shared between libc/net, named, nslookup and others. */
218#define b64_ntop                __b64_ntop
219#define b64_pton                __b64_pton
220#define dn_comp                 __dn_comp
221#define dn_count_labels         __dn_count_labels
222#define dn_expand               __dn_expand
223#define dn_skipname             __dn_skipname
224#define fp_resstat              __fp_resstat
225#define loc_aton                __loc_aton
226#define loc_ntoa                __loc_ntoa
227#define p_cdname                __p_cdname
228#define p_cdnname               __p_cdnname
229#define fp_resstat              __fp_resstat
230#define p_class                 __p_class
231#define p_fqname                __p_fqname
232#define p_fqnname               __p_fqnname
233#define p_option                __p_option
234#define p_secstodate            __p_secstodate
235#define p_section               __p_section
236#define p_time                  __p_time
237#define p_type                  __p_type
238#define putlong                 __putlong
239#define putshort                __putshort
240#define res_dnok                __res_dnok
241#define res_hnok                __res_hnok
242#define res_mailok              __res_mailok
243#define res_nameinquery         __res_nameinquery
244#define res_ownok               __res_ownok
245#define res_queriesmatch        __res_queriesmatch
246#define res_randomid            __res_randomid
247#define sym_ntop                __sym_ntop
248#define sym_ntos                __sym_ntos
249#define sym_ston                __sym_ston
250#define res_send_setqhook       __res_send_setqhook
251#define res_send_setrhook       __res_send_setrhook
252#define res_mkupdate            __res_mkupdate
253#define res_mkupdrec            __res_mkupdrec
254#define res_freeupdrec          __res_freeupdrec
255
256__BEGIN_DECLS
257int             res_hnok(const char *);
258int             res_ownok(const char *);
259int             res_mailok(const char *);
260int             res_dnok(const char *);
261int             sym_ston(const struct res_sym *, const char *, int *);
262const char *    sym_ntos(const struct res_sym *, int, int *);
263const char *    sym_ntop(const struct res_sym *, int, int *);
264int             b64_ntop(u_char const *, size_t, char *, size_t);
265int             b64_pton(char const *, u_char *, size_t);
266int             loc_aton(const char *, u_char *);
267const char *    loc_ntoa(const u_char *, char *);
268int             dn_skipname(const u_char *, const u_char *);
269void            fp_resstat(struct __res_state *, FILE *);
270void            putlong(u_int32_t, u_char *);
271void            putshort(u_int16_t, u_char *);
272const char *    p_class(int);
273const char *    p_time(u_int32_t);
274const char *    p_type(int);
275const u_char *  p_cdnname(const u_char *, const u_char *, int, FILE *);
276const u_char *  p_cdname(const u_char *, const u_char *, FILE *);
277const u_char *  p_fqnname(const u_char *, const u_char *, int, char *, int);
278const u_char *  p_fqname(const u_char *, const u_char *, FILE *);
279const char *    p_option(u_long);
280char *          p_secstodate(u_long);
281int             dn_count_labels(const char *);
282int             dn_comp(const char *, u_char *, int, u_char **, u_char **);
283int             dn_expand(const u_char *, const u_char *, const u_char *,
284                          char *, int);
285u_int           res_randomid(void);
286int             res_nameinquery(const char *, int, int, const u_char *,
287                                const u_char *);
288int             res_queriesmatch(const u_char *, const u_char *,
289                                 const u_char *, const u_char *);
290const char *    p_section(int, int);
291void            res_send_setqhook(res_send_qhook);
292void            res_send_setrhook(res_send_rhook);
293
294/* XXX The following depend on the ns_updrec typedef in arpa/nameser.h */
295#ifdef _ARPA_NAMESER_H_
296int             res_update (ns_updrec *);
297int             res_mkupdate (ns_updrec *, u_char *, int);
298ns_updrec *     res_mkupdrec (int, const char *, u_int, u_int, u_long);
299void            res_freeupdrec (ns_updrec *);
300#endif
301__END_DECLS
302
303#endif /* !_RESOLV_H_ */
Note: See TracBrowser for help on using the repository browser.