/*
- * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <security/mac_framework.h>
#endif
-#define GET_V4(x) ((const struct in_addr *)(&(x)->s6_addr16[1]))
+#define GET_V4(x) ((const struct in_addr *)(const void *)(&(x)->s6_addr16[1]))
static lck_grp_t *stf_mtx_grp;
static void in_stf_input(struct mbuf *, int);
static void stfinit(void);
-extern struct domain inetdomain;
-struct protosw in_stf_protosw =
-{ SOCK_RAW, &inetdomain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
- in_stf_input, NULL, NULL, rip_ctloutput,
- NULL,
- NULL, NULL, NULL, NULL,
- NULL,
- &rip_usrreqs,
- NULL, rip_unlock, NULL, {NULL, NULL}, NULL, {0}
+
+static struct protosw in_stf_protosw =
+{
+ .pr_type = SOCK_RAW,
+ .pr_protocol = IPPROTO_IPV6,
+ .pr_flags = PR_ATOMIC|PR_ADDR,
+ .pr_input = in_stf_input,
+ .pr_ctloutput = rip_ctloutput,
+ .pr_usrreqs = &rip_usrreqs,
+ .pr_unlock = rip_unlock,
};
static int stf_encapcheck(const struct mbuf *, int, int, void *);
if (error != 0)
printf("proto_register_plumber failed for AF_INET6 error=%d\n", error);
- sc = _MALLOC(sizeof(struct stf_softc), M_DEVBUF, M_WAITOK);
+ sc = _MALLOC(sizeof(struct stf_softc), M_DEVBUF, M_WAITOK | M_ZERO);
if (sc == 0) {
printf("stf softc attach failed\n" );
return;
}
- bzero(sc, sizeof(*sc));
-
p = encap_attach_func(AF_INET, IPPROTO_IPV6, stf_encapcheck,
&in_stf_protosw, sc);
if (p == NULL) {
IFA_UNLOCK(ia);
continue;
}
- sin6 = (struct sockaddr_in6 *)ia->ifa_addr;
+ sin6 = (struct sockaddr_in6 *)(void *)ia->ifa_addr;
if (!IN6_IS_ADDR_6TO4(&sin6->sin6_addr)) {
IFA_UNLOCK(ia);
continue;
struct ip6_hdr *ip6;
struct in6_ifaddr *ia6;
struct sockaddr_in *dst4;
- struct ip_out_args ipoa = { IFSCOPE_NONE, 0 };
+ struct ip_out_args ipoa =
+ { IFSCOPE_NONE, { 0 }, IPOAF_SELECT_SRCIF, 0 };
errno_t result = 0;
sc = ifnet_softc(ifp);
- dst6 = (const struct sockaddr_in6 *)dst;
+ dst6 = (const struct sockaddr_in6 *)(const void *)dst;
/* just in case */
if ((ifnet_flags(ifp) & IFF_UP) == 0) {
bpf_tap_out(ifp, 0, m, &af, sizeof(af));
}
- M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
+ M_PREPEND(m, sizeof(struct ip), M_DONTWAIT, 1);
if (m && mbuf_len(m) < sizeof(struct ip))
m = m_pullup(m, sizeof(struct ip));
if (m == NULL) {
ip->ip_ttl = ip_stf_ttl;
ip->ip_len = m->m_pkthdr.len; /*host order*/
if (ifp->if_flags & IFF_LINK1)
- ip_ecn_ingress(ECN_ALLOWED, &ip->ip_tos, &tos);
+ ip_ecn_ingress(ECN_NORMAL, &ip->ip_tos, &tos);
else
ip_ecn_ingress(ECN_NOCARE, &ip->ip_tos, &tos);
lck_mtx_lock(&sc->sc_ro_mtx);
- dst4 = (struct sockaddr_in *)&sc->sc_ro.ro_dst;
- if (dst4->sin_family != AF_INET ||
+ dst4 = (struct sockaddr_in *)(void *)&sc->sc_ro.ro_dst;
+ if (ROUTE_UNUSABLE(&sc->sc_ro) || dst4->sin_family != AF_INET ||
bcmp(&dst4->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)) != 0) {
+ ROUTE_RELEASE(&sc->sc_ro);
/* cache route doesn't match: always the case during the first use */
dst4->sin_family = AF_INET;
dst4->sin_len = sizeof(struct sockaddr_in);
bcopy(&ip->ip_dst, &dst4->sin_addr, sizeof(dst4->sin_addr));
- if (sc->sc_ro.ro_rt) {
- rtfree(sc->sc_ro.ro_rt);
- sc->sc_ro.ro_rt = NULL;
- }
}
- result = ip_output_list(m, 0, NULL, &sc->sc_ro, IP_OUTARGS, NULL, &ipoa);
+ result = ip_output(m, NULL, &sc->sc_ro, IP_OUTARGS, NULL, &ipoa);
lck_mtx_unlock(&sc->sc_ro_mtx);
/* Assumption: ip_output will free mbuf on errors */
itos = (ntohl(ip6.ip6_flow) >> 20) & 0xff;
if ((ifnet_flags(ifp) & IFF_LINK1) != 0)
- ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
+ ip_ecn_egress(ECN_NORMAL, &otos, &itos);
else
ip_ecn_egress(ECN_NOCARE, &otos, &itos);
ip6.ip6_flow &= ~htonl(0xff << 20);
error = EAFNOSUPPORT;
break;
}
- sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
+ sin6 = (struct sockaddr_in6 *)(void *)ifa->ifa_addr;
if (IN6_IS_ADDR_6TO4(&sin6->sin6_addr)) {
if ( !(ifnet_flags( ifp ) & IFF_UP) ) {
/* do this only if the interface is not already up */
break;
default:
- error = EINVAL;
+ error = EOPNOTSUPP;
break;
}