From d109e3131be86dce467aa2d9563c3b25349553ef Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sat, 12 Dec 2020 13:47:40 +0100 Subject: [PATCH] Added option ip-transparent (socket option IP_TRANSPARENT) --- CHANGES | 3 +++ doc/socat.yo | 4 ++++ filan.c | 3 +++ xio-ip.c | 3 +++ xio-ip.h | 1 + xioopts.c | 6 ++++++ xioopts.h | 3 +++ 7 files changed, 23 insertions(+) diff --git a/CHANGES b/CHANGES index f68d1ab..21cb847 100644 --- a/CHANGES +++ b/CHANGES @@ -142,6 +142,9 @@ New features: Added options -r and -R for raw dump of transferred data to files. Test: OPTION_RAW_DUMP + Added option ip-transparent (socket option IP_TRANSPARENT) + Thanks to Wang Shanker for sending a patch. + ####################### V 1.7.3.4: Corrections: diff --git a/doc/socat.yo b/doc/socat.yo index 98698ae..e489dd5 100644 --- a/doc/socat.yo +++ b/doc/socat.yo @@ -2116,6 +2116,10 @@ dit(bf(tt(ip-multicast-loop=))) label(OPTION_IP_MULTICAST_TTL) dit(bf(tt(ip-multicast-ttl=))) Sets the TTL used for outgoing multicast traffic. Default is 1. +label(OPTOIN_IP_TRANSPARENT) +dit(bf(tt(ip-transparent))) + Sets the IP_TRANSPARENT socket option. + This option might require root privilege. label(OPTION_RES_DEBUG)dit(bf(tt(res-debug))) label(OPTION_RES_AAONLY)dit(bf(tt(res-aaonly))) label(OPTION_RES_USEVC)dit(bf(tt(res-usevc))) diff --git a/filan.c b/filan.c index 7d7ceb2..cef23c1 100644 --- a/filan.c +++ b/filan.c @@ -745,6 +745,9 @@ int ipan(int fd, FILE *outfile) { #ifdef IP_RECVTOS {IP_RECVTOS, "IP_RECVTOS"}, #endif +#ifdef IP_TRANSPARENT + {IP_TRANSPARENT, "IP_TRANSPARENT"}, +#endif #ifdef IP_MTU {IP_MTU, "IP_MTU"}, #endif diff --git a/xio-ip.c b/xio-ip.c index ad99a64..afa3c94 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -50,6 +50,9 @@ const struct optdesc opt_ip_mtu_discover={"ip-mtu-discover","mtudiscover",OPT_IP #ifdef IP_MTU const struct optdesc opt_ip_mtu = { "ip-mtu", "mtu", OPT_IP_MTU, GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_INT, OFUNC_SOCKOPT, SOL_IP, IP_MTU }; #endif +#ifdef IP_TRANSPARENT +const struct optdesc opt_ip_transparent = {"ip-transparent", "transparent", OPT_IP_TRANSPARENT, GROUP_SOCK_IP, PH_PREBIND, TYPE_BOOL, OFUNC_SOCKOPT, SOL_IP, IP_TRANSPARENT}; +#endif #ifdef IP_FREEBIND const struct optdesc opt_ip_freebind= { "ip-freebind","freebind", OPT_IP_FREEBIND,GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_INT, OFUNC_SOCKOPT, SOL_IP, IP_FREEBIND }; #endif diff --git a/xio-ip.h b/xio-ip.h index eb744d8..801bd95 100644 --- a/xio-ip.h +++ b/xio-ip.h @@ -26,6 +26,7 @@ extern const struct optdesc opt_ip_pktoptions; extern const struct optdesc opt_ip_add_membership; extern const struct optdesc opt_ip_recvdstaddr; extern const struct optdesc opt_ip_recvif; +extern const struct optdesc opt_ip_transparent; extern const struct optdesc opt_res_debug; extern const struct optdesc opt_res_aaonly; diff --git a/xioopts.c b/xioopts.c index d9fe679..9947001 100644 --- a/xioopts.c +++ b/xioopts.c @@ -719,6 +719,9 @@ const struct optname optionnames[] = { IF_IP ("ip-router-alert", &opt_ip_router_alert) #endif IF_IP ("ip-tos", &opt_ip_tos) +#ifdef IP_TRANSPARENT + IF_IP ("ip-transparent", &opt_ip_transparent) +#endif IF_IP ("ip-ttl", &opt_ip_ttl) #ifdef IP_FREEBIND IF_IP ("ipfreebind", &opt_ip_freebind) @@ -1691,6 +1694,9 @@ const struct optname optionnames[] = { #endif IF_IP ("tos", &opt_ip_tos) IF_TERMIOS("tostop", &opt_tostop) +#ifdef IP_TRANSPARENT + IF_IP ("transparent", &opt_ip_transparent) +#endif IF_OPEN ("trunc", &opt_o_trunc) #if HAVE_FTRUNCATE64 IF_ANY ("truncate", &opt_ftruncate64) diff --git a/xioopts.h b/xioopts.h index 08056d8..30e9fd2 100644 --- a/xioopts.h +++ b/xioopts.h @@ -423,6 +423,9 @@ enum e_optcode { OPT_IP_ROUTER_ALERT, #endif OPT_IP_TOS, +#ifdef IP_TRANSPARENT + OPT_IP_TRANSPARENT, +#endif OPT_IP_TTL, OPT_ISIG, /* termios.c_lflag */ OPT_ISPEED, /* termios.c_ispeed */