66#ifndef __KAME_NETINET_IN_H_INCLUDED_
67#error "do not include netinet6/in6.h directly, include netinet/in.h. see RFC2553"
70#ifndef _NETINET6_IN6_H_
71#define _NETINET6_IN6_H_
79#define __KAME_VERSION "FreeBSD"
87#define IPV6PORT_RESERVED 1024
88#define IPV6PORT_ANONMIN 49152
89#define IPV6PORT_ANONMAX 65535
90#define IPV6PORT_RESERVEDMIN 600
91#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1)
105#define s6_addr __u6_addr.__u6_addr8
106#if defined(_KERNEL) || defined(_STANDALONE)
107#define s6_addr8 __u6_addr.__u6_addr8
108#define s6_addr16 __u6_addr.__u6_addr16
109#define s6_addr32 __u6_addr.__u6_addr32
112#define INET6_ADDRSTRLEN 46
138#define IN6MASK0 {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
139#define IN6MASK32 {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
141#define IN6MASK64 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
143#define IN6MASK96 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
144 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
145#define IN6MASK128 {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
146 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
163#if _BYTE_ORDER == _BIG_ENDIAN
164#define IPV6_ADDR_INT32_ONE 1
165#define IPV6_ADDR_INT32_TWO 2
166#define IPV6_ADDR_INT32_MNL 0xff010000
167#define IPV6_ADDR_INT32_MLL 0xff020000
168#define IPV6_ADDR_INT32_SMP 0x0000ffff
169#define IPV6_ADDR_INT16_ULL 0xfe80
170#define IPV6_ADDR_INT16_USL 0xfec0
171#define IPV6_ADDR_INT16_MLL 0xff02
172#elif _BYTE_ORDER == _LITTLE_ENDIAN
173#define IPV6_ADDR_INT32_ONE 0x01000000
174#define IPV6_ADDR_INT32_TWO 0x02000000
175#define IPV6_ADDR_INT32_MNL 0x000001ff
176#define IPV6_ADDR_INT32_MLL 0x000002ff
177#define IPV6_ADDR_INT32_SMP 0xffff0000
178#define IPV6_ADDR_INT16_ULL 0x80fe
179#define IPV6_ADDR_INT16_USL 0xc0fe
180#define IPV6_ADDR_INT16_MLL 0x02ff
188#define IN6ADDR_ANY_INIT \
189 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
191#define IN6ADDR_LOOPBACK_INIT \
192 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
194#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
195 {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
197#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
198 {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
200#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
201 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
203#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
204 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
206#define IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT \
207 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16 }}}
227#define IN6_ARE_ADDR_EQUAL(a, b) \
228 (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
231#define IN6_ARE_ADDR_EQUAL(a, b) \
232 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
239#define IN6_IS_ADDR_UNSPECIFIED(a) \
240 ((a)->__u6_addr.__u6_addr32[0] == 0 && \
241 (a)->__u6_addr.__u6_addr32[1] == 0 && \
242 (a)->__u6_addr.__u6_addr32[2] == 0 && \
243 (a)->__u6_addr.__u6_addr32[3] == 0)
248#define IN6_IS_ADDR_LOOPBACK(a) \
249 ((a)->__u6_addr.__u6_addr32[0] == 0 && \
250 (a)->__u6_addr.__u6_addr32[1] == 0 && \
251 (a)->__u6_addr.__u6_addr32[2] == 0 && \
252 (a)->__u6_addr.__u6_addr32[3] == ntohl(1))
257#define IN6_IS_ADDR_V4COMPAT(a) \
258 ((a)->__u6_addr.__u6_addr32[0] == 0 && \
259 (a)->__u6_addr.__u6_addr32[1] == 0 && \
260 (a)->__u6_addr.__u6_addr32[2] == 0 && \
261 (a)->__u6_addr.__u6_addr32[3] != 0 && \
262 (a)->__u6_addr.__u6_addr32[3] != ntohl(1))
267#define IN6_IS_ADDR_V4MAPPED(a) \
268 ((a)->__u6_addr.__u6_addr32[0] == 0 && \
269 (a)->__u6_addr.__u6_addr32[1] == 0 && \
270 (a)->__u6_addr.__u6_addr32[2] == ntohl(0x0000ffff))
277#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
278#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
279#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
280#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
281#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08
282#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
284#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01
285#define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
286#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02
287#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
288#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
289#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
296#define IN6_IS_ADDR_LINKLOCAL(a) \
297 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
298#define IN6_IS_ADDR_SITELOCAL(a) \
299 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
304#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
307#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
309#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
316#define IN6_IS_ADDR_MC_NODELOCAL(a) \
317 (IN6_IS_ADDR_MULTICAST(a) && \
318 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
319#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
320 (IN6_IS_ADDR_MULTICAST(a) && \
321 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
322#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
323 (IN6_IS_ADDR_MULTICAST(a) && \
324 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
325#define IN6_IS_ADDR_MC_SITELOCAL(a) \
326 (IN6_IS_ADDR_MULTICAST(a) && \
327 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
328#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
329 (IN6_IS_ADDR_MULTICAST(a) && \
330 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
331#define IN6_IS_ADDR_MC_GLOBAL(a) \
332 (IN6_IS_ADDR_MULTICAST(a) && \
333 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
335#define IN6_IS_ADDR_MC_NODELOCAL(a) \
336 (IN6_IS_ADDR_MULTICAST(a) && \
337 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
338#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
339 (IN6_IS_ADDR_MULTICAST(a) && \
340 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
341#define IN6_IS_ADDR_MC_SITELOCAL(a) \
342 (IN6_IS_ADDR_MULTICAST(a) && \
343 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
344#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
345 (IN6_IS_ADDR_MULTICAST(a) && \
346 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
347#define IN6_IS_ADDR_MC_GLOBAL(a) \
348 (IN6_IS_ADDR_MULTICAST(a) && \
349 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
356#define IN6_IS_SCOPE_LINKLOCAL(a) \
357 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
358 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
359#define IN6_IS_SCOPE_EMBED(a) \
360 ((IN6_IS_ADDR_LINKLOCAL(a)) || \
361 (IN6_IS_ADDR_MC_LINKLOCAL(a)) || \
362 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
364#define IFA6_IS_DEPRECATED(a) \
365 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
366 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
367 (a)->ia6_lifetime.ia6t_pltime)
368#define IFA6_IS_INVALID(a) \
369 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
370 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
371 (a)->ia6_lifetime.ia6t_vltime)
380 struct nhop_object *ro_nh;
381 struct llentry *ro_lle;
396#define MTAG_ABI_IPV6 1444287380
397#define IPV6_TAG_DIRECT 0
406#define IPV6_OPTIONS 1
407#define IPV6_RECVOPTS 5
408#define IPV6_RECVRETOPTS 6
409#define IPV6_RECVDSTADDR 7
410#define IPV6_RETOPTS 8
412#define IPV6_SOCKOPT_RESERVED1 3
413#define IPV6_UNICAST_HOPS 4
414#define IPV6_MULTICAST_IF 9
415#define IPV6_MULTICAST_HOPS 10
416#define IPV6_MULTICAST_LOOP 11
417#define IPV6_JOIN_GROUP 12
418#define IPV6_LEAVE_GROUP 13
419#define IPV6_PORTRANGE 14
420#define ICMP6_FILTER 18
423#define IPV6_2292PKTINFO 19
424#define IPV6_2292HOPLIMIT 20
425#define IPV6_2292NEXTHOP 21
426#define IPV6_2292HOPOPTS 22
427#define IPV6_2292DSTOPTS 23
428#define IPV6_2292RTHDR 24
429#define IPV6_2292PKTOPTIONS 25
432#define IPV6_CHECKSUM 26
433#define IPV6_V6ONLY 27
435#define IPV6_BINDV6ONLY IPV6_V6ONLY
438#define IPV6_IPSEC_POLICY 28
441#define IPV6_FW_ADD 30
442#define IPV6_FW_DEL 31
443#define IPV6_FW_FLUSH 32
444#define IPV6_FW_ZERO 33
445#define IPV6_FW_GET 34
449#define IPV6_RTHDRDSTOPTS 35
451#define IPV6_RECVPKTINFO 36
452#define IPV6_RECVHOPLIMIT 37
453#define IPV6_RECVRTHDR 38
454#define IPV6_RECVHOPOPTS 39
455#define IPV6_RECVDSTOPTS 40
457#define IPV6_RECVRTHDRDSTOPTS 41
460#define IPV6_USE_MIN_MTU 42
461#define IPV6_RECVPATHMTU 43
463#define IPV6_PATHMTU 44
466#define IPV6_REACHCONF 45
471#define IPV6_PKTINFO 46
472#define IPV6_HOPLIMIT 47
473#define IPV6_NEXTHOP 48
474#define IPV6_HOPOPTS 49
475#define IPV6_DSTOPTS 50
478#define IPV6_PKTOPTIONS 52
482#define IPV6_RECVTCLASS 57
484#define IPV6_AUTOFLOWLABEL 59
486#define IPV6_TCLASS 61
487#define IPV6_DONTFRAG 62
489#define IPV6_PREFER_TEMPADDR 63
493#define IPV6_BINDANY 64
495#define IPV6_BINDMULTI 65
496#define IPV6_RSS_LISTEN_BUCKET 66
497#define IPV6_FLOWID 67
498#define IPV6_FLOWTYPE 68
499#define IPV6_RSSBUCKETID 69
500#define IPV6_RECVFLOWID 70
501#define IPV6_RECVRSSBUCKETID 71
503#define IPV6_ORIGDSTADDR 72
504#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
510#define IPV6_MSFILTER 74
515#define IPV6_VLAN_PCP 75
520#define IPV6_RTHDR_LOOSE 0
521#define IPV6_RTHDR_STRICT 1
522#define IPV6_RTHDR_TYPE_0 0
527#define IPV6_DEFAULT_MULTICAST_HOPS 1
528#define IPV6_DEFAULT_MULTICAST_LOOP 1
533#define IPV6_MAX_MEMBERSHIPS 4095
539#define IPV6_MAX_GROUP_SRC_FILTER 512
540#define IPV6_MAX_SOCK_SRC_FILTER 128
570#define IPV6_PORTRANGE_DEFAULT 0
571#define IPV6_PORTRANGE_HIGH 1
572#define IPV6_PORTRANGE_LOW 2
581#define IPV6PROTO_MAXID (IPPROTO_PIM + 1)
586#define IPV6CTL_FORWARDING 1
587#define IPV6CTL_SENDREDIRECTS 2
588#define IPV6CTL_DEFHLIM 3
590#define IPV6CTL_DEFMTU 4
592#define IPV6CTL_FORWSRCRT 5
593#define IPV6CTL_STATS 6
594#define IPV6CTL_MRTSTATS 7
595#define IPV6CTL_MRTPROTO 8
596#define IPV6CTL_MAXFRAGPACKETS 9
597#define IPV6CTL_SOURCECHECK 10
598#define IPV6CTL_SOURCECHECK_LOGINT 11
599#define IPV6CTL_ACCEPT_RTADV 12
601#define IPV6CTL_LOG_INTERVAL 14
602#define IPV6CTL_HDRNESTLIMIT 15
603#define IPV6CTL_DAD_COUNT 16
604#define IPV6CTL_AUTO_FLOWLABEL 17
605#define IPV6CTL_DEFMCASTHLIM 18
606#define IPV6CTL_GIF_HLIM 19
607#define IPV6CTL_KAME_VERSION 20
608#define IPV6CTL_USE_DEPRECATED 21
609#define IPV6CTL_RR_PRUNE 22
611#define IPV6CTL_MAPPED_ADDR 23
613#define IPV6CTL_V6ONLY 24
618#define IPV6CTL_USETEMPADDR 32
619#define IPV6CTL_TEMPPLTIME 33
620#define IPV6CTL_TEMPVLTIME 34
621#define IPV6CTL_AUTO_LINKLOCAL 35
622#define IPV6CTL_RIP6STATS 36
623#define IPV6CTL_PREFER_TEMPADDR 37
624#define IPV6CTL_ADDRCTLPOLICY 38
625#define IPV6CTL_USE_DEFAULTZONE 39
627#define IPV6CTL_MAXFRAGS 41
629#define IPV6CTL_IFQ 42
630#define IPV6CTL_ISATAPRTR 43
632#define IPV6CTL_MCAST_PMTU 44
636#define IPV6CTL_STEALTH 45
638#define ICMPV6CTL_ND6_ONLINKNSRFC4861 47
639#define IPV6CTL_NO_RADR 48
640#define IPV6CTL_NORBIT_RAIF 49
642#define IPV6CTL_RFC6204W3 50
644#define IPV6CTL_INTRQMAXLEN 51
645#define IPV6CTL_INTRDQMAXLEN 52
647#define IPV6CTL_MAXFRAGSPERPACKET 53
648#define IPV6CTL_MAXFRAGBUCKETSIZE 54
649#define IPV6CTL_MAXID 55
656#define M_FASTFWD_OURS M_PROTO1
657#define M_IP6_NEXTHOP M_PROTO2
658#define M_IP_NEXTHOP M_PROTO2
659#define M_SKIP_FIREWALL M_PROTO3
660#define M_AUTHIPHDR M_PROTO4
661#define M_DECRYPTED M_PROTO5
662#define M_LOOP M_PROTO6
663#define M_AUTHIPDGM M_PROTO7
664#define M_RTALERT_MLD M_PROTO8
665#define M_FRAGMENTED M_PROTO9
672int in6_cksum(
struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
694#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
695#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
696#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
700#ifndef _SIZE_T_DECLARED
702#define _SIZE_T_DECLARED
705#ifndef _SOCKLEN_T_DECLARED
707#define _SOCKLEN_T_DECLARED
715extern int inet6_option_space(
int);
716extern int inet6_option_init(
void *,
struct cmsghdr **,
int);
717extern int inet6_option_append(
struct cmsghdr *,
const uint8_t *,
719extern uint8_t *inet6_option_alloc(
struct cmsghdr *,
int,
int,
int);
720extern int inet6_option_next(
const struct cmsghdr *, uint8_t **);
721extern int inet6_option_find(
const struct cmsghdr *, uint8_t **,
int);
723extern size_t inet6_rthdr_space(
int,
int);
724extern struct cmsghdr *inet6_rthdr_init(
void *,
int);
725extern int inet6_rthdr_add(
struct cmsghdr *,
const struct in6_addr *,
727extern int inet6_rthdr_lasthop(
struct cmsghdr *,
unsigned int);
729extern int inet6_rthdr_reverse(
const struct cmsghdr *,
struct cmsghdr *);
731extern int inet6_rthdr_segments(
const struct cmsghdr *);
732extern struct in6_addr *inet6_rthdr_getaddr(
struct cmsghdr *,
int);
733extern int inet6_rthdr_getflags(
const struct cmsghdr *,
int);
735extern int inet6_opt_init(
void *,
socklen_t);
738extern int inet6_opt_finish(
void *,
socklen_t,
int);
739extern int inet6_opt_set_val(
void *,
int,
void *,
socklen_t);
745extern int inet6_opt_get_val(
void *,
int,
void *,
socklen_t);
746extern socklen_t inet6_rth_space(
int,
int);
747extern void *inet6_rth_init(
void *,
socklen_t,
int,
int);
748extern int inet6_rth_add(
void *,
const struct in6_addr *);
749extern int inet6_rth_reverse(
const void *,
void *);
750extern int inet6_rth_segments(
const void *);
751extern struct in6_addr *inet6_rth_getaddr(
const void *,
int);
const struct in6_addr in6addr_linklocal_allrouters
const struct in6_addr in6addr_nodelocal_allnodes
const struct in6_addr in6addr_linklocal_allv2routers
const struct in6_addr in6addr_linklocal_allnodes
const struct in6_addr in6mask96
struct in6_ifaddr * in6_ifawithifp(struct ifnet *, struct in6_addr *)
const struct in6_addr in6mask128
int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t)
int in6_ifhasaddr(struct ifnet *, struct in6_addr *)
const struct in6_addr in6mask32
char * ip6_sprintf(char *, const struct in6_addr *)
void in6_sin_2_v4mapsin6(struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
int in6_addrscope(const struct in6_addr *)
const struct in6_addr in6addr_loopback
void in6_if_up(struct ifnet *)
void in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam)
int in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t, u_int32_t)
const struct in6_addr in6mask0
const struct in6_addr in6mask64
int in6_localip(struct in6_addr *)
bool in6_localip_fib(struct in6_addr *, uint16_t)
int in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t)
void in6_sin6_2_sin_in_sock(struct sockaddr *nam)
void addrsel_policy_init(void)
const struct sockaddr_in6 sa6_any
int in6_localaddr(struct in6_addr *)
const struct in6_addr in6addr_any
static struct sockaddr_in6 sin6
union in6_addr::@0 __u6_addr
struct in6_addr ipi6_addr
unsigned int ipi6_ifindex
struct sockaddr_in6 ip6m_addr
struct in6_addr ipv6mr_multiaddr
unsigned int ipv6mr_interface
struct in6_addr sin6_addr