]>
Commit | Line | Data |
---|---|---|
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 | |
97 | /*\r | |
98 | * Data types\r | |
99 | */\r | |
100 | #ifndef socklen_t\r | |
101 | typedef __socklen_t socklen_t;\r | |
102 | #define socklen_t __socklen_t\r | |
103 | #endif\r | |
104 | \r | |
105 | #ifdef _EFI_SIZE_T_\r | |
106 | typedef _EFI_SIZE_T_ size_t;\r | |
107 | #undef _EFI_SIZE_T_\r | |
108 | #undef _BSD_SIZE_T_\r | |
109 | #endif\r | |
110 | \r | |
111 | ////#if defined(_NETBSD_SOURCE)\r | |
112 | ////#ifndef _PATH_HEQUIV\r | |
113 | ////#define _PATH_HEQUIV "/etc/hosts.equiv"\r | |
114 | ////#endif\r | |
115 | #ifndef _PATH_HOSTS\r | |
116 | #define _PATH_HOSTS "/etc/hosts"\r | |
117 | #endif\r | |
118 | #ifndef _PATH_NETWORKS\r | |
119 | #define _PATH_NETWORKS "/etc/networks"\r | |
120 | #endif\r | |
121 | #ifndef _PATH_PROTOCOLS\r | |
122 | #define _PATH_PROTOCOLS "/etc/protocols"\r | |
123 | #endif\r | |
124 | #ifndef _PATH_SERVICES\r | |
125 | #define _PATH_SERVICES "/etc/services"\r | |
126 | #endif\r | |
127 | ////#ifndef _PATH_SERVICES_DB\r | |
128 | ////#define _PATH_SERVICES_DB "/var/db/services.db"\r | |
129 | ////#endif\r | |
130 | ////#endif\r | |
131 | \r | |
132 | __BEGIN_DECLS\r | |
133 | extern int h_errno;\r | |
134 | __END_DECLS\r | |
135 | \r | |
136 | /*%\r | |
137 | * Structures returned by network data base library. All addresses are\r | |
138 | * supplied in host order, and returned in network order (suitable for\r | |
139 | * use in system calls).\r | |
140 | */\r | |
141 | struct hostent {\r | |
142 | char *h_name; /*%< official name of host */\r | |
143 | char **h_aliases; /*%< alias list */\r | |
144 | int h_addrtype; /*%< host address type */\r | |
145 | int h_length; /*%< length of address */\r | |
146 | char **h_addr_list; /*%< list of addresses from name server */\r | |
147 | #define h_addr h_addr_list[0] /*%< address, for backward compatiblity */\r | |
148 | };\r | |
149 | \r | |
150 | /*%\r | |
151 | * Assumption here is that a network number\r | |
152 | * fits in an unsigned long -- probably a poor one.\r | |
153 | */\r | |
154 | struct netent {\r | |
155 | char *n_name; /*%< official name of net */\r | |
156 | char **n_aliases; /*%< alias list */\r | |
157 | int n_addrtype; /*%< net address type */\r | |
158 | #if (defined(__sparc__) && defined(_LP64)) || \\r | |
159 | (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _BIG_ENDIAN))\r | |
160 | int __n_pad0; /* ABI compatibility */\r | |
161 | #endif\r | |
162 | uint32_t n_net; /*%< network # */\r | |
163 | #if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) || \\r | |
164 | (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _LITTLE_ENDIAN))\r | |
165 | int __n_pad0; /* ABI compatibility */\r | |
166 | #endif\r | |
167 | };\r | |
168 | \r | |
169 | struct servent {\r | |
170 | char *s_name; /*%< official service name */\r | |
171 | char **s_aliases; /*%< alias list */\r | |
172 | int s_port; /*%< port # */\r | |
173 | char *s_proto; /*%< protocol to use */\r | |
174 | };\r | |
175 | \r | |
176 | struct protoent {\r | |
177 | char *p_name; /*%< official protocol name */\r | |
178 | char **p_aliases; /*%< alias list */\r | |
179 | int p_proto; /*%< protocol # */\r | |
180 | };\r | |
181 | \r | |
182 | /*\r | |
183 | * Note: ai_addrlen used to be a size_t, per RFC 2553.\r | |
184 | * In XNS5.2, and subsequently in POSIX-2001 and\r | |
185 | * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t.\r | |
186 | * To accommodate for this while preserving binary compatibility with the\r | |
187 | * old interface, we prepend or append 32 bits of padding, depending on\r | |
188 | * the (LP64) architecture's endianness.\r | |
189 | *\r | |
190 | * This should be deleted the next time the libc major number is\r | |
191 | * incremented.\r | |
192 | */\r | |
193 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
194 | defined(_NETBSD_SOURCE)\r | |
195 | struct addrinfo {\r | |
196 | int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */\r | |
197 | int ai_family; /*%< PF_xxx */\r | |
198 | int ai_socktype; /*%< SOCK_xxx */\r | |
199 | int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */\r | |
200 | #if defined(__sparc__) && defined(_LP64)\r | |
201 | int __ai_pad0; /* ABI compatibility */\r | |
202 | #endif\r | |
203 | socklen_t ai_addrlen; /*%< length of ai_addr */\r | |
204 | #if defined(__alpha__) || (defined(__i386__) && defined(_LP64))\r | |
205 | int __ai_pad0; /* ABI compatibility */\r | |
206 | #endif\r | |
207 | char *ai_canonname; /*%< canonical name for hostname */\r | |
208 | struct sockaddr *ai_addr; /*%< binary address */\r | |
209 | struct addrinfo *ai_next; /*%< next structure in linked list */\r | |
210 | };\r | |
211 | #endif\r | |
212 | \r | |
213 | /*%\r | |
214 | * Error return codes from gethostbyname() and gethostbyaddr()\r | |
215 | * (left in extern int h_errno).\r | |
216 | */\r | |
217 | \r | |
218 | #if defined(_NETBSD_SOURCE)\r | |
219 | #define NETDB_INTERNAL -1 /*%< see errno */\r | |
220 | #define NETDB_SUCCESS 0 /*%< no problem */\r | |
221 | #endif\r | |
222 | ////#define NO_ADDRESS NO_DATA /* no address, look for MX record */\r | |
223 | #define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */\r | |
224 | #define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */\r | |
225 | #define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */\r | |
226 | ////#define NO_DATA 4 /*%< Valid name, no data record of requested type */\r | |
227 | ////#if defined(_NETBSD_SOURCE)\r | |
228 | ////#define NO_ADDRESS NO_DATA /*%< no address, look for MX record */\r | |
229 | ////#endif\r | |
230 | \r | |
231 | /*\r | |
232 | * Error return codes from getaddrinfo()\r | |
233 | */\r | |
234 | #if 0 // Not supported by UEFI\r | |
235 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
236 | defined(_NETBSD_SOURCE)\r | |
237 | #define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */\r | |
238 | #define EAI_AGAIN 2 /*%< temporary failure in name resolution */\r | |
239 | #define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */\r | |
240 | #define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */\r | |
241 | #define EAI_FAMILY 5 /*%< ai_family not supported */\r | |
242 | #define EAI_MEMORY 6 /*%< memory allocation failure */\r | |
243 | #define EAI_NODATA 7 /*%< no address associated with hostname */\r | |
244 | #define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */\r | |
245 | #define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */\r | |
246 | #define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */\r | |
247 | #define EAI_SYSTEM 11 /*%< system error returned in errno */\r | |
248 | #define EAI_BADHINTS 12 /* invalid value for hints */\r | |
249 | #define EAI_PROTOCOL 13 /* resolved protocol is unknown */\r | |
250 | #define EAI_OVERFLOW 14 /* argument buffer overflow */\r | |
251 | #define EAI_MAX 15\r | |
252 | #endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */\r | |
253 | #endif // 0 Not supported by UEFI\r | |
254 | \r | |
255 | /*%\r | |
256 | * Flag values for getaddrinfo()\r | |
257 | */\r | |
258 | #if 0 // Not supported by UEFI\r | |
259 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
260 | defined(_NETBSD_SOURCE)\r | |
261 | #define AI_PASSIVE 0x00000001 /* get address to use bind() */\r | |
262 | #endif\r | |
263 | #endif // 0 Not supported by UEFI\r | |
264 | \r | |
265 | #define AI_CANONNAME 0x00000002 /* fill ai_canonname */\r | |
266 | \r | |
267 | #if 0 // Not supported by UEFI\r | |
268 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
269 | defined(_NETBSD_SOURCE)\r | |
270 | #define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */\r | |
271 | #define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */\r | |
272 | /* valid flags for addrinfo (not a standard def, apps should not use it) */\r | |
273 | #define AI_MASK \\r | |
274 | (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)\r | |
275 | #endif\r | |
276 | #endif // 0 Not supported by UEFI\r | |
277 | \r | |
278 | /*%\r | |
279 | * Constants for getnameinfo()\r | |
280 | */\r | |
281 | ////#if defined(_NETBSD_SOURCE)\r | |
282 | #define NI_MAXHOST 1025\r | |
283 | #define NI_MAXSERV 32\r | |
284 | ////#endif\r | |
285 | \r | |
286 | /*%\r | |
287 | * Flag values for getnameinfo()\r | |
288 | */\r | |
289 | ////#define NI_NOFQDN 0x00000001\r | |
290 | #define NI_NUMERICHOST 0x00000002\r | |
291 | ////#define NI_NAMEREQD 0x00000004\r | |
292 | #define NI_NUMERICSERV 0x00000008\r | |
293 | ////#define NI_DGRAM 0x00000010\r | |
294 | ////#define NI_NUMERICSCOPE 0x00000040\r | |
295 | \r | |
296 | #if 0 // Not supported by UEFI\r | |
297 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
298 | defined(_NETBSD_SOURCE)\r | |
299 | /*%\r | |
300 | * Scope delimit character\r | |
301 | */\r | |
302 | #if defined(_NETBSD_SOURCE)\r | |
303 | #define SCOPE_DELIMITER '%'\r | |
304 | #endif\r | |
305 | #endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */\r | |
306 | #endif // 0 Not supported by UEFI\r | |
307 | \r | |
308 | __BEGIN_DECLS\r | |
309 | void endhostent(void);\r | |
310 | void endnetent(void);\r | |
311 | void endprotoent(void);\r | |
312 | void endservent(void);\r | |
313 | #if 0 // Not supported by UEFI\r | |
314 | #if (_XOPEN_SOURCE - 0) >= 520 && (_XOPEN_SOURCE - 0) < 600 || \\r | |
315 | defined(_NETBSD_SOURCE)\r | |
316 | #if 0 /* we do not ship this */\r | |
317 | void freehostent(struct hostent *);\r | |
318 | #endif\r | |
319 | #endif\r | |
320 | #endif // 0 Not supported by UEFI\r | |
321 | struct hostent *gethostbyaddr(const char *, socklen_t, int);\r | |
322 | struct hostent *gethostbyname(const char *);\r | |
323 | #if defined(_NETBSD_SOURCE)\r | |
324 | struct hostent *gethostbyname2(const char *, int);\r | |
325 | #endif\r | |
326 | struct hostent *gethostent(void);\r | |
327 | struct netent *getnetbyaddr(uint32_t, int);\r | |
328 | struct netent *getnetbyname(const char *);\r | |
329 | struct netent *getnetent(void);\r | |
330 | struct protoent *getprotobyname(const char *);\r | |
331 | struct protoent *getprotobynumber(int);\r | |
332 | struct protoent *getprotoent(void);\r | |
333 | struct servent *getservbyname(const char *, const char *);\r | |
334 | struct servent *getservbyport(int, const char *);\r | |
335 | struct servent *getservent(void);\r | |
336 | ////#if defined(_NETBSD_SOURCE)\r | |
337 | ////void herror(const char *);\r | |
338 | ////const char *hstrerror(int);\r | |
339 | ////#endif\r | |
340 | void sethostent(int);\r | |
341 | ////#if defined(_NETBSD_SOURCE)\r | |
342 | /* void sethostfile(const char *); */\r | |
343 | ////#endif\r | |
344 | void setnetent(int);\r | |
345 | void setprotoent(int);\r | |
346 | #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \\r | |
347 | defined(_NETBSD_SOURCE)\r | |
348 | void setservent(int);\r | |
349 | int getaddrinfo(const char * __restrict, const char * __restrict,\r | |
350 | const struct addrinfo * __restrict,\r | |
351 | struct addrinfo ** __restrict);\r | |
352 | int getnameinfo(const struct sockaddr * __restrict, socklen_t,\r | |
353 | char * __restrict, socklen_t,\r | |
354 | char * __restrict, socklen_t, int);\r | |
355 | void freeaddrinfo(struct addrinfo *);\r | |
356 | const char *gai_strerror(int);\r | |
357 | #endif\r | |
358 | void setservent(int);\r | |
359 | \r | |
360 | __END_DECLS\r | |
361 | \r | |
362 | #endif /* !_NETDB_H_ */\r |