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