aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLee Salzman <[email protected]>2023-01-08 14:08:39 -0500
committerGitHub <[email protected]>2023-01-08 14:08:39 -0500
commitbb788ea48bf06184e1553da4e0375a9994ab34d3 (patch)
treef0126aedc5421ea5ac3eb1d5db212dae802ad04b
parent311360dbddc350722da00a3026077c47327e932d (diff)
parent4e69c700d6ca737c36c5a84829bbd04df8acc22b (diff)
downloadenet-bb788ea48bf06184e1553da4e0375a9994ab34d3.tar.gz
enet-bb788ea48bf06184e1553da4e0375a9994ab34d3.zip
Merge pull request #217 from skyfloogle/ttl
Add ENET_SOCKOPT_TTL
-rw-r--r--include/enet/enet.h3
-rw-r--r--unix.c9
-rw-r--r--win32.c10
3 files changed, 21 insertions, 1 deletions
diff --git a/include/enet/enet.h b/include/enet/enet.h
index d422ef5..522e30d 100644
--- a/include/enet/enet.h
+++ b/include/enet/enet.h
@@ -62,7 +62,8 @@ typedef enum _ENetSocketOption
ENET_SOCKOPT_RCVTIMEO = 6,
ENET_SOCKOPT_SNDTIMEO = 7,
ENET_SOCKOPT_ERROR = 8,
- ENET_SOCKOPT_NODELAY = 9
+ ENET_SOCKOPT_NODELAY = 9,
+ ENET_SOCKOPT_TTL = 10
} ENetSocketOption;
typedef enum _ENetSocketShutdown
diff --git a/unix.c b/unix.c
index b029221..2c7d847 100644
--- a/unix.c
+++ b/unix.c
@@ -348,6 +348,10 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
break;
+ case ENET_SOCKOPT_TTL:
+ result = setsockopt (socket, IPPROTO_IP, IP_TTL, (char *) & value, sizeof (int));
+ break;
+
default:
break;
}
@@ -366,6 +370,11 @@ enet_socket_get_option (ENetSocket socket, ENetSocketOption option, int * value)
result = getsockopt (socket, SOL_SOCKET, SO_ERROR, value, & len);
break;
+ case ENET_SOCKOPT_TTL:
+ len = sizeof (int);
+ result = getsockopt (socket, IPPROTO_IP, IP_TTL, (char *) value, & len);
+ break;
+
default:
break;
}
diff --git a/win32.c b/win32.c
index eebdb03..0953466 100644
--- a/win32.c
+++ b/win32.c
@@ -8,6 +8,7 @@
#include "enet/enet.h"
#include <windows.h>
#include <mmsystem.h>
+#include <ws2ipdef.h>
static enet_uint32 timeBase = 0;
@@ -231,6 +232,10 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int));
break;
+ case ENET_SOCKOPT_TTL:
+ result = setsockopt (socket, IPPROTO_IP, IP_TTL, (char *) & value, sizeof (int));
+ break;
+
default:
break;
}
@@ -248,6 +253,11 @@ enet_socket_get_option (ENetSocket socket, ENetSocketOption option, int * value)
result = getsockopt (socket, SOL_SOCKET, SO_ERROR, (char *) value, & len);
break;
+ case ENET_SOCKOPT_TTL:
+ len = sizeof(int);
+ result = getsockopt (socket, IPPROTO_IP, IP_TTL, (char *) value, & len);
+ break;
+
default:
break;
}