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 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
38 * $Id: netdb.h,v 1.5 1996/08/29 20:00:56 peter Exp $
40 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
42 * Permission to use, copy, modify, and distribute this software for any
43 * purpose with or without fee is hereby granted, provided that the above
44 * copyright notice and this permission notice appear in all copies, and that
45 * the name of Digital Equipment Corporation not be used in advertising or
46 * publicity pertaining to distribution of the document or software without
47 * specific, written prior permission.
49 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
50 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
51 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
52 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
53 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
54 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
55 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
65 #define _PATH_HEQUIV "/etc/hosts.equiv"
69 #define _PATH_HOSTS "/etc/hosts"
72 #ifndef _PATH_NETWORKS
73 #define _PATH_NETWORKS "/etc/networks"
76 #ifndef _PATH_PROTOCOLS
77 #define _PATH_PROTOCOLS "/etc/protocols"
80 #ifndef _PATH_SERVICES
81 #define _PATH_SERVICES "/etc/services"
84 #ifndef __SYS_W32API_H
85 #include <sys/w32api.h>
88 #ifndef __SYS_SOCKET_H
89 #include <sys/socket.h> /* struct sockaddr */
93 #include <sys/cdefs.h>
98 * Structures returned by network data base library. All addresses are
99 * supplied in host order, and returned in network order (suitable for
100 * use in system calls).
103 char *h_name; /* official name of host */
104 char **h_aliases; /* alias list */
105 int h_addrtype; /* host address type */
106 int h_length; /* length of address */
107 char **h_addr_list; /* list of addresses from name server */
108 #define h_addr h_addr_list[0] /* address, for backward compatiblity */
112 * Assumption here is that a network number
113 * fits in 32 bits -- probably a poor one.
116 char *n_name; /* official name of net */
117 char **n_aliases; /* alias list */
118 int n_addrtype; /* net address type */
119 unsigned long n_net; /* network # */
123 char *s_name; /* official service name */
124 char **s_aliases; /* alias list */
125 int s_port; /* port # */
126 char *s_proto; /* protocol to use */
130 char *p_name; /* official protocol name */
131 char **p_aliases; /* alias list */
132 int p_proto; /* protocol # */
136 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
137 int ai_family; /* PF_xxx */
138 int ai_socktype; /* SOCK_xxx */
139 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
140 int ai_addrlen; /* length of ai_addr */
141 char *ai_canonname; /* canonical name for hostname */
142 struct sockaddr *ai_addr; /* binary address */
143 struct addrinfo *ai_next; /* next structure in linked list */
147 * Error return codes from gethostbyname() and gethostbyaddr()
148 * (left in extern int h_errno).
150 W32_DATA int h_errno;
152 #define NETDB_INTERNAL -1 /* see errno */
153 #define NETDB_SUCCESS 0 /* no problem */
154 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
155 #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
156 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
157 #define NO_DATA 4 /* Valid name, no data record of requested type */
158 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
162 * Error return codes from getaddrinfo()
164 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
165 #define EAI_AGAIN 2 /* temporary failure in name resolution */
166 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
167 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
168 #define EAI_FAMILY 5 /* ai_family not supported */
169 #define EAI_MEMORY 6 /* memory allocation failure */
170 #define EAI_NODATA 7 /* no address associated with hostname */
171 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
172 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
173 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
174 #define EAI_SYSTEM 11 /* system error returned in errno */
175 #define EAI_BADHINTS 12
176 #define EAI_PROTOCOL 13
180 * Flag values for getaddrinfo()
182 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
183 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
184 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
186 /* valid flags for addrinfo
188 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
190 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
191 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
192 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
193 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
195 /* special recommended flags for getipnodebyname
197 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
200 * Constants for getnameinfo()
202 #define NI_MAXHOST 1025
203 #define NI_MAXSERV 32
206 * Flag values for getnameinfo()
208 #define NI_NOFQDN 0x00000001
209 #define NI_NUMERICHOST 0x00000002
210 #define NI_NAMEREQD 0x00000004
211 #define NI_NUMERICSERV 0x00000008
212 #define NI_DGRAM 0x00000010
213 #define NI_WITHSCOPEID 0x00000020
216 * Scope delimit character
218 #define SCOPE_DELIMITER '%'
222 W32_FUNC void W32_CALL endhostent (void);
223 W32_FUNC void W32_CALL endnetent (void);
224 W32_FUNC void W32_CALL endprotoent (void);
225 W32_FUNC void W32_CALL endservent (void);
227 W32_FUNC struct hostent * W32_CALL gethostbyaddr (const char *, int, int);
228 W32_FUNC struct hostent * W32_CALL gethostbyname (const char *);
229 W32_FUNC struct hostent * W32_CALL gethostbyname2 (const char *, int af);
230 W32_FUNC struct hostent * W32_CALL gethostent (void);
231 W32_FUNC struct hostent * W32_CALL getipnodebyaddr(const void *, size_t, int, int *);
232 W32_FUNC struct hostent * W32_CALL getipnodebyname(const char *, int, int, int *);
233 W32_FUNC struct netent * W32_CALL getnetbyaddr (long, int);
234 W32_FUNC struct netent * W32_CALL getnetbyname (const char *);
235 W32_FUNC struct netent * W32_CALL getnetent (void);
236 W32_FUNC struct protoent * W32_CALL getprotobyname (const char *);
237 W32_FUNC struct protoent * W32_CALL getprotobynumber (int);
238 W32_FUNC struct protoent * W32_CALL getprotoent (void);
239 W32_FUNC struct servent * W32_CALL getservbyname (const char *, const char *);
240 W32_FUNC struct servent * W32_CALL getservbyport (int, const char *);
241 W32_FUNC struct servent * W32_CALL getservent (void);
242 W32_FUNC void W32_CALL herror (const char *);
243 W32_FUNC const char * W32_CALL hstrerror (int);
244 W32_FUNC void W32_CALL sethostent (int);
245 W32_FUNC void W32_CALL setnetent (int);
246 W32_FUNC void W32_CALL setprotoent (int);
247 W32_FUNC void W32_CALL setservent (int);
249 W32_FUNC int W32_CALL getnameinfo (const struct sockaddr *sa, int salen,
250 char *host, int hostlen,
251 char *serv, int servlen, int flags);
253 W32_FUNC int W32_CALL getaddrinfo (const char *hostname, const char *servname,
254 const struct addrinfo *hints, struct addrinfo **res);
256 W32_FUNC void W32_CALL freeaddrinfo (struct addrinfo *ai);
257 W32_FUNC void W32_CALL freehostent (struct hostent *);
258 W32_FUNC char * W32_CALL gai_strerror (int ecode);
260 W32_FUNC int W32_CALL if_nametoindex (const char *);
261 W32_FUNC char * W32_CALL if_indextoname (int, char *);
263 W32_FUNC int * W32_CALL __h_errno_location (void);
265 #if defined(_REENTRANT)
266 W32_FUNC struct hostent * W32_CALL gethostbyaddr_r (
267 const char *addr, int len, int type, struct hostent *result,
268 char *buffer, int buflen, int *h_errnop);
270 W32_FUNC struct hostent * W32_CALL gethostbyname_r (
271 const char *name, struct hostent *result,
272 char *buffer, int buflen, int *h_errnop);
274 W32_FUNC struct hostent * W32_CALL gethostent_r (
275 struct hostent *result, char *buffer, int buflen, int *h_errnop);
277 W32_FUNC struct netent * W32_CALL getnetbyaddr_r (
278 long net, int type, struct netent *result, char *buffer, int buflen);
280 W32_FUNC struct netent * W32_CALL getnetbyname_r (
281 const char *name, struct netent *result, char *buffer, int buflen);
283 W32_FUNC struct netent * W32_CALL getnetent_r (
284 struct netent *result, char *buffer, int buflen);
286 W32_FUNC struct protoent * W32_CALL getprotobyname_r (
287 const char *name, struct protoent *result, char *buffer, int buflen);
289 W32_FUNC struct protoent * W32_CALL getprotobynumber_r (
290 int proto, struct protoent *result, char *buffer, int buflen);
292 W32_FUNC struct protoent * W32_CALL getprotoent_r (
293 struct protoent *result, char *buffer, int buflen);
295 W32_FUNC struct servent * W32_CALL getservbyname_r (
296 const char *name, const char *proto, struct servent *result,
297 char *buffer, int buflen);
299 W32_FUNC struct servent * W32_CALL getservbyport_r (
300 int port, const char *proto, struct servent *result,
301 char *buffer, int buflen);
303 W32_FUNC struct servent * W32_CALL getservent_r (
304 struct servent *result, char *buffer, int buflen);
306 #endif /* _REENTRANT */