/*
- * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
}
void
-esp4_input(m, off)
- struct mbuf *m;
- int off;
+esp4_input(struct mbuf *m, int off)
{
struct ip *ip;
#if INET6
esp = (struct esp *)(void *)(((u_int8_t *)ip) + off);
}
- if (sav->utun_is_keepalive_fn) {
- if (sav->utun_is_keepalive_fn(sav->utun_pcb, &m, nxt, sav->flags, (off + esplen + ivlen))) {
- if (m) {
- // not really bad, we just wanna exit
- IPSEC_STAT_INCREMENT(ipsecstat.in_success);
- m = NULL;
- }
- goto bad;
- }
- }
-
/* was it transmitted over the IPsec tunnel SA? */
if (ipsec4_tunnel_validate(m, off + esplen + ivlen, nxt, sav, &ifamily)) {
ifaddr_t ifa;
goto bad;
}
- if (ip_doscopedroute) {
- bzero(&addr, sizeof(addr));
- ipaddr = (__typeof__(ipaddr))&addr;
- ipaddr->sin_family = AF_INET;
- ipaddr->sin_len = sizeof(*ipaddr);
- ipaddr->sin_addr = ip->ip_dst;
- }
+ bzero(&addr, sizeof(addr));
+ ipaddr = (__typeof__(ipaddr))&addr;
+ ipaddr->sin_family = AF_INET;
+ ipaddr->sin_len = sizeof(*ipaddr);
+ ipaddr->sin_addr = ip->ip_dst;
#if INET6
} else if (ifamily == AF_INET6) {
struct sockaddr_in6 *ip6addr;
goto bad;
}
- if (ip6_doscopedroute) {
- bzero(&addr, sizeof(addr));
- ip6addr = (__typeof__(ip6addr))&addr;
- ip6addr->sin6_family = AF_INET6;
- ip6addr->sin6_len = sizeof(*ip6addr);
- ip6addr->sin6_addr = ip6->ip6_dst;
- }
+ bzero(&addr, sizeof(addr));
+ ip6addr = (__typeof__(ip6addr))&addr;
+ ip6addr->sin6_family = AF_INET6;
+ ip6addr->sin6_len = sizeof(*ip6addr);
+ ip6addr->sin6_addr = ip6->ip6_dst;
#endif /* INET6 */
} else {
ipseclog((LOG_ERR, "ipsec tunnel unsupported address family "
goto bad;
}
- if (ip_doscopedroute || ip6_doscopedroute) {
- // update the receiving interface address based on the inner address
- ifa = ifa_ifwithaddr((struct sockaddr *)&addr);
- if (ifa) {
- m->m_pkthdr.rcvif = ifa->ifa_ifp;
- IFA_REMREF(ifa);
- }
+ // update the receiving interface address based on the inner address
+ ifa = ifa_ifwithaddr((struct sockaddr *)&addr);
+ if (ifa) {
+ m->m_pkthdr.rcvif = ifa->ifa_ifp;
+ IFA_REMREF(ifa);
}
/* Clear the csum flags, they can't be valid for the inner headers */
}
}
- if (sav->utun_in_fn) {
- if (!(sav->utun_in_fn(sav->utun_pcb, &m, ifamily == AF_INET ? PF_INET : PF_INET6))) {
- m = NULL;
- // we just wanna exit since packet has been completely processed
- goto bad;
- }
- }
-
if (proto_input(ifamily == AF_INET ? PF_INET : PF_INET6, m) != 0)
goto bad;
}
}
- if (sav->utun_in_fn) {
- if (!(sav->utun_in_fn(sav->utun_pcb, &m, PF_INET))) {
- m = NULL;
- // we just wanna exit since packet has been completely processed
- goto bad;
- }
- }
-
ip_proto_dispatch_in(m, off, nxt, 0);
} else
m_freem(m);
ip6 = mtod(m, struct ip6_hdr *);
ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - taillen);
- if (sav->utun_is_keepalive_fn) {
- if (sav->utun_is_keepalive_fn(sav->utun_pcb, &m, nxt, sav->flags, (off + esplen + ivlen))) {
- if (m) {
- // not really bad, we just wanna exit
- IPSEC_STAT_INCREMENT(ipsec6stat.in_success);
- m = NULL;
- }
- goto bad;
- }
- }
-
if (*nproto == IPPROTO_UDP) {
// offset includes the outer ip and udp header lengths.
if (m->m_len < off) {
flowinfo = ip6->ip6_flow;
m_adj(m, off + esplen + ivlen);
if (ifamily == AF_INET6) {
+ struct sockaddr_in6 *ip6addr;
+
if (m->m_len < sizeof(*ip6)) {
#ifndef PULLDOWN_TEST
/*
goto bad;
}
- if (ip6_doscopedroute) {
- struct sockaddr_in6 *ip6addr;
-
- bzero(&addr, sizeof(addr));
- ip6addr = (__typeof__(ip6addr))&addr;
- ip6addr->sin6_family = AF_INET6;
- ip6addr->sin6_len = sizeof(*ip6addr);
- ip6addr->sin6_addr = ip6->ip6_dst;
- }
+ bzero(&addr, sizeof(addr));
+ ip6addr = (__typeof__(ip6addr))&addr;
+ ip6addr->sin6_family = AF_INET6;
+ ip6addr->sin6_len = sizeof(*ip6addr);
+ ip6addr->sin6_addr = ip6->ip6_dst;
} else if (ifamily == AF_INET) {
struct sockaddr_in *ipaddr;
goto bad;
}
- if (ip_doscopedroute) {
- bzero(&addr, sizeof(addr));
- ipaddr = (__typeof__(ipaddr))&addr;
- ipaddr->sin_family = AF_INET;
- ipaddr->sin_len = sizeof(*ipaddr);
- ipaddr->sin_addr = ip->ip_dst;
- }
+ bzero(&addr, sizeof(addr));
+ ipaddr = (__typeof__(ipaddr))&addr;
+ ipaddr->sin_family = AF_INET;
+ ipaddr->sin_len = sizeof(*ipaddr);
+ ipaddr->sin_addr = ip->ip_dst;
}
key_sa_recordxfer(sav, m);
goto bad;
}
- if (ip_doscopedroute || ip6_doscopedroute) {
- // update the receiving interface address based on the inner address
- ifa = ifa_ifwithaddr((struct sockaddr *)&addr);
- if (ifa) {
- m->m_pkthdr.rcvif = ifa->ifa_ifp;
- IFA_REMREF(ifa);
- }
+ // update the receiving interface address based on the inner address
+ ifa = ifa_ifwithaddr((struct sockaddr *)&addr);
+ if (ifa) {
+ m->m_pkthdr.rcvif = ifa->ifa_ifp;
+ IFA_REMREF(ifa);
}
// Input via IPSec interface
}
}
- if (sav->utun_in_fn) {
- if (!(sav->utun_in_fn(sav->utun_pcb, &m, PF_INET6))) {
- m = NULL;
- // we just wanna exit since packet has been completely processed
- goto bad;
- }
- }
-
if (proto_input(ifamily == AF_INET ? PF_INET : PF_INET6, m) != 0)
goto bad;
nxt = IPPROTO_DONE;
}
}
- if (sav->utun_in_fn) {
- if (!(sav->utun_in_fn(sav->utun_pcb, &m, PF_INET6))) {
- m = NULL;
- // we just wanna exit since packet has been completely processed
- goto bad;
- }
- }
}
done:
}
void
-esp6_ctlinput(cmd, sa, d)
- int cmd;
- struct sockaddr *sa;
- void *d;
+esp6_ctlinput(int cmd, struct sockaddr *sa, void *d)
{
const struct newesp *espp;
struct newesp esp;