Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/netdb.h
+++ new/usr/src/head/netdb.h
1 1 /*
2 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 + *
2 4 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3 5 * Use is subject to license terms.
4 6 */
5 7
6 8 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 9 /* All Rights Reserved */
8 10
9 11 /*
10 12 * BIND 4.9.3:
11 13 *
12 14 * Copyright (c) 1980, 1983, 1988, 1993
13 15 * The Regents of the University of California. All rights reserved.
14 16 *
15 17 * Redistribution and use in source and binary forms, with or without
16 18 * modification, are permitted provided that the following conditions
17 19 * are met:
18 20 * 1. Redistributions of source code must retain the above copyright
19 21 * notice, this list of conditions and the following disclaimer.
20 22 * 2. Redistributions in binary form must reproduce the above copyright
21 23 * notice, this list of conditions and the following disclaimer in the
22 24 * documentation and/or other materials provided with the distribution.
23 25 * 3. All advertising materials mentioning features or use of this software
24 26 * must display the following acknowledgement:
25 27 * This product includes software developed by the University of
26 28 * California, Berkeley and its contributors.
27 29 * 4. Neither the name of the University nor the names of its contributors
28 30 * may be used to endorse or promote products derived from this software
29 31 * without specific prior written permission.
30 32 *
31 33 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32 34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 36 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 43 * SUCH DAMAGE.
42 44 * -
43 45 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
44 46 *
45 47 * Permission to use, copy, modify, and distribute this software for any
46 48 * purpose with or without fee is hereby granted, provided that the above
47 49 * copyright notice and this permission notice appear in all copies, and that
48 50 * the name of Digital Equipment Corporation not be used in advertising or
49 51 * publicity pertaining to distribution of the document or software without
50 52 * specific, written prior permission.
51 53 *
52 54 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
53 55 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
54 56 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
55 57 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
56 58 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
57 59 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
58 60 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
59 61 * SOFTWARE.
60 62 * --Copyright--
61 63 *
62 64 * End BIND 4.9.3
63 65 */
64 66
65 67 /*
66 68 * Structures returned by network data base library.
67 69 * All addresses are supplied in host order, and
68 70 * returned in network order (suitable for use in system calls).
69 71 */
70 72
71 73 #ifndef _NETDB_H
72 74 #define _NETDB_H
73 75
74 76 #include <sys/types.h>
75 77 #include <netinet/in.h>
76 78 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
77 79 #include <sys/socket.h>
78 80 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
79 81 #include <sys/feature_tests.h>
80 82
81 83 #ifdef __cplusplus
82 84 extern "C" {
83 85 #endif
84 86
85 87 #define _PATH_HEQUIV "/etc/hosts.equiv"
86 88 #define _PATH_HOSTS "/etc/hosts"
87 89 #define _PATH_IPNODES "/etc/inet/ipnodes"
88 90 #define _PATH_IPSECALGS "/etc/inet/ipsecalgs"
89 91 #define _PATH_NETMASKS "/etc/netmasks"
90 92 #define _PATH_NETWORKS "/etc/networks"
91 93 #define _PATH_PROTOCOLS "/etc/protocols"
92 94 #define _PATH_SERVICES "/etc/services"
93 95
94 96 struct hostent {
95 97 char *h_name; /* official name of host */
96 98 char **h_aliases; /* alias list */
97 99 int h_addrtype; /* host address type */
98 100 int h_length; /* length of address */
99 101 char **h_addr_list; /* list of addresses from name server */
100 102 #define h_addr h_addr_list[0] /* address, for backward compatiblity */
101 103 };
102 104
103 105
104 106 /*
105 107 * addrinfo introduced with IPv6 for Protocol-Independent Hostname
106 108 * and Service Name Translation.
107 109 */
108 110
109 111 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
110 112 struct addrinfo {
111 113 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, ... */
112 114 int ai_family; /* PF_xxx */
113 115 int ai_socktype; /* SOCK_xxx */
114 116 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
115 117 #ifdef __sparcv9
116 118 int _ai_pad; /* for backwards compat with old size_t */
117 119 #endif /* __sparcv9 */
118 120 socklen_t ai_addrlen;
119 121 char *ai_canonname; /* canonical name for hostname */
120 122 struct sockaddr *ai_addr; /* binary address */
121 123 struct addrinfo *ai_next; /* next structure in linked list */
122 124 };
123 125
124 126
125 127 /* addrinfo flags */
126 128 #define AI_PASSIVE 0x0008 /* intended for bind() + listen() */
127 129 #define AI_CANONNAME 0x0010 /* return canonical version of host */
128 130 #define AI_NUMERICHOST 0x0020 /* use numeric node address string */
129 131 #define AI_NUMERICSERV 0x0040 /* servname is assumed numeric */
130 132
131 133 /* getipnodebyname() flags */
132 134 #define AI_V4MAPPED 0x0001 /* IPv4 mapped addresses if no IPv6 */
133 135 #define AI_ALL 0x0002 /* IPv6 and IPv4 mapped addresses */
134 136 #define AI_ADDRCONFIG 0x0004 /* AAAA or A records only if IPv6/IPv4 cnfg'd */
135 137
136 138
137 139 /*
138 140 * These were defined in RFC 2553 but not SUSv3
139 141 * or RFC 3493 which obsoleted 2553.
140 142 */
141 143 #if !defined(_XPG6) || defined(__EXTENSIONS__)
142 144 #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
143 145
144 146 /* addrinfo errors */
145 147 #define EAI_ADDRFAMILY 1 /* address family not supported */
146 148 #define EAI_NODATA 7 /* no address */
147 149 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
148 150 #define EAI_AGAIN 2 /* DNS temporary failure */
149 151 #define EAI_BADFLAGS 3 /* invalid ai_flags */
150 152 #define EAI_FAIL 4 /* DNS non-recoverable failure */
151 153 #define EAI_FAMILY 5 /* ai_family not supported */
152 154 #define EAI_MEMORY 6 /* memory allocation failure */
153 155 #define EAI_NONAME 8 /* host/servname not known */
154 156 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
155 157 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
156 158 #define EAI_SYSTEM 11 /* system error in errno */
157 159 #define EAI_OVERFLOW 12 /* argument buffer overflow */
158 160 #define EAI_PROTOCOL 13
159 161 #define EAI_MAX 14
160 162
161 163 /* getnameinfo flags */
162 164 #define NI_NOFQDN 0x0001
163 165 #define NI_NUMERICHOST 0x0002 /* return numeric form of address */
164 166 #define NI_NAMEREQD 0x0004 /* request DNS name */
165 167 #define NI_NUMERICSERV 0x0008
166 168 #define NI_DGRAM 0x0010
167 169
168 170 #if !defined(_XPG6) || defined(__EXTENSIONS__)
169 171 /* Not listed in any standards document */
170 172 #define NI_WITHSCOPEID 0x0020
171 173 #define NI_NUMERICSCOPE 0x0040
172 174
173 175 /* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
174 176 #define NI_MAXHOST 1025
175 177 #define NI_MAXSERV 32
176 178 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
177 179 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
178 180
179 181 /*
180 182 * Scope delimit character
181 183 */
182 184 #define SCOPE_DELIMITER '%'
183 185
184 186
185 187 /*
186 188 * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
187 189 * and algorithms.
188 190 */
189 191 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
190 192 typedef struct ipsecalgent {
191 193 char **a_names; /* algorithm names */
192 194 int a_proto_num; /* protocol number */
193 195 int a_alg_num; /* algorithm number */
194 196 char *a_mech_name; /* encryption framework mechanism name */
195 197 int *a_block_sizes; /* supported block sizes */
196 198 int *a_key_sizes; /* supported key sizes */
197 199 int a_key_increment; /* key size increment */
198 200 int *a_mech_params; /* mechanism specific parameters */
199 201 int a_alg_flags; /* algorithm flags */
200 202 } ipsecalgent_t;
201 203
202 204 /* well-known IPsec protocol numbers */
203 205
204 206 #define IPSEC_PROTO_AH 2
205 207 #define IPSEC_PROTO_ESP 3
206 208 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
207 209
208 210 /*
209 211 * Assumption here is that a network number
210 212 * fits in 32 bits -- probably a poor one.
211 213 */
212 214 struct netent {
213 215 char *n_name; /* official name of net */
214 216 char **n_aliases; /* alias list */
215 217 int n_addrtype; /* net address type */
216 218 in_addr_t n_net; /* network # */
217 219 };
218 220
219 221 struct protoent {
220 222 char *p_name; /* official protocol name */
221 223 char **p_aliases; /* alias list */
↓ open down ↓ |
210 lines elided |
↑ open up ↑ |
222 224 int p_proto; /* protocol # */
223 225 };
224 226
225 227 struct servent {
226 228 char *s_name; /* official service name */
227 229 char **s_aliases; /* alias list */
228 230 int s_port; /* port # */
229 231 char *s_proto; /* protocol to use */
230 232 };
231 233
232 -#ifdef __STDC__
233 234 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
234 235 struct hostent *gethostbyname_r
235 236 (const char *, struct hostent *, char *, int, int *h_errnop);
236 237 struct hostent *gethostbyaddr_r
237 238 (const char *, int, int, struct hostent *, char *, int, int *h_errnop);
238 239 struct hostent *getipnodebyname(const char *, int, int, int *);
239 240 struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
240 241 void freehostent(struct hostent *);
241 242 struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop);
242 243
243 244 struct servent *getservbyname_r
244 245 (const char *name, const char *, struct servent *, char *, int);
245 246 struct servent *getservbyport_r
246 247 (int port, const char *, struct servent *, char *, int);
247 248 struct servent *getservent_r(struct servent *, char *, int);
248 249
249 250 struct netent *getnetbyname_r
250 251 (const char *, struct netent *, char *, int);
251 252 struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int);
252 253 struct netent *getnetent_r(struct netent *, char *, int);
253 254
254 255 struct protoent *getprotobyname_r
255 256 (const char *, struct protoent *, char *, int);
256 257 struct protoent *getprotobynumber_r
257 258 (int, struct protoent *, char *, int);
258 259 struct protoent *getprotoent_r(struct protoent *, char *, int);
259 260
260 261 int getnetgrent_r(char **, char **, char **, char *, int);
261 262 int innetgr(const char *, const char *, const char *, const char *);
262 263 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
263 264
264 265 /* Old interfaces that return a pointer to a static area; MT-unsafe */
265 266 struct hostent *gethostbyname(const char *);
266 267 struct hostent *gethostent(void);
267 268 struct netent *getnetbyaddr(in_addr_t, int);
268 269 struct netent *getnetbyname(const char *);
269 270 struct netent *getnetent(void);
270 271 struct protoent *getprotobyname(const char *);
271 272 struct protoent *getprotobynumber(int);
272 273 struct protoent *getprotoent(void);
273 274 struct servent *getservbyname(const char *, const char *);
274 275 struct servent *getservbyport(int, const char *);
275 276 struct servent *getservent(void);
276 277
277 278 /* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
278 279 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
279 280 struct hostent *gethostbyaddr(const void *, socklen_t, int);
280 281 #else
281 282 struct hostent *gethostbyaddr(const void *, size_t, int);
282 283 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
283 284
284 285 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
285 286 int endhostent(void);
286 287 int endnetent(void);
287 288 int endprotoent(void);
288 289 int endservent(void);
289 290 int sethostent(int);
290 291 int setnetent(int);
291 292 int setprotoent(int);
292 293 int setservent(int);
293 294 #else
294 295 void endhostent(void);
295 296 void endnetent(void);
296 297 void endprotoent(void);
297 298 void endservent(void);
298 299 void sethostent(int);
299 300 void setnetent(int);
300 301 void setprotoent(int);
301 302 void setservent(int);
302 303 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
303 304
304 305 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
305 306
306 307 #ifdef _XPG6
307 308 #ifdef __PRAGMA_REDEFINE_EXTNAME
308 309 #pragma redefine_extname getaddrinfo __xnet_getaddrinfo
309 310 #else /* __PRAGMA_REDEFINE_EXTNAME */
310 311 #define getaddrinfo __xnet_getaddrinfo
311 312 #endif /* __PRAGMA_REDEFINE_EXTNAME */
312 313 #endif /* _XPG6 */
313 314
314 315 int getaddrinfo(const char *_RESTRICT_KYWD,
315 316 const char *_RESTRICT_KYWD,
316 317 const struct addrinfo *_RESTRICT_KYWD,
317 318 struct addrinfo **_RESTRICT_KYWD);
318 319 void freeaddrinfo(struct addrinfo *);
319 320 const char *gai_strerror(int);
320 321 int getnameinfo(const struct sockaddr *_RESTRICT_KYWD,
321 322 socklen_t, char *_RESTRICT_KYWD, socklen_t,
322 323 char *_RESTRICT_KYWD, socklen_t, int);
323 324 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
324 325
325 326 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
326 327 int getnetgrent(char **, char **, char **);
327 328 int setnetgrent(const char *);
328 329 int endnetgrent(void);
329 330 int rcmd(char **, unsigned short,
330 331 const char *, const char *, const char *, int *);
331 332 int rcmd_af(char **, unsigned short,
332 333 const char *, const char *, const char *, int *, int);
333 334 int rresvport_af(int *, int);
334 335 int rresvport_addr(int *, struct sockaddr_storage *);
335 336 int rexec(char **, unsigned short,
336 337 const char *, const char *, const char *, int *);
337 338 int rexec_af(char **, unsigned short,
338 339 const char *, const char *, const char *, int *, int);
339 340 int rresvport(int *);
340 341 int ruserok(const char *, int, const char *, const char *);
341 342 /* BIND */
342 343 struct hostent *gethostbyname2(const char *, int);
343 344 void herror(const char *);
344 345 const char *hstrerror(int);
345 346 /* End BIND */
↓ open down ↓ |
103 lines elided |
↑ open up ↑ |
346 347
347 348 /* IPsec algorithm prototype definitions */
348 349 struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
349 350 struct ipsecalgent *getipsecalgbynum(int, int, int *);
350 351 int getipsecprotobyname(const char *doi_name);
351 352 char *getipsecprotobynum(int doi_domain);
352 353 void freeipsecalgent(struct ipsecalgent *ptr);
353 354 /* END IPsec algorithm prototype definitions */
354 355
355 356 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
356 -#else /* __STDC__ */
357 -struct hostent *gethostbyname_r();
358 -struct hostent *gethostbyaddr_r();
359 -struct hostent *getipnodebyname();
360 -struct hostent *getipnodebyaddr();
361 -void freehostent();
362 -struct hostent *gethostent_r();
363 -struct servent *getservbyname_r();
364 -struct servent *getservbyport_r();
365 -struct servent *getservent_r();
366 -struct netent *getnetbyname_r();
367 -struct netent *getnetbyaddr_r();
368 -struct netent *getnetent_r();
369 -struct protoent *getprotobyname_r();
370 -struct protoent *getprotobynumber_r();
371 -struct protoent *getprotoent_r();
372 -int getnetgrent_r();
373 -int innetgr();
374 357
375 -/* Old interfaces that return a pointer to a static area; MT-unsafe */
376 -struct hostent *gethostbyname();
377 -struct hostent *gethostbyaddr();
378 -struct hostent *gethostent();
379 -struct netent *getnetbyname();
380 -struct netent *getnetbyaddr();
381 -struct netent *getnetent();
382 -struct servent *getservbyname();
383 -struct servent *getservbyport();
384 -struct servent *getservent();
385 -struct protoent *getprotobyname();
386 -struct protoent *getprotobynumber();
387 -struct protoent *getprotoent();
388 -int getnetgrent();
389 -
390 -int sethostent();
391 -int endhostent();
392 -int setnetent();
393 -int endnetent();
394 -int setservent();
395 -int endservent();
396 -int setprotoent();
397 -int endprotoent();
398 -int setnetgrent();
399 -int endnetgrent();
400 -int rcmd();
401 -int rcmd_af();
402 -int rexec();
403 -int rexec_af();
404 -int rresvport();
405 -int rresvport_af();
406 -int rresvport_addr();
407 -int ruserok();
408 -/* BIND */
409 -struct hostent *gethostbyname2();
410 -void herror();
411 -char *hstrerror();
412 -/* IPv6 prototype definitons */
413 -int getaddrinfo();
414 -void freeaddrinfo();
415 -const char *gai_strerror();
416 -int getnameinfo();
417 -/* END IPv6 prototype definitions */
418 -/* End BIND */
419 -
420 -#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
421 -/* IPsec algorithm prototype definitions */
422 -struct ipsecalgent *getalgbyname();
423 -struct ipsecalgent *getalgbydoi();
424 -int getdoidomainbyname();
425 -const char *getdoidomainbynum();
426 -void freealgent();
427 -/* END IPsec algorithm prototype definitions */
428 -#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
429 -
430 -#endif /* __STDC__ */
431 -
432 358 /*
433 359 * Error return codes from gethostbyname() and gethostbyaddr()
434 360 * (when using the resolver)
435 361 */
436 362
437 363 extern int h_errno;
438 364
439 365 #ifdef _REENTRANT
440 -#ifdef __STDC__
441 366 extern int *__h_errno(void);
442 -#else
443 -extern int *__h_errno();
444 -#endif /* __STDC__ */
445 367
446 368 /* Only #define h_errno if there is no conflict with other use */
447 369 #ifdef H_ERRNO_IS_FUNCTION
448 370 #define h_errno (*__h_errno())
449 371 #endif /* NO_H_ERRNO_DEFINE */
450 372 #endif /* _REENTRANT */
451 373
452 374 /*
453 375 * Error return codes from gethostbyname() and gethostbyaddr()
454 376 * (left in extern int h_errno).
455 377 */
456 378 #define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */
457 379 #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
458 380 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
459 381 #define NO_DATA 4 /* Valid name, no data record of requested type */
460 382
461 383 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
462 384 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
463 385
464 386 /* BIND */
465 387 #define NETDB_INTERNAL -1 /* see errno */
466 388 #define NETDB_SUCCESS 0 /* no problem */
467 389 /* End BIND */
468 390
469 391 #define MAXHOSTNAMELEN 256
470 392
471 393 #define MAXALIASES 35
472 394 #define MAXADDRS 35
473 395 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
474 396
475 397 #ifdef __cplusplus
476 398 }
477 399 #endif
478 400
479 401 #endif /* _NETDB_H */
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX