stun

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

commit a2ae33abf71547552e0ec89532d74e6ff024b0a9
parent 7cac10f93b137245c5f2728a811b04a0f9b07a01
Author: sin <sin@2f30.org>
Date:   Fri Apr  1 12:22:03 +0100

properly name field

Diffstat:
stun.c | 30+++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/stun.c b/stun.c @@ -85,11 +85,11 @@ #define NOPRIVUSER "nobody" #define RCVTIMEO 250 /* in milliseconds */ #define RECONNECTTIMEO 60 /* in seconds */ -#define MTU 1428 +#define MAXPAYLOADLEN 1428 #define HDRLEN 2 #define IVLEN 12 #define TAGLEN 16 -#define MAXPKTLEN (TAGLEN + IVLEN + HDRLEN + MTU) +#define MAXPKTLEN (TAGLEN + IVLEN + HDRLEN + MAXPAYLOADLEN) #define BADPKT 0x1000 enum { @@ -346,9 +346,9 @@ opendev(char *dev) if (s < 0) logerr("failed to create socket"); if (devtype == TUNDEV) - ifr.ifr_mtu = MTU; + ifr.ifr_mtu = MAXPAYLOADLEN; else - ifr.ifr_mtu = MTU - 14; /* make some room for ethernet header */ + ifr.ifr_mtu = MAXPAYLOADLEN - 14; /* make some room for ethernet header */ if (ioctl(s, SIOCSIFMTU, &ifr) < 0) logerr("failed to set MTU on %s", dev); close(s); @@ -380,9 +380,9 @@ opendev(char *dev) if (ioctl(fd, TUNGIFINFO, &ti) < 0) logerr("failed to set TUNGIFINFO on %s", dev); if (devtype == TUNDEV) - ti.mtu = MTU; + ti.mtu = MAXPAYLOADLEN; else - ti.mtu = MTU - 14; /* make some room for ethernet header */ + ti.mtu = MAXPAYLOADLEN - 14; /* make some room for ethernet header */ if (ioctl(fd, TUNSIFINFO, &ti) < 0) logerr("failed to set TUNSIFINFO on %s", dev); if (devtype == TUNDEV) { @@ -445,7 +445,7 @@ readdev(int fd, unsigned char *buf, int len) int writenet(int fd, unsigned char *pt, int len) { - unsigned char ct[MTU]; + unsigned char ct[MAXPAYLOADLEN]; unsigned char hdr[HDRLEN], iv[IVLEN], tag[TAGLEN]; unsigned char pkt[MAXPKTLEN]; int pktlen; @@ -464,7 +464,7 @@ writenet(int fd, unsigned char *pt, int len) int readnet(int fd, unsigned char *pt, int len) { - unsigned char ct[MTU]; + unsigned char ct[MAXPAYLOADLEN]; unsigned char hdr[HDRLEN], iv[IVLEN], tag[TAGLEN]; int n, ctlen; @@ -488,8 +488,8 @@ readnet(int fd, unsigned char *pt, int len) CHECKERR(n); ctlen = unpack16(hdr); - if (ctlen > MTU) - ctlen = MTU; + if (ctlen > MAXPAYLOADLEN) + ctlen = MAXPAYLOADLEN; n = readall(fd, ct, ctlen); CHECKERR(n); @@ -504,7 +504,7 @@ readnet(int fd, unsigned char *pt, int len) int challenge(int netfd) { - unsigned char buf[MTU]; + unsigned char buf[MAXPAYLOADLEN]; struct pollfd pfd[1]; uint64_t n, reply; int ret; @@ -542,7 +542,7 @@ challenge(int netfd) int response(int netfd) { - unsigned char buf[MTU]; + unsigned char buf[MAXPAYLOADLEN]; uint64_t reply; int ret; @@ -559,7 +559,7 @@ response(int netfd) int tunnel(int netfd, int devfd) { - unsigned char buf[MTU]; + unsigned char buf[MAXPAYLOADLEN]; struct pollfd pfd[2]; int ret, n; @@ -577,7 +577,7 @@ tunnel(int netfd, int devfd) logerr("bad fd in poll set"); if (pfd[0].revents & (POLLIN | POLLHUP)) { - n = readnet(netfd, buf, MTU); + n = readnet(netfd, buf, MAXPAYLOADLEN); if (n <= 0) return -1; if (n == BADPKT) { @@ -588,7 +588,7 @@ tunnel(int netfd, int devfd) } if (pfd[1].revents & (POLLIN | POLLHUP)) { - n = readdev(devfd, buf, MTU); + n = readdev(devfd, buf, MAXPAYLOADLEN); if (n > 0) { n = writenet(netfd, buf, n); if (n <= 0)