Watt-32 tcp/ip  2.2 dev-rel.10
netdb.h
Go to the documentation of this file.
1 
5 /*-
6  * Copyright (c) 1980, 1983, 1988, 1993
7  * The Regents of the University of California. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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.
24  *
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
35  * SUCH DAMAGE.
36  *
37  * @(#)netdb.h 8.1 (Berkeley) 6/2/93
38  * $Id: netdb.h,v 1.5 1996/08/29 20:00:56 peter Exp $
39  * -
40  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
41  *
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.
48  *
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
56  * SOFTWARE.
57  * -
58  * --Copyright--
59  */
60 
61 #ifndef __NETDB_H
62 #define __NETDB_H
63 
64 #ifndef _PATH_HEQUIV
65 #define _PATH_HEQUIV "/etc/hosts.equiv"
66 #endif
67 
68 #ifndef _PATH_HOSTS
69 #define _PATH_HOSTS "/etc/hosts"
70 #endif
71 
72 #ifndef _PATH_NETWORKS
73 #define _PATH_NETWORKS "/etc/networks"
74 #endif
75 
76 #ifndef _PATH_PROTOCOLS
77 #define _PATH_PROTOCOLS "/etc/protocols"
78 #endif
79 
80 #ifndef _PATH_SERVICES
81 #define _PATH_SERVICES "/etc/services"
82 #endif
83 
84 #ifndef __SYS_W32API_H
85 #include <sys/w32api.h>
86 #endif
87 
88 #ifndef __SYS_SOCKET_H
89 #include <sys/socket.h> /* struct sockaddr */
90 #endif
91 
92 #ifndef __SYS_CDEFS_H
93 #include <sys/cdefs.h>
94 #endif
95 
96 
97 /*
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).
101  */
102 struct hostent {
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 */
109 };
110 
111 /*
112  * Assumption here is that a network number
113  * fits in 32 bits -- probably a poor one.
114  */
115 struct netent {
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 # */
120  };
121 
122 struct servent {
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 */
127  };
128 
129 struct protoent {
130  char *p_name; /* official protocol name */
131  char **p_aliases; /* alias list */
132  int p_proto; /* protocol # */
133  };
134 
135 struct addrinfo {
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 */
144  };
145 
146 /*
147  * Error return codes from gethostbyname() and gethostbyaddr()
148  * (left in extern int h_errno).
149  */
150 W32_DATA int h_errno;
151 
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 */
159 
160 
161 /*
162  * Error return codes from getaddrinfo()
163  */
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
177 #define EAI_MAX 14
178 
179 /*
180  * Flag values for getaddrinfo()
181  */
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 */
185 
186 /* valid flags for addrinfo
187  */
188 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
189 
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 */
194 
195 /* special recommended flags for getipnodebyname
196  */
197 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
198 
199 /*
200  * Constants for getnameinfo()
201  */
202 #define NI_MAXHOST 1025
203 #define NI_MAXSERV 32
204 
205 /*
206  * Flag values for getnameinfo()
207  */
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
214 
215 /*
216  * Scope delimit character
217  */
218 #define SCOPE_DELIMITER '%'
219 
220 __BEGIN_DECLS
221 
222 W32_FUNC void W32_CALL endhostent (void);
223 W32_FUNC void W32_CALL endhostent6 (void);
224 W32_FUNC void W32_CALL endnetent (void);
225 W32_FUNC void W32_CALL endprotoent (void);
226 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 gethostbyaddr6 (const void *);
229 W32_FUNC struct hostent * W32_CALL gethostbyname (const char *name);
230 W32_FUNC struct hostent * W32_CALL gethostbyname2 (const char *name, int af);
231 W32_FUNC struct hostent * W32_CALL gethostbyname6 (const char *name);
232 W32_FUNC struct hostent * W32_CALL gethostent (void);
233 W32_FUNC struct hostent * W32_CALL gethostent6 (void);
234 W32_FUNC struct hostent * W32_CALL getipnodebyaddr(const void *, size_t, int, int *);
235 W32_FUNC struct hostent * W32_CALL getipnodebyname(const char *, int, int, int *);
236 W32_FUNC struct netent * W32_CALL getnetbyaddr (long, int);
237 W32_FUNC struct netent * W32_CALL getnetbyname (const char *);
238 W32_FUNC struct netent * W32_CALL getnetent (void);
239 W32_FUNC struct protoent * W32_CALL getprotobyname (const char *);
240 W32_FUNC struct protoent * W32_CALL getprotobynumber (int);
241 W32_FUNC struct protoent * W32_CALL getprotoent (void);
242 W32_FUNC struct servent * W32_CALL getservbyname (const char *, const char *);
243 W32_FUNC struct servent * W32_CALL getservbyport (int, const char *);
244 W32_FUNC struct servent * W32_CALL getservent (void);
245 W32_FUNC void W32_CALL herror (const char *);
246 W32_FUNC const char * W32_CALL hstrerror (int);
247 W32_FUNC void W32_CALL sethostent (int stayopen);
248 W32_FUNC void W32_CALL sethostent6 (int stayopen);
249 W32_FUNC void W32_CALL setnetent (int);
250 W32_FUNC void W32_CALL setprotoent (int);
251 W32_FUNC void W32_CALL setservent (int);
252 
253 W32_FUNC int W32_CALL getnameinfo (const struct sockaddr *sa, int salen,
254  char *host, int hostlen,
255  char *serv, int servlen, int flags);
256 
257 W32_FUNC int W32_CALL getaddrinfo (const char *hostname, const char *servname,
258  const struct addrinfo *hints,
259  struct addrinfo **res);
260 
261 W32_FUNC void W32_CALL freeaddrinfo (struct addrinfo *ai);
262 W32_FUNC void W32_CALL freehostent (struct hostent *);
263 W32_FUNC char * W32_CALL gai_strerror (int ecode);
264 
265 W32_FUNC int W32_CALL if_nametoindex (const char *);
266 W32_FUNC char * W32_CALL if_indextoname (int, char *);
267 
268 W32_FUNC int * W32_CALL __h_errno_location (void);
269 
270 #if defined(_REENTRANT)
271 W32_FUNC struct hostent * W32_CALL gethostbyaddr_r (
272  const char *addr, int len, int type, struct hostent *result,
273  char *buffer, int buflen, int *h_errnop);
274 
275 W32_FUNC struct hostent * W32_CALL gethostbyname_r (
276  const char *name, struct hostent *result,
277  char *buffer, int buflen, int *h_errnop);
278 
279 W32_FUNC struct hostent * W32_CALL gethostent_r (
280  struct hostent *result, char *buffer, int buflen, int *h_errnop);
281 
282 W32_FUNC struct netent * W32_CALL getnetbyaddr_r (
283  long net, int type, struct netent *result, char *buffer, int buflen);
284 
285 W32_FUNC struct netent * W32_CALL getnetbyname_r (
286  const char *name, struct netent *result, char *buffer, int buflen);
287 
288 W32_FUNC struct netent * W32_CALL getnetent_r (
289  struct netent *result, char *buffer, int buflen);
290 
291 W32_FUNC struct protoent * W32_CALL getprotobyname_r (
292  const char *name, struct protoent *result, char *buffer, int buflen);
293 
294 W32_FUNC struct protoent * W32_CALL getprotobynumber_r (
295  int proto, struct protoent *result, char *buffer, int buflen);
296 
297 W32_FUNC struct protoent * W32_CALL getprotoent_r (
298  struct protoent *result, char *buffer, int buflen);
299 
300 W32_FUNC struct servent * W32_CALL getservbyname_r (
301  const char *name, const char *proto, struct servent *result,
302  char *buffer, int buflen);
303 
304 W32_FUNC struct servent * W32_CALL getservbyport_r (
305  int port, const char *proto, struct servent *result,
306  char *buffer, int buflen);
307 
308 W32_FUNC struct servent * W32_CALL getservent_r (
309  struct servent *result, char *buffer, int buflen);
310 
311 #endif /* _REENTRANT */
312 
313 __END_DECLS
314 
315 #endif
Definition: netdb.h:115
Definition: netdb.h:122
Definition: netdb.h:102
char hostname[MAX_HOSTLEN+1]
Our configured hostname.
Definition: pctcp.c:59
W32_FUNC struct hostent *W32_CALL gethostent(void)
Return the next (non-commented) line from the host-file.
Definition: gethost.c:218