Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- stop using mip6_setpktaddrs.

  • Loading branch information...
commit a746f178496a9d685c5124faec68ed6e03eaf688 1 parent ccf77b3
keiichi authored
View
42 kame/sys/netinet6/mip6.c
@@ -1,4 +1,4 @@
-/* $KAME: mip6.c,v 1.184 2002/11/29 11:46:36 keiichi Exp $ */
+/* $KAME: mip6.c,v 1.185 2002/11/29 12:31:55 keiichi Exp $ */
/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
@@ -173,7 +173,6 @@ struct callout mip6_pfx_ch;
#endif
int mip6_pfx_timer_running = 0;
-#ifdef MIP6_DRAFT18
mip6_nonce_t mip6_nonce[MIP6_NONCE_HISTORY];
mip6_nodekey_t mip6_nodekey[MIP6_NONCE_HISTORY]; /* this is described as 'Kcn' in the spec */
u_int16_t nonce_index; /* the idx value pointed by nonce_head */
@@ -183,7 +182,6 @@ struct callout mip6_nonce_upd_ch = CALLOUT_INITIALIZER;
#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3)
struct callout mip6_nonce_upd_ch;
#endif
-#endif /* MIP6_DRAFT18 */
static int mip6_prefix_list_update_sub(struct hif_softc *,
struct sockaddr_in6 *, struct nd_prefix *, struct nd_defrouter *);
@@ -251,7 +249,6 @@ mip6_init()
LIST_INIT(&mip6_subnet_list);
LIST_INIT(&mip6_unuse_hoa);
-#ifdef MIP6_DRAFT18
/* Initialize nonce, key, and something else for CN */
nonce_head = mip6_nonce;
nonce_index = 0;
@@ -267,7 +264,6 @@ mip6_init()
timeout(mip6_update_nonce_nodekey, (caddr_t)0,
hz * NONCE_UPDATE_PERIOD);
#endif
-#endif /* MIP6_DRAFT18 */
}
/*
@@ -2547,41 +2543,6 @@ mip6_create_addr(addr, ifid, ndpr)
}
}
-/* an ad-hoc supplement function to set full sockaddr src/dst to a packet */
-int
-mip6_setpktaddrs(m)
- struct mbuf *m;
-{
- struct sockaddr_in6 src_sa, dst_sa;
- struct in6_addr *src, *dst;
- struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- int error;
-
- src = &ip6->ip6_src;
- dst = &ip6->ip6_dst;
-
- bzero(&src_sa, sizeof(src_sa));
- bzero(&dst_sa, sizeof(dst_sa));
-
- src_sa.sin6_family = dst_sa.sin6_family = AF_INET6;
- src_sa.sin6_len = dst_sa.sin6_len = sizeof(struct sockaddr_in6);
- src_sa.sin6_addr = *src;
- dst_sa.sin6_addr = *dst;
-
- /* recover scope zone IDs */
- if ((error = in6_recoverscope(&src_sa, src, NULL)) != 0)
- return (error);
- src_sa.sin6_addr = *src; /* XXX */
- if ((error = in6_recoverscope(&dst_sa, dst, NULL)) != 0)
- return (error);
- dst_sa.sin6_addr = *dst; /* XXX */
-
- if (!ip6_setpktaddrs(m, &src_sa, &dst_sa))
- return (ENOBUFS);
- return (0);
-}
-
-#ifdef MIP6_DRAFT18
static void
mip6_create_nonce(nonce)
mip6_nonce_t *nonce;
@@ -2939,4 +2900,3 @@ mip6_hexdump("MN: Auth: ", restlen, data + exclude_offset + exclude_data_len);
mip6_hexdump("MN: Authdata: ", MIP6_AUTHENTICATOR_LEN, result);
#endif
}
-#endif /* MIP6_DRAFT18 */
View
66 kame/sys/netinet6/mip6_icmp6.c
@@ -1,4 +1,4 @@
-/* $KAME: mip6_icmp6.c,v 1.58 2002/11/29 11:46:37 keiichi Exp $ */
+/* $KAME: mip6_icmp6.c,v 1.59 2002/11/29 12:31:56 keiichi Exp $ */
/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
@@ -287,37 +287,41 @@ mip6_icmp6_tunnel_input(m, off, icmp6len)
struct mbuf *n;
struct ip6_hdr *ip6, *otip6, oip6, *nip6;
int otip6off, nxt;
- struct sockaddr_in6 oip6dst;
+ struct sockaddr_in6 *dst_sa, oip6src_sa, oip6dst_sa;
struct icmp6_hdr *icmp6, *nicmp6;
struct mip6_bc *mbc;
int error = 0;
if (!MIP6_IS_HA) {
/*
- * this check is needed only for a node that is acting
- * as a homeagent.
+ * this check is needed only for the node that is
+ * acting as a home agent.
*/
return (0);
}
+ /* get packet addresses. */
+ if (ip6_getpktaddrs(m, NULL, &dst_sa))
+ return (EINVAL);
+
/* check if we have enough icmp payload size. */
if (icmp6len < sizeof(*otip6) + sizeof(oip6)) {
/*
* we don't have enough size of icmp payload. to
* determine that this icmp is against the tunneled
- * ip, we at least have two ip header, one is for
- * tunneling from the home agent to the correspondent
- * node and the other is the original header from the
- * mobile node to the correspondent node.
+ * packet, we at least have two ip header, one is for
+ * tunneling from a home agent to a correspondent node
+ * and the other is a original header from a mobile
+ * node to the correspondent node.
*/
return (0);
}
/*
- * check if this icmp is generated on the way to sending from
- * a home agent to a mobile node by encapsulating the original
- * packet. if so, relay this icmp to the sender of the
- * original packet.
+ * check if this icmp is generated on the way from a home
+ * agent to a mobile node by encapsulating an original packet
+ * which is from a correspondent node to the mobile node. if
+ * so, relay this icmp to the sender of the original packet.
*
* the icmp packet against the encapsulated packet looks like
* as follows.
@@ -365,14 +369,26 @@ mip6_icmp6_tunnel_input(m, off, icmp6len)
return (0);
}
m_copydata(m, otip6off, sizeof(oip6), (caddr_t)&oip6);
- oip6dst.sin6_len = sizeof(oip6dst);
- oip6dst.sin6_family = AF_INET6;
- oip6dst.sin6_addr = oip6.ip6_dst;
- if (in6_addr2zoneid(m->m_pkthdr.rcvif, &oip6dst.sin6_addr,
- &oip6dst.sin6_scope_id))
+ /* create a src addr of the original packet. */
+ oip6src_sa.sin6_len = sizeof(oip6src_sa);
+ oip6src_sa.sin6_family = AF_INET6;
+ oip6src_sa.sin6_addr = oip6.ip6_src;
+ if (in6_addr2zoneid(m->m_pkthdr.rcvif, &oip6src_sa.sin6_addr,
+ &oip6src_sa.sin6_scope_id))
+ return (0); /* XXX */
+ if (in6_embedscope(&oip6src_sa.sin6_addr, &oip6src_sa))
+ return (0); /* XXX */
+ /* create a dst addr of the original packet. */
+ oip6dst_sa.sin6_len = sizeof(oip6dst_sa);
+ oip6dst_sa.sin6_family = AF_INET6;
+ oip6dst_sa.sin6_addr = oip6.ip6_dst;
+ if (in6_addr2zoneid(m->m_pkthdr.rcvif, &oip6dst_sa.sin6_addr,
+ &oip6dst_sa.sin6_scope_id))
+ return (0); /* XXX */
+ if (in6_embedscope(&oip6dst_sa.sin6_addr, &oip6dst_sa))
return (0); /* XXX */
- mbc = mip6_bc_list_find_withphaddr(&mip6_bc_list, &oip6dst);
+ mbc = mip6_bc_list_find_withphaddr(&mip6_bc_list, &oip6dst_sa);
if (mbc == NULL) {
/* we are not a home agent of this mobile node ?? */
return (0);
@@ -396,6 +412,10 @@ mip6_icmp6_tunnel_input(m, off, icmp6len)
/* continue. */
return (0);
}
+ if (!ip6_setpktaddrs(n, dst_sa, &oip6src_sa)) {
+ m_freem(n);
+ return (0);
+ }
/* fill the ip6_hdr. */
nip6 = mtod(n, struct ip6_hdr *);
nip6->ip6_flow = 0;
@@ -404,8 +424,10 @@ mip6_icmp6_tunnel_input(m, off, icmp6len)
nip6->ip6_plen = htons(n->m_pkthdr.len - sizeof(struct ip6_hdr));
nip6->ip6_nxt = IPPROTO_ICMPV6;
nip6->ip6_hlim = ip6_defhlim;
- nip6->ip6_src = ip6->ip6_dst;
- nip6->ip6_dst = oip6.ip6_src;
+ nip6->ip6_src = dst_sa->sin6_addr;
+ in6_clearscope(&nip6->ip6_src);
+ nip6->ip6_dst = oip6src_sa.sin6_addr;
+ in6_clearscope(&nip6->ip6_dst);
/* fill the icmp6_hdr. */
nicmp6 = (struct icmp6_hdr *)(nip6 + 1);
@@ -422,10 +444,6 @@ mip6_icmp6_tunnel_input(m, off, icmp6len)
/* XXX IPSEC? */
- if ((error = mip6_setpktaddrs(n)) != 0) { /* XXX */
- m_freem(n);
- return (0);
- }
error = ip6_output(n, NULL, NULL, 0, NULL, NULL);
if (error) {
mip6log((LOG_ERR,
View
5 kame/sys/netinet6/mip6_var.h
@@ -1,4 +1,4 @@
-/* $KAME: mip6_var.h,v 1.73 2002/11/29 11:46:37 keiichi Exp $ */
+/* $KAME: mip6_var.h,v 1.74 2002/11/29 12:31:56 keiichi Exp $ */
/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
@@ -377,9 +377,7 @@ struct encaptab;
extern struct mip6_config mip6_config;
extern struct mip6_ha_list mip6_ha_list; /* Global val holding all HAs */
-#ifdef MIP6_DRAFT18
extern u_int16_t nonce_index; /* Current noce index */
-#endif /* MIP6_DRAFT18 */
extern struct mip6stat mip6stat; /* statistics */
void mip6_init(void);
@@ -557,7 +555,6 @@ int mip6_dad_duplicated(struct ifaddr *);
int mip6_dad_error(struct ifaddr *, int);
struct ifaddr *mip6_dad_find(struct in6_addr *, struct ifnet *);
-int mip6_setpktaddrs(struct mbuf *);
int mip6_get_nonce(int, mip6_nonce_t *);
int mip6_get_nodekey(int, mip6_nodekey_t *);
int mip6_is_valid_bu(struct ip6_hdr *, struct ip6m_binding_update *, int,
Please sign in to comment.
Something went wrong with that request. Please try again.