Signed-off-by: Charles Myers <charles.my...@spirent.com>
---
 bsd/sys/netinet/icmp6.h       |   2 +
 bsd/sys/netinet/ip6.h         |  93 +----------------------
 bsd/sys/netinet6/in6.h        | 125 +++++++------------------------
 bsd/sys/netinet6/in6_pcb.h    |  30 ++++----
 bsd/sys/netinet6/in6_var.h    | 170 +++++++++++++++++++++++++++++++++---------
 bsd/sys/netinet6/ip6_mroute.h |  12 +--
 bsd/sys/netinet6/ip6_var.h    |  15 ++--
 bsd/sys/netinet6/ip6protosw.h |   8 +-
 bsd/sys/netinet6/mld6.h       |   7 ++
 bsd/sys/netinet6/nd6.h        |  38 +++++-----
 bsd/sys/netinet6/scope6_var.h |   4 +-
 bsd/sys/netinet6/send.h       |   2 +-
 bsd/sys/netinet6/tcp6_var.h   |   2 +-
 bsd/sys/netinet6/udp6_var.h   |   2 +-
 include/api/netinet/__icmp6.h |  11 +++
 include/api/netinet6/__in6.h  |  70 +++++++++++++++++
 16 files changed, 312 insertions(+), 279 deletions(-)
 create mode 100644 include/api/netinet/__icmp6.h
 create mode 100644 include/api/netinet6/__in6.h

diff --git a/bsd/sys/netinet/icmp6.h b/bsd/sys/netinet/icmp6.h
index 5952225..2f9ea4c 100644
--- a/bsd/sys/netinet/icmp6.h
+++ b/bsd/sys/netinet/icmp6.h
@@ -64,6 +64,8 @@
 #ifndef _NETINET_ICMP6_H_
 #define _NETINET_ICMP6_H_
 
+#include <netinet/__icmp6.h>
+
 #define ICMPV6_PLD_MAXLEN      1232    /* IPV6_MMTU - sizeof(struct ip6_hdr)
                                           - sizeof(struct icmp6_hdr) */
 
diff --git a/bsd/sys/netinet/ip6.h b/bsd/sys/netinet/ip6.h
index 5f99fd9..a69aaa5 100644
--- a/bsd/sys/netinet/ip6.h
+++ b/bsd/sys/netinet/ip6.h
@@ -64,6 +64,10 @@
 #ifndef _NETINET_IP6_H_
 #define _NETINET_IP6_H_
 
+#include <sys/cdefs.h>
+#include <bsd/sys/sys/param.h>
+#include <bsd/sys/netinet6/in6.h>
+
 /*
  * Definition for internet protocol version 6.
  * RFC 2460
@@ -259,94 +263,5 @@ struct ip6_frag {
 #define IPV6_MAXPACKET 65535   /* ip6 max packet size without Jumbo payload*/
 #define IPV6_MAXOPTHDR 2048    /* max option header size, 256 64-bit words */
 
-#ifdef _KERNEL
-/*
- * IP6_EXTHDR_CHECK ensures that region between the IP6 header and the
- * target header (including IPv6 itself, extension headers and
- * TCP/UDP/ICMP6 headers) are contiguous. KAME requires drivers
- * to store incoming data into one internal mbuf or one or more external
- * mbufs(never into two or more internal mbufs). Thus, the third case is
- * supposed to never be matched but is prepared just in case.
- */
-
-#define IP6_EXTHDR_CHECK(m, off, hlen, ret)                            \
-do {                                                                   \
-    if ((m)->m_next != NULL) {                                         \
-       if (((m)->m_flags & M_LOOP) &&                                  \
-           ((m)->m_len < (off) + (hlen)) &&                            \
-           (((m) = m_pullup((m), (off) + (hlen))) == NULL)) {          \
-               V_ip6stat.ip6s_exthdrtoolong++;                         \
-               return ret;                                             \
-       } else if ((m)->m_flags & M_EXT) {                              \
-               if ((m)->m_len < (off) + (hlen)) {                      \
-                       V_ip6stat.ip6s_exthdrtoolong++;                 \
-                       m_freem(m);                                     \
-                       return ret;                                     \
-               }                                                       \
-       } else {                                                        \
-               if ((m)->m_len < (off) + (hlen)) {                      \
-                       V_ip6stat.ip6s_exthdrtoolong++;                 \
-                       m_freem(m);                                     \
-                       return ret;                                     \
-               }                                                       \
-       }                                                               \
-    } else {                                                           \
-       if ((m)->m_len < (off) + (hlen)) {                              \
-               V_ip6stat.ip6s_tooshort++;                              \
-               in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);   \
-               m_freem(m);                                             \
-               return ret;                                             \
-       }                                                               \
-    }                                                                  \
-} while (/*CONSTCOND*/ 0)
-
-/*
- * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
- * "len") is located in single mbuf, on contiguous memory region.
- * The pointer to the region will be returned to pointer variable "val",
- * with type "typ".
- * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
- * very top of mbuf.  GET0 is likely to make memory copy than GET.
- *
- * XXX we're now testing this, needs m_pulldown()
- */
-#define IP6_EXTHDR_GET(val, typ, m, off, len) \
-do {                                                                   \
-       struct mbuf *t;                                                 \
-       int tmp;                                                        \
-       if ((m)->m_len >= (off) + (len))                                \
-               (val) = (typ)(mtod((m), caddr_t) + (off));              \
-       else {                                                          \
-               t = m_pulldown((m), (off), (len), &tmp);                \
-               if (t) {                                                \
-                       if (t->m_len < tmp + (len))                     \
-                               panic("m_pulldown malfunction");        \
-                       (val) = (typ)(mtod(t, caddr_t) + tmp);          \
-               } else {                                                \
-                       (val) = (typ)NULL;                              \
-                       (m) = NULL;                                     \
-               }                                                       \
-       }                                                               \
-} while (/*CONSTCOND*/ 0)
-
-#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
-do {                                                                   \
-       struct mbuf *t;                                                 \
-       if ((off) == 0)                                                 \
-               (val) = (typ)mtod(m, caddr_t);                          \
-       else {                                                          \
-               t = m_pulldown((m), (off), (len), NULL);                \
-               if (t) {                                                \
-                       if (t->m_len < (len))                           \
-                               panic("m_pulldown malfunction");        \
-                       (val) = (typ)mtod(t, caddr_t);                  \
-               } else {                                                \
-                       (val) = (typ)NULL;                              \
-                       (m) = NULL;                                     \
-               }                                                       \
-       }                                                               \
-} while (/*CONSTCOND*/ 0)
-
-#endif /*_KERNEL*/
 
 #endif /* not _NETINET_IP6_H_ */
