eb797bc34679422486874be3307a4ba9a840c950
[external/busybox.git] / packaging / tcpsvd-udpsvd-conditionalize-usage-of-SO_ORIGINAL_DS.patch
1 From 2ea12d8b6d2a36c5d49df1ae97b86ba287835249 Mon Sep 17 00:00:00 2001
2 From: Jeremie Koenig <jk@jk.fr.eu.org>
3 Date: Thu, 27 May 2010 15:46:25 +0200
4 Subject: [PATCH 9/9] tcpsvd,udpsvd: conditionalize usage of SO_ORIGINAL_DST
5
6 On systems without this call, $TCPORIGDSTADDR is not set.
7
8 Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
10 ---
11  networking/Config.src |    2 --
12  networking/tcpudp.c   |    5 +++++
13  2 files changed, 5 insertions(+), 2 deletions(-)
14
15 diff --git a/networking/Config.src b/networking/Config.src
16 index fc613e8..2d29c42 100644
17 --- a/networking/Config.src
18 +++ b/networking/Config.src
19 @@ -733,7 +733,6 @@ config SLATTACH
20  config TCPSVD
21         bool "tcpsvd"
22         default y
23 -       depends on PLATFORM_LINUX
24         help
25           tcpsvd listens on a TCP port and runs a program for each new
26           connection.
27 @@ -966,7 +965,6 @@ config IFUPDOWN_UDHCPC_CMD_OPTIONS
28  config UDPSVD
29         bool "udpsvd"
30         default y
31 -       depends on PLATFORM_LINUX
32         help
33           udpsvd listens on an UDP port and runs a program for each new
34           connection.
35 diff --git a/networking/tcpudp.c b/networking/tcpudp.c
36 index 53e622b..40f6825 100644
37 --- a/networking/tcpudp.c
38 +++ b/networking/tcpudp.c
39 @@ -30,9 +30,12 @@
40   */
41  
42  #include "libbb.h"
43 +
44  /* Wants <limits.h> etc, thus included after libbb.h: */
45 +#ifdef __linux__
46  #include <linux/types.h> /* for __be32 etc */
47  #include <linux/netfilter_ipv4.h>
48 +#endif
49  
50  // TODO: move into this file:
51  #include "tcpudp_perhost.h"
52 @@ -464,6 +467,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
53                         /* setup ucspi env */
54                         const char *proto = tcp ? "TCP" : "UDP";
55  
56 +#ifdef SO_ORIGINAL_DST
57                         /* Extract "original" destination addr:port
58                          * from Linux firewall. Useful when you redirect
59                          * an outbond connection to local handler, and it needs
60 @@ -473,6 +477,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
61                                 xsetenv_plain("TCPORIGDSTADDR", addr);
62                                 free(addr);
63                         }
64 +#endif
65                         xsetenv_plain("PROTO", proto);
66                         xsetenv_proto(proto, "LOCALADDR", local_addr);
67                         xsetenv_proto(proto, "REMOTEADDR", remote_addr);
68 -- 
69 1.7.1
70