1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 * 8 * See the COPYRIGHT file distributed with this work for additional 9 * information regarding copyright ownership. 10 */ 11 12 #ifndef ISC_IPV6_H 13 #define ISC_IPV6_H 1 14 15 /***** 16 ***** Module Info 17 *****/ 18 19 /* 20 * IPv6 definitions for systems which do not support IPv6. 21 * 22 * MP: 23 * No impact. 24 * 25 * Reliability: 26 * No anticipated impact. 27 * 28 * Resources: 29 * N/A. 30 * 31 * Security: 32 * No anticipated impact. 33 * 34 * Standards: 35 * RFC2553. 36 */ 37 38 #if _MSC_VER < 1300 39 #define in6_addr in_addr6 40 #endif /* if _MSC_VER < 1300 */ 41 42 #ifndef IN6ADDR_ANY_INIT 43 #define IN6ADDR_ANY_INIT \ 44 { \ 45 { \ 46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ 47 } \ 48 } 49 #endif /* ifndef IN6ADDR_ANY_INIT */ 50 #ifndef IN6ADDR_LOOPBACK_INIT 51 #define IN6ADDR_LOOPBACK_INIT \ 52 { \ 53 { \ 54 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 \ 55 } \ 56 } 57 #endif /* ifndef IN6ADDR_LOOPBACK_INIT */ 58 #ifndef IN6ADDR_V4MAPPED_INIT 59 #define IN6ADDR_V4MAPPED_INIT \ 60 { \ 61 { \ 62 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0 \ 63 } \ 64 } 65 #endif /* ifndef IN6ADDR_V4MAPPED_INIT */ 66 67 LIBISC_EXTERNAL_DATA extern const struct in6_addr isc_in6addr_any; 68 LIBISC_EXTERNAL_DATA extern const struct in6_addr isc_in6addr_loopback; 69 70 /* 71 * Unspecified 72 */ 73 #ifndef IN6_IS_ADDR_UNSPECIFIED 74 #define IN6_IS_ADDR_UNSPECIFIED(a) \ 75 (*((u_long *)((a)->s6_addr)) == 0 && \ 76 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 77 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 78 *((u_long *)((a)->s6_addr) + 3) == 0) 79 #endif /* ifndef IN6_IS_ADDR_UNSPECIFIED */ 80 81 /* 82 * Loopback 83 */ 84 #ifndef IN6_IS_ADDR_LOOPBACK 85 #define IN6_IS_ADDR_LOOPBACK(a) \ 86 (*((u_long *)((a)->s6_addr)) == 0 && \ 87 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 88 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 89 *((u_long *)((a)->s6_addr) + 3) == htonl(1)) 90 #endif /* ifndef IN6_IS_ADDR_LOOPBACK */ 91 92 /* 93 * IPv4 compatible 94 */ 95 #define IN6_IS_ADDR_V4COMPAT(a) \ 96 (*((u_long *)((a)->s6_addr)) == 0 && \ 97 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 98 *((u_long *)((a)->s6_addr) + 2) == 0 && \ 99 *((u_long *)((a)->s6_addr) + 3) != 0 && \ 100 *((u_long *)((a)->s6_addr) + 3) != htonl(1)) 101 102 /* 103 * Mapped 104 */ 105 #define IN6_IS_ADDR_V4MAPPED(a) \ 106 (*((u_long *)((a)->s6_addr)) == 0 && \ 107 *((u_long *)((a)->s6_addr) + 1) == 0 && \ 108 *((u_long *)((a)->s6_addr) + 2) == htonl(0x0000ffff)) 109 110 /* 111 * Multicast 112 */ 113 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xffU) 114 115 /* 116 * Unicast link / site local. 117 */ 118 #ifndef IN6_IS_ADDR_LINKLOCAL 119 #define IN6_IS_ADDR_LINKLOCAL(a) \ 120 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) 121 #endif /* ifndef IN6_IS_ADDR_LINKLOCAL */ 122 123 #ifndef IN6_IS_ADDR_SITELOCAL 124 #define IN6_IS_ADDR_SITELOCAL(a) \ 125 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) 126 #endif /* ifndef IN6_IS_ADDR_SITELOCAL */ 127 128 #endif /* ISC_IPV6_H */ 129