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