Patch from Richard Kettlewell <richard@sfere.greenend.org.uk> to
support MacOS X; see also http://www.greenend.org.uk/rjk/2004/osx.html
#CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -DHACKY_PARALLEL
CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@
ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS)
#CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -DHACKY_PARALLEL
CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@
ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS)
LDFLAGS:=@LDFLAGS@
LDLIBS:=@LIBS@
LDFLAGS:=@LDFLAGS@
LDLIBS:=@LIBS@
$(DEPENDS): ${srcdir}/depend.sh
%.d: %.c
$(DEPENDS): ${srcdir}/depend.sh
%.d: %.c
- ${srcdir}/depend.sh $(srcdir) $(ALL_CFLAGS) $< > $@
+ ${srcdir}/depend.sh $(srcdir) $(CPPFLAGS) $(ALL_CFLAGS) $< > $@
netlink_icmp_simple(st,buf,client,ICMP_TYPE_UNREACHABLE,
ICMP_CODE_NET_PROHIBITED);
BUF_FREE(buf);
netlink_icmp_simple(st,buf,client,ICMP_TYPE_UNREACHABLE,
ICMP_CODE_NET_PROHIBITED);
BUF_FREE(buf);
- }
- if (best_quality>0) {
- /* XXX Fragment if required */
- st->routes[best_match]->deliver(
- st->routes[best_match]->dst, buf);
- st->routes[best_match]->outcount++;
- BUF_ASSERT_FREE(buf);
- /* Generate ICMP destination unreachable */
- netlink_icmp_simple(st,buf,client,ICMP_TYPE_UNREACHABLE,
- ICMP_CODE_NET_UNREACHABLE); /* client==NULL */
- BUF_FREE(buf);
+ if (best_quality>0) {
+ /* XXX Fragment if required */
+ st->routes[best_match]->deliver(
+ st->routes[best_match]->dst, buf);
+ st->routes[best_match]->outcount++;
+ BUF_ASSERT_FREE(buf);
+ } else {
+ /* Generate ICMP destination unreachable */
+ netlink_icmp_simple(st,buf,client,ICMP_TYPE_UNREACHABLE,
+ ICMP_CODE_NET_UNREACHABLE); /* client==NULL */
+ BUF_FREE(buf);
+ }
}
}
BUF_ASSERT_FREE(buf);
}
}
BUF_ASSERT_FREE(buf);
for (i=0; i<st->n_clients; i++) {
netlink_output_subnets(st,c,st->routes[i]->subnets);
Message(c,"-> tunnel %s (%s,mtu %d,%s routes,%s,"
for (i=0; i<st->n_clients; i++) {
netlink_output_subnets(st,c,st->routes[i]->subnets);
Message(c,"-> tunnel %s (%s,mtu %d,%s routes,%s,"
- "quality %d,use %d)\n",
+ "quality %d,use %d,pri %lu)\n",
st->routes[i]->name,
st->routes[i]->up?"up":"down",
st->routes[i]->mtu,
st->routes[i]->options&OPT_SOFTROUTE?"soft":"hard",
st->routes[i]->options&OPT_ALLOWROUTE?"free":"restricted",
st->routes[i]->link_quality,
st->routes[i]->name,
st->routes[i]->up?"up":"down",
st->routes[i]->mtu,
st->routes[i]->options&OPT_SOFTROUTE?"soft":"hard",
st->routes[i]->options&OPT_ALLOWROUTE?"free":"restricted",
st->routes[i]->link_quality,
- st->routes[i]->outcount);
+ st->routes[i]->outcount,
+ (unsigned long)st->routes[i]->priority);
}
net=ipaddr_to_string(st->secnet_address);
Message(c,"%s/32 -> netlink \"%s\" (use %d)\n",
}
net=ipaddr_to_string(st->secnet_address);
Message(c,"%s/32 -> netlink \"%s\" (use %d)\n",
break;
case TUN_CONFIG_IOCTL:
{
break;
case TUN_CONFIG_IOCTL:
{
+ /* darwin rtentry has a different format, use /sbin/route instead */
+#if HAVE_NET_ROUTE_H && ! __APPLE__
struct rtentry rt;
struct sockaddr_in *sa;
int action;
struct rtentry rt;
struct sockaddr_in *sa;
int action;
hostaddr,secnetaddr,"mtu",mtu,"up",(char *)0);
break;
case TUN_CONFIG_IOCTL:
hostaddr,secnetaddr,"mtu",mtu,"up",(char *)0);
break;
case TUN_CONFIG_IOCTL:
+#if HAVE_NET_IF_H && ! __APPLE__
{
int fd;
struct ifreq ifr;
{
int fd;
struct ifreq ifr;
}
} else if (strcmp(u.sysname,"SunOS")==0) {
st->tun_flavour=TUN_FLAVOUR_STREAMS;
}
} else if (strcmp(u.sysname,"SunOS")==0) {
st->tun_flavour=TUN_FLAVOUR_STREAMS;
- } else if (strcmp(u.sysname,"FreeBSD")==0) {
+ } else if (strcmp(u.sysname,"FreeBSD")==0
+ || strcmp(u.sysname,"Darwin")==0) {
st->tun_flavour=TUN_FLAVOUR_BSD;
}
}
st->tun_flavour=TUN_FLAVOUR_BSD;
}
}
st->ifconfig_type=TUN_CONFIG_IOCTL;
break;
case TUN_FLAVOUR_BSD:
st->ifconfig_type=TUN_CONFIG_IOCTL;
break;
case TUN_FLAVOUR_BSD:
/* XXX on Linux we still want TUN_CONFIG_IOCTL. Perhaps we can
use this on BSD too. */
st->ifconfig_type=TUN_CONFIG_IOCTL;
/* XXX on Linux we still want TUN_CONFIG_IOCTL. Perhaps we can
use this on BSD too. */
st->ifconfig_type=TUN_CONFIG_IOCTL;
+#else
+ st->ifconfig_type=TUN_CONFIG_BSD;
+#endif
break;
case TUN_FLAVOUR_STREAMS:
st->ifconfig_type=TUN_CONFIG_BSD;
break;
case TUN_FLAVOUR_STREAMS:
st->ifconfig_type=TUN_CONFIG_BSD;