diff options
author | Micael Karlberg <[email protected]> | 2018-05-08 12:16:11 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 13:01:37 +0200 |
commit | fece5e536ba4e814bcfe5896e23c2ef979468c7b (patch) | |
tree | 8578f9855ca420fa5db2694544217a133f07e0a7 /erts/emulator/nifs | |
parent | f7f70b94f90b1f500cb884be8ae722e1a22acf2e (diff) | |
download | otp-fece5e536ba4e814bcfe5896e23c2ef979468c7b.tar.gz otp-fece5e536ba4e814bcfe5896e23c2ef979468c7b.tar.bz2 otp-fece5e536ba4e814bcfe5896e23c2ef979468c7b.zip |
[socket-nif] More setopt
Add handling of nodelay tcp option setopt.
Added placeholder sctp options autoclose and nodelay
(since my machine does not actually have sctp installed...).
Diffstat (limited to 'erts/emulator/nifs')
-rw-r--r-- | erts/emulator/nifs/common/socket_nif.c | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index 11085ddab5..9887047135 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -366,10 +366,14 @@ typedef union { #define SOCKET_OPT_IP_TOS 2 #define SOCKET_OPT_IP_TTL 3 -#define SOCKET_OPT_IPV6_HOPLIMIT 0 +#define SOCKET_OPT_IPV6_HOPLIMIT 12 #define SOCKET_OPT_TCP_CONGESTION 0 #define SOCKET_OPT_TCP_MAXSEG 1 +#define SOCKET_OPT_TCP_NODELAY 2 + +#define SOCKET_OPT_SCTP_AUTOCLOSE 7 +#define SOCKET_OPT_SCTP_NODELAY 22 /* =================================================================== * @@ -3344,11 +3348,13 @@ BOOLEAN_T eoptval2optval_otp(ErlNifEnv* env, { if (decode_bool(env, eVal, &valP->u.boolVal)) { valP->tag = SOCKET_OPT_VALUE_BOOL; - result = TRUE; + *opt = eOpt; + result = TRUE; } else { - result = FALSE; + valP->tag = SOCKET_OPT_VALUE_UNDEF; + *opt = -1; + result = FALSE; } - *opt = eOpt; } break; @@ -3582,14 +3588,28 @@ BOOLEAN_T eoptval2optval_tcp(ErlNifEnv* env, #endif #if defined(TCP_MAXSEG) - case SOCKET_OPT_TCP_MAXSEG: - if (!GET_INT(env, eVal, &valP->u.intVal)) { - valP->tag = SOCKET_OPT_VALUE_INT; - *opt = TCP_MAXSEG; + case SOCKET_OPT_TCP_MAXSEG: + if (!GET_INT(env, eVal, &valP->u.intVal)) { + valP->tag = SOCKET_OPT_VALUE_INT; + *opt = TCP_MAXSEG; + return TRUE; + } else { + *opt = -1; + valP->tag = SOCKET_OPT_VALUE_UNDEF; + return FALSE; + } + break; +#endif + +#if defined(TCP_NODELAY) + case SOCKET_OPT_TCP_NODELAY: + if (decode_bool(env, eVal, &valP->u.boolVal)) { + valP->tag = SOCKET_OPT_VALUE_BOOL; + *opt = TCP_NODELAY; return TRUE; } else { - *opt = -1; valP->tag = SOCKET_OPT_VALUE_UNDEF; + *opt = -1; return FALSE; } break; @@ -3636,11 +3656,29 @@ BOOLEAN_T eoptval2optval_sctp(ErlNifEnv* env, switch (eOpt) { #if defined(SCTP_AUTOCLOSE) case SOCKET_OPT_SCTP_AUTOCLOSE: - if (!GET_INT(env, eVal, &valP->u.intVal)) + if (GET_INT(env, eVal, &valP->u.intVal)) { + valP->tag = SOCKET_OPT_VALUE_INT; + *opt = SCTP_AUTOCLOSE; + return TRUE; + } else { + valP->tag = SOCKET_OPT_VALUE_UNDEF; + *opt = -1; return FALSE; // PLACEHOLDER - We should really be more informative - valP->tag = SOCKET_OPT_VALUE_INT; - *opt = SCTP_AUTOCLOSE; - return TRUE; + } + break; +#endif + +#if defined(SCTP_NODELAY) + case SOCKET_OPT_SCTP_NODELAY: + if (decode_bool(env, eVal, &valP->u.boolVal)) { + valP->tag = SOCKET_OPT_VALUE_BOOL; + *opt = SCTP_NODELAY; + return TRUE; + } else { + valP->tag = SOCKET_OPT_VALUE_UNDEF; + *opt = -1; + return FALSE; + } break; #endif |