Print this page


   1 /*
   2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
   3  * Use is subject to license terms.
   4  */
   5 
   6 #pragma ident   "%Z%%M% %I%     %E% SMI"
   7 
   8 #ifndef PORT_AFTER_H
   9 #define PORT_AFTER_H
  10 #include "os_version.h"













  11 
  12 #undef HAVE_SA_LEN
  13 #define USE_POSIX
  14 #define POSIX_SIGNALS
  15 #define NETREAD_BROKEN
  16 #define USE_WAITPID
  17 #define HAVE_FCHMOD
  18 #define NEED_PSELECT
  19 #define SETGRENT_VOID
  20 #define SETPWENT_VOID
  21 #define SIOCGIFCONF_ADDR
  22 #define IP_OPT_BUF_SIZE 40
  23 #define HAVE_CHROOT
  24 #define CAN_CHANGE_ID
  25 #define POSIX_GETPWNAM_R
  26 #define POSIX_GETPWUID_R
  27 #define POSIX_GETGRGID_R
  28 #define POSIX_GETGRNAM_R
  29 #define NEED_SECURE_DIRECTORY
  30 #define HAVE_DEV_RANDOM
  31 #define NO_MSG_CONTROL
  32 
  33 #define PORT_NONBLOCK   O_NONBLOCK
  34 #define PORT_WOULDBLK   EWOULDBLOCK
  35 #define WAIT_T          int
  36 #ifndef SUNW_LIBNSL
  37 #define INADDR_NONE     0xffffffff
  38 #endif
  39 

  40 #include <sys/types.h>
  41 #include <sys/socket.h>
  42 #include <sys/param.h>

  43 #if (!defined(BSD)) || (BSD < 199306)
  44 #include <sys/bitypes.h>
  45 #endif
  46 #include <sys/time.h>





  47 
  48 #ifndef MIN
  49 #define MIN(x, y)       ((x > y) ?y :x)
  50 #endif
  51 #ifndef MAX
  52 #define MAX(x, y)       ((x > y) ?x :y)








  53 #endif





  54 


















  55 /*
  56  * We need to know the IPv6 address family number even on IPv4-only systems.
  57  * Note that this is NOT a protocol constant, and that if the system has its
  58  * own AF_INET6, different from ours below, all of BIND's libraries and
  59  * executables will need to be recompiled after the system <sys/socket.h>
  60  * has had this type added.  The type number below is correct on most BSD-
  61  * derived systems for which AF_INET6 is defined.
  62  */
  63 #ifndef AF_INET6
  64 #define AF_INET6        24
  65 #endif
  66 
  67 #ifndef PF_INET6
  68 #define PF_INET6        AF_INET6
  69 #endif
  70 #include <port_ipv6.h>
  71 





  72 #ifndef HAS_INET6_STRUCTS
  73 /* Replace with structure from later rev of O/S if known. */
  74 struct in6_addr {
  75         u_int8_t        s6_addr[16];
  76 };
  77 








  78 /* Replace with structure from later rev of O/S if known. */
  79 struct sockaddr_in6 {
  80 #ifdef  HAVE_SA_LEN
  81         u_int8_t        sin6_len;       /* length of this struct */
  82         u_int8_t        sin6_family;    /* AF_INET6 */
  83 #else
  84         u_int16_t       sin6_family;    /* AF_INET6 */
  85 #endif
  86         u_int16_t       sin6_port;      /* transport layer port # */
  87         u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
  88         struct in6_addr sin6_addr;      /* IPv6 address */
  89         u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
  90 };

  91 






  92 #ifndef IN6ADDR_ANY_INIT
  93 #define IN6ADDR_ANY_INIT        {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
  94 #endif
  95 #ifndef IN6ADDR_LOOPBACK_INIT
  96 #define IN6ADDR_LOOPBACK_INIT   {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}



  97 #endif
  98 #endif  /* HAS_INET6_STRUCTS */

  99 
 100 #if defined(NEED_SOCKADDR_STORAGE) || !defined(HAS_INET6_STRUCTS)
























 101 #define __SS_MAXSIZE 128
 102 #define __SS_ALLIGSIZE (sizeof (long))
 103 
 104 struct sockaddr_storage {
 105 #ifdef  HAVE_SA_LEN
 106         u_int8_t        ss_len; /* address length */
 107         u_int8_t        ss_family;      /* address family */
 108         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof (u_int8_t)];
 109         long            __ss_align;
 110         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
 111 #else
 112         u_int16_t       ss_family;      /* address family */
 113         char            __ss_pad1[__SS_ALLIGSIZE - sizeof (u_int16_t)];
 114         long            __ss_align;
 115         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
 116 #endif
 117 };
 118 #endif
 119 
 120 
 121 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
 122 #define in6addr_any isc_in6addr_any
 123 extern const struct in6_addr in6addr_any;
 124 #endif
 125 













 126 #ifndef IN6_ARE_ADDR_EQUAL
 127 #define IN6_ARE_ADDR_EQUAL(a, b) \
 128     (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof (struct in6_addr)) == 0)
 129 #endif
 130 
 131 #ifndef IN6_IS_ADDR_UNSPECIFIED
 132 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
 133         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
 134 #endif
 135 
 136 #ifndef IN6_IS_ADDR_LOOPBACK
 137 extern const struct in6_addr isc_in6addr_loopback;
 138 #define IN6_IS_ADDR_LOOPBACK(a)         \
 139         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
 140 #endif
 141 
 142 #ifndef IN6_IS_ADDR_V4COMPAT
 143 #define IN6_IS_ADDR_V4COMPAT(a)         \
 144         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
 145         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
 146         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
 147         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \
 148         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
 149         (a)->s6_addr[10] == 0x00 && (a)->s6_addr[11] == 0x00 && \
 150         ((a)->s6_addr[12] != 0x00 || (a)->s6_addr[13] != 0x00 || \
 151         (a)->s6_addr[14] != 0x00 || \
 152         ((a)->s6_addr[15] != 0x00 && (a)->s6_addr[15] != 1)))
 153 #endif
 154 
 155 #ifndef IN6_IS_ADDR_V4MAPPED
 156 #define IN6_IS_ADDR_V4MAPPED(a)         \
 157         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
 158         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
 159         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
 160         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \
 161         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
 162         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
 163 #endif
 164 
 165 #ifndef IN6_IS_ADDR_SITELOCAL
 166 #define IN6_IS_ADDR_SITELOCAL(a)        \
 167         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
 168 #endif
 169 
 170 #ifndef IN6_IS_ADDR_LINKLOCAL
 171 #define IN6_IS_ADDR_LINKLOCAL(a)        \
 172         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
 173 #endif
 174 
 175 #ifndef IN6_IS_ADDR_MULTICAST
 176 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
 177 #endif
 178 
 179 #ifndef __IPV6_ADDR_MC_SCOPE
 180 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
 181 #endif
 182 
 183 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
 184 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
 185 #endif
 186 
 187 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
 188 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
 189 #endif
 190 
 191 #ifndef IN6_IS_ADDR_MC_SITELOCAL
 192 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
 193         (IN6_IS_ADDR_MULTICAST(a) &&    \
 194         (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
 195 #endif
 196 
 197 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
 198 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
 199         (IN6_IS_ADDR_MULTICAST(a) &&    \
 200         (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
 201 #endif
 202 








 203 #ifndef INET6_ADDRSTRLEN

 204 #define INET6_ADDRSTRLEN 46
 205 #endif
 206 
 207 /*
 208  * Prior to 2.6, Solaris needs a prototype for gethostname().
 209  */
 210 #if (OS_MAJOR == 5 && OS_MINOR < 6)
 211 extern int gethostname(char *, size_t);
 212 #endif
 213 /*
 214  * gethostid() was not available until 2.5
 215  * setsockopt(SO_REUSEADDR) fails on unix domain sockets before 2.5
 216  * use ioctl(FIONBIO) rather than fcntl() calls to set/clear non-blocking i/o.
 217  */
 218 #if (OS_MAJOR == 5 && OS_MINOR < 5)
 219 #define GET_HOST_ID_MISSING
 220 #define NO_UNIX_REUSEADDR
 221 #define USE_FIONBIO_IOCTL
 222 #endif
 223 
 224 #define NEED_STRSEP
 225 extern char *strsep(char **, const char *);
 226 
 227 #define NEED_DAEMON
 228 int daemon(int nochdir, int noclose);

 229 
 230 /*
 231  * Solaris defines this in <netdb.h> instead of in <sys/param.h>.  We don't
 232  * define it in our <netdb.h>, so we define it here.
 233  */
 234 #ifndef MAXHOSTNAMELEN
 235 #define MAXHOSTNAMELEN 256
 236 #endif
 237 
 238 /*
 239  * Solaris 2.5 and later have getrlimit(), setrlimit() and getrusage().
 240  */
 241 #if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 5))
 242 #include <sys/resource.h>
 243 #define HAVE_GETRUSAGE
 244 #define RLIMIT_TYPE rlim_t
 245 #define RLIMIT_FILE_INFINITY
 246 #endif
 247 
 248 #include <resolv_mt.h>
 249 #include <netdb_private.h>
 250 #include <inet_private.h>
 251 #include <ctype.h>
 252 #include <sunw_dst_init.h>
 253 #include <sunw_irs_init.h>
 254 
 255 #ifdef  ORIGINAL_ISC_CODE
 256 const char *isc_strerror(int errnum);
 257 #define strerror isc_strerror
 258 #endif
 259 
 260 #ifndef ISC_FACILITY
 261 #define ISC_FACILITY LOG_DAEMON

 262 #endif
 263 
 264 /* res_mkquery.c refers explicitly to __putlong and __putshort */
 265 #define __putlong       putlong
 266 #define __putshort      putshort

 267 
 268 /*
 269  * If one wanted to use isc__gettimeofday for Solaris, they would
 270  * need to define NEED_GETTIMEOFDAY (common/bsd/gettimeofday.c),
 271  * which is not defined for Solaris. Hence there is no reason to
 272  * change the current definition of gettimeofday which currently
 273  * comes from libc and we comment the following out.
 274  */
 275 #ifdef  ORIGINAL_ISC_CODE
 276 int isc__gettimeofday(struct timeval *, struct timezone *);























































































 277 #define gettimeofday isc__gettimeofday




 278 #endif
 279 
 280 /*
 281  * Solaris 8 has if_nametoindex().
 282  */
 283 #if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 8))
 284 #define USE_IFNAMELINKID

 285 #endif
 286  
 287 #define UNUSED(x) (x) = (x)
 288 #define DE_CONST(konst, var) \
 289         do { \
 290                 union { const void *k; void *v; } _u; \
 291                 _u.k = konst; \
 292                 var = _u.v; \
 293         } while (0)
 294 
 295 #ifndef ALIGN
 296 #if (OS_MAJOR == 5 && OS_MINOR > 8)
 297 #define ALIGN(x) (((uintptr_t)(x) + (sizeof(char*) - 1UL)) & ~(sizeof(char*) - 1UL))


 298 #else
 299 #define ALIGN(x) (((unsigned long)(x) + (sizeof(char*) - 1UL)) & ~(sizeof(char*) - 1UL))

 300 #endif







 301 #endif
 302 
 303 #endif /* ! PORT_AFTER_H */














































































   1 /*
   2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   3  * Use is subject to license terms.
   4  */
   5 

   6 
   7 /*
   8  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
   9  * Copyright (C) 2001-2003  Internet Software Consortium.
  10  *
  11  * Permission to use, copy, modify, and/or distribute this software for any
  12  * purpose with or without fee is hereby granted, provided that the above
  13  * copyright notice and this permission notice appear in all copies.
  14  *
  15  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  16  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  17  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  18  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  19  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  20  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21  * PERFORMANCE OF THIS SOFTWARE.
  22  */
  23 
  24 /* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */



















  25 
  26 #ifndef port_after_h
  27 #define port_after_h




  28 
  29 #include <stdio.h>
  30 #include <sys/types.h>
  31 #include <sys/socket.h>
  32 #include <sys/param.h>
  33 #include <sys/time.h>
  34 #if (!defined(BSD)) || (BSD < 199306)
  35 #include <sys/bitypes.h>
  36 #endif
  37 #ifdef HAVE_INTTYPES_H
  38 #include <inttypes.h>
  39 #endif
  40 #ifdef HAVE_SYS_SELECT_H
  41 #include <sys/select.h>
  42 #endif /* HAVE_SYS_SELECT_H */
  43 
  44 #ifdef REENABLE_SEND
  45 #undef send
  46 #endif
  47 
  48 #undef NEED_PSELECT
  49 #undef HAVE_SA_LEN
  50 #undef HAVE_MINIMUM_IFREQ
  51 #define NEED_DAEMON 1
  52 #undef NEED_STRSEP
  53 #undef NEED_STRERROR
  54 #ifdef NEED_STRERROR
  55 const char *isc_strerror(int);
  56 #define strerror isc_strerror
  57 #endif
  58 /* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h
  59  * #define HAS_INET6_STRUCTS 1
  60  * #define HAVE_SIN6_SCOPE_ID 1
  61  */
  62 #include <port_ipv6.h>
  63 
  64 #undef NEED_IN6ADDR_ANY
  65 #undef HAS_IN_ADDR6
  66 #define HAVE_SOCKADDR_STORAGE 1
  67 #undef NEED_GETTIMEOFDAY
  68 #undef HAVE_STRNDUP
  69 #undef USE_FIONBIO_IOCTL
  70 #undef INNETGR_ARGS
  71 
  72 #undef USE_IFNAMELINKID
  73 #define PORT_NONBLOCK O_NONBLOCK
  74 
  75 #ifndef _POSIX_PATH_MAX
  76 #define _POSIX_PATH_MAX 255
  77 #endif
  78 #ifndef PATH_MAX
  79 #define PATH_MAX _POSIX_PATH_MAX
  80 #endif
  81 
  82 /*
  83  * We need to know the IPv6 address family number even on IPv4-only systems.
  84  * Note that this is NOT a protocol constant, and that if the system has its
  85  * own AF_INET6, different from ours below, all of BIND's libraries and
  86  * executables will need to be recompiled after the system <sys/socket.h>
  87  * has had this type added.  The type number below is correct on most BSD-
  88  * derived systems for which AF_INET6 is defined.
  89  */
  90 #ifndef AF_INET6
  91 #define AF_INET6        24
  92 #endif
  93 
  94 #ifndef PF_INET6
  95 #define PF_INET6        AF_INET6
  96 #endif

  97 
  98 #ifdef HAS_IN_ADDR6
  99 /* Map to pre-RFC structure. */
 100 #define in6_addr in_addr6
 101 #endif
 102 
 103 #ifndef HAS_INET6_STRUCTS
 104 /* Replace with structure from later rev of O/S if known. */
 105 struct in6_addr {
 106         u_int8_t        s6_addr[16];
 107 };
 108 
 109 #define IN6ADDR_ANY_INIT \
 110         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 111            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
 112 
 113 #define IN6ADDR_LOOPBACK_INIT \
 114         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 115            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
 116 
 117 /* Replace with structure from later rev of O/S if known. */
 118 struct sockaddr_in6 {
 119 #ifdef  HAVE_SA_LEN
 120         u_int8_t        sin6_len;       /* length of this struct */
 121         u_int8_t        sin6_family;    /* AF_INET6 */
 122 #else
 123         u_int16_t       sin6_family;    /* AF_INET6 */
 124 #endif
 125         u_int16_t       sin6_port;      /* transport layer port # */
 126         u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
 127         struct in6_addr sin6_addr;      /* IPv6 address */
 128         u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
 129 };
 130 #endif  /* HAS_INET6_STRUCTS */
 131 
 132 #ifdef BROKEN_IN6ADDR_INIT_MACROS
 133 #undef IN6ADDR_ANY_INIT
 134 #undef IN6ADDR_LOOPBACK_INIT
 135 #endif
 136 
 137 #ifdef _AIX
 138 #ifndef IN6ADDR_ANY_INIT
 139 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
 140 #endif
 141 #ifndef IN6ADDR_LOOPBACK_INIT
 142 #if BYTE_ORDER == BIG_ENDIAN
 143 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
 144 #else
 145 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
 146 #endif
 147 #endif
 148 #endif
 149 
 150 #ifndef IN6ADDR_ANY_INIT
 151 #ifdef s6_addr
 152 #define IN6ADDR_ANY_INIT \
 153         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 154             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
 155 #else
 156 #define IN6ADDR_ANY_INIT \
 157         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 158            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
 159 #endif
 160 
 161 #endif
 162 #ifndef IN6ADDR_LOOPBACK_INIT
 163 #ifdef s6_addr
 164 #define IN6ADDR_LOOPBACK_INIT \
 165         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 166             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
 167 #else
 168 #define IN6ADDR_LOOPBACK_INIT \
 169         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
 170            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
 171 #endif
 172 #endif
 173 
 174 #ifndef HAVE_SOCKADDR_STORAGE
 175 #define __SS_MAXSIZE 128
 176 #define __SS_ALLIGSIZE (sizeof (long))
 177 
 178 struct sockaddr_storage {
 179 #ifdef  HAVE_SA_LEN
 180         u_int8_t        ss_len;       /* address length */
 181         u_int8_t        ss_family;    /* address family */
 182         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
 183         long            __ss_align;
 184         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
 185 #else
 186         u_int16_t       ss_family;    /* address family */
 187         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
 188         long            __ss_align;
 189         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
 190 #endif
 191 };
 192 #endif
 193 
 194 
 195 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
 196 #define in6addr_any isc_in6addr_any
 197 extern const struct in6_addr in6addr_any;
 198 #endif
 199 
 200 /*
 201  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
 202  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
 203  */
 204 #ifdef __GLIBC__
 205 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
 206 #undef IN6_ARE_ADDR_EQUAL
 207 #undef IN6_IS_ADDR_UNSPECIFIED
 208 #undef IN6_IS_ADDR_V4COMPAT
 209 #undef IN6_IS_ADDR_V4MAPPED
 210 #endif
 211 #endif
 212 
 213 #ifndef IN6_ARE_ADDR_EQUAL
 214 #define IN6_ARE_ADDR_EQUAL(a,b) \
 215    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
 216 #endif
 217 
 218 #ifndef IN6_IS_ADDR_UNSPECIFIED
 219 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
 220         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
 221 #endif
 222 
 223 #ifndef IN6_IS_ADDR_LOOPBACK
 224 extern const struct in6_addr isc_in6addr_loopback;
 225 #define IN6_IS_ADDR_LOOPBACK(a) \
 226         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
 227 #endif
 228 













 229 #ifndef IN6_IS_ADDR_V4MAPPED
 230 #define IN6_IS_ADDR_V4MAPPED(a) \
 231         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
 232         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
 233         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
 234         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
 235         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
 236         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
 237 #endif
 238 
 239 #ifndef IN6_IS_ADDR_SITELOCAL
 240 #define IN6_IS_ADDR_SITELOCAL(a)        \
 241         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
 242 #endif
 243 
 244 #ifndef IN6_IS_ADDR_LINKLOCAL
 245 #define IN6_IS_ADDR_LINKLOCAL(a)        \
 246         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
 247 #endif
 248 
 249 #ifndef IN6_IS_ADDR_MULTICAST
 250 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
 251 #endif
 252 
 253 #ifndef __IPV6_ADDR_MC_SCOPE
 254 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
 255 #endif
 256 
 257 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
 258 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
 259 #endif

 260 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
 261 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
 262 #endif
 263 
 264 #ifndef IN6_IS_ADDR_MC_SITELOCAL
 265 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
 266         (IN6_IS_ADDR_MULTICAST(a) &&    \
 267          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
 268 #endif
 269 
 270 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
 271 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
 272         (IN6_IS_ADDR_MULTICAST(a) &&    \
 273          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
 274 #endif
 275 
 276 #ifndef INADDR_NONE
 277 #define INADDR_NONE 0xffffffff
 278 #endif
 279 
 280 #ifndef MAXHOSTNAMELEN
 281 #define MAXHOSTNAMELEN 256
 282 #endif
 283 
 284 #ifndef INET6_ADDRSTRLEN
 285 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
 286 #define INET6_ADDRSTRLEN 46
 287 #endif
 288 
 289 #ifndef MIN
 290 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))



 291 #endif
 292 
 293 #ifndef MAX
 294 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))






 295 #endif
 296 
 297 #ifdef NEED_DAEMON



 298 int daemon(int nochdir, int noclose);
 299 #endif
 300 
 301 #ifdef NEED_STRSEP
 302 char * strsep(char **stringp, const char *delim);




 303 #endif
 304 
 305 #ifndef ALIGN
 306 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))






 307 #endif
 308 
 309 #ifdef NEED_SETGROUPENT
 310 int setgroupent(int stayopen);
 311 #endif



 312 
 313 #ifdef NEED_GETGROUPLIST
 314 int getgrouplist(GETGROUPLIST_ARGS);

 315 #endif
 316 
 317 #ifdef POSIX_GETGRNAM_R
 318 int
 319 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
 320 #endif
 321 
 322 #ifdef NEED_GETGRNAM_R
 323 int
 324 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
 325 #endif
 326 
 327 #ifdef POSIX_GETGRGID_R
 328 int
 329 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
 330 #endif
 331 
 332 #ifdef NEED_GETGRGID_R
 333 int
 334 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
 335 #endif
 336 
 337 #ifdef NEED_GETGRENT_R
 338 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
 339 #endif
 340 
 341 #ifdef NEED_SETGRENT_R
 342 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
 343 #endif
 344 
 345 #ifdef NEED_ENDGRENT_R
 346 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
 347 #endif
 348 
 349 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
 350 NGR_R_RETURN
 351 innetgr_r(const char *, const char *, const char *, const char *);
 352 #endif
 353 
 354 #ifdef NEED_SETNETGRENT_R
 355 #ifdef NGR_R_SET_ARGS
 356 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
 357 #else
 358 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
 359 #endif
 360 #endif
 361 
 362 #ifdef NEED_ENDNETGRENT_R
 363 #ifdef NGR_R_END_ARGS
 364 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
 365 #else
 366 NGR_R_END_RETURN endnetgrent_r(void);
 367 #endif
 368 #endif
 369 
 370 #ifdef POSIX_GETPWNAM_R
 371 int
 372 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
 373                 char *buf, size_t buflen, struct passwd **result);
 374 #endif
 375 
 376 #ifdef NEED_GETPWNAM_R
 377 int
 378 getpwnam_r(const char *login,  struct passwd *pwptr,
 379                 char *buf, size_t buflen, struct passwd **result);
 380 #endif
 381 
 382 #ifdef POSIX_GETPWUID_R
 383 int
 384 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
 385                 char *buf, int buflen, struct passwd **result);
 386 #endif
 387 
 388 #ifdef NEED_GETPWUID_R
 389 int
 390 getpwuid_r(uid_t uid, struct passwd *pwptr,
 391                 char *buf, size_t buflen, struct passwd **result);
 392 #endif
 393 
 394 #ifdef NEED_SETPWENT_R
 395 #ifdef PASS_R_ENT_ARGS
 396 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
 397 #else
 398 PASS_R_SET_RETURN setpwent_r(void);
 399 #endif
 400 
 401 #endif
 402 
 403 #ifdef NEED_SETPASSENT_R
 404 #ifdef PASS_R_ENT_ARGS
 405 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
 406 #else
 407 PASS_R_SET_RETURN setpassent_r(int stayopen);
 408 #endif
 409 #endif
 410 
 411 #ifdef NEED_GETPWENT_R
 412 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
 413 #endif
 414 
 415 #ifdef NEED_ENDPWENT_R
 416 void endpwent_r(void);
 417 #endif
 418 
 419 #ifdef NEED_SETPASSENT
 420 int setpassent(int stayopen);
 421 #endif
 422 
 423 #define gettimeofday isc__gettimeofday
 424 #ifdef NEED_GETTIMEOFDAY
 425 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
 426 #else
 427 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
 428 #endif
 429 
 430 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
 431                 NGR_R_CONST char **domainp);
 432 
 433 #ifdef NGR_R_ARGS
 434 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
 435                   NGR_R_CONST char **domainp, NGR_R_ARGS);
 436 #endif
 437 
 438 /* setnetgrent and endnetgrent are defined in sunw_port_after.h 
 439 #ifdef SETNETGRENT_ARGS
 440 void setnetgrent(SETNETGRENT_ARGS);
 441 #else
 442 void setnetgrent(const char *netgroup);
 443 #endif

 444 
 445 void endnetgrent(void);
 446 */
 447 
 448 #ifdef INNETGR_ARGS
 449 int innetgr(INNETGR_ARGS);
 450 #else
 451 int innetgr(const char *netgroup, const char *machine,
 452             const char *user, const char *domain);
 453 #endif
 454 
 455 #ifdef NGR_R_SET_ARGS
 456 NGR_R_SET_RETURN
 457 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
 458 #else
 459 NGR_R_SET_RETURN
 460 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
 461 #endif
 462 
 463 #ifdef NEED_STRTOUL
 464 unsigned long strtoul(const char *, char **, int);
 465 #endif
 466 
 467 #ifdef NEED_SUN4PROTOS
 468 #include <stdarg.h>
 469 #ifndef __SIZE_TYPE__
 470 #define __SIZE_TYPE__ int
 471 #endif
 472 struct sockaddr;
 473 struct iovec;
 474 struct timeval;
 475 struct timezone;
 476 int fprintf(FILE *, const char *, ...);
 477 int getsockname(int, struct sockaddr *, int *);
 478 int getpeername(int, struct sockaddr *, int *);
 479 int socket(int, int, int);
 480 int connect(int, const struct sockaddr *, int);
 481 int writev(int, struct iovec *, int);
 482 int readv(int, struct iovec *, int);
 483 int send(int, const char *, int, int);
 484 void bzero(char *, int);
 485 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
 486 int syslog(int, const char *, ... );
 487 int printf(const char *, ...);
 488 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
 489 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
 490 int fclose(FILE *);
 491 int ungetc(int, FILE *);
 492 int scanf(const char *, ...);
 493 int sscanf(const char *, const char *, ... );
 494 int tolower(int);
 495 int toupper(int);
 496 int strcasecmp(const char *, const char *);
 497 int strncasecmp(const char *, const char *, int);
 498 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 499 #ifdef gettimeofday
 500 #undef gettimeofday
 501 int gettimeofday(struct timeval *, struct timezone *);
 502 #define gettimeofday isc__gettimeofday
 503 #else
 504 int gettimeofday(struct timeval *, struct timezone *);
 505 #endif
 506 long strtol(const char*, char **, int);
 507 int fseek(FILE *, long, int);
 508 int setsockopt(int, int, int, const char *, int);
 509 int bind(int, const struct sockaddr *, int);
 510 void bcopy(char *, char *, int);
 511 int fputc(char, FILE *);
 512 int listen(int, int);
 513 int accept(int, struct sockaddr *, int *);
 514 int getsockopt(int, int, int, char *, int *);
 515 int vfprintf(FILE *, const char *, va_list);
 516 int fflush(FILE *);
 517 int fgetc(FILE *);
 518 int fputs(const char *, FILE *);
 519 int fchown(int, int, int);
 520 void setbuf(FILE *, char *);
 521 int gethostname(char *, int);
 522 int rename(const char *, const char *);
 523 time_t time(time_t *);
 524 int fscanf(FILE *, const char *, ...);
 525 int sscanf(const char *, const char *, ...);
 526 int ioctl(int, int, caddr_t);
 527 void perror(const char *);
 528 
 529 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
 530 /*
 531  * 'gcc -ansi' changes the prototype for vsprintf().
 532  * Use this prototype when 'gcc -ansi' is not in effect.
 533  */
 534 char *vsprintf(char *, const char *, va_list);
 535 #endif
 536 #endif
 537 
 538 /* Solaris-specific changes */
 539 #include "sunw_port_after.h"
 540 
 541 #endif