1258945Sroberto/*
2280849Scy * Copyright (C) 2004, 2005, 2007, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
3258945Sroberto * Copyright (C) 1999-2002  Internet Software Consortium.
4258945Sroberto *
5258945Sroberto * Permission to use, copy, modify, and/or distribute this software for any
6258945Sroberto * purpose with or without fee is hereby granted, provided that the above
7258945Sroberto * copyright notice and this permission notice appear in all copies.
8258945Sroberto *
9258945Sroberto * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10258945Sroberto * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11258945Sroberto * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12258945Sroberto * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13258945Sroberto * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14258945Sroberto * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15258945Sroberto * PERFORMANCE OF THIS SOFTWARE.
16258945Sroberto */
17258945Sroberto
18280849Scy/* $Id$ */
19258945Sroberto
20258945Sroberto#ifndef ISC_IPV6_H
21258945Sroberto#define ISC_IPV6_H 1
22258945Sroberto
23258945Sroberto/*****
24258945Sroberto ***** Module Info
25258945Sroberto *****/
26258945Sroberto
27258945Sroberto/*
28258945Sroberto * IPv6 definitions for systems which do not support IPv6.
29258945Sroberto *
30258945Sroberto * MP:
31258945Sroberto *	No impact.
32258945Sroberto *
33258945Sroberto * Reliability:
34258945Sroberto *	No anticipated impact.
35258945Sroberto *
36258945Sroberto * Resources:
37258945Sroberto *	N/A.
38258945Sroberto *
39258945Sroberto * Security:
40258945Sroberto *	No anticipated impact.
41258945Sroberto *
42258945Sroberto * Standards:
43258945Sroberto *	RFC2553.
44258945Sroberto */
45258945Sroberto
46258945Sroberto#if _MSC_VER < 1300
47258945Sroberto#define in6_addr in_addr6
48258945Sroberto#endif
49258945Sroberto
50258945Sroberto#ifndef IN6ADDR_ANY_INIT
51258945Sroberto#define IN6ADDR_ANY_INIT 	{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}
52258945Sroberto#endif
53258945Sroberto#ifndef IN6ADDR_LOOPBACK_INIT
54258945Sroberto#define IN6ADDR_LOOPBACK_INIT 	{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}
55258945Sroberto#endif
56258945Sroberto
57258945SrobertoLIBISC_EXTERNAL_DATA extern const struct in6_addr isc_net_in6addrany;
58258945SrobertoLIBISC_EXTERNAL_DATA extern const struct in6_addr isc_net_in6addrloop;
59258945Sroberto
60258945Sroberto/*
61258945Sroberto * Unspecified
62258945Sroberto */
63258945Sroberto#ifndef IN6_IS_ADDR_UNSPECIFIED
64258945Sroberto#define IN6_IS_ADDR_UNSPECIFIED(a) (\
65258945Sroberto*((u_long *)((a)->s6_addr)    ) == 0 && \
66258945Sroberto*((u_long *)((a)->s6_addr) + 1) == 0 && \
67258945Sroberto*((u_long *)((a)->s6_addr) + 2) == 0 && \
68258945Sroberto*((u_long *)((a)->s6_addr) + 3) == 0 \
69258945Sroberto)
70258945Sroberto#endif
71258945Sroberto
72258945Sroberto/*
73258945Sroberto * Loopback
74258945Sroberto */
75258945Sroberto#ifndef IN6_IS_ADDR_LOOPBACK
76258945Sroberto#define IN6_IS_ADDR_LOOPBACK(a) (\
77258945Sroberto*((u_long *)((a)->s6_addr)    ) == 0 && \
78258945Sroberto*((u_long *)((a)->s6_addr) + 1) == 0 && \
79258945Sroberto*((u_long *)((a)->s6_addr) + 2) == 0 && \
80258945Sroberto*((u_long *)((a)->s6_addr) + 3) == htonl(1) \
81258945Sroberto)
82258945Sroberto#endif
83258945Sroberto
84258945Sroberto/*
85258945Sroberto * IPv4 compatible
86258945Sroberto */
87258945Sroberto#define IN6_IS_ADDR_V4COMPAT(a)  (\
88258945Sroberto*((u_long *)((a)->s6_addr)    ) == 0 && \
89258945Sroberto*((u_long *)((a)->s6_addr) + 1) == 0 && \
90258945Sroberto*((u_long *)((a)->s6_addr) + 2) == 0 && \
91258945Sroberto*((u_long *)((a)->s6_addr) + 3) != 0 && \
92258945Sroberto*((u_long *)((a)->s6_addr) + 3) != htonl(1) \
93258945Sroberto)
94258945Sroberto
95258945Sroberto/*
96258945Sroberto * Mapped
97258945Sroberto */
98258945Sroberto#define IN6_IS_ADDR_V4MAPPED(a) (\
99258945Sroberto*((u_long *)((a)->s6_addr)    ) == 0 && \
100258945Sroberto*((u_long *)((a)->s6_addr) + 1) == 0 && \
101258945Sroberto*((u_long *)((a)->s6_addr) + 2) == htonl(0x0000ffff))
102258945Sroberto
103258945Sroberto/*
104258945Sroberto * Multicast
105258945Sroberto */
106258945Sroberto#define IN6_IS_ADDR_MULTICAST(a)	\
107258945Sroberto	((a)->s6_addr[0] == 0xffU)
108258945Sroberto
109258945Sroberto/*
110258945Sroberto * Unicast link / site local.
111258945Sroberto */
112258945Sroberto#ifndef IN6_IS_ADDR_LINKLOCAL
113258945Sroberto#define IN6_IS_ADDR_LINKLOCAL(a)	(\
114258945Sroberto	((a)->s6_addr[0] == 0xfe) && \
115258945Sroberto	(((a)->s6_addr[1] & 0xc0) == 0x80))
116258945Sroberto#endif
117258945Sroberto
118258945Sroberto#ifndef IN6_IS_ADDR_SITELOCAL
119258945Sroberto#define IN6_IS_ADDR_SITELOCAL(a)	(\
120258945Sroberto	((a)->s6_addr[0] == 0xfe) && \
121258945Sroberto	(((a)->s6_addr[1] & 0xc0) == 0xc0))
122258945Sroberto#endif
123258945Sroberto
124258945Sroberto#endif /* ISC_IPV6_H */
125