version 1.98.2.4, 2007/07/02 13:46:08 |
version 1.113.8.2, 2008/03/24 07:16:24 |
Line 148 struct pfil_head inet6_pfil_hook; |
|
Line 148 struct pfil_head inet6_pfil_hook; |
|
|
|
struct ip6stat ip6stat; |
struct ip6stat ip6stat; |
|
|
static void ip6_init2 __P((void *)); |
static void ip6_init2(void *); |
static struct m_tag *ip6_setdstifaddr __P((struct mbuf *, struct in6_ifaddr *)); |
static struct m_tag *ip6_setdstifaddr(struct mbuf *, const struct in6_ifaddr *); |
|
|
static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *)); |
static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); |
static struct mbuf *ip6_pullexthdr __P((struct mbuf *, size_t, int)); |
static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); |
|
|
/* |
/* |
* IP6 initialization: fill in IP6 protocol switch table. |
* IP6 initialization: fill in IP6 protocol switch table. |
* All protocols not implemented in kernel go to raw IP6 protocol handler. |
* All protocols not implemented in kernel go to raw IP6 protocol handler. |
*/ |
*/ |
void |
void |
ip6_init() |
ip6_init(void) |
{ |
{ |
const struct ip6protosw *pr; |
const struct ip6protosw *pr; |
int i; |
int i; |
Line 217 ip6_init2(void *dummy) |
|
Line 217 ip6_init2(void *dummy) |
|
* IP6 input interrupt handling. Just pass the packet to ip6_input. |
* IP6 input interrupt handling. Just pass the packet to ip6_input. |
*/ |
*/ |
void |
void |
ip6intr() |
ip6intr(void) |
{ |
{ |
int s; |
int s; |
struct mbuf *m; |
struct mbuf *m; |
Line 490 ip6_input(struct mbuf *m) |
|
Line 490 ip6_input(struct mbuf *m) |
|
else |
else |
ip6stat.ip6s_forward_cachemiss++; |
ip6stat.ip6s_forward_cachemiss++; |
|
|
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) |
#define rt6_getkey(__rt) satocsin6(rt_getkey(__rt)) |
|
|
/* |
/* |
* Accept the packet if the forwarding interface to the destination |
* Accept the packet if the forwarding interface to the destination |
Line 510 ip6_input(struct mbuf *m) |
|
Line 510 ip6_input(struct mbuf *m) |
|
* the destination and the key of the rtentry has |
* the destination and the key of the rtentry has |
* already done through looking up the routing table. |
* already done through looking up the routing table. |
*/ |
*/ |
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &rt6_key(rt)->sin6_addr) && |
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &rt6_getkey(rt)->sin6_addr) && |
#endif |
#endif |
rt->rt_ifp->if_type == IFT_LOOP) { |
#ifdef MOBILE_IPV6 |
|
((rt->rt_flags & RTF_ANNOUNCE) || |
|
rt->rt_ifp->if_type == IFT_LOOP) |
|
#else |
|
rt->rt_ifp->if_type == IFT_LOOP |
|
#endif /* MOBILE_IPV6 */ |
|
) { |
struct in6_ifaddr *ia6 = (struct in6_ifaddr *)rt->rt_ifa; |
struct in6_ifaddr *ia6 = (struct in6_ifaddr *)rt->rt_ifa; |
if (ia6->ia6_flags & IN6_IFF_ANYCAST) |
if (ia6->ia6_flags & IN6_IFF_ANYCAST) |
m->m_flags |= M_ANYCAST6; |
m->m_flags |= M_ANYCAST6; |
|
#ifdef MOBILE_IPV6 |
|
/* check unicast NS */ |
|
if ((rtcache_validate(&ip6_forward_rt)->rt_flags & RTF_ANNOUNCE) != 0) { |
|
/* This route shows proxy nd. thus the packet was |
|
* captured. this packet should be tunneled to |
|
* actual coa with tunneling unless this is NS. |
|
*/ |
|
int nh, loff; |
|
struct icmp6_hdr *icp; |
|
loff = ip6_lasthdr(m, 0, IPPROTO_IPV6, &nh); |
|
if (loff < 0 || nh != IPPROTO_ICMPV6) |
|
goto mip6_forwarding; |
|
IP6_EXTHDR_GET(icp, struct icmp6_hdr *, m, loff, |
|
sizeof(*icp)); |
|
if (icp == NULL) { |
|
icmp6stat.icp6s_tooshort++; |
|
return; |
|
} |
|
if (icp->icmp6_type != ND_NEIGHBOR_SOLICIT) |
|
goto mip6_forwarding; |
|
} |
|
#endif /* MOBILE_IPV6 */ |
/* |
/* |
* packets to a tentative, duplicated, or somehow invalid |
* packets to a tentative, duplicated, or somehow invalid |
* address must not be accepted. |
* address must not be accepted. |
Line 536 ip6_input(struct mbuf *m) |
|
Line 564 ip6_input(struct mbuf *m) |
|
} |
} |
} |
} |
|
|
|
#ifdef MOBILE_IPV6 |
|
mip6_forwarding: |
|
#endif /* MOBILE_IPV6 */ |
|
|
/* |
/* |
* FAITH (Firewall Aided Internet Translator) |
* FAITH (Firewall Aided Internet Translator) |
*/ |
*/ |
Line 559 ip6_input(struct mbuf *m) |
|
Line 591 ip6_input(struct mbuf *m) |
|
* working right. |
* working right. |
*/ |
*/ |
struct ifaddr *ifa; |
struct ifaddr *ifa; |
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { |
IFADDR_FOREACH(ifa, m->m_pkthdr.rcvif) { |
if (ifa->ifa_addr == NULL) |
if (ifa->ifa_addr == NULL) |
continue; /* just for safety */ |
continue; /* just for safety */ |
if (ifa->ifa_addr->sa_family != AF_INET6) |
if (ifa->ifa_addr->sa_family != AF_INET6) |
Line 590 ip6_input(struct mbuf *m) |
|
Line 622 ip6_input(struct mbuf *m) |
|
* as our interface address (e.g. multicast addresses, addresses |
* as our interface address (e.g. multicast addresses, addresses |
* within FAITH prefixes and such). |
* within FAITH prefixes and such). |
*/ |
*/ |
if (deliverifp && !ip6_getdstifaddr(m)) { |
if (deliverifp && ip6_getdstifaddr(m) == NULL) { |
struct in6_ifaddr *ia6; |
struct in6_ifaddr *ia6; |
|
|
ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst); |
ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst); |
if (ia6) { |
if (ia6 != NULL && ip6_setdstifaddr(m, ia6) == NULL) { |
if (!ip6_setdstifaddr(m, ia6)) { |
/* |
/* |
* XXX maybe we should drop the packet here, |
* XXX maybe we should drop the packet here, |
* as we could not provide enough information |
* as we could not provide enough information |
* to the upper layers. |
* to the upper layers. |
*/ |
*/ |
|
} |
|
} |
} |
} |
} |
|
|
Line 810 ip6_input(struct mbuf *m) |
|
Line 840 ip6_input(struct mbuf *m) |
|
/* XXX error stat??? */ |
/* XXX error stat??? */ |
error = EINVAL; |
error = EINVAL; |
DPRINTF(("ip6_input: no SP, packet discarded\n"));/*XXX*/ |
DPRINTF(("ip6_input: no SP, packet discarded\n"));/*XXX*/ |
goto bad; |
|
} |
} |
splx(s); |
splx(s); |
if (error) |
if (error) |
Line 818 ip6_input(struct mbuf *m) |
|
Line 847 ip6_input(struct mbuf *m) |
|
} |
} |
#endif /* FAST_IPSEC */ |
#endif /* FAST_IPSEC */ |
|
|
|
if (dest6_mip6_hao(m, off, nxt) < 0) |
|
goto bad; |
|
|
nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt); |
nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt); |
} |
} |
Line 830 ip6_input(struct mbuf *m) |
|
Line 861 ip6_input(struct mbuf *m) |
|
* set/grab in6_ifaddr correspond to IPv6 destination address. |
* set/grab in6_ifaddr correspond to IPv6 destination address. |
*/ |
*/ |
static struct m_tag * |
static struct m_tag * |
ip6_setdstifaddr(struct mbuf *m, struct in6_ifaddr *ia6) |
ip6_setdstifaddr(struct mbuf *m, const struct in6_ifaddr *ia) |
{ |
{ |
struct m_tag *mtag; |
struct m_tag *mtag; |
|
|
mtag = ip6_addaux(m); |
mtag = ip6_addaux(m); |
if (mtag) |
if (mtag != NULL) { |
((struct ip6aux *)(mtag + 1))->ip6a_dstia6 = ia6; |
struct ip6aux *ip6a; |
|
|
|
ip6a = (struct ip6aux *)(mtag + 1); |
|
in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_src_scope_id); |
|
ip6a->ip6a_src = ia->ia_addr.sin6_addr; |
|
ip6a->ip6a_src_flags = ia->ia6_flags; |
|
} |
return mtag; /* NULL if failed to set */ |
return mtag; /* NULL if failed to set */ |
} |
} |
|
|
struct in6_ifaddr * |
const struct ip6aux * |
ip6_getdstifaddr(struct mbuf *m) |
ip6_getdstifaddr(struct mbuf *m) |
{ |
{ |
struct m_tag *mtag; |
struct m_tag *mtag; |
|
|
mtag = ip6_findaux(m); |
mtag = ip6_findaux(m); |
if (mtag) |
if (mtag != NULL) |
return ((struct ip6aux *)(mtag + 1))->ip6a_dstia6; |
return (struct ip6aux *)(mtag + 1); |
else |
else |
return NULL; |
return NULL; |
} |
} |