4 * ++Copyright++ 1980, 1983, 1988, 1993
6 * Copyright (c) 1980, 1983, 1988, 1993
7 * The Regents of the University of California. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
55 * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
56 * All rights reserved.
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
61 * 1. Redistributions of source code must retain the above copyright
62 * notice, this list of conditions and the following disclaimer.
63 * 2. Redistributions in binary form must reproduce the above copyright
64 * notice, this list of conditions and the following disclaimer in the
65 * documentation and/or other materials provided with the distribution.
66 * 3. All advertising materials mentioning features or use of this software
67 * must display the following acknowledgement:
68 * This product includes software developed by WIDE Project and
70 * 4. Neither the name of the project nor the names of its contributors
71 * may be used to endorse or promote products derived from this software
72 * without specific prior written permission.
74 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
75 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
78 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
80 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
81 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
82 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
83 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
90 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
91 * Id: netdb.h,v 1.22 2008/02/28 05:34:17 marka Exp
97 #include <sys/param.h>
98 #include <sys/types.h>
99 #if (!defined(BSD)) || (BSD < 199306)
100 # include <sys/bitypes.h>
102 #include <sys/cdefs.h>
103 #include <sys/socket.h>
104 #include <netinet/in.h>
108 #define _PATH_HEQUIV "/etc/hosts.equiv"
111 #define _PATH_HOSTS "/etc/hosts"
113 #ifndef _PATH_NETWORKS
114 #define _PATH_NETWORKS "/etc/networks"
116 #ifndef _PATH_PROTOCOLS
117 #define _PATH_PROTOCOLS "/etc/protocols"
119 #ifndef _PATH_SERVICES
120 #define _PATH_SERVICES "/etc/services"
123 #if (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
124 #define __h_errno __h_errno_location
127 extern int * __h_errno
__P((void));
129 #if defined(_REENTRANT) || \
130 (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
131 #define h_errno (*__h_errno())
137 * Structures returned by network data base library. All addresses are
138 * supplied in host order, and returned in network order (suitable for
139 * use in system calls).
142 char *h_name
; /*%< official name of host */
143 char **h_aliases
; /*%< alias list */
144 int h_addrtype
; /*%< host address type */
145 int h_length
; /*%< length of address */
146 char **h_addr_list
; /*%< list of addresses from name server */
147 #define h_addr h_addr_list[0] /*%< address, for backward compatiblity */
151 * Assumption here is that a network number
152 * fits in an unsigned long -- probably a poor one.
155 char *n_name
; /*%< official name of net */
156 char **n_aliases
; /*%< alias list */
157 int n_addrtype
; /*%< net address type */
158 unsigned long n_net
; /*%< network # */
162 char *s_name
; /*%< official service name */
163 char **s_aliases
; /*%< alias list */
164 int s_port
; /*%< port # */
165 char *s_proto
; /*%< protocol to use */
169 char *p_name
; /*%< official protocol name */
170 char **p_aliases
; /*%< alias list */
171 int p_proto
; /*%< protocol # */
175 int ai_flags
; /*%< AI_PASSIVE, AI_CANONNAME */
176 int ai_family
; /*%< PF_xxx */
177 int ai_socktype
; /*%< SOCK_xxx */
178 int ai_protocol
; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
179 #if defined(sun) && defined(_SOCKLEN_T)
183 socklen_t ai_addrlen
;
185 size_t ai_addrlen
; /*%< length of ai_addr */
188 struct sockaddr
*ai_addr
; /*%< binary address */
189 char *ai_canonname
; /*%< canonical name for hostname */
191 char *ai_canonname
; /*%< canonical name for hostname */
192 struct sockaddr
*ai_addr
; /*%< binary address */
194 struct addrinfo
*ai_next
; /*%< next structure in linked list */
198 * Error return codes from gethostbyname() and gethostbyaddr()
199 * (left in extern int h_errno).
202 #define NETDB_INTERNAL -1 /*%< see errno */
203 #define NETDB_SUCCESS 0 /*%< no problem */
204 #define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */
205 #define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */
206 #define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */
207 #define NO_DATA 4 /*%< Valid name, no data record of requested type */
208 #define NO_ADDRESS NO_DATA /*%< no address, look for MX record */
210 * Error return codes from getaddrinfo()
212 #define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */
213 #define EAI_AGAIN 2 /*%< temporary failure in name resolution */
214 #define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */
215 #define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */
216 #define EAI_FAMILY 5 /*%< ai_family not supported */
217 #define EAI_MEMORY 6 /*%< memory allocation failure */
218 #define EAI_NODATA 7 /*%< no address associated with hostname */
219 #define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */
220 #define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */
221 #define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */
222 #define EAI_SYSTEM 11 /*%< system error returned in errno */
223 #define EAI_BADHINTS 12
224 #define EAI_PROTOCOL 13
228 * Flag values for getaddrinfo()
230 #define AI_PASSIVE 0x00000001
231 #define AI_CANONNAME 0x00000002
232 #define AI_NUMERICHOST 0x00000004
233 #define AI_MASK 0x00000007
236 * Flag values for getipnodebyname()
238 #define AI_V4MAPPED 0x00000008
239 #define AI_ALL 0x00000010
240 #define AI_ADDRCONFIG 0x00000020
241 #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
244 * Constants for getnameinfo()
246 #define NI_MAXHOST 1025
247 #define NI_MAXSERV 32
250 * Flag values for getnameinfo()
252 #define NI_NOFQDN 0x00000001
253 #define NI_NUMERICHOST 0x00000002
254 #define NI_NAMEREQD 0x00000004
255 #define NI_NUMERICSERV 0x00000008
256 #define NI_DGRAM 0x00000010
257 #define NI_WITHSCOPEID 0x00000020
258 #define NI_NUMERICSCOPE 0x00000040
261 * Scope delimit character
263 #define SCOPE_DELIMITER '%'
267 #if defined (__hpux) || defined(__osf__) || defined(_AIX)
268 #define _MAXALIASES 35
269 #define _MAXLINELEN 1024
271 #define _HOSTBUFSIZE (BUFSIZ + 1)
273 struct hostent_data
{
274 struct in_addr host_addr
;
275 char *h_addr_ptrs
[_MAXADDRS
+ 1];
276 char hostaddr
[_MAXADDRS
];
277 char hostbuf
[_HOSTBUFSIZE
];
278 char *host_aliases
[_MAXALIASES
];
295 #if defined(__osf__) || defined(_AIX)
296 char line
[_MAXLINELEN
];
299 char line
[_MAXLINELEN
+1];
301 char *net_aliases
[_MAXALIASES
];
316 void *_net_reserv1
; /* reserved for future use */
317 void *_net_reserv2
; /* reserved for future use */
321 struct protoent_data
{
325 char line
[_MAXLINELEN
];
331 char line
[_MAXLINELEN
+1];
333 char *proto_aliases
[_MAXALIASES
];
336 int svc_getprotoflag
;
347 void *_proto_reserv1
; /* reserved for future use */
348 void *_proto_reserv2
; /* reserved for future use */
352 struct servent_data
{
354 #if defined(__osf__) || defined(_AIX)
355 char line
[_MAXLINELEN
];
358 char line
[_MAXLINELEN
+1];
360 char *serv_aliases
[_MAXALIASES
];
375 void *_serv_reserv1
; /* reserved for future use */
376 void *_serv_reserv2
; /* reserved for future use */
382 void endhostent
__P((void));
383 void endnetent
__P((void));
384 void endprotoent
__P((void));
385 void endservent
__P((void));
386 void freehostent
__P((struct hostent
*));
387 struct hostent
*gethostbyaddr
__P((const char *, int, int));
388 struct hostent
*gethostbyname
__P((const char *));
389 struct hostent
*gethostbyname2
__P((const char *, int));
390 struct hostent
*gethostent
__P((void));
391 struct hostent
*getipnodebyaddr
__P((const void *, size_t, int, int *));
392 struct hostent
*getipnodebyname
__P((const char *, int, int, int *));
393 struct netent
*getnetbyaddr
__P((unsigned long, int));
394 struct netent
*getnetbyname
__P((const char *));
395 struct netent
*getnetent
__P((void));
396 struct protoent
*getprotobyname
__P((const char *));
397 struct protoent
*getprotobynumber
__P((int));
398 struct protoent
*getprotoent
__P((void));
399 struct servent
*getservbyname
__P((const char *, const char *));
400 struct servent
*getservbyport
__P((int, const char *));
401 struct servent
*getservent
__P((void));
402 void herror
__P((const char *));
403 const char *hstrerror
__P((int));
404 void sethostent
__P((int));
405 /* void sethostfile __P((const char *)); */
406 void setnetent
__P((int));
407 void setprotoent
__P((int));
408 void setservent
__P((int));
409 int getaddrinfo
__P((const char *, const char *,
410 const struct addrinfo
*, struct addrinfo
**));
411 int getnameinfo
__P((const struct sockaddr
*, size_t, char *,
412 size_t, char *, size_t, int));
413 void freeaddrinfo
__P((struct addrinfo
*));
414 const char *gai_strerror
__P((int));
415 struct hostent
*getipnodebyname
__P((const char *, int, int, int *));
416 struct hostent
*getipnodebyaddr
__P((const void *, size_t, int, int *));
417 void freehostent
__P((struct hostent
*));
419 int getnetgrent
__P((/* const */ char **, /* const */ char **,
420 /* const */ char **));
421 void setnetgrent
__P((const char *));
422 void endnetgrent
__P((void));
423 int innetgr
__P((const char *, const char *, const char *,
428 #if defined(__hpux) || defined(__osf__) || defined(_AIX)
429 int gethostbyaddr_r
__P((const char *, int, int, struct hostent
*,
430 struct hostent_data
*));
431 int gethostbyname_r
__P((const char *, struct hostent
*,
432 struct hostent_data
*));
433 int gethostent_r
__P((struct hostent
*, struct hostent_data
*));
435 void sethostent_r
__P((int, struct hostent_data
*));
437 int sethostent_r
__P((int, struct hostent_data
*));
440 int endhostent_r
__P((struct hostent_data
*));
442 void endhostent_r
__P((struct hostent_data
*));
445 #if defined(__hpux) || defined(__osf__)
446 int getnetbyaddr_r
__P((int, int,
447 struct netent
*, struct netent_data
*));
449 int getnetbyaddr_r
__P((long, int,
450 struct netent
*, struct netent_data
*));
452 int getnetbyname_r
__P((const char *,
453 struct netent
*, struct netent_data
*));
454 int getnetent_r
__P((struct netent
*, struct netent_data
*));
455 int setnetent_r
__P((int, struct netent_data
*));
457 int endnetent_r
__P((struct netent_data
*buffer
));
459 void endnetent_r
__P((struct netent_data
*buffer
));
462 int getprotobyname_r
__P((const char *,
463 struct protoent
*, struct protoent_data
*));
464 int getprotobynumber_r
__P((int,
465 struct protoent
*, struct protoent_data
*));
466 int getprotoent_r
__P((struct protoent
*, struct protoent_data
*));
467 int setprotoent_r
__P((int, struct protoent_data
*));
469 int endprotoent_r
__P((struct protoent_data
*));
471 void endprotoent_r
__P((struct protoent_data
*));
474 int getservbyname_r
__P((const char *, const char *,
475 struct servent
*, struct servent_data
*));
476 int getservbyport_r
__P((int, const char *,
477 struct servent
*, struct servent_data
*));
478 int getservent_r
__P((struct servent
*, struct servent_data
*));
479 int setservent_r
__P((int, struct servent_data
*));
481 int endservent_r
__P((struct servent_data
*));
483 void endservent_r
__P((struct servent_data
*));
486 int setnetgrent_r
__P((char *, void **));
487 void endnetgrent_r
__P((void **));
489 * Note: AIX's netdb.h declares innetgr_r() as:
490 * int innetgr_r(char *, char *, char *, char *, struct innetgr_data *);
492 int innetgr_r
__P((const char *, const char *, const char *,
496 /* defined(sun) || defined(bsdi) */
497 #if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
498 int gethostbyaddr_r
__P((const char *, int, int, struct hostent
*,
499 char *, size_t, struct hostent
**, int *));
500 int gethostbyname_r
__P((const char *, struct hostent
*,
501 char *, size_t, struct hostent
**, int *));
502 int gethostent_r
__P((struct hostent
*, char *, size_t,
503 struct hostent
**, int *));
505 struct hostent
*gethostbyaddr_r
__P((const char *, int, int, struct hostent
*,
506 char *, int, int *));
507 struct hostent
*gethostbyname_r
__P((const char *, struct hostent
*,
508 char *, int, int *));
509 struct hostent
*gethostent_r
__P((struct hostent
*, char *, int, int *));
511 void sethostent_r
__P((int));
512 void endhostent_r
__P((void));
514 #if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
515 int getnetbyname_r
__P((const char *, struct netent
*,
516 char *, size_t, struct netent
**, int*));
517 int getnetbyaddr_r
__P((unsigned long int, int, struct netent
*,
518 char *, size_t, struct netent
**, int*));
519 int getnetent_r
__P((struct netent
*, char *, size_t, struct netent
**, int*));
521 struct netent
*getnetbyname_r
__P((const char *, struct netent
*,
523 struct netent
*getnetbyaddr_r
__P((long, int, struct netent
*,
525 struct netent
*getnetent_r
__P((struct netent
*, char *, int));
527 void setnetent_r
__P((int));
528 void endnetent_r
__P((void));
530 #if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
531 int getprotobyname_r
__P((const char *, struct protoent
*, char *,
532 size_t, struct protoent
**));
533 int getprotobynumber_r
__P((int, struct protoent
*, char *, size_t,
534 struct protoent
**));
535 int getprotoent_r
__P((struct protoent
*, char *, size_t, struct protoent
**));
537 struct protoent
*getprotobyname_r
__P((const char *,
538 struct protoent
*, char *, int));
539 struct protoent
*getprotobynumber_r
__P((int,
540 struct protoent
*, char *, int));
541 struct protoent
*getprotoent_r
__P((struct protoent
*, char *, int));
543 void setprotoent_r
__P((int));
544 void endprotoent_r
__P((void));
546 #if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
547 int getservbyname_r
__P((const char *name
, const char *,
548 struct servent
*, char *, size_t, struct servent
**));
549 int getservbyport_r
__P((int port
, const char *,
550 struct servent
*, char *, size_t, struct servent
**));
551 int getservent_r
__P((struct servent
*, char *, size_t, struct servent
**));
553 struct servent
*getservbyname_r
__P((const char *name
, const char *,
554 struct servent
*, char *, int));
555 struct servent
*getservbyport_r
__P((int port
, const char *,
556 struct servent
*, char *, int));
557 struct servent
*getservent_r
__P((struct servent
*, char *, int));
559 void setservent_r
__P((int));
560 void endservent_r
__P((void));
563 int getnetgrent_r
__P((char **, char **, char **, char *, size_t));
570 /* This is nec'y to make this include file properly replace the sun version. */
572 #ifdef __GNU_LIBRARY__
573 #include <rpc/netdb.h>
576 char *r_name
; /*%< name of server for this rpc program */
577 char **r_aliases
; /*%< alias list */
578 int r_number
; /*%< rpc program number */
580 struct rpcent
*getrpcbyname(), *getrpcbynumber(), *getrpcent();
581 #endif /* __GNU_LIBRARY__ */
583 #endif /* !_NETDB_H_ */