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