tcpsvd,udpsvd: conditionalize usage of SO_ORIGINAL_DST

On systems without this call, $TCPORIGDSTADDR is not set.

Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Jeremie Koenig 2010-05-27 15:46:25 +02:00 committed by Denys Vlasenko
parent 29885114a5
commit 2ea12d8b6d
2 changed files with 5 additions and 2 deletions

View File

@ -733,7 +733,6 @@ config SLATTACH
config TCPSVD config TCPSVD
bool "tcpsvd" bool "tcpsvd"
default y default y
depends on PLATFORM_LINUX
help help
tcpsvd listens on a TCP port and runs a program for each new tcpsvd listens on a TCP port and runs a program for each new
connection. connection.
@ -966,7 +965,6 @@ config IFUPDOWN_UDHCPC_CMD_OPTIONS
config UDPSVD config UDPSVD
bool "udpsvd" bool "udpsvd"
default y default y
depends on PLATFORM_LINUX
help help
udpsvd listens on an UDP port and runs a program for each new udpsvd listens on an UDP port and runs a program for each new
connection. connection.

View File

@ -30,9 +30,12 @@
*/ */
#include "libbb.h" #include "libbb.h"
/* Wants <limits.h> etc, thus included after libbb.h: */ /* Wants <limits.h> etc, thus included after libbb.h: */
#ifdef __linux__
#include <linux/types.h> /* for __be32 etc */ #include <linux/types.h> /* for __be32 etc */
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
#endif
// TODO: move into this file: // TODO: move into this file:
#include "tcpudp_perhost.h" #include "tcpudp_perhost.h"
@ -464,6 +467,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
/* setup ucspi env */ /* setup ucspi env */
const char *proto = tcp ? "TCP" : "UDP"; const char *proto = tcp ? "TCP" : "UDP";
#ifdef SO_ORIGINAL_DST
/* Extract "original" destination addr:port /* Extract "original" destination addr:port
* from Linux firewall. Useful when you redirect * from Linux firewall. Useful when you redirect
* an outbond connection to local handler, and it needs * an outbond connection to local handler, and it needs
@ -473,6 +477,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
xsetenv_plain("TCPORIGDSTADDR", addr); xsetenv_plain("TCPORIGDSTADDR", addr);
free(addr); free(addr);
} }
#endif
xsetenv_plain("PROTO", proto); xsetenv_plain("PROTO", proto);
xsetenv_proto(proto, "LOCALADDR", local_addr); xsetenv_proto(proto, "LOCALADDR", local_addr);
xsetenv_proto(proto, "REMOTEADDR", remote_addr); xsetenv_proto(proto, "REMOTEADDR", remote_addr);