diff --git a/bsd/sys/netinet6/in6.h b/bsd/sys/netinet6/in6.h
index c8e24e9..d7bfc59 100644
--- a/bsd/sys/netinet6/in6.h
+++ b/bsd/sys/netinet6/in6.h
@@ -154,7 +154,7 @@ extern const struct in6_addr in6mask128;
  * Macros started with IPV6_ADDR is KAME local
  */
 #ifdef _KERNEL /* XXX nonstandard */
-#if _BYTE_ORDER == _BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
 #define IPV6_ADDR_INT32_ONE    1
 #define IPV6_ADDR_INT32_TWO    2
 #define IPV6_ADDR_INT32_MNL    0xff010000
@@ -163,7 +163,7 @@ extern const struct in6_addr in6mask128;
 #define IPV6_ADDR_INT16_ULL    0xfe80
 #define IPV6_ADDR_INT16_USL    0xfec0
 #define IPV6_ADDR_INT16_MLL    0xff02
-#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#elif BYTE_ORDER == LITTLE_ENDIAN
 #define IPV6_ADDR_INT32_ONE    0x01000000
 #define IPV6_ADDR_INT32_TWO    0x02000000
 #define IPV6_ADDR_INT32_MNL    0x000001ff
@@ -355,13 +355,20 @@ extern const struct in6_addr 
in6addr_linklocal_allv2routers;
         (IN6_IS_ADDR_MC_LINKLOCAL(a)) ||       \
         (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
 
+static inline time_t ifa6_get_time_second(void)
+{
+    struct timeval tv;
+    getmicrotime(&tv);
+    return (time_t)tv.tv_sec;
+}
+
 #define IFA6_IS_DEPRECATED(a) \
        ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
-        (u_int32_t)((time_second - (a)->ia6_updatetime)) > \
+        (u_int32_t)((ifa6_get_time_second() - (a)->ia6_updatetime)) >   \
         (a)->ia6_lifetime.ia6t_pltime)
 #define IFA6_IS_INVALID(a) \
        ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
-        (u_int32_t)((time_second - (a)->ia6_updatetime)) > \
+        (u_int32_t)((ifa6_get_time_second() - (a)->ia6_updatetime)) >  \
         (a)->ia6_lifetime.ia6t_vltime)
 #endif /* _KERNEL */
 
@@ -378,104 +385,19 @@ struct route_in6 {
 };
 #endif
 
-/*
- * Options for use with [gs]etsockopt at the IPV6 level.
- * First word of comment is data type; bool is stored in int.
- */
-/* no hdrincl */
-#if 0 /* the followings are relic in IPv4 and hence are disabled */
-#define IPV6_OPTIONS           1  /* buf/ip6_opts; set/get IP6 options */
-#define IPV6_RECVOPTS          5  /* bool; receive all IP6 opts w/dgram */
-#define IPV6_RECVRETOPTS       6  /* bool; receive IP6 opts for response */
-#define IPV6_RECVDSTADDR       7  /* bool; receive IP6 dst addr w/dgram */
-#define IPV6_RETOPTS           8  /* ip6_opts; set/get IP6 options */
-#endif
-#define IPV6_SOCKOPT_RESERVED1 3  /* reserved for future use */
-#define IPV6_UNICAST_HOPS      4  /* int; IP6 hops */
-#define IPV6_MULTICAST_IF      9  /* u_int; set/get IP6 multicast i/f  */
-#define IPV6_MULTICAST_HOPS    10 /* int; set/get IP6 multicast hops */
-#define IPV6_MULTICAST_LOOP    11 /* u_int; set/get IP6 multicast loopback */
-#define IPV6_JOIN_GROUP                12 /* ipv6_mreq; join a group 
membership */
-#define IPV6_LEAVE_GROUP       13 /* ipv6_mreq; leave a group membership */
-#define IPV6_PORTRANGE         14 /* int; range to choose for unspec port */
-#define ICMP6_FILTER           18 /* icmp6_filter; icmp6 filter */
-/* RFC2292 options */
-#ifdef _KERNEL
-#define IPV6_2292PKTINFO       19 /* bool; send/recv if, src/dst addr */
-#define IPV6_2292HOPLIMIT      20 /* bool; hop limit */
-#define IPV6_2292NEXTHOP       21 /* bool; next hop addr */
-#define IPV6_2292HOPOPTS       22 /* bool; hop-by-hop option */
-#define IPV6_2292DSTOPTS       23 /* bool; destinaion option */
-#define IPV6_2292RTHDR         24 /* bool; routing header */
-#define IPV6_2292PKTOPTIONS    25 /* buf/cmsghdr; set/get IPv6 options */
-#endif
-
-#define IPV6_CHECKSUM          26 /* int; checksum offset for raw socket */
-#define IPV6_V6ONLY            27 /* bool; make AF_INET6 sockets v6 only */
-#ifndef _KERNEL
-#define IPV6_BINDV6ONLY                IPV6_V6ONLY
-#endif
-
-#if 1 /* IPSEC */
-#define IPV6_IPSEC_POLICY      28 /* struct; get/set security policy */
-#endif /* IPSEC */
-
-#define IPV6_FAITH             29 /* bool; accept FAITH'ed connections */
-
-#if 1 /* IPV6FIREWALL */
-#define IPV6_FW_ADD            30 /* add a firewall rule to chain */
-#define IPV6_FW_DEL            31 /* delete a firewall rule from chain */
-#define IPV6_FW_FLUSH          32 /* flush firewall rule chain */
-#define IPV6_FW_ZERO           33 /* clear single/all firewall counter(s) */
-#define IPV6_FW_GET            34 /* get entire firewall rule chain */
-#endif
-
-/* new socket options introduced in RFC3542 */
-#define IPV6_RTHDRDSTOPTS      35 /* ip6_dest; send dst option before rthdr */
-
-#define IPV6_RECVPKTINFO       36 /* bool; recv if, dst addr */
-#define IPV6_RECVHOPLIMIT      37 /* bool; recv hop limit */
-#define IPV6_RECVRTHDR         38 /* bool; recv routing header */
-#define IPV6_RECVHOPOPTS       39 /* bool; recv hop-by-hop option */
-#define IPV6_RECVDSTOPTS       40 /* bool; recv dst option after rthdr */
-#ifdef _KERNEL
-#define IPV6_RECVRTHDRDSTOPTS  41 /* bool; recv dst option before rthdr */
-#endif
 
-#define IPV6_USE_MIN_MTU       42 /* bool; send packets at the minimum MTU */
-#define IPV6_RECVPATHMTU       43 /* bool; notify an according MTU */
+#include <netinet6/__in6.h>
 
