projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use WSAGetLastError() to determine cause of network errors on Windows.
[tinc]
/
src
/
net_packet.c
diff --git
a/src/net_packet.c
b/src/net_packet.c
index
3466f87
..
3243670
100644
(file)
--- a/
src/net_packet.c
+++ b/
src/net_packet.c
@@
-46,8
+46,16
@@
#include "utils.h"
#include "xalloc.h"
#include "utils.h"
#include "xalloc.h"
-#ifdef WSAEMSGSIZE
+#ifdef HAVE_MINGW
+#include <winerror.h>
#define EMSGSIZE WSAEMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
+#define EAGAIN WSATRY_AGAIN
+#define EINTR WSAEINTR
+#define sockstrerror(x) winerror(x)
+#define sockerrno WSAGetLastError()
+#else
+#define sockstrerror(x) strerror(x)
+#define sockerrno errno
#endif
int keylifetime = 0;
#endif
int keylifetime = 0;
@@
-369,10
+377,13
@@
static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (inpkt->data[12] | inpkt->data[13])) {
ifdebug(TRAFFIC) logger(LOG_INFO,
if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (inpkt->data[12] | inpkt->data[13])) {
ifdebug(TRAFFIC) logger(LOG_INFO,
- "Packet for %s (%s) larger than minimum MTU, forwarding via
TCP
",
- n->name, n->hostname);
+ "Packet for %s (%s) larger than minimum MTU, forwarding via
%s
",
+ n->name, n->hostname
, n != n->nexthop ? n->nexthop->name : "TCP"
);
- send_tcppacket(n->nexthop->connection, origpkt);
+ if(n != n->nexthop)
+ send_packet(n->nexthop, origpkt);
+ else
+ send_tcppacket(n->nexthop->connection, origpkt);
return;
}
return;
}
@@
-447,13
+458,13
@@
static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
#endif
if((sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa))) < 0) {
#endif
if((sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa))) < 0) {
- if(errno == EMSGSIZE) {
+ if(
sock
errno == EMSGSIZE) {
if(n->maxmtu >= origlen)
n->maxmtu = origlen - 1;
if(n->mtu >= origlen)
n->mtu = origlen - 1;
} else
if(n->maxmtu >= origlen)
n->maxmtu = origlen - 1;
if(n->mtu >= origlen)
n->mtu = origlen - 1;
} else
- logger(LOG_ERR, "Error sending packet to %s (%s): %s", n->name, n->hostname, s
trerror(
errno));
+ logger(LOG_ERR, "Error sending packet to %s (%s): %s", n->name, n->hostname, s
ockstrerror(sock
errno));
}
end:
}
end:
@@
-559,8
+570,8
@@
void handle_incoming_vpn_data(int sock) {
pkt.len = recvfrom(sock, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
if(pkt.len < 0) {
pkt.len = recvfrom(sock, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
if(pkt.len < 0) {
- if(
errno != EAGAIN &&
errno != EINTR)
- logger(LOG_ERR, "Receiving packet failed: %s", s
trerror(
errno));
+ if(
sockerrno != EAGAIN && sock
errno != EINTR)
+ logger(LOG_ERR, "Receiving packet failed: %s", s
ockstrerror(sock
errno));
return;
}
return;
}