Skip to contentSkip to conversation

Build issues on OSX Lion

Openvpn-devel Eric Crist 1 participant 1 message Sep 20, 2011 11 messages not in the archive

lore
Share & tools
lore

Eric Crist

author
#11 lore raw
In reply to a message not in the archive
Quoted 12 lines · JuanJo
Quoted 2 lines · JuanJo Ciarlante
Quoted 1 line · Eric Crist

After testing, this appears to compile and function, with David's tun-stuff.patch, which was attached to the first message.

FYI indeed had to add tun-stuff.patch to compile under freebsd, quickly tested ok also.

Quoted 5 lines

Great! ... thanks Eric for testing this (fwiw checked building+test under openbsd ok - just to assert that I didn't broke any BSDism).

Cheers,

JuanJo,

I forgot to mention the FreeBSD bit, that was something I already knew, sorry for wasting your time by not saying something. For posterity, I've attached the patches here, and added the openvpn-devel list as a CC.

Eric Crist

From f11d7ddb965c6bd65d7dd02cc57539ea4f1c5598 Mon Sep 17 00:00:00 2001
From: JuanJo Ciarlante <[email protected]...>
Date: Mon, 19 Sep 2011 16:07:14 +0200
Subject: [PATCH] fix ipv6 compilation under macosx >= 1070 - v3
- use __APPLE_USE_RFC_3542 for macosx build environment >= 1070
- define SOL_IP from IPPROTO_IP if it's missing
In Linux man 7 ip says:
"Using SOL_IP socket options level isn't portable, BSD-based stacks use IPPROTO_IP level."

---
 socket.c  |    3 +--
 socket.h  |    6 ++----
 syshead.h |   14 ++++++++++++++
 3 files changed, 17 insertions(+), 6 deletions(-)
socket.c +1 -2
index a2f9511..47e44ed 100644
@@ -2878,8 +2878,7 @@ struct openvpn_in4_pktinfo
   struct cmsghdr cmsghdr;
 #ifdef HAVE_IN_PKTINFO
   struct in_pktinfo pi4;
-#endif
-#ifdef IP_RECVDSTADDR
+#elif defined(IP_RECVDSTADDR)
   struct in_addr pi4;
 #endif
 };
socket.h +2 -4
index a9a29c5..4a4f75d 100644
@@ -86,8 +86,7 @@ struct link_socket_actual
   union {
 #ifdef HAVE_IN_PKTINFO
     struct in_pktinfo in4;
-#endif
-#ifdef IP_RECVDSTADDR
+#elif defined(IP_RECVDSTADDR)
     struct in_addr in4;
 #endif
     struct in6_pktinfo in6;
@@ -589,8 +588,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa)
   switch (lsa->dest.addr.sa.sa_family) {
 #ifdef HAVE_IN_PKTINFO
     case AF_INET: return lsa->pi.in4.ipi_spec_dst.s_addr != 0;
-#endif
-#ifdef IP_RECVDSTADDR
+#elif defined(IP_RECVDSTADDR)
     case AF_INET: return lsa->pi.in4.s_addr != 0;
 #endif
     case AF_INET6: return !IN6_IS_ADDR_UNSPECIFIED(&lsa->pi.in6.ipi6_addr);
syshead.h +14 -0
index e208d4c..66a2538 100644
@@ -57,6 +57,12 @@
 #define srandom srand
 #endif
 
+#if defined(__APPLE__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
+#define __APPLE_USE_RFC_3542  1
+#endif
+#endif
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -401,6 +407,14 @@
 #endif
 
 /*
+ * Does this platform define SOL_IP
+ * or only bsd-style IPPROTO_IP ?
+ */
+#ifndef SOL_IP
+#define SOL_IP IPPROTO_IP
+#endif
+
+/*
  * Disable ESEC
  */
 #if 0
Signature · 1 line
1.7.3.1
tun.c +10 -10
index aa17c36..5185f73 100644
@@ -865,13 +865,13 @@ do_ifconfig (struct tuntap *tt,
 	  /* Add a network route for the local tun interface */
 	  struct route r;
 	  CLEAR (r);      
-	  r.defined = true;       
+	  r.flags = RT_DEFINED
 	  r.network = tt->local & tt->remote_netmask;
 	  r.netmask = tt->remote_netmask;
 	  r.gateway = tt->local;  
 	  r.metric_defined = true;
 	  r.metric = 0;
-	  add_route (&r, tt, 0, es);
+	  add_route (&r, tt, 0, NULL, es);
 	}
 
       tt->did_ifconfig = true;
@@ -1061,11 +1061,11 @@ do_ifconfig (struct tuntap *tt,
 	{
 	  struct route r;
 	  CLEAR (r);
-	  r.defined = true;
+	  r.flags = RT_DEFINED;
 	  r.network = tt->local & tt->remote_netmask;
 	  r.netmask = tt->remote_netmask;
 	  r.gateway = tt->local;
-	  add_route (&r, tt, 0, es);
+	  add_route (&r, tt, 0, NULL, es);
 	}
 
       if ( do_ipv6 )
@@ -1105,21 +1105,21 @@ do_ifconfig (struct tuntap *tt,
                               ifconfig_remote_netmask,
                               tun_mtu
                               );
-	
+
       argv_msg (M_INFO, &argv);
       openvpn_execve_check (&argv, es, S_FATAL, "FreeBSD ifconfig failed");
       tt->did_ifconfig = true;
 
 	/* Add a network route for the local tun interface */
       if (!tun && tt->topology == TOP_SUBNET)
-        {               
+        {
           struct route r;
-          CLEAR (r);      
-          r.defined = true;       
+          CLEAR (r);
+          r.flags = RT_DEFINED;
           r.network = tt->local & tt->remote_netmask;
           r.netmask = tt->remote_netmask;
-          r.gateway = tt->local;  
-          add_route (&r, tt, 0, es);
+          r.gateway = tt->local;
+          add_route (&r, tt, 0, NULL, es);
         }
 
       if ( do_ipv6 )