-#define IPV6_PATHMTU           44 /* mtuinfo; get the current path MTU (sopt),
-                                     4 bytes int; MTU notification (cmsg) */
-#if 0 /*obsoleted during 2292bis -> 3542*/
-#define IPV6_REACHCONF         45 /* no data; ND reachability confirm
-                                     (cmsg only/not in of RFC3542) */
-#endif
-
-/* more new socket options introduced in RFC3542 */
-#define IPV6_PKTINFO           46 /* in6_pktinfo; send if, src addr */
-#define IPV6_HOPLIMIT          47 /* int; send hop limit */
-#define IPV6_NEXTHOP           48 /* bsd_sockaddr; next hop addr */
-#define IPV6_HOPOPTS           49 /* ip6_hbh; send hop-by-hop option */
-#define IPV6_DSTOPTS           50 /* ip6_dest; send dst option befor rthdr */
-#define IPV6_RTHDR             51 /* ip6_rthdr; send routing header */
-#if 0
-#define IPV6_PKTOPTIONS                52 /* buf/cmsghdr; set/get IPv6 options 
*/
-                                  /* obsoleted by RFC3542 */
-#endif
-
-#define IPV6_RECVTCLASS                57 /* bool; recv traffic class values */
-
-#define IPV6_AUTOFLOWLABEL     59 /* bool; attach flowlabel automagically */
-
-#define IPV6_TCLASS            61 /* int; send traffic class value */
-#define IPV6_DONTFRAG          62 /* bool; disable IPv6 fragmentation */
-
-#define IPV6_PREFER_TEMPADDR   63 /* int; prefer temporary addresses as
-                                   * the source address.
-                                   */
-
-#define        IPV6_BINDANY            64 /* bool: allow bind to any address */
+/* IPV6 socket options defined in FreeBSD but not Linux/Musl
+ *
+ * These options might eventually just get removed...
+ */
+#define IPV6_BINDANY            (IPV6_XOPTS_START + 0)
+#define IPV6_RECVRTHDRDSTOPTS   (IPV6_XOPTS_START + 1)
+#define IPV6_FAITH              (IPV6_XOPTS_START + 2)
+#define IPV6_PREFER_TEMPADDR    (IPV6_XOPTS_START + 3)
+#define IPV6_PORTRANGE          (IPV6_XOPTS_START + 4)
+#define IPV6_2292NEXTHOP        (IPV6_XOPTS_START + 5)
 
 /*
  * The following option is private; do not use it from user applications.
@@ -670,6 +592,9 @@ typedef     __socklen_t     socklen_t;
 __BEGIN_DECLS
 struct cmsghdr;
 
+
+extern void ip6_init2(void *);
+
 extern int inet6_option_space(int);
 extern int inet6_option_init(void *, struct cmsghdr **, int);
 extern int inet6_option_append(struct cmsghdr *, const uint8_t *,
diff --git a/bsd/sys/netinet6/in6_pcb.h b/bsd/sys/netinet6/in6_pcb.h
index 597e195..d338d7e 100644
--- a/bsd/sys/netinet6/in6_pcb.h
+++ b/bsd/sys/netinet6/in6_pcb.h
@@ -65,8 +65,8 @@
 #define        _NETINET6_IN6_PCB_H_
 
 #ifdef _KERNEL
-#define        satosin6(sa)    ((struct sockaddr_in6 *)(sa))
-#define        sin6tosa(sin6)  ((struct sockaddr *)(sin6))
+#define        satosin6(sa)    ((struct bsd_sockaddr_in6 *)(sa))
+#define        sin6tosa(sin6)  ((struct bsd_sockaddr *)(sin6))
 #define        ifatoia6(ifa)   ((struct in6_ifaddr *)(ifa))
 
 struct inpcbgroup *
@@ -81,12 +81,12 @@ struct      inpcbgroup *
 
 void   in6_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
 void   in6_losing(struct inpcb *);
-int    in6_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *);
-int    in6_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *);
-int    in6_pcbconnect_mbuf(struct inpcb *, struct sockaddr *,
+int    in6_pcbbind(struct inpcb *, struct bsd_sockaddr *, struct ucred *);
+int    in6_pcbconnect(struct inpcb *, struct bsd_sockaddr *, struct ucred *);
+int    in6_pcbconnect_mbuf(struct inpcb *, struct bsd_sockaddr *,
            struct ucred *, struct mbuf *);
 void   in6_pcbdisconnect(struct inpcb *);
-int    in6_pcbladdr(struct inpcb *, struct sockaddr *, struct in6_addr *);
+int    in6_pcbladdr(struct inpcb *, struct bsd_sockaddr *, struct in6_addr *);
 struct inpcb *
        in6_pcblookup_local(struct inpcbinfo *,
                                 struct in6_addr *, u_short, int,
@@ -103,22 +103,22 @@ struct    inpcb *
        in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *,
                           u_int, struct in6_addr *, u_int, int,
                           struct ifnet *ifp, struct mbuf *);
-void   in6_pcbnotify(struct inpcbinfo *, struct sockaddr *,
-                          u_int, const struct sockaddr *, u_int, int, void *,
+void   in6_pcbnotify(struct inpcbinfo *, struct bsd_sockaddr *,
+                          u_int, const struct bsd_sockaddr *, u_int, int, void 
*,
                           struct inpcb *(*)(struct inpcb *, int));
 struct inpcb *
        in6_rtchange(struct inpcb *, int);
-struct sockaddr *
+struct bsd_sockaddr *
        in6_sockaddr(in_port_t port, struct in6_addr *addr_p);
-struct sockaddr *
+struct bsd_sockaddr *
        in6_v4mapsin6_sockaddr(in_port_t port, struct in_addr *addr_p);
-int    in6_getpeeraddr(struct socket *so, struct sockaddr **nam);
-int    in6_getsockaddr(struct socket *so, struct sockaddr **nam);
-int    in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam);
-int    in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam);
+int    in6_getpeeraddr(struct socket *so, struct bsd_sockaddr **nam);
+int    in6_getsockaddr(struct socket *so, struct bsd_sockaddr **nam);
+int    in6_mapped_sockaddr(struct socket *so, struct bsd_sockaddr **nam);
+int    in6_mapped_peeraddr(struct socket *so, struct bsd_sockaddr **nam);
 int    in6_selecthlim(struct in6pcb *, struct ifnet *);
 int    in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);
-void   init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m);
+void   init_sin6(struct bsd_sockaddr_in6 *sin6, struct mbuf *m);
 #endif /* _KERNEL */
 
 #endif /* !_NETINET6_IN6_PCB_H_ */
diff --git a/bsd/sys/netinet6/in6_var.h b/bsd/sys/netinet6/in6_var.h
index 193f672..1182a35 100644
--- a/bsd/sys/netinet6/in6_var.h
+++ b/bsd/sys/netinet6/in6_var.h
@@ -64,7 +64,8 @@
 #ifndef _NETINET6_IN6_VAR_H_
 #define _NETINET6_IN6_VAR_H_
 
-#include <sys/tree.h>
+#include <bsd/sys/netinet6/in6.h>
+#include <bsd/sys/tree.h>
 
 #ifdef _KERNEL
 #include <sys/libkern.h>
