Portably check for IPSEC_* constants (defined in ipsec.h).
authorTobias Brunner <tobias@strongswan.org>
Wed, 20 May 2009 18:15:06 +0000 (20:15 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 20 May 2009 18:15:06 +0000 (20:15 +0200)
The problem is that FreeBSD defines them as #defines whereas Linux defines them as enums.

configure.in
src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c

index eb76cd8..1a5f1d0 100644 (file)
@@ -839,6 +839,36 @@ AC_CHECK_MEMBERS([struct sadb_x_policy.sadb_x_policy_priority], [], [],
        #endif
 ])
 
+AC_MSG_CHECKING([for IPSEC_MODE_BEET])
+AC_TRY_COMPILE(
+       [#ifdef HAVE_NETIPSEC_IPSEC_H
+       #include <netipsec/ipsec.h>
+       #elif defined(HAVE_NETINET6_IPSEC_H)
+       #include <netinet6/ipsec.h>
+       #else
+       #include <linux/ipsec.h>
+       #endif],
+       [int mode = IPSEC_MODE_BEET;
+        return mode;],
+       [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_MODE_BEET])],
+       [AC_MSG_RESULT([no])]
+)
+
+AC_MSG_CHECKING([for IPSEC_DIR_FWD])
+AC_TRY_COMPILE(
+       [#ifdef HAVE_NETIPSEC_IPSEC_H
+       #include <netipsec/ipsec.h>
+       #elif defined(HAVE_NETINET6_IPSEC_H)
+       #include <netinet6/ipsec.h>
+       #else
+       #include <linux/ipsec.h>
+       #endif],
+       [int dir = IPSEC_DIR_FWD;
+        return dir;],
+       [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_DIR_FWD])],
+       [AC_MSG_RESULT([no])]
+)
+
 AC_MSG_CHECKING([for gcc atomic operations])
 AC_TRY_RUN(
 [
index 2b7bbe4..56f0320 100644 (file)
@@ -442,7 +442,7 @@ static u_int8_t mode2kernel(ipsec_mode_t mode)
                        return IPSEC_MODE_TRANSPORT;
                case MODE_TUNNEL:
                        return IPSEC_MODE_TUNNEL;
-#ifdef IPSEC_MODE_BEET
+#ifdef HAVE_IPSEC_MODE_BEET
                case MODE_BEET:
                        return IPSEC_MODE_BEET;
 #endif
@@ -462,7 +462,7 @@ static u_int8_t dir2kernel(policy_dir_t dir)
                        return IPSEC_DIR_INBOUND;
                case POLICY_OUT:
                        return IPSEC_DIR_OUTBOUND;
-#ifdef IPSEC_DIR_FWD
+#ifdef HAVE_IPSEC_DIR_FWD
                case POLICY_FWD:
                        return IPSEC_DIR_FWD;
 #endif
@@ -483,7 +483,7 @@ static policy_dir_t kernel2dir(u_int8_t  dir)
                        return POLICY_IN;
                case IPSEC_DIR_OUTBOUND:
                        return POLICY_OUT;
-#ifdef IPSEC_DIR_FWD
+#ifdef HAVE_IPSEC_DIR_FWD
                case IPSEC_DIR_FWD:
                        return POLICY_FWD;
 #endif