Portably check for IPSEC_* constants (defined in ipsec.h).

The problem is that FreeBSD defines them as #defines whereas Linux defines them as enums.
This commit is contained in:
Tobias Brunner 2009-05-20 20:15:06 +02:00
parent ad36ab252e
commit 617e59b7bc
2 changed files with 33 additions and 3 deletions

View 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(
[

View 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