aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-05-08 12:36:35 +0200
committerMicael Karlberg <[email protected]>2018-09-18 13:01:37 +0200
commitd6b051d9b09aeba00d1bbd0d448dde6e551c4442 (patch)
treef550f2dfe8a5689f8503ee05494c7c742948d048 /erts/emulator/nifs
parentfece5e536ba4e814bcfe5896e23c2ef979468c7b (diff)
downloadotp-d6b051d9b09aeba00d1bbd0d448dde6e551c4442.tar.gz
otp-d6b051d9b09aeba00d1bbd0d448dde6e551c4442.tar.bz2
otp-d6b051d9b09aeba00d1bbd0d448dde6e551c4442.zip
[socket-nif] More setopt - udp
Add setopt for one udp option: cork. This is not platform independent. Aas fas as I know, it only works on linux, so for now this serves as a placeholder.
Diffstat (limited to 'erts/emulator/nifs')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 9887047135..14d7cd2611 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -133,6 +133,7 @@
#endif
#include <netinet/tcp.h>
+#include <netinet/udp.h>
#include <arpa/inet.h>
#include <sys/param.h>
@@ -372,6 +373,8 @@ typedef union {
#define SOCKET_OPT_TCP_MAXSEG 1
#define SOCKET_OPT_TCP_NODELAY 2
+#define SOCKET_OPT_UDP_CORK 0
+
#define SOCKET_OPT_SCTP_AUTOCLOSE 7
#define SOCKET_OPT_SCTP_NODELAY 22
@@ -3625,8 +3628,8 @@ BOOLEAN_T eoptval2optval_tcp(ErlNifEnv* env,
/* +++ decode UDP socket options +++
- * Currently there are no such options, so this function
- * is just a placeholder!
+ * Currently there are only one option, cork, and that may only
+ * work on linux...
*/
static
BOOLEAN_T eoptval2optval_udp(ErlNifEnv* env,
@@ -3636,6 +3639,20 @@ BOOLEAN_T eoptval2optval_udp(ErlNifEnv* env,
SocketOptValue* valP)
{
switch (eOpt) {
+#if defined(UDP_CORK)
+ case SOCKET_OPT_UDP_CORK:
+ if (decode_bool(env, eVal, &valP->u.boolVal)) {
+ valP->tag = SOCKET_OPT_VALUE_BOOL;
+ *opt = UDP_CORK;
+ return TRUE;
+ } else {
+ valP->tag = SOCKET_OPT_VALUE_UNDEF;
+ *opt = -1;
+ return FALSE;
+ }
+ break;
+#endif
+
default:
*opt = -1;
valP->tag = SOCKET_OPT_VALUE_UNDEF;