ipv6.h revision 280849
1/* 2 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (C) 1999-2002 Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 * PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18/* $Id: ipv6.h,v 1.24 2007/06/19 23:47:18 tbox Exp $ */ 19 20#ifndef ISC_IPV6_H 21#define ISC_IPV6_H 1 22 23/*! 24 * Also define LWRES_IPV6_H to keep it from being included if liblwres is 25 * being used, or redefinition errors will occur. 26 */ 27#define LWRES_IPV6_H 1 28 29/***** 30 ***** Module Info 31 *****/ 32 33/*! \file isc/ipv6.h 34 * \brief IPv6 definitions for systems which do not support IPv6. 35 * 36 * \li MP: 37 * No impact. 38 * 39 * \li Reliability: 40 * No anticipated impact. 41 * 42 * \li Resources: 43 * N/A. 44 * 45 * \li Security: 46 * No anticipated impact. 47 * 48 * \li Standards: 49 * RFC2553. 50 */ 51 52/*** 53 *** Imports. 54 ***/ 55 56#include <isc/int.h> 57#include <isc/platform.h> 58 59/*** 60 *** Types. 61 ***/ 62 63struct in6_addr { 64 union { 65 isc_uint8_t _S6_u8[16]; 66 isc_uint16_t _S6_u16[8]; 67 isc_uint32_t _S6_u32[4]; 68 } _S6_un; 69}; 70#define s6_addr _S6_un._S6_u8 71#define s6_addr8 _S6_un._S6_u8 72#define s6_addr16 _S6_un._S6_u16 73#define s6_addr32 _S6_un._S6_u32 74 75#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}} 76#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}} 77 78LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any; 79LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback; 80 81struct sockaddr_in6 { 82#ifdef ISC_PLATFORM_HAVESALEN 83 isc_uint8_t sin6_len; 84 isc_uint8_t sin6_family; 85#else 86 isc_uint16_t sin6_family; 87#endif 88 isc_uint16_t sin6_port; 89 isc_uint32_t sin6_flowinfo; 90 struct in6_addr sin6_addr; 91 isc_uint32_t sin6_scope_id; 92}; 93 94#ifdef ISC_PLATFORM_HAVESALEN 95#define SIN6_LEN 1 96#endif 97 98/*% 99 * Unspecified 100 */ 101#define IN6_IS_ADDR_UNSPECIFIED(a) \ 102 (((a)->s6_addr32[0] == 0) && \ 103 ((a)->s6_addr32[1] == 0) && \ 104 ((a)->s6_addr32[2] == 0) && \ 105 ((a)->s6_addr32[3] == 0)) 106 107/*% 108 * Loopback 109 */ 110#define IN6_IS_ADDR_LOOPBACK(a) \ 111 (((a)->s6_addr32[0] == 0) && \ 112 ((a)->s6_addr32[1] == 0) && \ 113 ((a)->s6_addr32[2] == 0) && \ 114 ((a)->s6_addr32[3] == htonl(1))) 115 116/*% 117 * IPv4 compatible 118 */ 119#define IN6_IS_ADDR_V4COMPAT(a) \ 120 (((a)->s6_addr32[0] == 0) && \ 121 ((a)->s6_addr32[1] == 0) && \ 122 ((a)->s6_addr32[2] == 0) && \ 123 ((a)->s6_addr32[3] != 0) && \ 124 ((a)->s6_addr32[3] != htonl(1))) 125 126/*% 127 * Mapped 128 */ 129#define IN6_IS_ADDR_V4MAPPED(a) \ 130 (((a)->s6_addr32[0] == 0) && \ 131 ((a)->s6_addr32[1] == 0) && \ 132 ((a)->s6_addr32[2] == htonl(0x0000ffff))) 133 134/*% 135 * Multicast 136 */ 137#define IN6_IS_ADDR_MULTICAST(a) \ 138 ((a)->s6_addr8[0] == 0xffU) 139 140/*% 141 * Unicast link / site local. 142 */ 143#define IN6_IS_ADDR_LINKLOCAL(a) \ 144 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) 145#define IN6_IS_ADDR_SITELOCAL(a) \ 146 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) 147 148#endif /* ISC_IPV6_H */ 149