diff options
author | Micael Karlberg <[email protected]> | 2018-07-13 14:42:34 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 14:50:18 +0200 |
commit | 5e0a36abaa984358f617541b102b4e4cbb112956 (patch) | |
tree | 0431de23a2aa25700b4bbb6696dd17551dd82160 /erts/preloaded/src | |
parent | 416644989e26ac76038523511d81ebf9e0b8fc4f (diff) | |
download | otp-5e0a36abaa984358f617541b102b4e4cbb112956.tar.gz otp-5e0a36abaa984358f617541b102b4e4cbb112956.tar.bz2 otp-5e0a36abaa984358f617541b102b4e4cbb112956.zip |
[socket-nif] Add support for socket (level socket) option bindtodevice
Added support for socket level socket option BINDTODEVICE.
OTP-14831
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r-- | erts/preloaded/src/socket.erl | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 8d377d808e..d4bf55511c 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -366,15 +366,15 @@ status | use_ext_recvinfo. -%% -type plain_socket_options() :: integer(). -%% -type sockopts() :: otp_socket_options() | -%% socket_options() | -%% ip_socket_options() | -%% ipv6_socket_options() | -%% tcp_socket_options() | -%% udp_socket_options() | -%% sctp_socket_options() | -%% plain_socket_options(). +%% -type plain_socket_option() :: integer(). +%% -type sockopt() :: otp_socket_option() | +%% socket_option() | +%% ip_socket_option() | +%% ipv6_socket_option() | +%% tcp_socket_option() | +%% udp_socket_option() | +%% sctp_socket_option() | +%% plain_socket_option(). %% If the integer value is used its up to the caller to ensure its valid! -type ip_tos_flag() :: lowdeley | @@ -496,7 +496,7 @@ -define(SOCKET_OPT_SOCK_ACCEPTCONN, 1). %% -define(SOCKET_OPT_SOCK_ACCEPTFILTER, 2). -%% -define(SOCKET_OPT_SOCK_BINDTODEVICE, 3). +-define(SOCKET_OPT_SOCK_BINDTODEVICE, 3). -define(SOCKET_OPT_SOCK_BROADCAST, 4). %% -define(SOCKET_OPT_SOCK_BUSY_POLL, 5). -define(SOCKET_OPT_SOCK_DEBUG, 6). @@ -1959,6 +1959,8 @@ enc_setopt_value(otp, controlling_process, V, _, _, _) when is_pid(V) -> enc_setopt_value(otp = L, Opt, V, _D, _T, _P) -> not_supported({L, Opt, V}); +enc_setopt_value(socket, bindtodevice, V, _D, _T, _P) when is_list(V) -> + V; enc_setopt_value(socket, broadcast, V, _D, _T, _P) when is_boolean(V) -> V; enc_setopt_value(socket, debug, V, _D, _T, _P) when is_integer(V) -> @@ -2253,10 +2255,10 @@ enc_sockopt_key(socket = _L, acceptconn = _Opt, get = _Dir, _D, _T, _P) -> enc_sockopt_key(socket = L, acceptfilter = Opt, _Dir, _D, _T, _P) -> not_supported({L, Opt}); %% Before linux 3.8, this socket option could be set. -%% Size of buffer for name: IFNAMSZ +%% Maximum size of buffer for name: IFNAMSZIZ %% So, we let the implementation decide. -enc_sockopt_key(socket = L, bindtodevide = Opt, _Dir, _D, _T, _P) -> - not_supported({L, Opt}); +enc_sockopt_key(socket = _L, bindtodevice = _Opt, _Dir, _D, _T, _P) -> + ?SOCKET_OPT_SOCK_BINDTODEVICE; enc_sockopt_key(socket, broadcast = _Opt, _Dir, _D, dgram = _T, _P) -> ?SOCKET_OPT_SOCK_BROADCAST; enc_sockopt_key(socket = L, busy_poll = Opt, _Dir, _D, _T, _P) -> |