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