stun

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

commit 50f2f564028ce0f1e114a1ec7fc592c77c3f3f45
parent 9955d22852338540e0b7d71b48a1ad58b54e9e6b
Author: sin <sin@2f30.org>
Date:   Thu Mar 24 10:24:01 +0000

reverse check to avoid indenting

Diffstat:
stun.c | 52++++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/stun.c b/stun.c @@ -254,19 +254,19 @@ writedev(int fd, unsigned char *buf, int len) uint32_t type = htonl(AF_INET); int n; - if (devtype == TUNDEV) { - iov[0].iov_base = &type; - iov[0].iov_len = sizeof(type); - iov[1].iov_base = buf; - iov[1].iov_len = len; - n = writev(fd, iov, 2); - if (n < 0) - logerr("writev failed"); - else if (n > 0) - return n - sizeof(type); - return n; - } - return write(fd, buf, len); + if (devtype == TAPDEV) + return write(fd, buf, len); + + iov[0].iov_base = &type; + iov[0].iov_len = sizeof(type); + iov[1].iov_base = buf; + iov[1].iov_len = len; + n = writev(fd, iov, 2); + if (n < 0) + logerr("writev failed"); + else if (n > 0) + return n - sizeof(type); + return n; } int @@ -276,19 +276,19 @@ readdev(int fd, unsigned char *buf, int len) uint32_t type; int n; - if (devtype == TUNDEV) { - iov[0].iov_base = &type; - iov[0].iov_len = sizeof(type); - iov[1].iov_base = buf; - iov[1].iov_len = len; - n = readv(fd, iov, 2); - if (n < 0) - logerr("readv failed"); - else if (n > 0) - return n - sizeof(type); - return n; - } - return read(fd, buf, len); + if (devtype == TAPDEV) + return read(fd, buf, len); + + iov[0].iov_base = &type; + iov[0].iov_len = sizeof(type); + iov[1].iov_base = buf; + iov[1].iov_len = len; + n = readv(fd, iov, 2); + if (n < 0) + logerr("readv failed"); + else if (n > 0) + return n - sizeof(type); + return n; } #endif