34#if !defined(_NETINET6_IN6_H_) || !defined(_KERNEL)
35#error "must be included via <netinet6/in6.h> in kernel space"
39#define s6_addr8 __u6_addr.__u6_addr8
40#define s6_addr16 __u6_addr.__u6_addr16
41#define s6_addr32 __u6_addr.__u6_addr32
47#define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
48#define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
50#define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
52#define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
53 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
54#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
55 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
57extern const struct sockaddr_in6 sa6_any;
59extern const struct in6_addr in6mask0;
60extern const struct in6_addr in6mask32;
61extern const struct in6_addr in6mask64;
62extern const struct in6_addr in6mask96;
63extern const struct in6_addr in6mask128;
69#if _BYTE_ORDER == _BIG_ENDIAN
70#define IPV6_ADDR_INT32_ONE 1
71#define IPV6_ADDR_INT32_TWO 2
72#define IPV6_ADDR_INT32_MNL 0xff010000
73#define IPV6_ADDR_INT32_MLL 0xff020000
74#define IPV6_ADDR_INT32_SMP 0x0000ffff
75#define IPV6_ADDR_INT16_ULL 0xfe80
76#define IPV6_ADDR_INT16_USL 0xfec0
77#define IPV6_ADDR_INT16_MLL 0xff02
78#elif _BYTE_ORDER == _LITTLE_ENDIAN
79#define IPV6_ADDR_INT32_ONE 0x01000000
80#define IPV6_ADDR_INT32_TWO 0x02000000
81#define IPV6_ADDR_INT32_MNL 0x000001ff
82#define IPV6_ADDR_INT32_MLL 0x000002ff
83#define IPV6_ADDR_INT32_SMP 0xffff0000
84#define IPV6_ADDR_INT16_ULL 0x80fe
85#define IPV6_ADDR_INT16_USL 0xc0fe
86#define IPV6_ADDR_INT16_MLL 0x02ff
90#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
91#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
92#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
93#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
94#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08
95#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
97#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
100#define IN6_IS_ADDR_MC_NODELOCAL(a) \
101 (IN6_IS_ADDR_MULTICAST(a) && \
102 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
103#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
104 (IN6_IS_ADDR_MULTICAST(a) && \
105 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
106#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
107 (IN6_IS_ADDR_MULTICAST(a) && \
108 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
109#define IN6_IS_ADDR_MC_SITELOCAL(a) \
110 (IN6_IS_ADDR_MULTICAST(a) && \
111 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
112#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
113 (IN6_IS_ADDR_MULTICAST(a) && \
114 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
115#define IN6_IS_ADDR_MC_GLOBAL(a) \
116 (IN6_IS_ADDR_MULTICAST(a) && \
117 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
123#define IN6_IS_SCOPE_LINKLOCAL(a) \
124 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
125 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
126#define IN6_IS_SCOPE_EMBED(a) \
127 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
128 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
129 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
131#define IFA6_IS_DEPRECATED(a) \
132 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
133 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
134 (a)->ia6_lifetime.ia6t_pltime)
135#define IFA6_IS_INVALID(a) \
136 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
137 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
138 (a)->ia6_lifetime.ia6t_vltime)
140#define MTAG_ABI_IPV6 1444287380
141#define IPV6_TAG_DIRECT 0
144#define IPV6_2292PKTINFO 19
145#define IPV6_2292HOPLIMIT 20
146#define IPV6_2292NEXTHOP 21
147#define IPV6_2292HOPOPTS 22
148#define IPV6_2292DSTOPTS 23
149#define IPV6_2292RTHDR 24
150#define IPV6_2292PKTOPTIONS 25
152#define IPV6_RECVRTHDRDSTOPTS 41
157int in6_cksum_pseudo(
struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
158int in6_cksum(
struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
159int in6_cksum_partial(
struct mbuf *, u_int8_t, u_int32_t, u_int32_t,
161int in6_localaddr(
struct in6_addr *);
162int in6_localip(
struct in6_addr *);
163int in6_ifhasaddr(
struct ifnet *,
struct in6_addr *);
164int in6_addrscope(
const struct in6_addr *);
165char *ip6_sprintf(
char *,
const struct in6_addr *);
166struct in6_ifaddr *in6_ifawithifp(
struct ifnet *,
struct in6_addr *);
167extern void in6_if_up(
struct ifnet *);
169extern u_char ip6_protox[];
171void in6_sin6_2_sin(
struct sockaddr_in *sin,
172 struct sockaddr_in6 *sin6);
173void in6_sin_2_v4mapsin6(
struct sockaddr_in *sin,
174 struct sockaddr_in6 *sin6);
175void in6_sin6_2_sin_in_sock(
struct sockaddr *nam);
176void in6_sin_2_v4mapsin6_in_sock(
struct sockaddr **nam);
177extern void addrsel_policy_init(
void);
179#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
180#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
181#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))