Skip to content
Browse files

Compilable on darwin with mip6 configuration

  • Loading branch information...
1 parent 01e56da commit a9fe4a5b2eaf5f8c5ec79a1bf594744f7de32e2a t-momose committed Jul 17, 2005
View
2 kame/sys/net/if_mip.c
@@ -1,4 +1,4 @@
-/* $Id: if_mip.c,v 1.4 2005/04/14 06:22:38 suz Exp $ */
+/* $KAME: if_mip.c,v 1.5 2005/07/17 20:40:45 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
View
2 kame/sys/net/if_mip.h
@@ -1,4 +1,4 @@
-/* $ID: $ */
+/* $KAME: if_mip.h,v 1.2 2005/07/17 20:40:45 t-momose Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
View
12 kame/sys/net/net_osdep.c
@@ -1,4 +1,4 @@
-/* $KAME: net_osdep.c,v 1.15 2005/04/14 06:22:38 suz Exp $ */
+/* $KAME: net_osdep.c,v 1.16 2005/07/17 20:40:45 t-momose Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -41,17 +41,23 @@
#endif
#include <sys/time.h>
#include <sys/syslog.h>
+#ifdef __APPLE__
+#include <kern/cpu_number.h>
+#else
#include <machine/cpu.h>
+#endif
#include <net/if.h>
#include <net/if_types.h>
+#ifndef __APPLE__
#include <net/netisr.h>
+#endif
#include <net/route.h>
#include <net/bpf.h>
#include <net/net_osdep.h>
-#if 0
+#ifdef __APPLE__
const char *
if_name(ifp)
struct ifnet *ifp;
@@ -96,7 +102,7 @@ ppsratecheck(lasttime, curpps, maxpps)
int s, rv;
s = splclock();
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__APPLE__)
tv = mono_time;
#else
microtime(&tv);
View
12 kame/sys/net/net_osdep.h
@@ -1,4 +1,4 @@
-/* $KAME: net_osdep.h,v 1.85 2004/05/20 08:15:53 suz Exp $ */
+/* $KAME: net_osdep.h,v 1.86 2005/07/17 20:40:45 t-momose Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -260,6 +260,9 @@
* NetBSD 1.5: always use IFAREF whenever reference gets added.
* always use IFAFREE whenever reference gets freed.
* IFAFREE frees ifaddr when ifa_refcnt reaches 0.
+ * Darwin: always use ifaref whenever reference gets added.
+ * always use ifafree whenever reference gets freed.
+ * ifaref and ifafree are responsible for determining when to free.
* others: do not increase refcnt for ifp->if_addrlist and in_ifaddr.
* use IFAFREE once when ifaddr is disconnected from
* ifp->if_addrlist and in_ifaddr. IFAFREE frees ifaddr when
@@ -321,7 +324,7 @@
#define if_name(ifp) ((ifp)->if_xname)
#else
struct ifnet;
-extern const char *if_name __P((struct ifnet *));
+extern const char *if_name(struct ifnet *);
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
@@ -330,8 +333,11 @@ extern const char *if_name __P((struct ifnet *));
#if defined(__FreeBSD__) && __FreeBSD_version < 500000
#define HAVE_NEW_BPF
#endif
+#ifdef __APPLE__
+#define HAVE_OLD_BPF
+#endif
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__APPLE__)
#define ifa_list ifa_link
#define if_addrlist if_addrhead
#define if_list if_link
View
14 kame/sys/netinet6/dest6.c
@@ -1,4 +1,4 @@
-/* $KAME: dest6.c,v 1.72 2005/06/16 18:29:26 jinmei Exp $ */
+/* $KAME: dest6.c,v 1.73 2005/07/17 20:40:46 t-momose Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -79,9 +79,15 @@ static void mip6_notify_be_hint(struct in6_addr *, struct in6_addr *,
* Destination options header processing.
*/
int
+#ifndef __APPLE__
dest6_input(mp, offp, proto)
struct mbuf **mp;
int *offp, proto;
+#else
+dest6_input(mp, offp)
+ struct mbuf **mp;
+ int *offp;
+#endif
{
struct mbuf *m = *mp;
int off = *offp, dstoptlen, optlen;
@@ -190,7 +196,11 @@ dest6_input(mp, offp, proto)
#endif /* MIP6 */
default: /* unknown option */
optlen = ip6_unknown_opt(opt, m,
- opt - mtod(m, u_int8_t *));
+ opt - mtod(m, u_int8_t *)
+#ifdef __APPLE__
+ ,0
+#endif
+ );
if (optlen == -1)
return (IPPROTO_DONE);
optlen += 2;
View
98 kame/sys/netinet6/mip6.c
@@ -1,4 +1,4 @@
-/* $Id: mip6.c,v 1.221 2005/06/21 10:53:02 keiichi Exp $ */
+/* $Id: mip6.c,v 1.222 2005/07/17 20:40:46 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -43,13 +43,13 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
#include <sys/malloc.h>
#endif
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/syslog.h>
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__APPLE__)
#include <sys/sysctl.h>
#endif
@@ -83,6 +83,10 @@
#include <netinet/ip_ipsp.h>
#endif
+#ifdef __APPLE__
+#include <machine/spl.h>
+#endif /* __APPLE__ */
+
#include "mip.h"
#ifndef MIP6_BC_HASH_SIZE
@@ -228,7 +232,7 @@ SYSCTL_SETUP(sysctl_net_inet6_mip6_setup, "sysctl net.inet6.mip6 subtree setup")
}
#endif /* __NetBSD__ */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
SYSCTL_DECL(_net_inet6_mip6);
SYSCTL_INT(_net_inet6_mip6, MIP6CTL_DEBUG, debug, CTLFLAG_RW,
@@ -237,15 +241,21 @@ SYSCTL_INT(_net_inet6_mip6, MIP6CTL_USE_IPSEC, use_ipsec, CTLFLAG_RW,
&mip6ctl_use_ipsec, 0, "");
SYSCTL_INT(_net_inet6_mip6, MIP6CTL_RR_HINT_PPSLIM, rr_hint_ppslimit, CTLFLAG_RW,
&mip6ctl_rr_hint_ppslim, 0, "");
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ || __APPLE__*/
/*
* Mobility Header processing.
*/
int
+#ifndef __APPLE__
mip6_input(mp, offp, proto)
struct mbuf **mp;
int *offp, proto;
+#else
+mip6_input(mp, offp)
+ struct mbuf **mp;
+ int *offp;
+#endif
{
struct mbuf *m = *mp;
struct ip6_hdr *ip6;
@@ -359,7 +369,11 @@ mip6_input(mp, offp, proto)
}
/* deliver the packet using Raw IPv6 interface. */
- return (rip6_input(mp, offp, proto));
+ return (rip6_input(mp, offp
+#ifndef __APPLE__
+ ,proto
+#endif
+ ));
}
int
@@ -415,7 +429,7 @@ mip6_tunnel_input(mp, offp, proto)
#ifdef __NetBSD__
s = splnet();
-#elif defined(__OpenBSD__)
+#elif defined(__OpenBSD__) || defined(__APPLE__)
s = splimp();
#endif
@@ -675,6 +689,7 @@ static void
mip6_bce_update_ipsecdb(bce)
struct mip6_bc_internal *bce;
{
+#ifndef __APPLE__
#ifdef IPSEC
/* racoon2 guys want us to update ipsecdb. (2004.10.8) */
struct sockaddr_in6 hoa_sa, coa_sa, haaddr_sa;
@@ -698,6 +713,7 @@ mip6_bce_update_ipsecdb(bce)
key_mip6_update_home_agent_ipsecdb(&hoa_sa, NULL, &coa_sa,
&haaddr_sa);
#endif /* IPSEC */
+#endif /* __APPLE__ */
}
void
@@ -769,8 +785,18 @@ mip6_ifa_ifwithin6addr(in6)
sin6.sin6_len = sizeof(struct sockaddr_in6);
sin6.sin6_family = AF_INET6;
sin6.sin6_addr = *in6;
+#ifndef __APPLE__
if (sa6_recoverscope(&sin6) != 0)
return (NULL);
+#else
+ /* XXXX */
+ /* should support scope6.c */
+ if (IN6_IS_SCOPE_LINKLOCAL(&sin6.sin6_addr)
+ /*||IN6_IS_ADDR_MC_INTFACELOCAL(&sin6.sin6_addr)*/) {
+ sin6.sin6_scope_id = ntohs(sin6.sin6_addr.s6_addr16[1]);
+ sin6.sin6_addr.s6_addr16[1] = 0;
+ }
+#endif
return ((struct in6_ifaddr *)ifa_ifwithaddr((struct sockaddr *)&sin6));
}
@@ -917,6 +943,7 @@ static void
mip6_bul_update_ipsecdb(mbul)
struct mip6_bul_internal *mbul;
{
+#ifndef __APPLE__
#ifdef IPSEC
/* racoon2 guys want us to update ipsecdb. (2004.10.8) */
struct sockaddr_in6 hoa_sa, coa_sa, haaddr_sa;
@@ -940,6 +967,7 @@ mip6_bul_update_ipsecdb(mbul)
key_mip6_update_mobile_node_ipsecdb(&hoa_sa, NULL, &coa_sa,
&haaddr_sa);
#endif
+#endif
}
void
@@ -957,14 +985,16 @@ mip6_bul_remove_all()
s = splnet();
#endif
+#if defined(__FreeBSD__) || defined(__APPLE__)
#ifdef __FreeBSD__
IFNET_RLOCK();
+#endif
TAILQ_FOREACH(ifp, &ifnet, if_link)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
TAILQ_FOREACH(ifp, &ifnet, if_list)
#endif
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
@@ -1091,7 +1121,7 @@ mip6_create_hoa_opt(coa)
/* allocating a new buffer space for a home address option. */
buflen = optlen + pad + sizeof(struct ip6_opt_home_address);
- optbuf = (char *)malloc(buflen, M_IP6OPT, M_NOWAIT);
+ MALLOC(optbuf, char *, buflen, M_IP6OPT, M_NOWAIT);
if (optbuf == NULL)
return (NULL);
bzero(optbuf, buflen);
@@ -1202,10 +1232,17 @@ mip6_append_ip6_hdr(mp, osrc, odst)
/* if the prefix is equal to one of home prefixes, return TRUE */
int
-mip6_are_homeprefix(ndprctl)
- struct nd_prefixctl *ndprctl;
+mip6_are_homeprefix(ndpr)
+#ifndef __APPLE__
+ struct nd_prefixctl *ndpr;
+#else
+ struct nd_prefix *ndpr;
+#endif
{
struct in6_ifaddr *ia6;
+#ifdef __APPLE__
+#define in6_ifaddr in6_ifaddrs
+#endif
for (ia6 = in6_ifaddr; ia6; ia6 = ia6->ia_next) {
if (ia6->ia_ifp == NULL)
@@ -1214,10 +1251,13 @@ mip6_are_homeprefix(ndprctl)
if (ia6->ia_ifp->if_type != IFT_MIP)
continue;
- if (in6_are_prefix_equal(&ndprctl->ndpr_prefix.sin6_addr, &ia6->ia_addr.sin6_addr, ndprctl->ndpr_plen))
+ if (in6_are_prefix_equal(&ndpr->ndpr_prefix.sin6_addr, &ia6->ia_addr.sin6_addr, ndpr->ndpr_plen))
return (TRUE);
}
return (FALSE);
+#ifdef __APPLE__
+#undef in6_ifaddr
+#endif
}
int
@@ -1310,11 +1350,11 @@ mip6_bc_proxy_control(target, local, cmd)
switch (cmd) {
case RTM_DELETE:
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
rt = rtalloc1((struct sockaddr *)&target_sa, 0, 0UL);
-#else /* __FreeBSD__ */
+#else /* __FreeBSD__ || __APPLE__ */
rt = rtalloc1((struct sockaddr *)&target_sa, 0);
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ || __APPLE__ */
if (rt) {
#ifdef __FreeBSD__
RT_REMREF(rt);
@@ -1398,13 +1438,16 @@ mip6_bc_proxy_control(target, local, cmd)
}
daddr = in6addr_linklocal_allnodes;
+#ifndef __APPLE__
if ((error = in6_setscope(&daddr, ifp, NULL)) != 0) {
mip6log((LOG_ERR, "in6_setscope failed\n"));
- } else {
- nd6_na_output(ifp, &daddr, &target_sa.sin6_addr,
- ND_NA_FLAG_OVERRIDE, 1, (struct sockaddr *)sdl);
+ break;
}
-
+#else
+ daddr.s6_addr16[1] = htons(ifp->if_index);
+#endif
+ nd6_na_output(ifp, &daddr, &target_sa.sin6_addr,
+ ND_NA_FLAG_OVERRIDE, 1, (struct sockaddr *)sdl);
break;
default:
@@ -1486,15 +1529,15 @@ mip6_encapsulate(mm, osrc, odst)
#ifdef IPV6_MINMTU
/* XXX */
return (ip6_output(m, 0, 0, IPV6_MINMTU, 0
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
, NULL, NULL
#else
, NULL
#endif
));
#else
return (ip6_output(m, 0, 0, 0, 0
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
, NULL, NULL
#else
, NULL
@@ -1516,7 +1559,9 @@ mip6_probe_routers(void)
(ln->ln_state == ND6_LLINFO_STALE))) {
ln->ln_asked = 0;
ln->ln_state = ND6_LLINFO_DELAY;
+#ifndef __APPLE__
nd6_llinfo_settimer(ln, 0);
+#endif
}
ln = ln->ln_next;
}
@@ -1680,12 +1725,21 @@ mip6_get_logical_src_dst(m, src, dst)
#if NMIP > 0
void
-mip6_md_scan(u_int16_t ifindex) {
+mip6_md_scan(u_int16_t ifindex)
+{
int s;
struct nd_defrouter *dr;
#ifndef __FreeBSD__
+#ifdef APPLE
+ time_t time_second;
+ struct timeval timenow;
+
+ getmicrotime(&timenow);
+ time_second = (time_t)timenow.tv_sec;
+#else
long time_second = time.tv_sec;
#endif
+#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
s = splsoftnet();
View
6 kame/sys/netinet6/mip6_var.h
@@ -1,4 +1,4 @@
-/* $KAME: mip6_var.h,v 1.122 2005/06/21 10:53:03 keiichi Exp $ */
+/* $KAME: mip6_var.h,v 1.123 2005/07/17 20:40:46 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -175,8 +175,12 @@ struct mip6_bul_internal *mip6_bul_get(const struct in6_addr *,
void mip6_bul_remove(struct mip6_bul_internal *);
void mip6_bul_remove_all(void);
struct mip6_bul_internal *mip6_bul_get_home_agent(const struct in6_addr *);
+#ifndef __APPLE__
struct nd_prefixctl;
int mip6_are_homeprefix(struct nd_prefixctl *);
+#else
+int mip6_are_homeprefix(struct nd_prefix *);
+#endif
int mip6_ifa6_is_addr_valid_hoa(struct in6_ifaddr *);
u_int8_t *mip6_create_hoa_opt(struct in6_addr *);
struct ip6_opt_home_address *mip6_search_hoa_in_destopt(u_int8_t *);

0 comments on commit a9fe4a5

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