1 /* $NetBSD: ipv6.h,v 1.6 2014/12/10 04:38:01 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") 5 * Copyright (C) 1999-2002 Internet Software Consortium. 6 * 7 * Permission to use, copy, modify, and/or distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* Id */ 21 22 #ifndef ISC_IPV6_H 23 #define ISC_IPV6_H 1 24 25 /***** 26 ***** Module Info 27 *****/ 28 29 /* 30 * IPv6 definitions for systems which do not support IPv6. 31 * 32 * MP: 33 * No impact. 34 * 35 * Reliability: 36 * No anticipated impact. 37 * 38 * Resources: 39 * N/A. 40 * 41 * Security: 42 * No anticipated impact. 43 * 44 * Standards: 45 * RFC2553. 46 */ 47 48 #if _MSC_VER < 1300 49 #define in6_addr in_addr6 50 #endif 51 52 #ifndef IN6ADDR_ANY_INIT 53 #define IN6ADDR_ANY_INIT {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }} 54 #endif 55 #ifndef IN6ADDR_LOOPBACK_INIT 56 #define IN6ADDR_LOOPBACK_INIT {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }} 57 #endif 58 59 LIBISC_EXTERNAL_DATA extern const struct in6_addr isc_in6addr_any; 60 LIBISC_EXTERNAL_DATA extern const struct in6_addr isc_in6addr_loopback; 61 62 /* 63 * Unspecified 64 */ 65 #ifndef IN6_IS_ADDR_UNSPECIFIED 66 #define IN6_IS_ADDR_UNSPECIFIED(a) (\ 67 *((u_long *)((a)->s6_addr) ) == 0 && \ 68 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 69 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 70 *((u_long *)((a)->s6_addr) + 3) == 0 \ 71 ) 72 #endif 73 74 /* 75 * Loopback 76 */ 77 #ifndef IN6_IS_ADDR_LOOPBACK 78 #define IN6_IS_ADDR_LOOPBACK(a) (\ 79 *((u_long *)((a)->s6_addr) ) == 0 && \ 80 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 81 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 82 *((u_long *)((a)->s6_addr) + 3) == htonl(1) \ 83 ) 84 #endif 85 86 /* 87 * IPv4 compatible 88 */ 89 #define IN6_IS_ADDR_V4COMPAT(a) (\ 90 *((u_long *)((a)->s6_addr) ) == 0 && \ 91 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 92 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 93 *((u_long *)((a)->s6_addr) + 3) != 0 && \ 94 *((u_long *)((a)->s6_addr) + 3) != htonl(1) \ 95 ) 96 97 /* 98 * Mapped 99 */ 100 #define IN6_IS_ADDR_V4MAPPED(a) (\ 101 *((u_long *)((a)->s6_addr) ) == 0 && \ 102 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 103 *((u_long *)((a)->s6_addr) + 2) == htonl(0x0000ffff)) 104 105 /* 106 * Multicast 107 */ 108 #define IN6_IS_ADDR_MULTICAST(a) \ 109 ((a)->s6_addr[0] == 0xffU) 110 111 /* 112 * Unicast link / site local. 113 */ 114 #ifndef IN6_IS_ADDR_LINKLOCAL 115 #define IN6_IS_ADDR_LINKLOCAL(a) (\ 116 ((a)->s6_addr[0] == 0xfe) && \ 117 (((a)->s6_addr[1] & 0xc0) == 0x80)) 118 #endif 119 120 #ifndef IN6_IS_ADDR_SITELOCAL 121 #define IN6_IS_ADDR_SITELOCAL(a) (\ 122 ((a)->s6_addr[0] == 0xfe) && \ 123 (((a)->s6_addr[1] & 0xc0) == 0xc0)) 124 #endif 125 126 #endif /* ISC_IPV6_H */ 127