aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-07-12 17:30:59 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit2151895b4eb4cb3172ba7597477fd83eb85b444a (patch)
tree6d61fa5da5fed2e5355692a0c8d17f31cbddb349 /erts/emulator
parent31ed3b1d9cff6171432459bf2de2b761e987ac97 (diff)
downloadotp-2151895b4eb4cb3172ba7597477fd83eb85b444a.tar.gz
otp-2151895b4eb4cb3172ba7597477fd83eb85b444a.tar.bz2
otp-2151895b4eb4cb3172ba7597477fd83eb85b444a.zip
[socket-nif] Add support for socket (level ip) option minttl
Added support for the IP option MINTTL. OTP-14831
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index a851dc94b4..37bb307e2b 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -367,6 +367,7 @@ typedef union {
#define SOCKET_OPT_IP_BLOCK_SOURCE 3
#define SOCKET_OPT_IP_DROP_MEMBERSHIP 5
#define SOCKET_OPT_IP_DROP_SOURCE_MEMBERSHIP 6
+#define SOCKET_OPT_IP_MINTTL 9
#define SOCKET_OPT_IP_MTU 11
#define SOCKET_OPT_IP_MTU_DISCOVER 12
#define SOCKET_OPT_IP_MULTICAST_ALL 13
@@ -887,6 +888,11 @@ static ERL_NIF_TERM nsetopt_lvl_ip_drop_source_membership(ErlNifEnv* env,
SocketDescriptor* descP,
ERL_NIF_TERM eVal);
#endif
+#if defined(IP_MINTTL)
+static ERL_NIF_TERM nsetopt_lvl_ip_minttl(ErlNifEnv* env,
+ SocketDescriptor* descP,
+ ERL_NIF_TERM eVal);
+#endif
#if defined(IP_MTU_DISCOVER)
static ERL_NIF_TERM nsetopt_lvl_ip_mtu_discover(ErlNifEnv* env,
SocketDescriptor* descP,
@@ -1113,6 +1119,10 @@ static ERL_NIF_TERM ngetopt_lvl_sock_type(ErlNifEnv* env,
static ERL_NIF_TERM ngetopt_lvl_ip(ErlNifEnv* env,
SocketDescriptor* descP,
int eOpt);
+#if defined(IP_MINTTL)
+static ERL_NIF_TERM ngetopt_lvl_ip_minttl(ErlNifEnv* env,
+ SocketDescriptor* descP);
+#endif
#if defined(IP_MTU)
static ERL_NIF_TERM ngetopt_lvl_ip_mtu(ErlNifEnv* env,
SocketDescriptor* descP);
@@ -4129,6 +4139,12 @@ ERL_NIF_TERM nsetopt_lvl_ip(ErlNifEnv* env,
break;
#endif
+#if defined(IP_MINTTL)
+ case SOCKET_OPT_IP_MINTTL:
+ result = nsetopt_lvl_ip_minttl(env, descP, eVal);
+ break;
+#endif
+
#if defined(IP_MTU_DISCOVER)
case SOCKET_OPT_IP_MTU_DISCOVER:
result = nsetopt_lvl_ip_mtu_discover(env, descP, eVal);
@@ -4321,6 +4337,26 @@ ERL_NIF_TERM nsetopt_lvl_ip_drop_source_membership(ErlNifEnv* env,
+/* nsetopt_lvl_ip_minttl - Level IP MINTTL option
+ */
+#if defined(IP_MINTTL)
+static
+ERL_NIF_TERM nsetopt_lvl_ip_minttl(ErlNifEnv* env,
+ SocketDescriptor* descP,
+ ERL_NIF_TERM eVal)
+{
+#if defined(SOL_IP)
+ int level = SOL_IP;
+#else
+ int level = IPPROTO_IP;
+#endif
+
+ return nsetopt_int_opt(env, descP, level, IP_MINTTL, eVal);
+}
+#endif
+
+
+
/* nsetopt_lvl_ip_mtu_discover - Level IP MTU_DISCOVER option
*
* The value is an atom of the type ip_pmtudisc().
@@ -5883,6 +5919,12 @@ ERL_NIF_TERM ngetopt_lvl_ip(ErlNifEnv* env,
ERL_NIF_TERM result;
switch (eOpt) {
+#if defined(IP_MINTTL)
+ case SOCKET_OPT_IP_MINTTL:
+ result = ngetopt_lvl_ip_minttl(env, descP);
+ break;
+#endif
+
#if defined(IP_MTU)
case SOCKET_OPT_IP_MTU:
result = ngetopt_lvl_ip_mtu(env, descP);
@@ -5970,6 +6012,24 @@ ERL_NIF_TERM ngetopt_lvl_ip(ErlNifEnv* env,
}
+/* ngetopt_lvl_ip_minttl - Level IP MINTTL option
+ */
+#if defined(IP_MINTTL)
+static
+ERL_NIF_TERM ngetopt_lvl_ip_minttl(ErlNifEnv* env,
+ SocketDescriptor* descP)
+{
+#if defined(SOL_IP)
+ int level = SOL_IP;
+#else
+ int level = IPPROTO_IP;
+#endif
+
+ return ngetopt_int_opt(env, descP, level, IP_MINTTL);
+}
+#endif
+
+
/* ngetopt_lvl_ip_mtu - Level IP MTU option
*/
#if defined(IP_MTU)