@@ -109,13 +110,13 @@ struct in6_ifextra {
 #define        LLTABLE6(ifp)   (((struct in6_ifextra 
*)(ifp)->if_afdata[AF_INET6])->lltable)
 
 struct in6_ifaddr {
-       struct  ifaddr ia_ifa;          /* protocol-independent info */
+       struct  bsd_ifaddr ia_ifa;              /* protocol-independent info */
 #define        ia_ifp          ia_ifa.ifa_ifp
 #define ia_flags       ia_ifa.ifa_flags
-       struct  sockaddr_in6 ia_addr;   /* interface address */
-       struct  sockaddr_in6 ia_net;    /* network number of interface */
-       struct  sockaddr_in6 ia_dstaddr; /* space for destination addr */
-       struct  sockaddr_in6 ia_prefixmask; /* prefix mask */
+       struct  bsd_sockaddr_in6 ia_addr;       /* interface address */
+       struct  bsd_sockaddr_in6 ia_net;        /* network number of interface 
*/
+       struct  bsd_sockaddr_in6 ia_dstaddr; /* space for destination addr */
+       struct  bsd_sockaddr_in6 ia_prefixmask; /* prefix mask */
        u_int32_t ia_plen;              /* prefix length */
        TAILQ_ENTRY(in6_ifaddr) ia_link;        /* list of IPv6 addresses */
        int     ia6_flags;
@@ -138,8 +139,8 @@ TAILQ_HEAD(in6_ifaddrhead, in6_ifaddr);
 
 /* control structure to manage address selection policy */
 struct in6_addrpolicy {
-       struct sockaddr_in6 addr; /* prefix address */
-       struct sockaddr_in6 addrmask; /* prefix mask */
+       struct bsd_sockaddr_in6 addr; /* prefix address */
+       struct bsd_sockaddr_in6 addrmask; /* prefix mask */
        int preced;             /* precedence */
        int label;              /* matching label */
        u_quad_t use;           /* statistics */
@@ -267,8 +268,8 @@ struct icmp6_ifstat {
 struct in6_ifreq {
        char    ifr_name[IFNAMSIZ];
        union {
-               struct  sockaddr_in6 ifru_addr;
-               struct  sockaddr_in6 ifru_dstaddr;
+               struct  bsd_sockaddr_in6 ifru_addr;
+               struct  bsd_sockaddr_in6 ifru_dstaddr;
                int     ifru_flags;
                int     ifru_flags6;
                int     ifru_metric;
@@ -282,9 +283,9 @@ struct      in6_ifreq {
 
 struct in6_aliasreq {
        char    ifra_name[IFNAMSIZ];
-       struct  sockaddr_in6 ifra_addr;
-       struct  sockaddr_in6 ifra_dstaddr;
-       struct  sockaddr_in6 ifra_prefixmask;
+       struct  bsd_sockaddr_in6 ifra_addr;
+       struct  bsd_sockaddr_in6 ifra_dstaddr;
+       struct  bsd_sockaddr_in6 ifra_prefixmask;
        int     ifra_flags;
        struct in6_addrlifetime ifra_lifetime;
 };
@@ -293,16 +294,19 @@ struct    in6_aliasreq {
 #define IN6_PREFIX_ND  1
 #define IN6_PREFIX_RR  2
 
+struct prf_ra {
+       u_char onlink : 1;
+       u_char autonomous : 1;
+       u_char reserved : 6;
+};
+
+
 /*
  * prefix related flags passed between kernel(NDP related part) and
  * user land command(ifconfig) and daemon(rtadvd).
  */
 struct in6_prflags {
-       struct prf_ra {
-               u_char onlink : 1;
-               u_char autonomous : 1;
-               u_char reserved : 6;
-       } prf_ra;
+       struct prf_ra prf_ra;
        u_char prf_reserved1;
        u_short prf_reserved2;
        /* want to put this on 4byte offset */
@@ -322,7 +326,7 @@ struct  in6_prefixreq {
        u_int32_t ipr_vltime;
        u_int32_t ipr_pltime;
        struct in6_prflags ipr_flags;
-       struct  sockaddr_in6 ipr_prefix;
+       struct  bsd_sockaddr_in6 ipr_prefix;
 };
 
 #define PR_ORIG_RA     0
@@ -354,8 +358,8 @@ struct      in6_rrenumreq {
        u_int32_t irr_vltime;
        u_int32_t irr_pltime;
        struct in6_prflags irr_flags;
-       struct  sockaddr_in6 irr_matchprefix;
-       struct  sockaddr_in6 irr_useprefix;
+       struct  bsd_sockaddr_in6 irr_matchprefix;
+       struct  bsd_sockaddr_in6 irr_useprefix;
 };
 
 #define irr_raf_mask_onlink    irr_raflagmask.onlink
@@ -380,10 +384,10 @@ struct    in6_rrenumreq {
 #define IA6_MASKIN6(ia)        (&((ia)->ia_prefixmask.sin6_addr))
 #define IA6_SIN6(ia)   (&((ia)->ia_addr))
 #define IA6_DSTSIN6(ia)        (&((ia)->ia_dstaddr))
-#define IFA_IN6(x)     (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
-#define IFA_DSTIN6(x)  (&((struct sockaddr_in6 
*)((x)->ifa_dstaddr))->sin6_addr)
+#define IFA_IN6(x)     (&((struct bsd_sockaddr_in6 
*)((x)->ifa_addr))->sin6_addr)
+#define IFA_DSTIN6(x)  (&((struct bsd_sockaddr_in6 
*)((x)->ifa_dstaddr))->sin6_addr)
 
-#define IFPR_IN6(x)    (&((struct sockaddr_in6 
*)((x)->ifpr_prefix))->sin6_addr)
+#define IFPR_IN6(x)    (&((struct bsd_sockaddr_in6 
*)((x)->ifpr_prefix))->sin6_addr)
 
 #ifdef _KERNEL
 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)     (       \
@@ -726,7 +730,7 @@ struct sockopt;
 
 /* Multicast KPIs. */
 int    im6o_mc_filter(const struct ip6_moptions *, const struct ifnet *,
-           const struct sockaddr *, const struct sockaddr *);
+           const struct bsd_sockaddr *, const struct bsd_sockaddr *);
 int    in6_mc_join(struct ifnet *, const struct in6_addr *,
            struct in6_mfilter *, struct in6_multi **, int);
 int    in6_mc_join_locked(struct ifnet *, const struct in6_addr *,
@@ -755,7 +759,7 @@ int in6_control(struct socket *, u_long, caddr_t, struct 
ifnet *,
        struct thread *);
 int    in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
        struct in6_ifaddr *, int);
-void   in6_purgeaddr(struct ifaddr *);
+void   in6_purgeaddr(struct bsd_ifaddr *);
 int    in6if_do_dad(struct ifnet *);
 void   in6_purgeif(struct ifnet *);
 void   in6_savemkludge(struct in6_ifaddr *);
