From 6bb60f1fecef368991806e25a0022c63b8650f39 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 17:34:15 +0200 Subject: [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 --- erts/preloaded/ebin/socket.beam | Bin 53256 -> 53668 bytes erts/preloaded/src/socket.erl | 26 +++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'erts/preloaded') diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam index 0c496443bf..427c08cd57 100644 Binary files a/erts/preloaded/ebin/socket.beam and b/erts/preloaded/ebin/socket.beam differ 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) -> -- cgit v1.2.3