diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-09 15:44:13 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-09 15:44:13 -0800 |
commit | 2cc50bdb10c0a7849763ae1dfa37ca7707299a16 (patch) | |
tree | da3da6516d7162e6aaf432f5303fde6ae5dac722 /osdep | |
parent | 94f4316a0ecb56f7e34422a7dfed73efb2bbe1a3 (diff) | |
download | infinitytier-2cc50bdb10c0a7849763ae1dfa37ca7707299a16.tar.gz infinitytier-2cc50bdb10c0a7849763ae1dfa37ca7707299a16.zip |
Try bringing back TTL escalation -- may help with Docker (IP-MASQ) type NAT
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/Phy.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/osdep/Phy.hpp b/osdep/Phy.hpp index 8dde279c..1ba6c40b 100644 --- a/osdep/Phy.hpp +++ b/osdep/Phy.hpp @@ -415,6 +415,24 @@ public: } /** + * 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<PhySocketImpl *>(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 * * @param sock UDP socket |