@@ -765,6 +769,7 @@ void        in6_setmaxmtu(void);
 int    in6_if2idlen(struct ifnet *);
 struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
 struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
+struct in6_ifaddr *in6ifa_llaonifp(struct ifnet *);
 char   *ip6_sprintf(char *, const struct in6_addr *);
 int    in6_addr2zoneid(struct ifnet *, struct in6_addr *, u_int32_t *);
 int    in6_matchlen(struct in6_addr *, struct in6_addr *);
@@ -775,22 +780,119 @@ int      in6_prefix_ioctl(struct socket *, u_long, 
caddr_t,
 int    in6_prefix_add_ifid(int, struct in6_ifaddr *);
 void   in6_prefix_remove_ifid(int, struct in6_ifaddr *);
 void   in6_purgeprefix(struct ifnet *);
-void   in6_ifremloop(struct ifaddr *);
-void   in6_ifaddloop(struct ifaddr *);
+void   in6_ifremloop(struct bsd_ifaddr *);
+void   in6_ifaddloop(struct bsd_ifaddr *);
 
-int    in6_is_addr_deprecated(struct sockaddr_in6 *);
+int    in6_is_addr_deprecated(struct bsd_sockaddr_in6 *);
 int    in6_src_ioctl(u_long, caddr_t);
 
 /*
  * Extended API for IPv6 FIB support.
  */
-void   in6_rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *,
-           int, struct sockaddr *, u_int);
-int    in6_rtrequest(int, struct sockaddr *, struct sockaddr *,
-           struct sockaddr *, int, struct rtentry **, u_int);
+void   in6_rtredirect(struct bsd_sockaddr *, struct bsd_sockaddr *, struct 
bsd_sockaddr *,
+           int, struct bsd_sockaddr *, u_int);
+int    in6_rtrequest(int, struct bsd_sockaddr *, struct bsd_sockaddr *,
+           struct bsd_sockaddr *, int, struct rtentry **, u_int);
 void   in6_rtalloc(struct route_in6 *, u_int);
 void   in6_rtalloc_ign(struct route_in6 *, u_long, u_int);
-struct rtentry *in6_rtalloc1(struct sockaddr *, int, u_long, u_int);
+struct rtentry *in6_rtalloc1(struct bsd_sockaddr *, int, u_long, u_int);
 #endif /* _KERNEL */
 
+#ifdef _KERNEL
+
+/*
+ * These macros were originally ip6.h but g++ won't compile with it there
+ * and due to cicrular dependency had to move to in6_var.h
+ */
+
+/*
+ * IP6_EXTHDR_CHECK ensures that region between the IP6 header and the
+ * target header (including IPv6 itself, extension headers and
+ * TCP/UDP/ICMP6 headers) are contiguous. KAME requires drivers
+ * to store incoming data into one internal mbuf or one or more external
+ * mbufs(never into two or more internal mbufs). Thus, the third case is
+ * supposed to never be matched but is prepared just in case.
+ */
+
+#define IP6_EXTHDR_CHECK(m, off, hlen, ret)                            \
+do {                                                                   \
+    if ((m)->m_hdr.mh_next != NULL) {                                  \
+       if (((m)->m_hdr.mh_flags & M_LOOP) &&                           \
+           ((m)->m_hdr.mh_len < (off) + (hlen)) &&                     \
+           (((m) = m_pullup((m), (off) + (hlen))) == NULL)) {          \
+               V_ip6stat.ip6s_exthdrtoolong++;                         \
+               return ret;                                             \
+       } else if ((m)->m_hdr.mh_flags & M_EXT) {                       \
+               if ((m)->m_hdr.mh_len < (off) + (hlen)) {               \
+                       V_ip6stat.ip6s_exthdrtoolong++;                 \
+                       m_freem(m);                                     \
+                       return ret;                                     \
+               }                                                       \
+       } else {                                                        \
+               if ((m)->m_hdr.mh_len < (off) + (hlen)) {               \
+                       V_ip6stat.ip6s_exthdrtoolong++;                 \
+                       m_freem(m);                                     \
+                       return ret;                                     \
+               }                                                       \
+       }                                                               \
+    } else {                                                           \
+       if ((m)->m_hdr.mh_len < (off) + (hlen)) {                       \
+               V_ip6stat.ip6s_tooshort++;                              \
+               in6_ifstat_inc(m->M_dat.MH.MH_pkthdr.rcvif, ifs6_in_truncated); 
\
+               m_freem(m);                                             \
+               return ret;                                             \
+       }                                                               \
+    }                                                                  \
+} while (/*CONSTCOND*/ 0)
+
+/*
+ * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
+ * "len") is located in single mbuf, on contiguous memory region.
+ * The pointer to the region will be returned to pointer variable "val",
+ * with type "typ".
+ * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
+ * very top of mbuf.  GET0 is likely to make memory copy than GET.
+ *
+ * XXX we're now testing this, needs m_pulldown()
+ */
+#define IP6_EXTHDR_GET(val, typ, m, off, len) \
+do {                                                                   \
+       struct mbuf *t;                                                 \
+       int tmp;                                                        \
+       if ((m)->m_hdr.mh_len >= (off) + (len))                         \
+               (val) = (typ)(mtod((m), caddr_t) + (off));              \
+       else {                                                          \
+               t = m_pulldown((m), (off), (len), &tmp);                \
+               if (t) {                                                \
+                       if (t->m_hdr.mh_len < tmp + (len))              \
+                               panic("m_pulldown malfunction");        \
+                       (val) = (typ)(mtod(t, caddr_t) + tmp);          \
+               } else {                                                \
+                       (val) = (typ)NULL;                              \
+                       (m) = NULL;                                     \
+               }                                                       \
+       }                                                               \
+} while (/*CONSTCOND*/ 0)
+
+#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
+do {                                                                   \
+       struct mbuf *t;                                                 \
+       if ((off) == 0)                                                 \
+               (val) = (typ)mtod(m, caddr_t);                          \
+       else {                                                          \
+               t = m_pulldown((m), (off), (len), NULL);                \
+               if (t) {                                                \
+                       if (t->m_hdr.mh_len < (len))                    \
+                               panic("m_pulldown malfunction");        \
+                       (val) = (typ)mtod(t, caddr_t);                  \
+               } else {                                                \
+                       (val) = (typ)NULL;                              \
+                       (m) = NULL;                                     \
+               }                                                       \
+       }                                                               \
+} while (/*CONSTCOND*/ 0)
+
+#endif /*_KERNEL*/
+
+
 #endif /* _NETINET6_IN6_VAR_H_ */
