Browse code

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."

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>

JuanJo Ciarlante authored on 2011/09/19 23:07:14
Showing 4 changed files
... ...
@@ -2878,8 +2878,7 @@ struct openvpn_in4_pktinfo
2878 2878
   struct cmsghdr cmsghdr;
2879 2879
 #ifdef HAVE_IN_PKTINFO
2880 2880
   struct in_pktinfo pi4;
2881
-#endif
2882
-#ifdef IP_RECVDSTADDR
2881
+#elif defined(IP_RECVDSTADDR)
2883 2882
   struct in_addr pi4;
2884 2883
 #endif
2885 2884
 };
... ...
@@ -86,8 +86,7 @@ struct link_socket_actual
86 86
   union {
87 87
 #ifdef HAVE_IN_PKTINFO
88 88
     struct in_pktinfo in4;
89
-#endif
90
-#ifdef IP_RECVDSTADDR
89
+#elif defined(IP_RECVDSTADDR)
91 90
     struct in_addr in4;
92 91
 #endif
93 92
     struct in6_pktinfo in6;
... ...
@@ -589,8 +588,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa)
589 589
   switch (lsa->dest.addr.sa.sa_family) {
590 590
 #ifdef HAVE_IN_PKTINFO
591 591
     case AF_INET: return lsa->pi.in4.ipi_spec_dst.s_addr != 0;
592
-#endif
593
-#ifdef IP_RECVDSTADDR
592
+#elif defined(IP_RECVDSTADDR)
594 593
     case AF_INET: return lsa->pi.in4.s_addr != 0;
595 594
 #endif
596 595
     case AF_INET6: return !IN6_IS_ADDR_UNSPECIFIED(&lsa->pi.in6.ipi6_addr);
... ...
@@ -57,6 +57,12 @@
57 57
 #define srandom srand
58 58
 #endif
59 59
 
60
+#if defined(__APPLE__)
61
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
62
+#define __APPLE_USE_RFC_3542  1
63
+#endif
64
+#endif
65
+
60 66
 #ifdef HAVE_SYS_TYPES_H
61 67
 #include <sys/types.h>
62 68
 #endif
... ...
@@ -401,6 +407,14 @@
401 401
 #endif
402 402
 
403 403
 /*
404
+ * Does this platform define SOL_IP
405
+ * or only bsd-style IPPROTO_IP ?
406
+ */
407
+#ifndef SOL_IP
408
+#define SOL_IP IPPROTO_IP
409
+#endif
410
+
411
+/*
404 412
  * Disable ESEC
405 413
  */
406 414
 #if 0
... ...
@@ -1060,11 +1060,11 @@ do_ifconfig (struct tuntap *tt,
1060 1060
 	{
1061 1061
 	  struct route r;
1062 1062
 	  CLEAR (r);
1063
-	  r.defined = true;
1063
+	  r.flags = RT_DEFINED;
1064 1064
 	  r.network = tt->local & tt->remote_netmask;
1065 1065
 	  r.netmask = tt->remote_netmask;
1066 1066
 	  r.gateway = tt->local;
1067
-	  add_route (&r, tt, 0, es);
1067
+	  add_route (&r, tt, 0, NULL, es);
1068 1068
 	}
1069 1069
 
1070 1070
       if ( do_ipv6 )