warp-vpn

simple point to point tunnel
git clone git://git.2f30.org/warp-vpn.git
Log | Files | Refs | README

commit c57cbb84aa431bd3d376ed70a6b096bd0de97357
parent f64e709e8160fdd72ec6ad4a456c98852cd75d50
Author: sin <sin@2f30.org>
Date:   Fri Apr  8 15:40:33 +0100

warn for bad packets so things are easier to debug

Diffstat:
stun.c | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/stun.c b/stun.c @@ -461,8 +461,12 @@ challenge(int netfd) if (pfd[0].revents & (POLLIN | POLLHUP)) { ret = readnet(netfd, buf, sizeof(uint64_t)); - if (ret <= 0 || ret == BADPKT) + if (ret <= 0) { return -1; + } else if (ret == BADPKT) { + logwarn("bad packet"); + return -1; + } reply = unpack64(buf); if (n + 1 == reply) return 0; @@ -478,8 +482,12 @@ response(int netfd) int ret; ret = readnet(netfd, buf, sizeof(uint64_t)); - if (ret <= 0 || ret == BADPKT) + if (ret <= 0) { return -1; + } else if (ret == BADPKT) { + logwarn("bad packet"); + return -1; + } reply = unpack64(buf); pack64(buf, reply + 1); if (writenet(netfd, buf, sizeof(uint64_t)) <= 0) @@ -506,7 +514,7 @@ tunnel(int netfd, int devfd) n = readnet(netfd, buf, MAXPAYLOADLEN); if (n <= 0) return -1; - if (n == BADPKT) + else if (n == BADPKT) logwarn("bad packet"); else writedev(devfd, buf, n);