|
|
|
@ -20,6 +20,10 @@
|
|
|
|
|
#include <wspiapi.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef IP_DONTFRAGMENT
|
|
|
|
|
#define IP_DONTFRAGMENT IP_DONTFRAG
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
|
{
|
|
|
|
|
namespace utp
|
|
|
|
@ -330,13 +334,59 @@ namespace llarp
|
|
|
|
|
static_cast< LinkLayer* >(utp_context_get_userdata(arg->context));
|
|
|
|
|
llarp::LogDebug("utp_sendto ", Addr(*arg->address), " ", arg->len,
|
|
|
|
|
" bytes");
|
|
|
|
|
// For whatever reason, the UTP_UDP_DONTFRAG flag is set
|
|
|
|
|
// on the socket itself....which isn't correct and causes
|
|
|
|
|
// winsock (at minimum) to reeee
|
|
|
|
|
// here, we check its value, then set fragmentation the _right_
|
|
|
|
|
// way. Naturally, Linux has its own special procedure.
|
|
|
|
|
// Of course, the flag itself is cleared. -rick
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
#ifndef __linux__
|
|
|
|
|
if(arg->flags == 2)
|
|
|
|
|
{
|
|
|
|
|
int val = 1;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_DONTFRAGMENT, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int val = 0;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_DONTFRAGMENT, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
if(arg->flags == 2)
|
|
|
|
|
{
|
|
|
|
|
int val = IP_PMTUDISC_DO;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_MTU_DISCOVER, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int val = IP_PMTUDISC_DONT;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_MTU_DISCOVER, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
arg->flags = 0;
|
|
|
|
|
if(::sendto(l->m_udp.fd, (char*)arg->buf, arg->len, arg->flags,
|
|
|
|
|
arg->address, arg->address_len)
|
|
|
|
|
== -1
|
|
|
|
|
&& errno)
|
|
|
|
|
#else
|
|
|
|
|
WSASetLastError(0);
|
|
|
|
|
if(arg->flags == 2)
|
|
|
|
|
{
|
|
|
|
|
char val = 1;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_DONTFRAGMENT, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char val = 0;
|
|
|
|
|
setsockopt(l->m_udp.fd, IPPROTO_IP, IP_DONTFRAGMENT, &val,
|
|
|
|
|
sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
arg->flags = 0;
|
|
|
|
|
if(::sendto(l->m_udp.fd, (char*)arg->buf, arg->len, arg->flags,
|
|
|
|
|
arg->address, arg->address_len)
|
|
|
|
|
== -1)
|
|
|
|
@ -347,7 +397,6 @@ namespace llarp
|
|
|
|
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, LANG_NEUTRAL,
|
|
|
|
|
buf, 1024, nullptr);
|
|
|
|
|
llarp::LogError("sendto failed: ", buf);
|
|
|
|
|
llarp::LogInfo("flags: ", arg->flags);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|