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