]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/netdb.h
Fix GCC build errors.
[mirror_edk2.git] / StdLib / Include / netdb.h
1 /* $NetBSD: netdb.h,v 1.55.2.1 2007/05/17 21:25:10 jdc Exp $ */
2
3 /*
4 * Copyright (c) 1980, 1983, 1988, 1993
5 * The Regents of the University of California. 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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 * -
31 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
32 *
33 * Permission to use, copy, modify, and distribute this software for any
34 * purpose with or without fee is hereby granted, provided that the above
35 * copyright notice and this permission notice appear in all copies, and that
36 * the name of Digital Equipment Corporation not be used in advertising or
37 * publicity pertaining to distribution of the document or software without
38 * specific, written prior permission.
39 *
40 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
41 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
42 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
43 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
44 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
45 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
46 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 * SOFTWARE.
48 * -
49 * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
50 * All rights reserved.
51 *
52 * Redistribution and use in source and binary forms, with or without
53 * modification, are permitted provided that the following conditions
54 * are met:
55 * 1. Redistributions of source code must retain the above copyright
56 * notice, this list of conditions and the following disclaimer.
57 * 2. Redistributions in binary form must reproduce the above copyright
58 * notice, this list of conditions and the following disclaimer in the
59 * documentation and/or other materials provided with the distribution.
60 * 3. All advertising materials mentioning features or use of this software
61 * must display the following acknowledgement:
62 * This product includes software developed by WIDE Project and
63 * its contributors.
64 * 4. Neither the name of the project nor the names of its contributors
65 * may be used to endorse or promote products derived from this software
66 * without specific prior written permission.
67 *
68 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
69 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
70 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
71 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
72 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
73 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
74 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
75 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
76 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
77 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
78 * SUCH DAMAGE.
79 * -
80 * --Copyright--
81 */
82
83 /*
84 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
85 * Id: netdb.h,v 1.15.18.6 2006/10/02 01:23:09 marka Exp
86 */
87
88 #ifndef _NETDB_H_
89 #define _NETDB_H_
90
91 #include <machine/ansi.h>
92 #include <machine/endian_machdep.h>
93 #include <sys/ansi.h>
94 #include <sys/cdefs.h>
95 #include <sys/featuretest.h>
96 #include <inttypes.h>
97 #include <paths.h>
98 /*
99 * Data types
100 */
101 #ifndef socklen_t
102 typedef __socklen_t socklen_t;
103 #define socklen_t __socklen_t
104 #endif
105
106 #ifdef _EFI_SIZE_T_
107 typedef _EFI_SIZE_T_ size_t;
108 #undef _EFI_SIZE_T_
109 #undef _BSD_SIZE_T_
110 #endif
111
112 __BEGIN_DECLS
113 extern int h_errno;
114 __END_DECLS
115
116 /*%
117 * Structures returned by network data base library. All addresses are
118 * supplied in host order, and returned in network order (suitable for
119 * use in system calls).
120 */
121 struct hostent {
122 char *h_name; /*%< official name of host */
123 char **h_aliases; /*%< alias list */
124 int h_addrtype; /*%< host address type */
125 int h_length; /*%< length of address */
126 char **h_addr_list; /*%< list of addresses from name server */
127 #define h_addr h_addr_list[0] /*%< address, for backward compatiblity */
128 };
129
130 /*%
131 * Assumption here is that a network number
132 * fits in an unsigned long -- probably a poor one.
133 */
134 struct netent {
135 char *n_name; /*%< official name of net */
136 char **n_aliases; /*%< alias list */
137 int n_addrtype; /*%< net address type */
138 #if (defined(__sparc__) && defined(_LP64)) || \
139 (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _BIG_ENDIAN))
140 int __n_pad0; /* ABI compatibility */
141 #endif
142 uint32_t n_net; /*%< network # */
143 #if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) || \
144 (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _LITTLE_ENDIAN))
145 int __n_pad0; /* ABI compatibility */
146 #endif
147 };
148
149 struct servent {
150 char *s_name; /*%< official service name */
151 char **s_aliases; /*%< alias list */
152 int s_port; /*%< port # */
153 char *s_proto; /*%< protocol to use */
154 };
155
156 struct protoent {
157 char *p_name; /*%< official protocol name */
158 char **p_aliases; /*%< alias list */
159 int p_proto; /*%< protocol # */
160 };
161
162 /*
163 * Note: ai_addrlen used to be a size_t, per RFC 2553.
164 * In XNS5.2, and subsequently in POSIX-2001 and
165 * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t.
166 * To accommodate for this while preserving binary compatibility with the
167 * old interface, we prepend or append 32 bits of padding, depending on
168 * the (LP64) architecture's endianness.
169 *
170 * This should be deleted the next time the libc major number is
171 * incremented.
172 */
173 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
174 defined(_NETBSD_SOURCE)
175 struct addrinfo {
176 int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */
177 int ai_family; /*%< PF_xxx */
178 int ai_socktype; /*%< SOCK_xxx */
179 int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
180 #if defined(__sparc__) && defined(_LP64)
181 int __ai_pad0; /* ABI compatibility */
182 #endif
183 socklen_t ai_addrlen; /*%< length of ai_addr */
184 #if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
185 int __ai_pad0; /* ABI compatibility */
186 #endif
187 char *ai_canonname; /*%< canonical name for hostname */
188 struct sockaddr *ai_addr; /*%< binary address */
189 struct addrinfo *ai_next; /*%< next structure in linked list */
190 };
191 #endif
192
193 /*%
194 * Error return codes from gethostbyname() and gethostbyaddr()
195 * (left in extern int h_errno).
196 */
197
198 #if defined(_NETBSD_SOURCE)
199 #define NETDB_INTERNAL -1 /*%< see errno */
200 #define NETDB_SUCCESS 0 /*%< no problem */
201 #endif
202 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
203 #define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */
204 #define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */
205 #define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */
206 #define NO_DATA 4 /*%< Valid name, no data record of requested type */
207
208 /*
209 * Error return codes from getaddrinfo()
210 */
211 #if 0 // Not supported by UEFI
212 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
213 defined(_NETBSD_SOURCE)
214 #define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */
215 #define EAI_AGAIN 2 /*%< temporary failure in name resolution */
216 #define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */
217 #define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */
218 #define EAI_FAMILY 5 /*%< ai_family not supported */
219 #define EAI_MEMORY 6 /*%< memory allocation failure */
220 #define EAI_NODATA 7 /*%< no address associated with hostname */
221 #define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */
222 #define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */
223 #define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */
224 #define EAI_SYSTEM 11 /*%< system error returned in errno */
225 #define EAI_BADHINTS 12 /* invalid value for hints */
226 #define EAI_PROTOCOL 13 /* resolved protocol is unknown */
227 #define EAI_OVERFLOW 14 /* argument buffer overflow */
228 #define EAI_MAX 15
229 #endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */
230 #endif // 0 Not supported by UEFI
231
232 /*%
233 * Flag values for getaddrinfo()
234 */
235 #if 0 // Not supported by UEFI
236 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
237 defined(_NETBSD_SOURCE)
238 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
239 #endif
240 #endif // 0 Not supported by UEFI
241
242 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
243
244 #if 0 // Not supported by UEFI
245 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
246 defined(_NETBSD_SOURCE)
247 #define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */
248 #define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */
249 /* valid flags for addrinfo (not a standard def, apps should not use it) */
250 #define AI_MASK \
251 (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
252 #endif
253 #endif // 0 Not supported by UEFI
254
255 /*%
256 * Constants for getnameinfo()
257 */
258 ////#if defined(_NETBSD_SOURCE)
259 #define NI_MAXHOST 1025
260 #define NI_MAXSERV 32
261 ////#endif
262
263 /*%
264 * Flag values for getnameinfo()
265 */
266 ////#define NI_NOFQDN 0x00000001
267 #define NI_NUMERICHOST 0x00000002
268 ////#define NI_NAMEREQD 0x00000004
269 #define NI_NUMERICSERV 0x00000008
270 ////#define NI_DGRAM 0x00000010
271 ////#define NI_NUMERICSCOPE 0x00000040
272
273 #if 0 // Not supported by UEFI
274 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
275 defined(_NETBSD_SOURCE)
276 /*%
277 * Scope delimit character
278 */
279 #if defined(_NETBSD_SOURCE)
280 #define SCOPE_DELIMITER '%'
281 #endif
282 #endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */
283 #endif // 0 Not supported by UEFI
284
285 __BEGIN_DECLS
286 void endhostent(void);
287 void endnetent(void);
288 void endprotoent(void);
289 void endservent(void);
290 #if 0 // Not supported by UEFI
291 #if (_XOPEN_SOURCE - 0) >= 520 && (_XOPEN_SOURCE - 0) < 600 || \
292 defined(_NETBSD_SOURCE)
293 #if 0 /* we do not ship this */
294 void freehostent(struct hostent *);
295 #endif
296 #endif
297 #endif // 0 Not supported by UEFI
298 struct hostent *gethostbyaddr(const char *, socklen_t, int);
299 struct hostent *gethostbyname(const char *);
300 #if defined(_NETBSD_SOURCE)
301 struct hostent *gethostbyname2(const char *, int);
302 #endif
303 struct hostent *gethostent(void);
304 struct netent *getnetbyaddr(uint32_t, int);
305 struct netent *getnetbyname(const char *);
306 struct netent *getnetent(void);
307 struct protoent *getprotobyname(const char *);
308 struct protoent *getprotobynumber(int);
309 struct protoent *getprotoent(void);
310 struct servent *getservbyname(const char *, const char *);
311 struct servent *getservbyport(int, const char *);
312 struct servent *getservent(void);
313 ////#if defined(_NETBSD_SOURCE)
314 ////void herror(const char *);
315 ////const char *hstrerror(int);
316 ////#endif
317 void sethostent(int);
318 ////#if defined(_NETBSD_SOURCE)
319 /* void sethostfile(const char *); */
320 ////#endif
321 void setnetent(int);
322 void setprotoent(int);
323 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
324 defined(_NETBSD_SOURCE)
325 void setservent(int);
326 int getaddrinfo(const char * __restrict, const char * __restrict,
327 const struct addrinfo * __restrict,
328 struct addrinfo ** __restrict);
329 int getnameinfo(const struct sockaddr * __restrict, socklen_t,
330 char * __restrict, socklen_t,
331 char * __restrict, socklen_t, int);
332 void freeaddrinfo(struct addrinfo *);
333 const char *gai_strerror(int);
334 #endif
335 void setservent(int);
336
337 __END_DECLS
338
339 #endif /* !_NETDB_H_ */