diff options
author | Micael Karlberg <[email protected]> | 2018-07-19 17:34:15 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 14:50:18 +0200 |
commit | 6bb60f1fecef368991806e25a0022c63b8650f39 (patch) | |
tree | 92eabb798b7d0813dfe65e4b0f9369ba99e08264 /erts/preloaded/src/socket.erl | |
parent | 7a5b320b5bb5ec45b21839005e8538172908fb57 (diff) | |
download | otp-6bb60f1fecef368991806e25a0022c63b8650f39.tar.gz otp-6bb60f1fecef368991806e25a0022c63b8650f39.tar.bz2 otp-6bb60f1fecef368991806e25a0022c63b8650f39.zip |
[socket-nif] Add (partial) support for socket (level sctp) option rtoinfo
Added support for the SCTP option RTOINFO.
We have the same questions for this option as for ASSOCINFO.
Maybe the assoc field shall be made 'out' only (that is, it will
be ignored for setopt). The assoc id used will be that which
is stored in the descriptor (how do we get it to begin with?).
Questions, questions...
OTP-14831
Diffstat (limited to 'erts/preloaded/src/socket.erl')
-rw-r--r-- | erts/preloaded/src/socket.erl | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index feb2e25312..0bc3ed8ec9 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -96,6 +96,7 @@ ipv6_pmtudisc/0, sctp_event_subscribe/0, sctp_assocparams/0, + sctp_rtoinfo/0, msg_hdr/0 @@ -195,6 +196,11 @@ local_rwnd := non_neg_integer(), cookie_life := non_neg_integer()}. +-type sctp_rtoinfo() :: #{assoc_id := integer(), + initial := non_neg_integer(), + max := non_neg_integer(), + min := non_neg_integer()}. + -type sockaddr_un() :: #{family := local, path := binary() | string()}. -type sockaddr_in4() :: #{family := inet, @@ -672,7 +678,7 @@ %% -define(SOCKET_OPT_SCTP_PEER_AUTH_CHUNKS, 26). %% -define(SOCKET_OPT_SCTP_PRIMARY_ADDR, 27). %% -define(SOCKET_OPT_SCTP_RESET_STREAMS, 28). -%% -define(SOCKET_OPT_SCTP_RTOINFO, 29). +-define(SOCKET_OPT_SCTP_RTOINFO, 29). %% -define(SOCKET_OPT_SCTP_SET_PEER_PRIMARY_ADDR, 30). %% -define(SOCKET_OPT_SCTP_STATUS, 31). %% -define(SOCKET_OPT_SCTP_USE_EXT_RECVINFO, 32). @@ -2226,7 +2232,21 @@ enc_setopt_value(sctp, events, #{data_in := DataIn, enc_setopt_value(sctp, nodelay, V, _D, _T, P) when is_boolean(V) andalso (P =:= sctp) -> V; +enc_setopt_value(sctp, rtoinfo, #{assoc_id := AssocId, + initial := Init, + max := Max, + min := Min} = V, + _D, _T, P) + when is_integer(AssocId) andalso + is_integer(Init) andalso (Init >= 0) andalso + is_integer(Max) andalso (Max >= 0) andalso + is_integer(Min) andalso (Min >= 0) andalso + (P =:= sctp) -> + V; +enc_setopt_value(sctp = L, Opt, V, _D, _T, _P) -> + not_supported({L, Opt, V}); +%% Is this correct? What about getopt? enc_setopt_value(L, Opt, V, _, _, _) when is_integer(L) andalso is_integer(Opt) andalso is_binary(V) -> V. @@ -2672,8 +2692,8 @@ enc_sockopt_key(sctp = L, primary_addr = Opt, _Dir, _D, _T, _P) -> not_supported({L, Opt}); enc_sockopt_key(sctp = L, reset_streams = Opt, _Dir, _D, _T, _P) -> not_supported({L, Opt}); -enc_sockopt_key(sctp = L, rtoinfo = Opt, _Dir, _D, _T, _P) -> - not_supported({L, Opt}); +enc_sockopt_key(sctp = _L, rtoinfo = _Opt, _Dir, _D, _T, _P) -> + ?SOCKET_OPT_SCTP_RTOINFO; enc_sockopt_key(sctp = L, set_peer_primary_addr = Opt, _Dir, _D, _T, _P) -> not_supported({L, Opt}); enc_sockopt_key(sctp = L, status = Opt, _Dir, _D, _T, _P) -> |