43#if defined(_NETINET6_IN6_H_) && defined(_KERNEL)
46#define s6_addr8 __u6_addr.__u6_addr8
47#define s6_addr16 __u6_addr.__u6_addr16
48#define s6_addr32 __u6_addr.__u6_addr32
54#define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
55#define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
57#define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
59#define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
60 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
61#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
62 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
64extern const struct sockaddr_in6 sa6_any;
66extern const struct in6_addr in6mask0;
67extern const struct in6_addr in6mask32;
68extern const struct in6_addr in6mask64;
69extern const struct in6_addr in6mask96;
70extern const struct in6_addr in6mask128;
76#if _BYTE_ORDER == _BIG_ENDIAN
77#define IPV6_ADDR_INT32_ONE 1
78#define IPV6_ADDR_INT32_TWO 2
79#define IPV6_ADDR_INT32_MNL 0xff010000
80#define IPV6_ADDR_INT32_MLL 0xff020000
81#define IPV6_ADDR_INT32_SMP 0x0000ffff
82#define IPV6_ADDR_INT16_ULL 0xfe80
83#define IPV6_ADDR_INT16_USL 0xfec0
84#define IPV6_ADDR_INT16_MLL 0xff02
85#elif _BYTE_ORDER == _LITTLE_ENDIAN
86#define IPV6_ADDR_INT32_ONE 0x01000000
87#define IPV6_ADDR_INT32_TWO 0x02000000
88#define IPV6_ADDR_INT32_MNL 0x000001ff
89#define IPV6_ADDR_INT32_MLL 0x000002ff
90#define IPV6_ADDR_INT32_SMP 0xffff0000
91#define IPV6_ADDR_INT16_ULL 0x80fe
92#define IPV6_ADDR_INT16_USL 0xc0fe
93#define IPV6_ADDR_INT16_MLL 0x02ff
97#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
98#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
99#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
100#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
101#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08
102#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
104#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
107#define IN6_IS_ADDR_MC_NODELOCAL(a) \
108 (IN6_IS_ADDR_MULTICAST(a) && \
109 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
110#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
111 (IN6_IS_ADDR_MULTICAST(a) && \
112 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
113#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
114 (IN6_IS_ADDR_MULTICAST(a) && \
115 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
116#define IN6_IS_ADDR_MC_SITELOCAL(a) \
117 (IN6_IS_ADDR_MULTICAST(a) && \
118 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
119#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
120 (IN6_IS_ADDR_MULTICAST(a) && \
121 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
122#define IN6_IS_ADDR_MC_GLOBAL(a) \
123 (IN6_IS_ADDR_MULTICAST(a) && \
124 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
130#define IN6_IS_SCOPE_LINKLOCAL(a) \
131 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
132 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
133#define IN6_IS_SCOPE_EMBED(a) \
134 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
135 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
136 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
138#define IFA6_IS_DEPRECATED(a) \
139 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
140 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
141 (a)->ia6_lifetime.ia6t_pltime)
142#define IFA6_IS_INVALID(a) \
143 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
144 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
145 (a)->ia6_lifetime.ia6t_vltime)
147#define MTAG_ABI_IPV6 1444287380
148#define IPV6_TAG_DIRECT 0
151#define IPV6_2292PKTINFO 19
152#define IPV6_2292HOPLIMIT 20
153#define IPV6_2292NEXTHOP 21
154#define IPV6_2292HOPOPTS 22
155#define IPV6_2292DSTOPTS 23
156#define IPV6_2292RTHDR 24
157#define IPV6_2292PKTOPTIONS 25
159#define IPV6_RECVRTHDRDSTOPTS 41
164int in6_cksum_pseudo(
struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
165int in6_cksum(
struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
166int in6_cksum_partial(
struct mbuf *, u_int8_t, u_int32_t, u_int32_t,
168int in6_localaddr(
struct in6_addr *);
169int in6_localip(
struct in6_addr *);
170bool in6_localip_fib(
struct in6_addr *, uint16_t);
171int in6_ifhasaddr(
struct ifnet *,
struct in6_addr *);
172int in6_addrscope(
const struct in6_addr *);
173char *ip6_sprintf(
char *,
const struct in6_addr *);
174struct in6_ifaddr *in6_ifawithifp(
struct ifnet *,
struct in6_addr *);
175extern void in6_if_up(
struct ifnet *);
177extern u_char ip6_protox[];
179void in6_sin6_2_sin(
struct sockaddr_in *sin,
180 struct sockaddr_in6 *sin6);
181void in6_sin_2_v4mapsin6(
struct sockaddr_in *sin,
182 struct sockaddr_in6 *sin6);
183void in6_sin6_2_sin_in_sock(
struct sockaddr *nam);
184void in6_sin_2_v4mapsin6_in_sock(
struct sockaddr **nam);
185extern void addrsel_policy_init(
void);
187#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
188#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
189#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
192#error "must be included via <netinet6/in6.h> in kernel space"