]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
fix ipv6 compilation under macosx >= 1070 - v3
authorJuanJo Ciarlante <jjo+ml@google.com>
Mon, 19 Sep 2011 14:07:14 +0000 (16:07 +0200)
committerDavid Sommerseth <davids@redhat.com>
Wed, 21 Sep 2011 13:19:41 +0000 (15:19 +0200)
 - 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."

Signed-off-by: JuanJo Ciarlante <jjo+ml@google.com>
Tested-by: Eric F Crist <ecrist@secure-computing.net>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
socket.c
socket.h
syshead.h
tun.c

index a2f9511c1b2f0aaae940c5ab89382fcaed9b341a..47e44edb3d74787cd7348a592abbfa11b043998b 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -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
 };
index a9a29c5ba3be60c83989e7fa6a5eefbc267faf55..4a4f75df0f0dd9b0fafa66efe5e5eafbeb1b6f8f 100644 (file)
--- a/socket.h
+++ b/socket.h
@@ -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);
index e208d4cdcbe1ebe768e0cb46e4aead8cdf481fbd..66a25386d4307b57ccd2a681b6300cd9b5f5e1a8 100644 (file)
--- a/syshead.h
+++ b/syshead.h
 #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
 #define ENABLE_IP_PKTINFO 0
 #endif
 
+/*
+ * Does this platform define SOL_IP
+ * or only bsd-style IPPROTO_IP ?
+ */
+#ifndef SOL_IP
+#define SOL_IP IPPROTO_IP
+#endif
+
 /*
  * Disable ESEC
  */
diff --git a/tun.c b/tun.c
index 5e645ca7b9631603d7319def67a8231a57890e83..d121fc1f6870761ac018fbb0ef25b429e96341bd 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -1060,11 +1060,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 )