xref: /titanic_41/usr/src/lib/libresolv2/include/port_after.h (revision 989f28072d20c73ae0955d6a1e3e2fc74831cb39)
1 /*
2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3  */
4 
5 /*
6  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (C) 2001-2003  Internet Software Consortium.
8  *
9  * Permission to use, copy, modify, and/or distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
14  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
16  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
18  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */
23 
24 #ifndef port_after_h
25 #define port_after_h
26 
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <sys/param.h>
31 #include <sys/time.h>
32 #if (!defined(BSD)) || (BSD < 199306)
33 #include <sys/bitypes.h>
34 #endif
35 #ifdef HAVE_INTTYPES_H
36 #include <inttypes.h>
37 #endif
38 #ifdef HAVE_SYS_SELECT_H
39 #include <sys/select.h>
40 #endif /* HAVE_SYS_SELECT_H */
41 
42 #ifdef REENABLE_SEND
43 #undef send
44 #endif
45 
46 #undef NEED_PSELECT
47 #undef HAVE_SA_LEN
48 #undef HAVE_MINIMUM_IFREQ
49 #define NEED_DAEMON 1
50 #undef NEED_STRSEP
51 #undef NEED_STRERROR
52 #ifdef NEED_STRERROR
53 const char *isc_strerror(int);
54 #define strerror isc_strerror
55 #endif
56 /* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h
57  * #define HAS_INET6_STRUCTS 1
58  * #define HAVE_SIN6_SCOPE_ID 1
59  */
60 #include <port_ipv6.h>
61 
62 #undef NEED_IN6ADDR_ANY
63 #undef HAS_IN_ADDR6
64 #define HAVE_SOCKADDR_STORAGE 1
65 #undef NEED_GETTIMEOFDAY
66 #define HAVE_STRNDUP
67 #undef USE_FIONBIO_IOCTL
68 #undef INNETGR_ARGS
69 
70 #undef USE_IFNAMELINKID
71 #define PORT_NONBLOCK O_NONBLOCK
72 
73 #ifndef _POSIX_PATH_MAX
74 #define _POSIX_PATH_MAX 255
75 #endif
76 #ifndef PATH_MAX
77 #define PATH_MAX _POSIX_PATH_MAX
78 #endif
79 
80 /*
81  * We need to know the IPv6 address family number even on IPv4-only systems.
82  * Note that this is NOT a protocol constant, and that if the system has its
83  * own AF_INET6, different from ours below, all of BIND's libraries and
84  * executables will need to be recompiled after the system <sys/socket.h>
85  * has had this type added.  The type number below is correct on most BSD-
86  * derived systems for which AF_INET6 is defined.
87  */
88 #ifndef AF_INET6
89 #define AF_INET6        24
90 #endif
91 
92 #ifndef PF_INET6
93 #define PF_INET6        AF_INET6
94 #endif
95 
96 #ifdef HAS_IN_ADDR6
97 /* Map to pre-RFC structure. */
98 #define in6_addr in_addr6
99 #endif
100 
101 #ifndef HAS_INET6_STRUCTS
102 /* Replace with structure from later rev of O/S if known. */
103 struct in6_addr {
104 	u_int8_t        s6_addr[16];
105 };
106 
107 #define IN6ADDR_ANY_INIT \
108 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
109 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
110 
111 #define IN6ADDR_LOOPBACK_INIT \
112 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
113 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
114 
115 /* Replace with structure from later rev of O/S if known. */
116 struct sockaddr_in6 {
117 #ifdef  HAVE_SA_LEN
118 	u_int8_t        sin6_len;       /* length of this struct */
119 	u_int8_t        sin6_family;    /* AF_INET6 */
120 #else
121 	u_int16_t       sin6_family;    /* AF_INET6 */
122 #endif
123 	u_int16_t       sin6_port;      /* transport layer port # */
124 	u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
125 	struct in6_addr sin6_addr;      /* IPv6 address */
126 	u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
127 };
128 #endif  /* HAS_INET6_STRUCTS */
129 
130 #ifdef BROKEN_IN6ADDR_INIT_MACROS
131 #undef IN6ADDR_ANY_INIT
132 #undef IN6ADDR_LOOPBACK_INIT
133 #endif
134 
135 #ifdef _AIX
136 #ifndef IN6ADDR_ANY_INIT
137 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
138 #endif
139 #ifndef IN6ADDR_LOOPBACK_INIT
140 #if BYTE_ORDER == BIG_ENDIAN
141 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
142 #else
143 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
144 #endif
145 #endif
146 #endif
147 
148 #ifndef IN6ADDR_ANY_INIT
149 #ifdef s6_addr
150 #define IN6ADDR_ANY_INIT \
151 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
152 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
153 #else
154 #define IN6ADDR_ANY_INIT \
155 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
156 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
157 #endif
158 
159 #endif
160 #ifndef IN6ADDR_LOOPBACK_INIT
161 #ifdef s6_addr
162 #define IN6ADDR_LOOPBACK_INIT \
163 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
164 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
165 #else
166 #define IN6ADDR_LOOPBACK_INIT \
167 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
168 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
169 #endif
170 #endif
171 
172 #ifndef HAVE_SOCKADDR_STORAGE
173 #define __SS_MAXSIZE 128
174 #define __SS_ALLIGSIZE (sizeof (long))
175 
176 struct sockaddr_storage {
177 #ifdef  HAVE_SA_LEN
178 	u_int8_t        ss_len;       /* address length */
179 	u_int8_t        ss_family;    /* address family */
180 	char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
181 	long            __ss_align;
182 	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
183 #else
184 	u_int16_t       ss_family;    /* address family */
185 	char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
186 	long            __ss_align;
187 	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
188 #endif
189 };
190 #endif
191 
192 
193 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
194 #define in6addr_any isc_in6addr_any
195 extern const struct in6_addr in6addr_any;
196 #endif
197 
198 /*
199  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
200  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
201  */
202 #ifdef __GLIBC__
203 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
204 #undef IN6_ARE_ADDR_EQUAL
205 #undef IN6_IS_ADDR_UNSPECIFIED
206 #undef IN6_IS_ADDR_V4COMPAT
207 #undef IN6_IS_ADDR_V4MAPPED
208 #endif
209 #endif
210 
211 #ifndef IN6_ARE_ADDR_EQUAL
212 #define IN6_ARE_ADDR_EQUAL(a,b) \
213    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
214 #endif
215 
216 #ifndef IN6_IS_ADDR_UNSPECIFIED
217 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
218 	IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
219 #endif
220 
221 #ifndef IN6_IS_ADDR_LOOPBACK
222 extern const struct in6_addr isc_in6addr_loopback;
223 #define IN6_IS_ADDR_LOOPBACK(a) \
224 	IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
225 #endif
226 
227 #ifndef IN6_IS_ADDR_V4MAPPED
228 #define IN6_IS_ADDR_V4MAPPED(a)	\
229 	((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
230 	(a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
231 	(a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
232 	(a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
233 	(a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
234 	(a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
235 #endif
236 
237 #ifndef IN6_IS_ADDR_SITELOCAL
238 #define IN6_IS_ADDR_SITELOCAL(a)        \
239 	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
240 #endif
241 
242 #ifndef IN6_IS_ADDR_LINKLOCAL
243 #define IN6_IS_ADDR_LINKLOCAL(a)        \
244 	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
245 #endif
246 
247 #ifndef IN6_IS_ADDR_MULTICAST
248 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
249 #endif
250 
251 #ifndef __IPV6_ADDR_MC_SCOPE
252 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
253 #endif
254 
255 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
256 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
257 #endif
258 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
259 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
260 #endif
261 
262 #ifndef IN6_IS_ADDR_MC_SITELOCAL
263 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
264 	(IN6_IS_ADDR_MULTICAST(a) &&    \
265 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
266 #endif
267 
268 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
269 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
270 	(IN6_IS_ADDR_MULTICAST(a) &&    \
271 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
272 #endif
273 
274 #ifndef INADDR_NONE
275 #define INADDR_NONE 0xffffffff
276 #endif
277 
278 #ifndef MAXHOSTNAMELEN
279 #define MAXHOSTNAMELEN 256
280 #endif
281 
282 #ifndef INET6_ADDRSTRLEN
283 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
284 #define INET6_ADDRSTRLEN 46
285 #endif
286 
287 #ifndef MIN
288 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
289 #endif
290 
291 #ifndef MAX
292 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
293 #endif
294 
295 #ifdef NEED_DAEMON
296 int daemon(int nochdir, int noclose);
297 #endif
298 
299 #ifdef NEED_STRSEP
300 char * strsep(char **stringp, const char *delim);
301 #endif
302 
303 #ifndef ALIGN
304 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
305 #endif
306 
307 #ifdef NEED_SETGROUPENT
308 int setgroupent(int stayopen);
309 #endif
310 
311 #ifdef NEED_GETGROUPLIST
312 int getgrouplist(GETGROUPLIST_ARGS);
313 #endif
314 
315 #ifdef POSIX_GETGRNAM_R
316 int
317 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
318 #endif
319 
320 #ifdef NEED_GETGRNAM_R
321 int
322 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
323 #endif
324 
325 #ifdef POSIX_GETGRGID_R
326 int
327 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
328 #endif
329 
330 #ifdef NEED_GETGRGID_R
331 int
332 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
333 #endif
334 
335 #ifdef NEED_GETGRENT_R
336 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
337 #endif
338 
339 #ifdef NEED_SETGRENT_R
340 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
341 #endif
342 
343 #ifdef NEED_ENDGRENT_R
344 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
345 #endif
346 
347 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
348 NGR_R_RETURN
349 innetgr_r(const char *, const char *, const char *, const char *);
350 #endif
351 
352 #ifdef NEED_SETNETGRENT_R
353 #ifdef NGR_R_SET_ARGS
354 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
355 #else
356 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
357 #endif
358 #endif
359 
360 #ifdef NEED_ENDNETGRENT_R
361 #ifdef NGR_R_END_ARGS
362 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
363 #else
364 NGR_R_END_RETURN endnetgrent_r(void);
365 #endif
366 #endif
367 
368 #ifdef POSIX_GETPWNAM_R
369 int
370 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
371 		char *buf, size_t buflen, struct passwd **result);
372 #endif
373 
374 #ifdef NEED_GETPWNAM_R
375 int
376 getpwnam_r(const char *login,  struct passwd *pwptr,
377 		char *buf, size_t buflen, struct passwd **result);
378 #endif
379 
380 #ifdef POSIX_GETPWUID_R
381 int
382 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
383 		char *buf, int buflen, struct passwd **result);
384 #endif
385 
386 #ifdef NEED_GETPWUID_R
387 int
388 getpwuid_r(uid_t uid, struct passwd *pwptr,
389 		char *buf, size_t buflen, struct passwd **result);
390 #endif
391 
392 #ifdef NEED_SETPWENT_R
393 #ifdef PASS_R_ENT_ARGS
394 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
395 #else
396 PASS_R_SET_RETURN setpwent_r(void);
397 #endif
398 
399 #endif
400 
401 #ifdef NEED_SETPASSENT_R
402 #ifdef PASS_R_ENT_ARGS
403 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
404 #else
405 PASS_R_SET_RETURN setpassent_r(int stayopen);
406 #endif
407 #endif
408 
409 #ifdef NEED_GETPWENT_R
410 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
411 #endif
412 
413 #ifdef NEED_ENDPWENT_R
414 void endpwent_r(void);
415 #endif
416 
417 #ifdef NEED_SETPASSENT
418 int setpassent(int stayopen);
419 #endif
420 
421 #define gettimeofday isc__gettimeofday
422 #ifdef NEED_GETTIMEOFDAY
423 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
424 #else
425 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
426 #endif
427 
428 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
429 		NGR_R_CONST char **domainp);
430 
431 #ifdef NGR_R_ARGS
432 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
433 		  NGR_R_CONST char **domainp, NGR_R_ARGS);
434 #endif
435 
436 /* setnetgrent and endnetgrent are defined in sunw_port_after.h
437 #ifdef SETNETGRENT_ARGS
438 void setnetgrent(SETNETGRENT_ARGS);
439 #else
440 void setnetgrent(const char *netgroup);
441 #endif
442 
443 void endnetgrent(void);
444 */
445 
446 #ifdef INNETGR_ARGS
447 int innetgr(INNETGR_ARGS);
448 #else
449 int innetgr(const char *netgroup, const char *machine,
450 	    const char *user, const char *domain);
451 #endif
452 
453 #ifdef NGR_R_SET_ARGS
454 NGR_R_SET_RETURN
455 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
456 #else
457 NGR_R_SET_RETURN
458 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
459 #endif
460 
461 #ifdef NEED_STRTOUL
462 unsigned long strtoul(const char *, char **, int);
463 #endif
464 
465 #ifdef NEED_SUN4PROTOS
466 #include <stdarg.h>
467 #ifndef __SIZE_TYPE__
468 #define __SIZE_TYPE__ int
469 #endif
470 struct sockaddr;
471 struct iovec;
472 struct timeval;
473 struct timezone;
474 int fprintf(FILE *, const char *, ...);
475 int getsockname(int, struct sockaddr *, int *);
476 int getpeername(int, struct sockaddr *, int *);
477 int socket(int, int, int);
478 int connect(int, const struct sockaddr *, int);
479 int writev(int, struct iovec *, int);
480 int readv(int, struct iovec *, int);
481 int send(int, const char *, int, int);
482 void bzero(char *, int);
483 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
484 int syslog(int, const char *, ... );
485 int printf(const char *, ...);
486 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
487 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
488 int fclose(FILE *);
489 int ungetc(int, FILE *);
490 int scanf(const char *, ...);
491 int sscanf(const char *, const char *, ... );
492 int tolower(int);
493 int toupper(int);
494 int strcasecmp(const char *, const char *);
495 int strncasecmp(const char *, const char *, int);
496 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
497 #ifdef gettimeofday
498 #undef gettimeofday
499 int gettimeofday(struct timeval *, struct timezone *);
500 #define gettimeofday isc__gettimeofday
501 #else
502 int gettimeofday(struct timeval *, struct timezone *);
503 #endif
504 long strtol(const char*, char **, int);
505 int fseek(FILE *, long, int);
506 int setsockopt(int, int, int, const char *, int);
507 int bind(int, const struct sockaddr *, int);
508 void bcopy(char *, char *, int);
509 int fputc(char, FILE *);
510 int listen(int, int);
511 int accept(int, struct sockaddr *, int *);
512 int getsockopt(int, int, int, char *, int *);
513 int vfprintf(FILE *, const char *, va_list);
514 int fflush(FILE *);
515 int fgetc(FILE *);
516 int fputs(const char *, FILE *);
517 int fchown(int, int, int);
518 void setbuf(FILE *, char *);
519 int gethostname(char *, int);
520 int rename(const char *, const char *);
521 time_t time(time_t *);
522 int fscanf(FILE *, const char *, ...);
523 int sscanf(const char *, const char *, ...);
524 int ioctl(int, int, caddr_t);
525 void perror(const char *);
526 
527 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
528 /*
529  * 'gcc -ansi' changes the prototype for vsprintf().
530  * Use this prototype when 'gcc -ansi' is not in effect.
531  */
532 char *vsprintf(char *, const char *, va_list);
533 #endif
534 #endif
535 
536 /* Solaris-specific changes */
537 #include "sunw_port_after.h"
538 
539 #endif	/* port_after_h */
540