diff options
author | Micael Karlberg <[email protected]> | 2018-05-08 15:40:07 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 13:01:37 +0200 |
commit | 3d719906dd0ad8d07547c3a20a2190a416dda364 (patch) | |
tree | e138e87266d9dedc15472e17a7d194d1f62546e7 /erts | |
parent | 56641fca11c50306c6c62266844f7828e325ae7d (diff) | |
download | otp-3d719906dd0ad8d07547c3a20a2190a416dda364.tar.gz otp-3d719906dd0ad8d07547c3a20a2190a416dda364.tar.bz2 otp-3d719906dd0ad8d07547c3a20a2190a416dda364.zip |
[socket-nif] setopt of socket option dontroute
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/nifs/common/socket_nif.c | 60 | ||||
-rw-r--r-- | erts/preloaded/src/socket.erl | 13 |
2 files changed, 47 insertions, 26 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index 905e04848c..d8e274341f 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -348,36 +348,37 @@ typedef union { #define SOCKET_SHUTDOWN_HOW_RDWR 2 -#define SOCKET_OPT_LEVEL_OTP 0 -#define SOCKET_OPT_LEVEL_SOCKET 1 -#define SOCKET_OPT_LEVEL_IP 2 -#define SOCKET_OPT_LEVEL_IPV6 3 -#define SOCKET_OPT_LEVEL_TCP 4 -#define SOCKET_OPT_LEVEL_UDP 5 -#define SOCKET_OPT_LEVEL_SCTP 6 - -#define SOCKET_OPT_OTP_DEBUG 0 -#define SOCKET_OPT_OTP_IOW 1 - +#define SOCKET_OPT_LEVEL_OTP 0 +#define SOCKET_OPT_LEVEL_SOCKET 1 +#define SOCKET_OPT_LEVEL_IP 2 +#define SOCKET_OPT_LEVEL_IPV6 3 +#define SOCKET_OPT_LEVEL_TCP 4 +#define SOCKET_OPT_LEVEL_UDP 5 +#define SOCKET_OPT_LEVEL_SCTP 6 + +#define SOCKET_OPT_OTP_DEBUG 0 +#define SOCKET_OPT_OTP_IOW 1 + +#define SOCKET_OPT_SOCK_DONTROUTE 7 #define SOCKET_OPT_SOCK_KEEPALIVE 9 #define SOCKET_OPT_SOCK_LINGER 10 #define SOCKET_OPT_SOCK_PRIORITY 16 #define SOCKET_OPT_SOCK_REUSEADDR 21 -#define SOCKET_OPT_IP_RECVTOS 0 -#define SOCKET_OPT_IP_ROUTER_ALERT 1 -#define SOCKET_OPT_IP_TOS 2 -#define SOCKET_OPT_IP_TTL 3 +#define SOCKET_OPT_IP_RECVTOS 25 +#define SOCKET_OPT_IP_ROUTER_ALERT 28 +#define SOCKET_OPT_IP_TOS 30 +#define SOCKET_OPT_IP_TTL 32 #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_TCP_CONGESTION 0 +#define SOCKET_OPT_TCP_MAXSEG 1 +#define SOCKET_OPT_TCP_NODELAY 2 -#define SOCKET_OPT_UDP_CORK 0 +#define SOCKET_OPT_UDP_CORK 0 -#define SOCKET_OPT_SCTP_AUTOCLOSE 7 +#define SOCKET_OPT_SCTP_AUTOCLOSE 7 #define SOCKET_OPT_SCTP_NODELAY 22 @@ -3397,6 +3398,25 @@ BOOLEAN_T eoptval2optval_socket(ErlNifEnv* env, SocketOptValue* valP) { switch (eOpt) { +#if defined(SO_DONTROUTE) + case SOCKET_OPT_SOCK_DONTROUTE: + { + BOOLEAN_T val; + + if (decode_bool(env, eVal, &val)) { + *opt = SO_DONTROUTE; + valP->tag = SOCKET_OPT_VALUE_INT; + valP->u.intVal = (val) ? 1 : 0; + return TRUE; + } else { + *opt = -1; + valP->tag = SOCKET_OPT_VALUE_UNDEF; + return FALSE; + } + } + break; +#endif + #if defined(SO_KEEPALIVE) case SOCKET_OPT_SOCK_KEEPALIVE: { diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 4c903bb759..f1b5623362 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -432,15 +432,16 @@ -define(SOCKET_OPT_OTP_DEBUG, 0). -define(SOCKET_OPT_OTP_IOW, 1). +-define(SOCKET_OPT_SOCK_DONTROUTE, 7). -define(SOCKET_OPT_SOCK_KEEPALIVE, 9). -define(SOCKET_OPT_SOCK_LINGER, 10). -define(SOCKET_OPT_SOCK_PRIORITY, 16). -define(SOCKET_OPT_SOCK_REUSEADDR, 21). --define(SOCKET_OPT_IP_RECVTOS, 0). --define(SOCKET_OPT_IP_ROUTER_ALERT, 1). --define(SOCKET_OPT_IP_TOS, 2). --define(SOCKET_OPT_IP_TTL, 3). +-define(SOCKET_OPT_IP_RECVTOS, 25). +-define(SOCKET_OPT_IP_ROUTER_ALERT, 28). +-define(SOCKET_OPT_IP_TOS, 30). +-define(SOCKET_OPT_IP_TTL, 32). -define(SOCKET_OPT_IPV6_HOPLIMIT, 12). @@ -1803,8 +1804,8 @@ enc_sockopt_key(socket, busy_poll = Opt, _Dir, _D, _T, _P) -> not_supported(Opt); enc_sockopt_key(socket, debug = Opt, _Dir, _D, _T, _P) -> not_supported(Opt); -enc_sockopt_key(socket, dontroute = Opt, _Dir, _D, _T, _P) -> - not_supported(Opt); +enc_sockopt_key(socket, dontroute = _Opt, _Dir, _D, _T, _P) -> + ?SOCKET_OPT_SOCK_DONTROUTE; enc_sockopt_key(socket, error = Opt, get = _Dir, _D, _T, _P) -> not_supported(Opt); %% This is only for connection-oriented sockets, but who are those? |