Yank potentially costly support for TTL out of UdpSocket since we dont use this anymore.

This commit is contained in:
Adam Ierymenko 2014-10-13 09:37:17 -07:00
parent 7943414c89
commit 05309037a8
2 changed files with 0 additions and 24 deletions

View File

@ -64,33 +64,20 @@ UdpSocket::~UdpSocket()
} }
bool UdpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen) bool UdpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen)
{
return sendWithHopLimit(to,msg,msglen,0);
}
bool UdpSocket::sendWithHopLimit(const InetAddress &to,const void *msg,unsigned int msglen,int hopLimit)
{ {
#ifdef ZT_BREAK_UDP #ifdef ZT_BREAK_UDP
return true; return true;
#else #else
if (hopLimit <= 0)
hopLimit = 255;
if (to.isV6()) { if (to.isV6()) {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
DWORD hltmp = (DWORD)hopLimit;
setsockopt(_sock,IPPROTO_IPV6,IPV6_UNICAST_HOPS,(const char *)&hltmp,sizeof(hltmp));
return ((int)sendto(_sock,(const char *)msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen); return ((int)sendto(_sock,(const char *)msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
#else #else
setsockopt(_sock,IPPROTO_IPV6,IPV6_UNICAST_HOPS,&hopLimit,sizeof(hopLimit));
return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen); return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
#endif #endif
} else { } else {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
DWORD hltmp = (DWORD)hopLimit;
setsockopt(_sock,IPPROTO_IP,IP_TTL,(const char *)&hltmp,sizeof(hltmp));
return ((int)sendto(_sock,(const char *)msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen); return ((int)sendto(_sock,(const char *)msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
#else #else
setsockopt(_sock,IPPROTO_IP,IP_TTL,&hopLimit,sizeof(hopLimit));
return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen); return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
#endif #endif
} }

View File

@ -46,17 +46,6 @@ public:
virtual ~UdpSocket(); virtual ~UdpSocket();
virtual bool send(const InetAddress &to,const void *msg,unsigned int msglen); virtual bool send(const InetAddress &to,const void *msg,unsigned int msglen);
/**
* Send UDP packet with IP max hops set (<= 0 for default/infinite)
*
* @param to Destination address
* @param msg Message data
* @param msglen Message length
* @param hopLimit IP TTL / max hops
* @return True if packet appears sent
*/
bool sendWithHopLimit(const InetAddress &to,const void *msg,unsigned int msglen,int hopLimit);
protected: protected:
#ifdef __WINDOWS__ #ifdef __WINDOWS__
UdpSocket(Type t,SOCKET s) : UdpSocket(Type t,SOCKET s) :