ipv6.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2002  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: ipv6.h,v 1.24 2007/06/19 23:47:18 tbox Exp $ */
00019 
00020 #ifndef ISC_IPV6_H
00021 #define ISC_IPV6_H 1
00022 
00023 /*!
00024  * Also define LWRES_IPV6_H to keep it from being included if liblwres is
00025  * being used, or redefinition errors will occur.
00026  */
00027 #define LWRES_IPV6_H 1
00028 
00029 /*****
00030  ***** Module Info
00031  *****/
00032 
00033 /*! \file isc/ipv6.h
00034  * \brief IPv6 definitions for systems which do not support IPv6.
00035  *
00036  * \li MP:
00037  *      No impact.
00038  *
00039  * \li Reliability:
00040  *      No anticipated impact.
00041  *
00042  * \li Resources:
00043  *      N/A.
00044  *
00045  * \li Security:
00046  *      No anticipated impact.
00047  *
00048  * \li Standards:
00049  *      RFC2553.
00050  */
00051 
00052 /***
00053  *** Imports.
00054  ***/
00055 
00056 #include <isc/int.h>
00057 #include <isc/platform.h>
00058 
00059 /***
00060  *** Types.
00061  ***/
00062 
00063 struct in6_addr {
00064         union {
00065                 isc_uint8_t     _S6_u8[16];
00066                 isc_uint16_t    _S6_u16[8];
00067                 isc_uint32_t    _S6_u32[4];
00068         } _S6_un;
00069 };
00070 #define s6_addr         _S6_un._S6_u8
00071 #define s6_addr8        _S6_un._S6_u8
00072 #define s6_addr16       _S6_un._S6_u16
00073 #define s6_addr32       _S6_un._S6_u32
00074 
00075 #define IN6ADDR_ANY_INIT        {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
00076 #define IN6ADDR_LOOPBACK_INIT   {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
00077 
00078 LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
00079 LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
00080 
00081 struct sockaddr_in6 {
00082 #ifdef ISC_PLATFORM_HAVESALEN
00083         isc_uint8_t             sin6_len;
00084         isc_uint8_t             sin6_family;
00085 #else
00086         isc_uint16_t            sin6_family;
00087 #endif
00088         isc_uint16_t            sin6_port;
00089         isc_uint32_t            sin6_flowinfo;
00090         struct in6_addr         sin6_addr;
00091         isc_uint32_t            sin6_scope_id;
00092 };
00093 
00094 #ifdef ISC_PLATFORM_HAVESALEN
00095 #define SIN6_LEN 1
00096 #endif
00097 
00098 /*%
00099  * Unspecified
00100  */
00101 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
00102         (((a)->s6_addr32[0] == 0) &&    \
00103          ((a)->s6_addr32[1] == 0) &&    \
00104          ((a)->s6_addr32[2] == 0) &&    \
00105          ((a)->s6_addr32[3] == 0))
00106 
00107 /*%
00108  * Loopback
00109  */
00110 #define IN6_IS_ADDR_LOOPBACK(a)         \
00111         (((a)->s6_addr32[0] == 0) &&    \
00112          ((a)->s6_addr32[1] == 0) &&    \
00113          ((a)->s6_addr32[2] == 0) &&    \
00114          ((a)->s6_addr32[3] == htonl(1)))
00115 
00116 /*%
00117  * IPv4 compatible
00118  */
00119 #define IN6_IS_ADDR_V4COMPAT(a)         \
00120         (((a)->s6_addr32[0] == 0) &&    \
00121          ((a)->s6_addr32[1] == 0) &&    \
00122          ((a)->s6_addr32[2] == 0) &&    \
00123          ((a)->s6_addr32[3] != 0) &&    \
00124          ((a)->s6_addr32[3] != htonl(1)))
00125 
00126 /*%
00127  * Mapped
00128  */
00129 #define IN6_IS_ADDR_V4MAPPED(a)               \
00130         (((a)->s6_addr32[0] == 0) &&          \
00131          ((a)->s6_addr32[1] == 0) &&          \
00132          ((a)->s6_addr32[2] == htonl(0x0000ffff)))
00133 
00134 /*%
00135  * Multicast
00136  */
00137 #define IN6_IS_ADDR_MULTICAST(a)        \
00138         ((a)->s6_addr8[0] == 0xffU)
00139 
00140 /*%
00141  * Unicast link / site local.
00142  */
00143 #define IN6_IS_ADDR_LINKLOCAL(a)        \
00144         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
00145 #define IN6_IS_ADDR_SITELOCAL(a)        \
00146         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
00147 
00148 #endif /* ISC_IPV6_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha