Skip to content
Browse files

Several fixes to work mobility functions on darwin

  • Loading branch information...
1 parent ffdb81e commit 1713155950deff85e1da8319038493f618e8435e t-momose committed Aug 10, 2006
Showing with 52 additions and 29 deletions.
  1. +39 −17 kame/sys/net/if_mip.c
  2. +13 −12 kame/sys/netinet6/dest6.c
View
56 kame/sys/net/if_mip.c
@@ -1,4 +1,4 @@
-/* $KAME: if_mip.c,v 1.9 2006/06/08 11:47:37 keiichi Exp $ */
+/* $KAME: if_mip.c,v 1.10 2006/08/10 17:55:00 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
@@ -80,6 +80,8 @@ int mip_demux(struct ifnet *, struct mbuf *, char *, u_long *);
static int mip_add_proto(struct ifnet *, u_long, struct ddesc_head_str *);
static int mip_del_proto(struct ifnet *, u_long);
int mip_attach_proto_family(struct ifnet *, u_long);
+int mip_pre_output(struct ifnet *ifp, u_long protocol_family, struct mbuf **m0,
+ const struct sockaddr *dst, caddr_t rt, char *frame, char *address);
#endif /* __APPLE__ */
#if NMIP > 0
@@ -164,7 +166,7 @@ mipattach(dummy)
sc->mip_if.if_demux = mip_demux;
sc->mip_if.if_add_proto = mip_add_proto;
sc->mip_if.if_del_proto = mip_del_proto;
- sc->mip_if.if_output = NULL;
+ sc->mip_if.if_output = NULL; /* pre_output returns error or EJUSTRETURN */
dlil_if_attach(&sc->mip_if);
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -187,15 +189,32 @@ mipattach(dummy)
}
}
+#ifndef __APPLE__
int
mip_output(ifp, m, dst, rt)
struct ifnet *ifp;
struct mbuf *m;
struct sockaddr *dst;
struct rtentry *rt;
+#else
+int
+mip_pre_output(
+ struct ifnet *ifp,
+ u_long protocol_family,
+ struct mbuf **m0,
+ const struct sockaddr *dst,
+ caddr_t rt0,
+ char *frame,
+ char *address)
+#endif /* __APPLE__ */
{
+ int error = 0;
struct mip6_bul_internal *mbul;
struct ip6_hdr *ip6;
+#ifdef __APPLE__
+ register struct mbuf * m = *m0;
+ struct rtentry *rt = (struct rtentry *)rt0;
+#endif /* __APPLE__ */
/* This function is copyed from looutput */
@@ -295,7 +314,11 @@ mip_output(ifp, m, dst, rt)
if (m && m->m_len < sizeof(struct ip6_hdr))
m = m_pullup(m, sizeof(struct ip6_hdr));
if (m == NULL)
+#ifdef __APPLE__
+ return (EJUSTRETURN);
+#else
return (0);
+#endif
ip6 = mtod(m, struct ip6_hdr *);
ip6->ip6_flow = 0;
@@ -307,9 +330,14 @@ mip_output(ifp, m, dst, rt)
ip6->ip6_src = mbul->mbul_coa;
ip6->ip6_dst = mbul->mbul_peeraddr;
mip6stat.mip6s_orevtunnel++;
-#ifdef IPV6_MINMTU
/* XXX */
- return (ip6_output(m, 0, 0, IPV6_MINMTU, 0
+ error = ip6_output(m, 0, 0,
+#ifdef IPV6_MINMTU
+ IPV6_MINMTU,
+#else
+ 0,
+#endif /* IPV6_MINMTU*/
+ 0
#ifdef __FreeBSD__
, &ifp, NULL
#elif defined(__NetBSD__)
@@ -319,18 +347,12 @@ mip_output(ifp, m, dst, rt)
#else
, &ifp
#endif
- ));
-#else
- return (ip6_output(m, 0, 0, 0, 0
-#ifdef __FreeBSD__
- , &ifp, NULL
-#elif defined(__NetBSD__)
- , NULL, &ifp
-#else
- , &ifp
-#endif
- ));
-#endif
+ );
+#ifdef __APPLE__
+ if (error == 0)
+ error = EJUSTRETURN;
+#endif /* __APPLE__ */
+ return (error);
done:
break;
default:
@@ -527,7 +549,7 @@ mip_attach_proto_family(
reg.interface_family = ifp->if_family;
reg.unit_number = ifp->if_unit;
reg.input = NULL;
- reg.pre_output = mip_output;
+ reg.pre_output = mip_pre_output;
reg.protocol_family = protocol_family;
stat = dlil_attach_protocol(&reg);
View
25 kame/sys/netinet6/dest6.c
@@ -1,4 +1,4 @@
-/* $KAME: dest6.c,v 1.73 2005/07/17 20:40:46 t-momose Exp $ */
+/* $KAME: dest6.c,v 1.74 2006/08/10 17:55:00 t-momose Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,6 +66,7 @@
#ifdef MIP6
#include <net/mipsock.h>
#include <netinet/ip6mh.h>
+#include <netinet6/mip6.h>
#include <netinet6/mip6_var.h>
static int dest6_swap_hao(struct ip6_hdr *, struct ip6aux *,
@@ -106,7 +107,7 @@ dest6_input(mp, offp)
#endif /* MIP6 */
/* validation of the length of the header */
#ifndef PULLDOWN_TEST
- IP6_EXTHDR_CHECK(m, off, sizeof(*dstopts), IPPROTO_DONE);
+ IP6_EXTHDR_CHECK(m, off, (int)sizeof(*dstopts), IPPROTO_DONE);
dstopts = (struct ip6_dest *)(mtod(m, caddr_t) + off);
#else
IP6_EXTHDR_GET(dstopts, struct ip6_dest *, m, off, sizeof(*dstopts));
@@ -145,6 +146,10 @@ dest6_input(mp, offp)
#ifdef MIP6
case IP6OPT_HOME_ADDRESS:
/* HAO must appear only once */
+ if ((mip6_nodetype &
+ (MIP6_NODETYPE_HOME_AGENT |
+ MIP6_NODETYPE_CORRESPONDENT_NODE)) == 0)
+ goto nomip;
n = ip6_addaux(m);
if (!n) {
/* not enough core */
@@ -193,6 +198,7 @@ dest6_input(mp, offp)
* beleive this HAO is a correct one.
*/
break;
+ nomip:
#endif /* MIP6 */
default: /* unknown option */
optlen = ip6_unknown_opt(opt, m,
@@ -228,7 +234,6 @@ dest6_swap_hao(ip6, ip6a, haopt)
struct ip6aux *ip6a;
struct ip6_opt_home_address *haopt;
{
-
if ((ip6a->ip6a_flags & (IP6A_HASEEN | IP6A_SWAP)) != IP6A_HASEEN)
return (EINVAL);
@@ -302,6 +307,7 @@ dest6_mip6_hao(m, mhoff, nxt)
n = ip6_findaux(m);
if (!n)
return (0);
+
ip6a = (struct ip6aux *) (n + 1);
if ((ip6a->ip6a_flags & (IP6A_HASEEN | IP6A_SWAP)) != IP6A_HASEEN)
@@ -311,25 +317,20 @@ dest6_mip6_hao(m, mhoff, nxt)
/* find home address */
off = 0;
proto = IPPROTO_IPV6;
- while (1) {
+ while (proto != IPPROTO_DSTOPTS) {
int nxt;
newoff = ip6_nexthdr(m, off, proto, &nxt);
if (newoff < 0 || newoff < off)
return (0); /* XXX */
off = newoff;
proto = nxt;
- if (proto == IPPROTO_DSTOPTS)
- break;
}
ip6o.ip6o_type = IP6OPT_PADN;
ip6o.ip6o_len = 0;
- while (1) {
- newoff = dest6_nextopt(m, off, &ip6o);
- if (newoff < 0)
+ while (ip6o.ip6o_type != IP6OPT_HOME_ADDRESS) {
+ off = dest6_nextopt(m, off, &ip6o);
+ if (off < 0)
return (0); /* XXX */
- off = newoff;
- if (ip6o.ip6o_type == IP6OPT_HOME_ADDRESS)
- break;
}
m_copydata(m, off, sizeof(struct ip6_opt_home_address),
(caddr_t)&haopt);

0 comments on commit 1713155

Please sign in to comment.
Something went wrong with that request. Please try again.