2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
6 * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (C) 2001-2003 Internet Software Consortium.
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.
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.
22 /* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <sys/param.h>
32 #if (!defined(BSD)) || (BSD < 199306)
33 #include <sys/bitypes.h>
35 #ifdef HAVE_INTTYPES_H
38 #ifdef HAVE_SYS_SELECT_H
39 #include <sys/select.h>
40 #endif /* HAVE_SYS_SELECT_H */
48 #undef HAVE_MINIMUM_IFREQ
52 const char *isc_strerror(int);
53 #define strerror isc_strerror
55 /* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h
56 * #define HAS_INET6_STRUCTS 1
57 * #define HAVE_SIN6_SCOPE_ID 1
59 #include <port_ipv6.h>
61 #undef NEED_IN6ADDR_ANY
63 #define HAVE_SOCKADDR_STORAGE 1
64 #undef NEED_GETTIMEOFDAY
66 #undef USE_FIONBIO_IOCTL
69 #undef USE_IFNAMELINKID
70 #define PORT_NONBLOCK O_NONBLOCK
72 #ifndef _POSIX_PATH_MAX
73 #define _POSIX_PATH_MAX 255
76 #define PATH_MAX _POSIX_PATH_MAX
80 * We need to know the IPv6 address family number even on IPv4-only systems.
81 * Note that this is NOT a protocol constant, and that if the system has its
82 * own AF_INET6, different from ours below, all of BIND's libraries and
83 * executables will need to be recompiled after the system <sys/socket.h>
84 * has had this type added. The type number below is correct on most BSD-
85 * derived systems for which AF_INET6 is defined.
92 #define PF_INET6 AF_INET6
96 /* Map to pre-RFC structure. */
97 #define in6_addr in_addr6
100 #ifndef HAS_INET6_STRUCTS
101 /* Replace with structure from later rev of O/S if known. */
103 u_int8_t s6_addr
[16];
106 #define IN6ADDR_ANY_INIT \
107 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
110 #define IN6ADDR_LOOPBACK_INIT \
111 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
114 /* Replace with structure from later rev of O/S if known. */
115 struct sockaddr_in6
{
117 u_int8_t sin6_len
; /* length of this struct */
118 u_int8_t sin6_family
; /* AF_INET6 */
120 u_int16_t sin6_family
; /* AF_INET6 */
122 u_int16_t sin6_port
; /* transport layer port # */
123 u_int32_t sin6_flowinfo
; /* IPv6 flow information */
124 struct in6_addr sin6_addr
; /* IPv6 address */
125 u_int32_t sin6_scope_id
; /* set of interfaces for a scope */
127 #endif /* HAS_INET6_STRUCTS */
129 #ifdef BROKEN_IN6ADDR_INIT_MACROS
130 #undef IN6ADDR_ANY_INIT
131 #undef IN6ADDR_LOOPBACK_INIT
135 #ifndef IN6ADDR_ANY_INIT
136 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
138 #ifndef IN6ADDR_LOOPBACK_INIT
139 #if BYTE_ORDER == BIG_ENDIAN
140 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
142 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
147 #ifndef IN6ADDR_ANY_INIT
149 #define IN6ADDR_ANY_INIT \
150 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
153 #define IN6ADDR_ANY_INIT \
154 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
159 #ifndef IN6ADDR_LOOPBACK_INIT
161 #define IN6ADDR_LOOPBACK_INIT \
162 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
165 #define IN6ADDR_LOOPBACK_INIT \
166 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
171 #ifndef HAVE_SOCKADDR_STORAGE
172 #define __SS_MAXSIZE 128
173 #define __SS_ALLIGSIZE (sizeof (long))
175 struct sockaddr_storage
{
177 u_int8_t ss_len
; /* address length */
178 u_int8_t ss_family
; /* address family */
179 char __ss_pad1
[__SS_ALLIGSIZE
- 2 * sizeof(u_int8_t
)];
181 char __ss_pad2
[__SS_MAXSIZE
- 2 * __SS_ALLIGSIZE
];
183 u_int16_t ss_family
; /* address family */
184 char __ss_pad1
[__SS_ALLIGSIZE
- sizeof(u_int16_t
)];
186 char __ss_pad2
[__SS_MAXSIZE
- 2 * __SS_ALLIGSIZE
];
192 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
193 #define in6addr_any isc_in6addr_any
194 extern const struct in6_addr in6addr_any
;
198 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
199 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
202 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
203 #undef IN6_ARE_ADDR_EQUAL
204 #undef IN6_IS_ADDR_UNSPECIFIED
205 #undef IN6_IS_ADDR_V4COMPAT
206 #undef IN6_IS_ADDR_V4MAPPED
210 #ifndef IN6_ARE_ADDR_EQUAL
211 #define IN6_ARE_ADDR_EQUAL(a,b) \
212 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
215 #ifndef IN6_IS_ADDR_UNSPECIFIED
216 #define IN6_IS_ADDR_UNSPECIFIED(a) \
217 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
220 #ifndef IN6_IS_ADDR_LOOPBACK
221 extern const struct in6_addr isc_in6addr_loopback
;
222 #define IN6_IS_ADDR_LOOPBACK(a) \
223 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
226 #ifndef IN6_IS_ADDR_V4MAPPED
227 #define IN6_IS_ADDR_V4MAPPED(a) \
228 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
229 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
230 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
231 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
232 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
233 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
236 #ifndef IN6_IS_ADDR_SITELOCAL
237 #define IN6_IS_ADDR_SITELOCAL(a) \
238 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
241 #ifndef IN6_IS_ADDR_LINKLOCAL
242 #define IN6_IS_ADDR_LINKLOCAL(a) \
243 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
246 #ifndef IN6_IS_ADDR_MULTICAST
247 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
250 #ifndef __IPV6_ADDR_MC_SCOPE
251 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
254 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
255 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
257 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
258 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
261 #ifndef IN6_IS_ADDR_MC_SITELOCAL
262 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
263 (IN6_IS_ADDR_MULTICAST(a) && \
264 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
267 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
268 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
269 (IN6_IS_ADDR_MULTICAST(a) && \
270 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
274 #define INADDR_NONE 0xffffffff
277 #ifndef MAXHOSTNAMELEN
278 #define MAXHOSTNAMELEN 256
281 #ifndef INET6_ADDRSTRLEN
282 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
283 #define INET6_ADDRSTRLEN 46
287 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
291 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
295 char * strsep(char **stringp
, const char *delim
);
299 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
302 #ifdef NEED_SETGROUPENT
303 int setgroupent(int stayopen
);
306 #ifdef NEED_GETGROUPLIST
307 int getgrouplist(GETGROUPLIST_ARGS
);
310 #ifdef POSIX_GETGRNAM_R
312 __posix_getgrnam_r(const char *, struct group
*, char *, int, struct group
**);
315 #ifdef NEED_GETGRNAM_R
317 getgrnam_r(const char *, struct group
*, char *, size_t, struct group
**);
320 #ifdef POSIX_GETGRGID_R
322 __posix_getgrgid_r(gid_t
, struct group
*, char *, int, struct group
**) ;
325 #ifdef NEED_GETGRGID_R
327 getgrgid_r(gid_t
, struct group
*, char *, size_t, struct group
**);
330 #ifdef NEED_GETGRENT_R
331 GROUP_R_RETURN
getgrent_r(struct group
*gptr
, GROUP_R_ARGS
);
334 #ifdef NEED_SETGRENT_R
335 GROUP_R_SET_RETURN
setgrent_r(GROUP_R_ENT_ARGS
);
338 #ifdef NEED_ENDGRENT_R
339 GROUP_R_END_RETURN
endgrent_r(GROUP_R_ENT_ARGS
);
342 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
344 innetgr_r(const char *, const char *, const char *, const char *);
347 #ifdef NEED_SETNETGRENT_R
348 #ifdef NGR_R_SET_ARGS
349 NGR_R_SET_RETURN
setnetgrent_r(NGR_R_SET_CONST
char *netgroup
, NGR_R_SET_ARGS
);
351 NGR_R_SET_RETURN
setnetgrent_r(NGR_R_SET_CONST
char *netgroup
);
355 #ifdef NEED_ENDNETGRENT_R
356 #ifdef NGR_R_END_ARGS
357 NGR_R_END_RETURN
endnetgrent_r(NGR_R_END_ARGS
);
359 NGR_R_END_RETURN
endnetgrent_r(void);
363 #ifdef POSIX_GETPWNAM_R
365 __posix_getpwnam_r(const char *login
, struct passwd
*pwptr
,
366 char *buf
, size_t buflen
, struct passwd
**result
);
369 #ifdef NEED_GETPWNAM_R
371 getpwnam_r(const char *login
, struct passwd
*pwptr
,
372 char *buf
, size_t buflen
, struct passwd
**result
);
375 #ifdef POSIX_GETPWUID_R
377 __posix_getpwuid_r(uid_t uid
, struct passwd
*pwptr
,
378 char *buf
, int buflen
, struct passwd
**result
);
381 #ifdef NEED_GETPWUID_R
383 getpwuid_r(uid_t uid
, struct passwd
*pwptr
,
384 char *buf
, size_t buflen
, struct passwd
**result
);
387 #ifdef NEED_SETPWENT_R
388 #ifdef PASS_R_ENT_ARGS
389 PASS_R_SET_RETURN
setpwent_r(PASS_R_ENT_ARGS
);
391 PASS_R_SET_RETURN
setpwent_r(void);
396 #ifdef NEED_SETPASSENT_R
397 #ifdef PASS_R_ENT_ARGS
398 PASS_R_SET_RETURN
setpassent_r(int stayopen
, PASS_R_ENT_ARGS
);
400 PASS_R_SET_RETURN
setpassent_r(int stayopen
);
404 #ifdef NEED_GETPWENT_R
405 PASS_R_RETURN
getpwent_r(struct passwd
*pwptr
, PASS_R_ARGS
);
408 #ifdef NEED_ENDPWENT_R
409 void endpwent_r(void);
412 #ifdef NEED_SETPASSENT
413 int setpassent(int stayopen
);
416 #define gettimeofday isc__gettimeofday
417 #ifdef NEED_GETTIMEOFDAY
418 int isc__gettimeofday(struct timeval
*tvp
, struct _TIMEZONE
*tzp
);
420 int isc__gettimeofday(struct timeval
*tp
, struct timezone
*tzp
);
423 int getnetgrent(NGR_R_CONST
char **machinep
, NGR_R_CONST
char **userp
,
424 NGR_R_CONST
char **domainp
);
427 int getnetgrent_r(NGR_R_CONST
char **machinep
, NGR_R_CONST
char **userp
,
428 NGR_R_CONST
char **domainp
, NGR_R_ARGS
);
431 /* setnetgrent and endnetgrent are defined in sunw_port_after.h
432 #ifdef SETNETGRENT_ARGS
433 void setnetgrent(SETNETGRENT_ARGS);
435 void setnetgrent(const char *netgroup);
438 void endnetgrent(void);
442 int innetgr(INNETGR_ARGS
);
444 int innetgr(const char *netgroup
, const char *machine
,
445 const char *user
, const char *domain
);
448 #ifdef NGR_R_SET_ARGS
450 setnetgrent_r(NGR_R_SET_CONST
char *netgroup
, NGR_R_SET_ARGS
);
453 setnetgrent_r(NGR_R_SET_CONST
char *netgroup
);
457 unsigned long strtoul(const char *, char **, int);
460 #ifdef NEED_SUN4PROTOS
462 #ifndef __SIZE_TYPE__
463 #define __SIZE_TYPE__ int
469 int fprintf(FILE *, const char *, ...);
470 int getsockname(int, struct sockaddr
*, int *);
471 int getpeername(int, struct sockaddr
*, int *);
472 int socket(int, int, int);
473 int connect(int, const struct sockaddr
*, int);
474 int writev(int, struct iovec
*, int);
475 int readv(int, struct iovec
*, int);
476 int send(int, const char *, int, int);
477 void bzero(char *, int);
478 int recvfrom(int, char *, int, int, struct sockaddr
*, int *);
479 int syslog(int, const char *, ... );
480 int printf(const char *, ...);
481 __SIZE_TYPE__
fread(void *, __SIZE_TYPE__
, __SIZE_TYPE__
, FILE *);
482 __SIZE_TYPE__
fwrite(const void *, __SIZE_TYPE__
, __SIZE_TYPE__
, FILE *);
484 int ungetc(int, FILE *);
485 int scanf(const char *, ...);
486 int sscanf(const char *, const char *, ... );
489 int strcasecmp(const char *, const char *);
490 int strncasecmp(const char *, const char *, int);
491 int select(int, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
494 int gettimeofday(struct timeval
*, struct timezone
*);
495 #define gettimeofday isc__gettimeofday
497 int gettimeofday(struct timeval
*, struct timezone
*);
499 long strtol(const char*, char **, int);
500 int fseek(FILE *, long, int);
501 int setsockopt(int, int, int, const char *, int);
502 int bind(int, const struct sockaddr
*, int);
503 void bcopy(char *, char *, int);
504 int fputc(char, FILE *);
505 int listen(int, int);
506 int accept(int, struct sockaddr
*, int *);
507 int getsockopt(int, int, int, char *, int *);
508 int vfprintf(FILE *, const char *, va_list);
511 int fputs(const char *, FILE *);
512 int fchown(int, int, int);
513 void setbuf(FILE *, char *);
514 int gethostname(char *, int);
515 int rename(const char *, const char *);
516 time_t time(time_t *);
517 int fscanf(FILE *, const char *, ...);
518 int sscanf(const char *, const char *, ...);
519 int ioctl(int, int, caddr_t
);
520 void perror(const char *);
522 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
524 * 'gcc -ansi' changes the prototype for vsprintf().
525 * Use this prototype when 'gcc -ansi' is not in effect.
527 char *vsprintf(char *, const char *, va_list);
531 /* Solaris-specific changes */
532 #include "sunw_port_after.h"
534 #endif /* port_after_h */