diff options
-rw-r--r-- | erts/doc/src/socket_usage.xml | 9 | ||||
-rw-r--r-- | erts/emulator/nifs/common/socket_nif.c | 67 | ||||
-rw-r--r-- | erts/preloaded/ebin/socket.beam | bin | 59056 -> 59092 bytes | |||
-rw-r--r-- | erts/preloaded/src/socket.erl | 9 | ||||
-rw-r--r-- | lib/kernel/test/socket_server.erl | 7 |
5 files changed, 88 insertions, 4 deletions
diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 443d4edec7..b1fe22b231 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -412,7 +412,14 @@ <cell>ip_tos()</cell> <cell>yes</cell> <cell>yes</cell> - <cell>none</cell> + <cell>may require admin capability</cell> + </row> + <row> + <cell>transparent</cell> + <cell>boolean()</cell> + <cell>yes</cell> + <cell>yes</cell> + <cell>require admin capability</cell> </row> <row> <cell>ttl</cell> diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index f4da7cdbb0..9e9ac333e7 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -538,6 +538,7 @@ typedef union { #define SOCKET_OPT_IP_RECVTTL 26 #define SOCKET_OPT_IP_ROUTER_ALERT 28 #define SOCKET_OPT_IP_TOS 30 +#define SOCKET_OPT_IP_TRANSPARENT 31 #define SOCKET_OPT_IP_TTL 32 #define SOCKET_OPT_IP_UNBLOCK_SOURCE 33 @@ -1204,6 +1205,11 @@ static ERL_NIF_TERM nsetopt_lvl_ip_tos(ErlNifEnv* env, SocketDescriptor* descP, ERL_NIF_TERM eVal); #endif +#if defined(IP_TRANSPARENT) +static ERL_NIF_TERM nsetopt_lvl_ip_transparent(ErlNifEnv* env, + SocketDescriptor* descP, + ERL_NIF_TERM eVal); +#endif #if defined(IP_TTL) static ERL_NIF_TERM nsetopt_lvl_ip_ttl(ErlNifEnv* env, SocketDescriptor* descP, @@ -1608,6 +1614,10 @@ static ERL_NIF_TERM ngetopt_lvl_ip_router_alert(ErlNifEnv* env, static ERL_NIF_TERM ngetopt_lvl_ip_tos(ErlNifEnv* env, SocketDescriptor* descP); #endif +#if defined(IP_TRANSPARENT) +static ERL_NIF_TERM ngetopt_lvl_ip_transparent(ErlNifEnv* env, + SocketDescriptor* descP); +#endif #if defined(IP_TTL) static ERL_NIF_TERM ngetopt_lvl_ip_ttl(ErlNifEnv* env, SocketDescriptor* descP); @@ -5073,6 +5083,12 @@ ERL_NIF_TERM nsetopt_lvl_ip(ErlNifEnv* env, break; #endif +#if defined(IP_TRANSPARENT) + case SOCKET_OPT_IP_TRANSPARENT: + result = nsetopt_lvl_ip_transparent(env, descP, eVal); + break; +#endif + #if defined(IP_TTL) case SOCKET_OPT_IP_TTL: result = nsetopt_lvl_ip_ttl(env, descP, eVal); @@ -5086,10 +5102,16 @@ ERL_NIF_TERM nsetopt_lvl_ip(ErlNifEnv* env, #endif default: + SSDBG( descP, ("SOCKET", "nsetopt_lvl_ip -> unknown opt (%d)\r\n", eOpt) ); result = esock_make_error(env, esock_atom_einval); break; } + SSDBG( descP, + ("SOCKET", "nsetopt_lvl_ip -> done when" + "\r\n result: %T" + "\r\n", result) ); + return result; } @@ -5714,6 +5736,26 @@ ERL_NIF_TERM nsetopt_lvl_ip_tos(ErlNifEnv* env, #endif +/* nsetopt_lvl_ip_transparent - Level IP TRANSPARENT option + */ +#if defined(IP_TRANSPARENT) +static +ERL_NIF_TERM nsetopt_lvl_ip_transparent(ErlNifEnv* env, + SocketDescriptor* descP, + ERL_NIF_TERM eVal) +{ +#if defined(SOL_IP) + int level = SOL_IP; +#else + int level = IPPROTO_IP; +#endif + + return nsetopt_bool_opt(env, descP, level, IP_TRANSPARENT, eVal); +} +#endif + + + /* nsetopt_lvl_ip_ttl - Level IP TTL option */ #if defined(IP_TTL) @@ -8259,6 +8301,12 @@ ERL_NIF_TERM ngetopt_lvl_ip(ErlNifEnv* env, break; #endif +#if defined(IP_TRANSPARENT) + case SOCKET_OPT_IP_TRANSPARENT: + result = ngetopt_lvl_ip_transparent(env, descP); + break; +#endif + #if defined(IP_TTL) case SOCKET_OPT_IP_TTL: result = ngetopt_lvl_ip_ttl(env, descP); @@ -8651,6 +8699,25 @@ ERL_NIF_TERM ngetopt_lvl_ip_tos(ErlNifEnv* env, #endif +/* ngetopt_lvl_ip_transparent - Level IP TRANSPARENT option + */ +#if defined(IP_TRANSPARENT) +static +ERL_NIF_TERM ngetopt_lvl_ip_transparent(ErlNifEnv* env, + SocketDescriptor* descP) +{ +#if defined(SOL_IP) + int level = SOL_IP; +#else + int level = IPPROTO_IP; +#endif + + return ngetopt_bool_opt(env, descP, level, IP_TRANSPARENT); +} +#endif + + + /* ngetopt_lvl_ip_ttl - Level IP TTL option */ #if defined(IP_TTL) diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam Binary files differindex b5b18e1c3a..960a465fb6 100644 --- a/erts/preloaded/ebin/socket.beam +++ b/erts/preloaded/ebin/socket.beam diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 28931e4ed0..c7589cbd48 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -644,7 +644,7 @@ -define(SOCKET_OPT_IP_ROUTER_ALERT, 28). %% -define(SOCKET_OPT_IP_SNDSRCADDR, 29). -define(SOCKET_OPT_IP_TOS, 30). -%% -define(SOCKET_OPT_IP_TRANSPARENT, 31). +-define(SOCKET_OPT_IP_TRANSPARENT, 31). -define(SOCKET_OPT_IP_TTL, 32). -define(SOCKET_OPT_IP_UNBLOCK_SOURCE, 33). @@ -2274,6 +2274,9 @@ enc_setopt_value(ip, tos, V, _D, _T, _P) (V =:= mincost) orelse is_integer(V) -> V; +enc_setopt_value(ip, transparent, V, _D, _T, _P) + when is_boolean(V) -> + V; enc_setopt_value(ip, ttl, V, _D, _T, _P) when is_integer(V) -> V; @@ -2731,8 +2734,8 @@ enc_sockopt_key(ip, router_alert = _Opt, _Dir, _D, raw = _T, _P) -> %% No such condition on linux (in the man page)... enc_sockopt_key(ip, tos = _Opt, _Dir, _D, _T, _P) -> ?SOCKET_OPT_IP_TOS; -enc_sockopt_key(ip = L, transparent = Opt, _Dir, _D, _T, _P) -> - not_supported({L, Opt}); +enc_sockopt_key(ip = _L, transparent = _Opt, _Dir, _D, _T, _P) -> + ?SOCKET_OPT_IP_TRANSPARENT; enc_sockopt_key(ip, ttl = _Opt, _Dir, _D, _T, _P) -> ?SOCKET_OPT_IP_TTL; enc_sockopt_key(ip = _L, unblock_source = _Opt, set = _Dir, _D, _T, _P) -> diff --git a/lib/kernel/test/socket_server.erl b/lib/kernel/test/socket_server.erl index 0ae6bb2dd0..447e742895 100644 --- a/lib/kernel/test/socket_server.erl +++ b/lib/kernel/test/socket_server.erl @@ -642,6 +642,9 @@ handler_init(Manager, ID, Peek, Sock) -> RecvOPTS = GIP4(recvopts), % Not stream RecvTOS = GIP4(recvtos), RecvTTL = GIP4(recvttl), % not stream + TOS = GIP4(tos), + Transparent = GIP4(transparent), + TTL = GIP4(ttl), MHops = GIP6(multicast_hops), MIF6 = GIP6(multicast_if), % Only dgram and raw MLoop6 = GIP6(multicast_loop), @@ -684,6 +687,9 @@ handler_init(Manager, ID, Peek, Sock) -> "~n (ip) Recv OPTS: ~s" "~n (ip) Recv TOS: ~s" "~n (ip) Recv TTL: ~s" + "~n (ip) TOS: ~s" + "~n (ip) Transparent: ~s" + "~n (ip) TTL: ~s" "~n (ipv6) Multicast Hops: ~s" "~n (ipv6) Multicast IF: ~s" "~n (ipv6) Multicast Loop: ~s" @@ -702,6 +708,7 @@ handler_init(Manager, ID, Peek, Sock) -> Linger, Timestamp, FreeBind, MTU, MTUDisc, MALL, MIF4, MLoop4, MTTL, NF, PktInfo,RecvErr4, RecvIF, RecvOPTS, RecvTOS, RecvTTL, + TOS, Transparent, TTL, MHops, MIF6, MLoop6, RecvErr6, RecvPktInfo, RtHdr, AuthHdr, HopLimit, HopOpts, DstOpts, FlowInfo, UHops]), |