From 2cc50bdb10c0a7849763ae1dfa37ca7707299a16 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 9 Nov 2015 15:44:13 -0800 Subject: Try bringing back TTL escalation -- may help with Docker (IP-MASQ) type NAT --- osdep/Phy.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'osdep') diff --git a/osdep/Phy.hpp b/osdep/Phy.hpp index 8dde279c..1ba6c40b 100644 --- a/osdep/Phy.hpp +++ b/osdep/Phy.hpp @@ -414,6 +414,24 @@ public: return (PhySocket *)&sws; } + /** + * Set the IP TTL for the next outgoing packet (for IPv4 UDP sockets only) + * + * @param ttl New TTL (0 or >255 will set it to 255) + * @return True on success + */ + inline bool setIp4UdpTtl(PhySocket *sock,unsigned int ttl) + { + PhySocketImpl &sws = *(reinterpret_cast(sock)); +#if defined(_WIN32) || defined(_WIN64) + DWORD tmp = ((ttl == 0)||(ttl > 255)) ? 255 : (DWORD)ttl; + return (::setsockopt(sws.sock,IPPROTO_IP,IP_TTL,(const char *)&tmp,sizeof(tmp)) == 0); +#else + int tmp = ((ttl == 0)||(ttl > 255)) ? 255 : (int)ttl; + return (::setsockopt(sws.sock,IPPROTO_IP,IP_TTL,(void *)&tmp,sizeof(tmp)) == 0); +#endif + } + /** * Send a UDP packet * -- cgit v1.2.3