Added some IPv6 tweaks for Android.
authorTobias Brunner <tobias@strongswan.org>
Wed, 23 Dec 2009 10:30:41 +0000 (11:30 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 23 Dec 2009 16:03:42 +0000 (17:03 +0100)
Android 1.6 does not yet support the Advanced Sockets API for IPv6 as defined in
RFC 3542. Also, in6addr_any is missing.

configure.in
src/charon/network/socket.c

index 9272097..8ba844e 100644 (file)
@@ -334,6 +334,32 @@ AC_CHECK_MEMBERS([struct sadb_x_policy.sadb_x_policy_priority], [], [],
        #endif
 ])
 
+AC_MSG_CHECKING([for in6addr_any])
+AC_TRY_COMPILE(
+       [#include <sys/types.h>
+       #include <sys/socket.h>
+       #include <netinet/in.h>],
+       [struct in6_addr in6;
+       in6 = in6addr_any;],
+       [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IN6ADDR_ANY])],
+       [AC_MSG_RESULT([no])]
+)
+
+AC_MSG_CHECKING([for in6_pktinfo])
+AC_TRY_COMPILE(
+       [#define _GNU_SOURCE
+       #include <sys/types.h>
+       #include <sys/socket.h>
+       #include <netinet/in.h>],
+       [struct in6_pktinfo pi;
+       if (pi.ipi6_ifindex)
+       {
+               return 0;
+       }],
+       [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IN6_PKTINFO])],
+       [AC_MSG_RESULT([no])]
+)
+
 AC_MSG_CHECKING([for IPSEC_MODE_BEET])
 AC_TRY_COMPILE(
        [#include <sys/types.h>
index 42528de..81f860b 100644 (file)
@@ -34,7 +34,6 @@
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
-#include <netinet/ip6.h>
 #include <netinet/udp.h>
 #include <net/if.h>
 #ifdef __APPLE__
 #define IPV6_RECVPKTINFO IPV6_PKTINFO
 #endif
 
+#ifndef IN6ADDR_ANY_INIT
+#define IN6ADDR_ANY_INIT {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}}
+#endif
+
+#ifndef HAVE_IN6ADDR_ANY
+static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+#endif
 
 typedef struct private_socket_t private_socket_t;
 
@@ -218,6 +224,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                                return FAILED;
                        }
 
+#ifdef HAVE_IN6_PKTINFO
                        if (cmsgptr->cmsg_level == SOL_IPV6 &&
                                cmsgptr->cmsg_type == IPV6_PKTINFO)
                        {
@@ -231,6 +238,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                                dst.sin6_port = htons(port);
                                dest = host_create_from_sockaddr((sockaddr_t*)&dst);
                        }
+#endif /* HAVE_IN6_PKTINFO */
                        if (cmsgptr->cmsg_level == SOL_IP &&
 #ifdef IP_PKTINFO
                                cmsgptr->cmsg_type == IP_PKTINFO
@@ -404,6 +412,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        memcpy(addr, &sin->sin_addr, sizeof(struct in_addr));
 #endif /* IP_PKTINFO || IP_SENDSRCADDR */
                }
+#ifdef HAVE_IN6_PKTINFO
                else
                {
                        char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
@@ -421,6 +430,7 @@ status_t sender(private_socket_t *this, packet_t *packet)
                        sin = (struct sockaddr_in6*)src->get_sockaddr(src);
                        memcpy(&pktinfo->ipi6_addr, &sin->sin6_addr, sizeof(struct in6_addr));
                }
+#endif /* HAVE_IN6_PKTINFO */
        }
 
        bytes_sent = sendmsg(skt, &msg, 0);