diff --git a/bsd/sys/netinet6/ip6_mroute.h b/bsd/sys/netinet6/ip6_mroute.h
index 3f0e12b..44ef099 100644
--- a/bsd/sys/netinet6/ip6_mroute.h
+++ b/bsd/sys/netinet6/ip6_mroute.h
@@ -111,8 +111,8 @@ struct mif6ctl {
  * Argument structure for MRT6_ADD_MFC and MRT6_DEL_MFC
  */
 struct mf6cctl {
-       struct sockaddr_in6 mf6cc_origin;       /* IPv6 origin of mcasts */
-       struct sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
+       struct bsd_sockaddr_in6 mf6cc_origin;   /* IPv6 origin of mcasts */
+       struct bsd_sockaddr_in6 mf6cc_mcastgrp; /* multicast group associated */
        mifi_t          mf6cc_parent;   /* incoming ifindex */
        struct if_set   mf6cc_ifset;    /* set of forwarding ifs */
 };
@@ -181,8 +181,8 @@ struct mrt6msg {
  * packet counts
  */
 struct sioc_sg_req6 {
-       struct sockaddr_in6 src;
-       struct sockaddr_in6 grp;
+       struct bsd_sockaddr_in6 src;
+       struct bsd_sockaddr_in6 grp;
        u_quad_t pktcnt;
        u_quad_t bytecnt;
        u_quad_t wrong_if;
@@ -222,8 +222,8 @@ struct mif6 {
  * The kernel's multicast forwarding cache entry structure
  */
 struct mf6c {
-       struct sockaddr_in6  mf6c_origin;       /* IPv6 origin of mcasts     */
-       struct sockaddr_in6  mf6c_mcastgrp;     /* multicast group associated*/
+       struct bsd_sockaddr_in6  mf6c_origin;   /* IPv6 origin of mcasts     */
+       struct bsd_sockaddr_in6  mf6c_mcastgrp; /* multicast group associated*/
        mifi_t           mf6c_parent;           /* incoming IF               */
        struct if_set    mf6c_ifset;            /* set of outgoing IFs */
 
diff --git a/bsd/sys/netinet6/ip6_var.h b/bsd/sys/netinet6/ip6_var.h
index 5e44c87..b2f9178 100644
--- a/bsd/sys/netinet6/ip6_var.h
+++ b/bsd/sys/netinet6/ip6_var.h
@@ -127,7 +127,7 @@ struct      ip6po_rhinfo {
 
 /* Nexthop related info */
 struct ip6po_nhinfo {
-       struct  sockaddr *ip6po_nhi_nexthop;
+       struct  bsd_sockaddr *ip6po_nhi_nexthop;
        struct  route_in6 ip6po_nhi_route; /* Route to the nexthop */
 };
 #define ip6po_nexthop  ip6po_nhinfo.ip6po_nhi_nexthop
@@ -402,13 +402,12 @@ int       ip6_process_hopopts(struct mbuf *, u_int8_t *, 
int, u_int32_t *,
 struct mbuf    **ip6_savecontrol_v4(struct inpcb *, struct mbuf *,
            struct mbuf **, int *);
 void   ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **);
-void   ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *,
-                            u_int32_t *);
+void   ip6_notify_pmtu(struct inpcb *, struct bsd_sockaddr_in6 *, u_int32_t *);
 int    ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 
 void   ip6_forward(struct mbuf *, int);
 
-void   ip6_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in6 *);
+void   ip6_mloopback(struct ifnet *, struct mbuf *, struct bsd_sockaddr_in6 *);
 int    ip6_output(struct mbuf *, struct ip6_pktopts *,
                        struct route_in6 *,
                        int,
@@ -432,7 +431,7 @@ void        frag6_drain(void);
 
 void   rip6_init(void);
 int    rip6_input(struct mbuf **, int *, int);
-void   rip6_ctlinput(int, struct sockaddr *, void *);
+void   rip6_ctlinput(int, struct bsd_sockaddr *, void *);
 int    rip6_ctloutput(struct socket *, struct sockopt *);
 int    rip6_output(struct mbuf *, ...);
 int    rip6_usrreq(struct socket *,
@@ -441,13 +440,13 @@ int       rip6_usrreq(struct socket *,
 int    dest6_input(struct mbuf **, int *, int);
 int    none_input(struct mbuf **, int *, int);
 
-int    in6_selectsrc(struct sockaddr_in6 *, struct ip6_pktopts *,
+int    in6_selectsrc(struct bsd_sockaddr_in6 *, struct ip6_pktopts *,
        struct inpcb *inp, struct route_in6 *, struct ucred *cred,
        struct ifnet **, struct in6_addr *);
-int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
+int in6_selectroute(struct bsd_sockaddr_in6 *, struct ip6_pktopts *,
        struct ip6_moptions *, struct route_in6 *, struct ifnet **,
        struct rtentry **);
-int    in6_selectroute_fib(struct sockaddr_in6 *, struct ip6_pktopts *,
+int    in6_selectroute_fib(struct bsd_sockaddr_in6 *, struct ip6_pktopts *,
            struct ip6_moptions *, struct route_in6 *, struct ifnet **,
            struct rtentry **, u_int);
 u_int32_t ip6_randomid(void);
diff --git a/bsd/sys/netinet6/ip6protosw.h b/bsd/sys/netinet6/ip6protosw.h
index 2924835..3b2c34b 100644
--- a/bsd/sys/netinet6/ip6protosw.h
+++ b/bsd/sys/netinet6/ip6protosw.h
@@ -71,7 +71,7 @@
  */
 
 struct mbuf;
-struct sockaddr;
+struct bsd_sockaddr;
 struct socket;
 struct domain;
 struct thread;
@@ -103,8 +103,8 @@ struct ip6ctlparam {
        struct icmp6_hdr *ip6c_icmp6;   /* icmp6 header of target packet */
        struct ip6_hdr *ip6c_ip6;       /* ip6 header of target packet */
        int ip6c_off;                   /* offset of the target proto header */
-       struct sockaddr_in6 *ip6c_src;  /* srcaddr w/ additional info */
-       struct sockaddr_in6 *ip6c_dst;  /* (final) dstaddr w/ additional info */
+       struct bsd_sockaddr_in6 *ip6c_src;      /* srcaddr w/ additional info */
+       struct bsd_sockaddr_in6 *ip6c_dst;      /* (final) dstaddr w/ 
additional info */
        struct in6_addr *ip6c_finaldst; /* final destination address */
        void *ip6c_cmdarg;              /* control command dependent data */
        u_int8_t ip6c_nxt;              /* final next header field */
@@ -122,7 +122,7 @@ struct ip6protosw {
        int     (*pr_output)            /* output to protocol (from above) */
                        (struct mbuf *, ...);
        void    (*pr_ctlinput)          /* control input (from below) */
-                       (int, struct sockaddr *, void *);
+                       (int, struct bsd_sockaddr *, void *);
        int     (*pr_ctloutput)         /* control output (from above) */
                        (struct socket *, struct sockopt *);
 
diff --git a/bsd/sys/netinet6/mld6.h b/bsd/sys/netinet6/mld6.h
index 415cf5c..0d7f3f1 100644
--- a/bsd/sys/netinet6/mld6.h
+++ b/bsd/sys/netinet6/mld6.h
@@ -109,4 +109,11 @@ struct mldv2_record {
  */
 #define MLD_TIMER_SCALE                        1000
 
+__BEGIN_DECLS
+
+extern void mld_init(void *);
+extern void vnet_mld_init(const void *);
+
+__END_DECLS
+
 #endif /* _NETINET6_MLD6_H_ */
diff --git a/bsd/sys/netinet6/nd6.h b/bsd/sys/netinet6/nd6.h
index a40caab..5708e85 100644
--- a/bsd/sys/netinet6/nd6.h
+++ b/bsd/sys/netinet6/nd6.h
@@ -38,8 +38,10 @@
 #define RTF_ANNOUNCE   RTF_PROTO2
 #endif
 
-#include <sys/queue.h>
-#include <sys/callout.h>
+#include <bsd/sys/sys/queue.h>
+#include <bsd/sys/netinet6/in6.h>
+#include <bsd/sys/netinet6/in6_var.h>
+#include <bsd/porting/callout.h>
 
 struct llentry;
 
@@ -103,7 +105,7 @@ struct nd_ifinfo {
 
 struct in6_nbrinfo {
        char ifname[IFNAMSIZ];  /* if name, e.g. "en0" */
-       struct in6_addr addr;   /* IPv6 address of the neighbor */
+       struct  in6_addr addr;  /* IPv6 address of the neighbor */
        long    asked;          /* number of queries already sent for this addr 
*/
        int     isrouter;       /* if it acts as a router */
        int     state;          /* reachability state */
@@ -124,7 +126,7 @@ struct      in6_drlist {
 };
 
 struct in6_defrouter {
-       struct  sockaddr_in6 rtaddr;
+       struct  bsd_sockaddr_in6 rtaddr;
        u_char  flags;
        u_short rtlifetime;
        u_long  expire;
@@ -166,7 +168,7 @@ struct      in6_prlist {
 };
 
 struct in6_prefix {
-       struct  sockaddr_in6 prefix;
+       struct  bsd_sockaddr_in6 prefix;
        struct prf_ra raflags;
        u_char  prefixlen;
        u_char  origin;
@@ -177,7 +179,7 @@ struct in6_prefix {
        int refcnt;
        u_short if_index;
        u_short advrtrs; /* number of advertisement routers */
-       /* struct sockaddr_in6 advrtr[] */
+       /* struct bsd_sockaddr_in6 advrtr[] */
 };
 
 #ifdef _KERNEL
@@ -248,7 +250,7 @@ struct nd_prefixctl {
        struct ifnet *ndpr_ifp;
 
        /* prefix */
-       struct sockaddr_in6 ndpr_prefix;
+       struct bsd_sockaddr_in6 ndpr_prefix;
        u_char  ndpr_plen;
 
        u_int32_t ndpr_vltime;  /* advertised valid lifetime */
@@ -261,7 +263,7 @@ struct nd_prefixctl {
 struct nd_prefix {
        struct ifnet *ndpr_ifp;
        LIST_ENTRY(nd_prefix) ndpr_entry;
-       struct sockaddr_in6 ndpr_prefix;        /* prefix */
+       struct bsd_sockaddr_in6 ndpr_prefix;    /* prefix */
        struct in6_addr ndpr_mask; /* netmask derived from the prefix */
 
        u_int32_t ndpr_vltime;  /* advertised valid lifetime */
@@ -341,7 +343,7 @@ VNET_DECLARE(int, nd6_onlink_ns_rfc4861);
 #define        V_nd6_debug                     VNET(nd6_debug)
 #define        V_nd6_onlink_ns_rfc4861         VNET(nd6_onlink_ns_rfc4861)
 
-#define nd6log(x)      do { if (V_nd6_debug) log x; } while (/*CONSTCOND*/ 0)
+#define nd6log(x)      do { if (V_nd6_debug) bsd_log x; } while (/*CONSTCOND*/ 
0)
 
 VNET_DECLARE(struct callout, nd6_timer_ch);
 #define        V_nd6_timer_ch                  VNET(nd6_timer_ch)
@@ -391,7 +393,7 @@ void nd6_destroy(void);
 #endif
 struct nd_ifinfo *nd6_ifattach(struct ifnet *);
 void nd6_ifdetach(struct nd_ifinfo *);
-int nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *);
+int nd6_is_addr_neighbor(struct bsd_sockaddr_in6 *, struct ifnet *);
 void nd6_option_init(void *, int, union nd_opts *);
 struct nd_opt_hdr *nd6_option(union nd_opts *);
 int nd6_options(union nd_opts *);
@@ -409,27 +411,27 @@ int nd6_ioctl(u_long, caddr_t, struct ifnet *);
 struct llentry *nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
        char *, int, int, int);
 int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
-       struct sockaddr_in6 *, struct rtentry *);
+       struct bsd_sockaddr_in6 *, struct rtentry *);
 int nd6_output_lle(struct ifnet *, struct ifnet *, struct mbuf *,
-       struct sockaddr_in6 *, struct rtentry *, struct llentry *,
+       struct bsd_sockaddr_in6 *, struct rtentry *, struct llentry *,
        struct mbuf **);
 int nd6_output_flush(struct ifnet *, struct ifnet *, struct mbuf *,
-       struct sockaddr_in6 *, struct route *);
+       struct bsd_sockaddr_in6 *, struct route *);
 int nd6_need_cache(struct ifnet *);
 int nd6_storelladdr(struct ifnet *, struct mbuf *,
-       struct sockaddr *, u_char *, struct llentry **);
+       struct bsd_sockaddr *, u_char *, struct llentry **);
 
 /* nd6_nbr.c */
 void nd6_na_input(struct mbuf *, int, int);
 void nd6_na_output(struct ifnet *, const struct in6_addr *,
-       const struct in6_addr *, u_long, int, struct sockaddr *);
+       const struct in6_addr *, u_long, int, struct bsd_sockaddr *);
 void nd6_ns_input(struct mbuf *, int, int);
 void nd6_ns_output(struct ifnet *, const struct in6_addr *,
        const struct in6_addr *, struct llentry *, int);
 caddr_t nd6_ifptomac(struct ifnet *);
-void nd6_dad_start(struct ifaddr *, int);
-void nd6_dad_stop(struct ifaddr *);
-void nd6_dad_duplicated(struct ifaddr *);
+void nd6_dad_start(struct bsd_ifaddr *, int);
+void nd6_dad_stop(struct bsd_ifaddr *);
+void nd6_dad_duplicated(struct bsd_ifaddr *);
 
 /* nd6_rtr.c */
 void nd6_rs_input(struct mbuf *, int, int);
diff --git a/bsd/sys/netinet6/scope6_var.h b/bsd/sys/netinet6/scope6_var.h
index 08402ed..c29526d 100644
--- a/bsd/sys/netinet6/scope6_var.h
+++ b/bsd/sys/netinet6/scope6_var.h
@@ -50,8 +50,8 @@ int   scope6_get(struct ifnet *, struct scope6_id *);
 void   scope6_setdefault(struct ifnet *);
 int    scope6_get_default(struct scope6_id *);
 u_int32_t scope6_addr2default(struct in6_addr *);
-int    sa6_embedscope(struct sockaddr_in6 *, int);
-int    sa6_recoverscope(struct sockaddr_in6 *);
+int    sa6_embedscope(struct bsd_sockaddr_in6 *, int);
+int    sa6_recoverscope(struct bsd_sockaddr_in6 *);
 int    in6_setscope(struct in6_addr *, struct ifnet *, u_int32_t *);
 int    in6_clearscope(struct in6_addr *);
 uint16_t in6_getscope(struct in6_addr *);
diff --git a/bsd/sys/netinet6/send.h b/bsd/sys/netinet6/send.h
index 23dc7ab..ab13478 100644
--- a/bsd/sys/netinet6/send.h
+++ b/bsd/sys/netinet6/send.h
@@ -34,7 +34,7 @@
 
 struct sockaddr_send {
        uint8_t                 send_len;       /* total length */
-       sa_family_t             send_family;    /* address family */
+       bsd_sa_family_t         send_family;    /* address family */
        int                     send_direction;
        int                     send_ifidx;
        char                    send_zero[8];
diff --git a/bsd/sys/netinet6/tcp6_var.h b/bsd/sys/netinet6/tcp6_var.h
index 0ea572e..c12ded1 100644
--- a/bsd/sys/netinet6/tcp6_var.h
+++ b/bsd/sys/netinet6/tcp6_var.h
@@ -71,7 +71,7 @@ VNET_DECLARE(int, tcp_v6mssdflt);     /* XXX */
 #endif
 
 struct ip6_hdr;
-void   tcp6_ctlinput(int, struct sockaddr *, void *);
+void   tcp6_ctlinput(int, struct bsd_sockaddr *, void *);
 void   tcp6_init(void);
 int    tcp6_input(struct mbuf **, int *, int);
 struct rtentry *tcp_rtlookup6(struct in_conninfo *);
diff --git a/bsd/sys/netinet6/udp6_var.h b/bsd/sys/netinet6/udp6_var.h
index e1549e2..721d257 100644
--- a/bsd/sys/netinet6/udp6_var.h
+++ b/bsd/sys/netinet6/udp6_var.h
@@ -68,7 +68,7 @@ SYSCTL_DECL(_net_inet6_udp6);
 
 extern struct pr_usrreqs       udp6_usrreqs;
 
-void   udp6_ctlinput(int, struct sockaddr *, void *);
+void   udp6_ctlinput(int, struct bsd_sockaddr *, void *);
 int    udp6_input(struct mbuf **, int *, int);
 #endif
 
diff --git a/include/api/netinet/__icmp6.h b/include/api/netinet/__icmp6.h
new file mode 100644
index 0000000..f2ec2c9
--- /dev/null
+++ b/include/api/netinet/__icmp6.h
@@ -0,0 +1,11 @@
+#ifndef OSV__ICMP6_H_
+#define OSV__ICMP6_H_
+
+#define ICMP6_FILTER 1
+
+#define ICMP6_FILTER_BLOCK              1
+#define ICMP6_FILTER_PASS               2
+#define ICMP6_FILTER_BLOCKOTHERS        3
+#define ICMP6_FILTER_PASSONLY           4
+
+#endif /* OSV__ICMP6_H_ */
diff --git a/include/api/netinet6/__in6.h b/include/api/netinet6/__in6.h
new file mode 100644
index 0000000..fc4e3f3
--- /dev/null
+++ b/include/api/netinet6/__in6.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018 Cloudius Systems, Ltd.
+ *
+ * This work is open source software, licensed under the terms of the
+ * BSD license as described in the LICENSE file in the top-level directory.
+ */
+
+#ifndef OSV__IN6_H_
+#define OSV__IN6_H_
+
+
+#define IPV6_ADDRFORM           1
+#define IPV6_2292PKTINFO        2
+#define IPV6_2292HOPOPTS        3
+#define IPV6_2292DSTOPTS        4
+#define IPV6_2292RTHDR          5
+#define IPV6_2292PKTOPTIONS     6
+#define IPV6_CHECKSUM           7
+#define IPV6_2292HOPLIMIT       8
+#define SCM_SRCRT               IPV6_RXSRCRT
+#define IPV6_NEXTHOP            9
+#define IPV6_AUTHHDR            10
+#define IPV6_UNICAST_HOPS       16
+#define IPV6_MULTICAST_IF       17
+#define IPV6_MULTICAST_HOPS     18
+#define IPV6_MULTICAST_LOOP     19
+#define IPV6_JOIN_GROUP         20
+#define IPV6_LEAVE_GROUP        21
+#define IPV6_ROUTER_ALERT       22
+#define IPV6_MTU_DISCOVER       23
+#define IPV6_MTU                24
+#define IPV6_RECVERR            25
+#define IPV6_V6ONLY             26
+#define IPV6_JOIN_ANYCAST       27
+#define IPV6_LEAVE_ANYCAST      28
+#define IPV6_IPSEC_POLICY       34
+#define IPV6_XFRM_POLICY        35
+
+#define IPV6_RECVPKTINFO        49
+#define IPV6_PKTINFO            50
+#define IPV6_RECVHOPLIMIT       51
+#define IPV6_HOPLIMIT           52
+#define IPV6_RECVHOPOPTS        53
+#define IPV6_HOPOPTS            54
+#define IPV6_RTHDRDSTOPTS       55
+#define IPV6_RECVRTHDR          56
+#define IPV6_RTHDR              57
+#define IPV6_RECVDSTOPTS        58
+#define IPV6_DSTOPTS            59
+#define IPV6_DSTOPTS            59
+#define IPV6_RECVPATHMTU        60
+#define IPV6_PATHMTU            61
+#define IPV6_DONTFRAG           62
+#define IPV6_USE_MIN_MTU        63
+
+#define IPV6_RECVTCLASS         66
+#define IPV6_TCLASS             67
+
+#define IPV6_AUTOFLOWLABEL      70
+#define IPV6_ADDR_PREFERENCES   72
+
+#define IPV6_ADD_MEMBERSHIP     IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP    IPV6_LEAVE_GROUP
+#define IPV6_RXHOPOPTS          IPV6_HOPOPTS
+#define IPV6_RXDSTOPTS          IPV6_DSTOPTS
+
+/* This range is used for FreeBSD options which are not linux compatible */
+#define IPV6_XOPTS_START        100
+
+#endif
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to