warp-vpn

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

commit e53219cb5eb97b320b0d5e851ceaf16033155dfb
parent 8a39d364378f507c92bd989a2c39a68735018dac
Author: sin <sin@2f30.org>
Date:   Wed, 30 Mar 2016 19:29:13 +0100

setrcvtimeo is a util function, move it up

Diffstat:
Mstun.c | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/stun.c b/stun.c @@ -232,6 +232,20 @@ readall(int fd, void *buf, int len) return total; } +int +setrcvtimeo(int netfd, time_t sec) +{ + struct timeval tv; + int ret; + + tv.tv_sec = sec; + tv.tv_usec = 0; + ret = setsockopt(netfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if (ret < 0) + logwarn("failed to set timeout on socket"); + return ret; +} + void revokeprivs(void) { @@ -522,20 +536,6 @@ readnet(int fd, unsigned char *pt, int len) } int -setrcvtimeo(int netfd, time_t sec) -{ - struct timeval tv; - int ret; - - tv.tv_sec = sec; - tv.tv_usec = 0; - ret = setsockopt(netfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); - if (ret < 0) - logwarn("failed to set timeout on socket"); - return ret; -} - -int challenge(int netfd) { unsigned char buf[MTU + AES_BLOCK_SIZE];