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