aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-07-19 17:54:14 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit08ce39bbc2cd3006475c87807042c2d08a68736f (patch)
treed8d31294b97c2db2ec97629c698aa5dac07381af /erts
parent6bb60f1fecef368991806e25a0022c63b8650f39 (diff)
downloadotp-08ce39bbc2cd3006475c87807042c2d08a68736f.tar.gz
otp-08ce39bbc2cd3006475c87807042c2d08a68736f.tar.bz2
otp-08ce39bbc2cd3006475c87807042c2d08a68736f.zip
[socket-nif] Add support for socket (level sctp) option maxseg
Added support for the SCTP option MAXSEG. OTP-14831
Diffstat (limited to 'erts')
-rw-r--r--erts/doc/src/socket_usage.xml7
-rw-r--r--erts/emulator/nifs/common/socket_nif.c47
-rw-r--r--erts/preloaded/ebin/socket.beambin53668 -> 53748 bytes
-rw-r--r--erts/preloaded/src/socket.erl9
4 files changed, 60 insertions, 3 deletions
diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml
index 1e325016ff..21f5d17e84 100644
--- a/erts/doc/src/socket_usage.xml
+++ b/erts/doc/src/socket_usage.xml
@@ -487,6 +487,13 @@
<cell>none</cell>
</row>
<row>
+ <cell>maxseg</cell>
+ <cell>non_neg_integer()</cell>
+ <cell>yes</cell>
+ <cell>yes</cell>
+ <cell>none</cell>
+ </row>
+ <row>
<cell>nodelay</cell>
<cell>boolean()</cell>
<cell>yes</cell>
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index f9643cccbf..e84eb7aa8e 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -546,6 +546,7 @@ typedef union {
#define SOCKET_OPT_SCTP_AUTOCLOSE 8
#define SOCKET_OPT_SCTP_DISABLE_FRAGMENTS 12
#define SOCKET_OPT_SCTP_EVENTS 14
+#define SOCKET_OPT_SCTP_MAXSEG 21
#define SOCKET_OPT_SCTP_NODELAY 23
#define SOCKET_OPT_SCTP_RTOINFO 29
@@ -1234,6 +1235,11 @@ static ERL_NIF_TERM nsetopt_lvl_sctp_events(ErlNifEnv* env,
SocketDescriptor* descP,
ERL_NIF_TERM eVal);
#endif
+#if defined(SCTP_MAXSEG)
+static ERL_NIF_TERM nsetopt_lvl_sctp_maxseg(ErlNifEnv* env,
+ SocketDescriptor* descP,
+ ERL_NIF_TERM eVal);
+#endif
#if defined(SCTP_NODELAY)
static ERL_NIF_TERM nsetopt_lvl_sctp_nodelay(ErlNifEnv* env,
SocketDescriptor* descP,
@@ -1459,6 +1465,10 @@ static ERL_NIF_TERM ngetopt_lvl_sctp_autoclose(ErlNifEnv* env,
static ERL_NIF_TERM ngetopt_lvl_sctp_disable_fragments(ErlNifEnv* env,
SocketDescriptor* descP);
#endif
+#if defined(SCTP_MAXSEG)
+static ERL_NIF_TERM ngetopt_lvl_sctp_maxseg(ErlNifEnv* env,
+ SocketDescriptor* descP);
+#endif
#if defined(SCTP_NODELAY)
static ERL_NIF_TERM ngetopt_lvl_sctp_nodelay(ErlNifEnv* env,
SocketDescriptor* descP);
@@ -5575,6 +5585,12 @@ ERL_NIF_TERM nsetopt_lvl_sctp(ErlNifEnv* env,
break;
#endif
+#if defined(SCTP_MAXSEG)
+ case SOCKET_OPT_SCTP_MAXSEG:
+ result = nsetopt_lvl_sctp_maxseg(env, descP, eVal);
+ break;
+#endif
+
#if defined(SCTP_NODELAY)
case SOCKET_OPT_SCTP_NODELAY:
result = nsetopt_lvl_sctp_nodelay(env, descP, eVal);
@@ -5822,6 +5838,19 @@ ERL_NIF_TERM nsetopt_lvl_sctp_events(ErlNifEnv* env,
#endif
+/* nsetopt_lvl_sctp_maxseg - Level SCTP MAXSEG option
+ */
+#if defined(SCTP_MAXSEG)
+static
+ERL_NIF_TERM nsetopt_lvl_sctp_maxseg(ErlNifEnv* env,
+ SocketDescriptor* descP,
+ ERL_NIF_TERM eVal)
+{
+ return nsetopt_int_opt(env, descP, IPPROTO_SCTP, SCTP_MAXSEG, eVal);
+}
+#endif
+
+
/* nsetopt_lvl_sctp_nodelay - Level SCTP NODELAY option
*/
#if defined(SCTP_NODELAY)
@@ -7585,6 +7614,12 @@ ERL_NIF_TERM ngetopt_lvl_sctp(ErlNifEnv* env,
break;
#endif
+#if defined(SCTP_MAXSEG)
+ case SOCKET_OPT_SCTP_MAXSEG:
+ result = ngetopt_lvl_sctp_maxseg(env, descP);
+ break;
+#endif
+
#if defined(SCTP_NODELAY)
case SOCKET_OPT_SCTP_NODELAY:
result = ngetopt_lvl_sctp_nodelay(env, descP);
@@ -7697,6 +7732,18 @@ ERL_NIF_TERM ngetopt_lvl_sctp_disable_fragments(ErlNifEnv* env,
#endif
+/* ngetopt_lvl_sctp_maxseg - Level SCTP MAXSEG option
+ */
+#if defined(SCTP_MAXSEG)
+static
+ERL_NIF_TERM ngetopt_lvl_sctp_maxseg(ErlNifEnv* env,
+ SocketDescriptor* descP)
+{
+ return ngetopt_int_opt(env, descP, IPPROTO_SCTP, SCTP_MAXSEG);
+}
+#endif
+
+
/* ngetopt_lvl_sctp_nodelay - Level SCTP NODELAY option
*/
#if defined(SCTP_NODELAY)
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index 427c08cd57..2e284e3343 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 0bc3ed8ec9..1c24c75dac 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -670,7 +670,7 @@
%% -define(SOCKET_OPT_SCTP_INITMSG, 18).
%% -define(SOCKET_OPT_SCTP_I_WANT_MAPPED_V4_ADDR, 19).
%% -define(SOCKET_OPT_SCTP_LOCAL_AUTH_CHUNKS, 20).
-%% -define(SOCKET_OPT_SCTP_MAXSEG, 21).
+-define(SOCKET_OPT_SCTP_MAXSEG, 21).
%% -define(SOCKET_OPT_SCTP_MAXBURST, 22).
-define(SOCKET_OPT_SCTP_NODELAY, 23).
%% -define(SOCKET_OPT_SCTP_PARTIAL_DELIVERY_POINT, 24).
@@ -2229,6 +2229,9 @@ enc_setopt_value(sctp, events, #{data_in := DataIn,
is_boolean(SndDry) andalso
(P =:= sctp) ->
V;
+enc_setopt_value(sctp, maxseg, V, _D, _T, P)
+ when is_integer(V) andalso (V >= 0) andalso (P =:= sctp) ->
+ V;
enc_setopt_value(sctp, nodelay, V, _D, _T, P)
when is_boolean(V) andalso (P =:= sctp) ->
V;
@@ -2676,8 +2679,8 @@ enc_sockopt_key(sctp = L, i_want_mapped_v4_addr = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
enc_sockopt_key(sctp = L, local_auth_chunks = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
-enc_sockopt_key(sctp = L, maxseg = Opt, _Dir, _D, _T, _P) ->
- not_supported({L, Opt});
+enc_sockopt_key(sctp = _L, maxseg = _Opt, _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_SCTP_MAXSEG;
enc_sockopt_key(sctp = L, maxburst = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
enc_sockopt_key(sctp, nodelay = _Opt, _Dir, _D, _T, _P) ->