version 1.109.6.3, 2008/03/23 02:05:07 |
version 1.110, 2007/09/11 14:18:09 |
|
|
/* ip6_input.c,v 1.109.6.2 2008/01/09 01:57:37 matt Exp */ |
/* $NetBSD$ */ |
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ |
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ |
|
|
/* |
/* |
|
|
*/ |
*/ |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "ip6_input.c,v 1.109.6.2 2008/01/09 01:57:37 matt Exp"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include "opt_inet.h" |
#include "opt_inet.h" |
#include "opt_inet6.h" |
#include "opt_inet6.h" |
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(void *); |
static void ip6_init2 __P((void *)); |
static struct m_tag *ip6_setdstifaddr(struct mbuf *, const struct in6_ifaddr *); |
static struct m_tag *ip6_setdstifaddr __P((struct mbuf *, struct in6_ifaddr *)); |
|
|
static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); |
static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *)); |
static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); |
static struct mbuf *ip6_pullexthdr __P((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(void) |
ip6_init() |
{ |
{ |
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(void) |
ip6intr() |
{ |
{ |
int s; |
int s; |
struct mbuf *m; |
struct mbuf *m; |
Line 559 ip6_input(struct mbuf *m) |
|
Line 559 ip6_input(struct mbuf *m) |
|
* working right. |
* working right. |
*/ |
*/ |
struct ifaddr *ifa; |
struct ifaddr *ifa; |
IFADDR_FOREACH(ifa, m->m_pkthdr.rcvif) { |
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { |
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 590 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) == NULL) { |
if (deliverifp && !ip6_getdstifaddr(m)) { |
struct in6_ifaddr *ia6; |
struct in6_ifaddr *ia6; |
|
|
ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst); |
ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst); |
if (ia6 != NULL && ip6_setdstifaddr(m, ia6) == NULL) { |
if (ia6) { |
/* |
if (!ip6_setdstifaddr(m, ia6)) { |
* XXX maybe we should drop the packet here, |
/* |
* as we could not provide enough information |
* XXX maybe we should drop the packet here, |
* to the upper layers. |
* as we could not provide enough information |
*/ |
* to the upper layers. |
|
*/ |
|
} |
} |
} |
} |
} |
|
|
Line 827 ip6_input(struct mbuf *m) |
|
Line 829 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, const struct in6_ifaddr *ia) |
ip6_setdstifaddr(struct mbuf *m, struct in6_ifaddr *ia6) |
{ |
{ |
struct m_tag *mtag; |
struct m_tag *mtag; |
|
|
mtag = ip6_addaux(m); |
mtag = ip6_addaux(m); |
if (mtag != NULL) { |
if (mtag) |
struct ip6aux *ip6a; |
((struct ip6aux *)(mtag + 1))->ip6a_dstia6 = ia6; |
|
|
ip6a = (struct ip6aux *)(mtag + 1); |
|
in6_setscope(&ip6a->ip6a_src, ia->ia_ifp, &ip6a->ip6a_scope_id); |
|
ip6a->ip6a_src = ia->ia_addr.sin6_addr; |
|
ip6a->ip6a_flags = ia->ia6_flags; |
|
} |
|
return mtag; /* NULL if failed to set */ |
return mtag; /* NULL if failed to set */ |
} |
} |
|
|
const struct ip6aux * |
struct in6_ifaddr * |
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 != NULL) |
if (mtag) |
return (struct ip6aux *)(mtag + 1); |
return ((struct ip6aux *)(mtag + 1))->ip6a_dstia6; |
else |
else |
return NULL; |
return NULL; |
} |
} |