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