summaryrefslogtreecommitdiff
path: root/node/UdpSocket.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-03-27 18:23:02 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-03-27 18:23:02 -0700
commitb73c36acbf03431fd7fa3584e8621875fdcbebf4 (patch)
treea08a976e4d4a63efecc2892bc969cc60141b4c5f /node/UdpSocket.cpp
parent181369964f501c3c702971b30c82b9e84eed58db (diff)
parentd2c5d7150253a5ae5613cac1d65e84b3aa5d33bc (diff)
downloadinfinitytier-b73c36acbf03431fd7fa3584e8621875fdcbebf4.tar.gz
infinitytier-b73c36acbf03431fd7fa3584e8621875fdcbebf4.zip
Merge branch 'adamierymenko-dev' of ssh://shub-niggurath.zerotier.com:222/git/ZeroTierOne into adamierymenko-dev
Diffstat (limited to 'node/UdpSocket.cpp')
-rw-r--r--node/UdpSocket.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/node/UdpSocket.cpp b/node/UdpSocket.cpp
index 8fce9588..115298e9 100644
--- a/node/UdpSocket.cpp
+++ b/node/UdpSocket.cpp
@@ -48,6 +48,9 @@
#include <signal.h>
#endif
+// Uncomment to intentionally break UDP in order to test TCP fallback
+#define ZT_BREAK_UDP
+
namespace ZeroTier {
UdpSocket::~UdpSocket()
@@ -66,6 +69,9 @@ bool UdpSocket::send(const InetAddress &to,const void *msg,unsigned int msglen)
bool UdpSocket::sendWithHopLimit(const InetAddress &to,const void *msg,unsigned int msglen,int hopLimit)
{
+#ifdef ZT_BREAK_UDP
+ return true;
+#else
if (hopLimit <= 0)
hopLimit = 255;
if (to.isV6()) {
@@ -87,6 +93,7 @@ bool UdpSocket::sendWithHopLimit(const InetAddress &to,const void *msg,unsigned
return ((int)sendto(_sock,msg,msglen,0,to.saddr(),to.saddrLen()) == (int)msglen);
#endif
}
+#endif
}
bool UdpSocket::notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManager *sm)
@@ -97,7 +104,9 @@ bool UdpSocket::notifyAvailableForRead(const SharedPtr<Socket> &self,SocketManag
int n = (int)recvfrom(_sock,(char *)(buf.data()),ZT_SOCKET_MAX_MESSAGE_LEN,0,from.saddr(),&salen);
if (n > 0) {
buf.setSize((unsigned int)n);
+#ifndef ZT_BREAK_UDP
sm->handleReceivedPacket(self,from,buf);
+#endif
}
return true;
}