Skip to content

Commit

Permalink
add checks for netfilter's headers
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Oct 27, 2014
1 parent 8b4539e commit e3e9018
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET

/* Define to 1 if you have the <linux/if.h> header file. */
#undef HAVE_LINUX_IF_H

/* Define to 1 if you have the <linux/netfilter_ipv4.h> header file. */
#undef HAVE_LINUX_NETFILTER_IPV4_H

/* Define to 1 if you have the <linux/netfilter_ipv6/ip6_tables.h> header
file. */
#undef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H

/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H

Expand Down
29 changes: 29 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -13290,6 +13290,35 @@ else
as_fn_error $? "Missing MinGW headers" "$LINENO" 5
fi

done

;;
*-linux*)
for ac_header in linux/if.h linux/netfilter_ipv4.h linux/netfilter_ipv6/ip6_tables.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
#if HAVE_LIMITS_H
#include <limits.h>
#endif
/* Netfilter ip(6)tables v1.4.0 has broken headers */
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_LINUX_IF_H
#include <net/if.h>
#endif
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

else
as_fn_error $? "Missing netfilter headers" "$LINENO" 5
fi

done

;;
Expand Down
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ case $host in
*-mingw*)
AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
;;
*-linux*)
dnl Checks for netfilter headers
AC_CHECK_HEADERS([linux/if.h linux/netfilter_ipv4.h linux/netfilter_ipv6/ip6_tables.h],
[], [AC_MSG_ERROR([Missing netfilter headers])],
[[
#if HAVE_LIMITS_H
#include <limits.h>
#endif
/* Netfilter ip(6)tables v1.4.0 has broken headers */
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_LINUX_IF_H
#include <net/if.h>
#endif
]])
;;
*)
# These are POSIX-like systems using BSD-like sockets API.
;;
Expand Down
4 changes: 4 additions & 0 deletions src/redir.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
#define BUF_SIZE 2048
#endif

#ifndef IP6T_SO_ORIGINAL_DST
#define IP6T_SO_ORIGINAL_DST 80
#endif

int getdestaddr(int fd, struct sockaddr_storage *destaddr)
{
socklen_t socklen = sizeof(*destaddr);
Expand Down

0 comments on commit e3e9018

Please sign in to comment.