--------------------- PatchSet 951 Date: 2000/12/18 08:31:31 Author: hno Branch: hno-2_2-mara Tag: (none) Log: Transparent support for Linux-2.4 Members: acconfig.h:1.1.1.2.2.1->1.1.1.2.2.1.4.1 configure.in:1.1.1.2.2.1->1.1.1.2.2.1.4.1 src/client_side.c:1.1.1.2.2.1->1.1.1.2.2.1.4.1 Index: squid/acconfig.h =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/acconfig.h,v retrieving revision 1.1.1.2.2.1 retrieving revision 1.1.1.2.2.1.4.1 diff -u -r1.1.1.2.2.1 -r1.1.1.2.2.1.4.1 --- squid/acconfig.h 17 Sep 2000 00:48:05 -0000 1.1.1.2.2.1 +++ squid/acconfig.h 18 Dec 2000 08:31:31 -0000 1.1.1.2.2.1.4.1 @@ -20,7 +20,7 @@ * */ @ TOP @ -/* $Id: acconfig.h,v 1.1.1.2.2.1 2000/09/17 00:48:05 hno Exp $ */ +/* $Id: acconfig.h,v 1.1.1.2.2.1.4.1 2000/12/18 08:31:31 hno Exp $ */ /********************************* * START OF CONFIGURABLE OPTIONS * @@ -207,6 +207,12 @@ #undef IPF_TRANSPARENT /* + * Enable support for Transparent Proxy on Linux using Netfilter + * (Linux-2.4) + */ +#undef LINUX_NETFILTER_TRANSPARENT + +/* * Enable code for assiting in finding memory leaks. Hacker stuff only. */ #undef USE_LEAKFINDER Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.1.1.2.2.1 retrieving revision 1.1.1.2.2.1.4.1 diff -u -r1.1.1.2.2.1 -r1.1.1.2.2.1.4.1 --- squid/configure.in 17 Sep 2000 00:48:05 -0000 1.1.1.2.2.1 +++ squid/configure.in 18 Dec 2000 08:31:31 -0000 1.1.1.2.2.1.4.1 @@ -3,13 +3,13 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.1.1.2.2.1 2000/09/17 00:48:05 hno Exp $ +dnl $Id: configure.in,v 1.1.1.2.2.1.4.1 2000/12/18 08:31:31 hno Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.1.1.2.2.1 $)dnl +AC_REVISION($Revision: 1.1.1.2.2.1.4.1 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(cfgaux) @@ -508,6 +508,17 @@ fi ]) +dnl Enable Linux Netfilter (2.4) Transparent Proxy +AC_ARG_ENABLE(linux-netfilter, +[ --enable-linux-netfilter + Enable Transparent Proxy support for Linux 2.4.], +[ if test "$enableval" = "yes" ; then + echo "Linux-Netfilter Transparent Proxy enabled" + AC_DEFINE(LINUX_NETFILTER_TRANSPARENT) + LINUX_NETFILTER_TRANSPARENT="yes" + fi +]) + dnl Enable Leak Finding Functions AC_ARG_ENABLE(leakfinder, [ --enable-leakfinder @@ -625,6 +636,7 @@ ip_nat.h \ libc.h \ limits.h \ + linux/netfilter_ipv4.h \ malloc.h \ math.h \ memory.h \ @@ -1055,6 +1067,26 @@ sleep 10 fi +dnl Linux-Netfilter support requires Linux 2.4 kernel header files. +dnl Shamelessly copied from above +if test "$LINUX_NETFILTER_TRANSPARENT" ; then + AC_MSG_CHECKING(if Linux 2.4 kernel header files are installed) + # hold on to your hats... + if test "$ac_cv_header_linux_netfilter_ipv4_h" = "yes"; then + LINUX_NETFILTER_TRANSPARENT="yes" + AC_DEFINE(LINUX_NETFILTER_TRANSPARENT, 1) + else + LINUX_NETFILTER_TRANSPARENT="no" + AC_DEFINE(LINUX_NETFILTER_TRANSPARENT, 0) + fi + AC_MSG_RESULT($LINUX_NETFILTER_TRANSPARENT) +fi +if test "$LINUX_NETFILTER_TRANSPARENT" = "no" ; then + echo "WARNING: Cannot find necessary Linux 2.4 kernel header files" + echo " Linux 2.4 Transparent Proxy support WILL NOT be enabled" + sleep 10 +fi + if test -z "$USE_GNUREGEX" ; then case "$host" in *-sun-solaris2.[[0-4]]) Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.2.2.1 retrieving revision 1.1.1.2.2.1.4.1 diff -u -r1.1.1.2.2.1 -r1.1.1.2.2.1.4.1 --- squid/src/client_side.c 4 Feb 2000 16:41:12 -0000 1.1.1.2.2.1 +++ squid/src/client_side.c 18 Dec 2000 08:31:31 -0000 1.1.1.2.2.1.4.1 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.2.2.1 2000/02/04 16:41:12 hno Exp $ + * $Id: client_side.c,v 1.1.1.2.2.1.4.1 2000/12/18 08:31:31 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -58,6 +58,9 @@ #endif #endif +#if LINUX_NETFILTER_TRANSPARENT +#include +#endif #if LINGERING_CLOSE @@ -1978,6 +1981,9 @@ struct natlookup natLookup; static int natfd = -1; #endif +#if LINUX_NETFILTER_TRANSPARENT + size_t sock_sz = sizeof(conn->me); +#endif if ((req_sz = headersEnd(conn->in.buf, conn->in.offset)) == 0) { debug(33, 5) ("Incomplete request, waiting for end of headers\n"); @@ -2144,6 +2150,11 @@ (int) Config.Accel.port, url); #else +#if LINUX_NETFILTER_TRANSPARENT + /* If the call fails the address structure will be unchanged */ + getsockopt(conn->fd, SOL_IP, SO_ORIGINAL_DST, &conn->me, &sock_sz ); +#endif + debug(33, 5) ("parseHttpRequest: addr = %s", inet_ntoa(conn->me.sin_addr) ); snprintf(http->uri, url_sz, "http://%s:%d%s", inet_ntoa(http->conn->me.sin_addr), (int) Config.Accel.port,