summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-08-10 09:01:46 +0000
committerNick Mathewson <nickm@torproject.org>2006-08-10 09:01:46 +0000
commitd893d8c52ed7a66eaea630cffe94cdaf82fbc99d (patch)
treea5f150c89866f69116da7ffa6c31568bc2bfdfd8
parent5cff4164a08af2a869e5e85aa6d359b865eee9aa (diff)
downloadtor-d893d8c52ed7a66eaea630cffe94cdaf82fbc99d.tar.gz
tor-d893d8c52ed7a66eaea630cffe94cdaf82fbc99d.zip
r7300@Kushana: nickm | 2006-08-10 01:36:40 -0700
Distinguish netfilter vs pf at configure time based on headers, not on OS. svn:r7008
-rw-r--r--configure.in38
-rw-r--r--src/or/connection_edge.c11
-rw-r--r--src/or/or.h9
3 files changed, 36 insertions, 22 deletions
diff --git a/configure.in b/configure.in
index f8adb490b1..331d99689e 100644
--- a/configure.in
+++ b/configure.in
@@ -58,23 +58,11 @@ fi
AC_ARG_ENABLE(transparent,
AC_HELP_STRING(--disable-transparent, disable transparent proxy support),
- [case "${enableval}" in
+ [case "${enableval}" in
yes) transparent=true ;;
no) transparent=false ;;
*) AC_MSG_ERROR(bad value for --enable-transparent) ;;
esac], [transparent=true])
-if test x$transparent = xtrue; then
- AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
- case $host in
- *-*-linux* )
- AC_DEFINE(TRANS_NETFILTER, 1, "Define for transparent netfilter") ;;
- *-*-openbsd*)
- AC_DEFINE(TRANS_PF, 1, "Define for transparent pf")
- AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
- *-*-*bsd* )
- AC_DEFINE(TRANS_PF, 1, "Define for transparent pf") ;;
- esac
-fi
case $host in
*-*-solaris* )
@@ -379,6 +367,11 @@ dnl These headers are not essential
AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h stddef.h inttypes.h utime.h sys/utime.h sys/mman.h alloca.h)
+AC_CHECK_HEADERS(net/if.h, [net_if_found=1], [net_if_found=0])
+AC_CHECK_HEADERS(net/pfvar.h, [net_pfvar_found=1], [net_pfvar_found=0])
+AC_CHECK_HEADERS(linux/netfilter_ipv4, [linux_netfilter_ipv4=1],
+ [linux_netfilter_ipv4=0])
+
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem mmap strtok_r)
if test $enable_threads = "yes"; then
@@ -386,6 +379,25 @@ if test $enable_threads = "yes"; then
AC_CHECK_FUNCS(pthread_create)
fi
+if test x$transparent = xtrue ; then
+ transparent_ok=0
+ if test x$net_if_found = x1 -a x$net_pfvar_found = x1 ; then
+ transparent_ok=1
+ fi
+ if test x$linux_netfilter_ipv4 = x1 ; then
+ transparent_ok=1
+ fi
+ if x$transparent_ok = x1 ; then
+ AC_DEFINE(USE_TRANSPARENT, 1, "Define to enable transparent proxy support")
+ case $host in
+ *-*-openbsd*)
+ AC_DEFINE(OPENBSD, 1, "Define to handle pf on OpenBSD properly") ;;
+ esac
+ else
+ AC_MSG_NOTICE([Transparent proxy support enabled, but missing headers.])
+ fi
+fi
+
AC_FUNC_FSEEKO
AC_CHECK_MEMBERS([struct timeval.tv_sec])
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 289538e6f6..62fa699e00 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -13,6 +13,17 @@ const char connection_edge_c_id[] =
#include "or.h"
+#ifdef HAVE_LINUX_NETFILTER_IPV4_H
+#include <linux/netfilter_ipv4.h>
+#define TRANS_NETFILTER
+#endif
+
+#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
+#include <net/if.h>
+#include <net/pfvar.h>
+#define TRANS_PF
+#endif
+
/* List of exit_redirect_t */
static smartlist_t *redirect_exit_list = NULL;
diff --git a/src/or/or.h b/src/or/or.h
index 24701301fb..a984819cfb 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -113,15 +113,6 @@
#error "Tor requires libevent to build."
#endif
-#ifdef TRANS_NETFILTER
-#include <linux/netfilter_ipv4.h>
-#endif
-
-#ifdef TRANS_PF
-#include <net/if.h>
-#include <net/pfvar.h>
-#endif
-
#include "../common/crypto.h"
#include "../common/tortls.h"
#include "../common/log.h"