Don't log useless things in the main loop
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
23
src/bind.c
23
src/bind.c
@@ -222,9 +222,8 @@ gt_bind(int argc, char **argv)
|
||||
if (ret == -1) {
|
||||
if (errno == EBADF) {
|
||||
perror("select");
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -315,28 +314,16 @@ gt_bind(int argc, char **argv)
|
||||
struct ip_common ic;
|
||||
const int r = tun_read(tun_fd, buf, bufsize);
|
||||
|
||||
if (r <= 0) {
|
||||
if (r == -1 && errno != EAGAIN)
|
||||
perror("tun_read");
|
||||
} else if ((!ip_get_common(&ic, buf, r)) &&
|
||||
(mud_send(mud, buf, r, ic.tc) == -1)) {
|
||||
if (errno != EAGAIN)
|
||||
perror("mud_send");
|
||||
}
|
||||
if (!ip_get_common(&ic, buf, r))
|
||||
mud_send(mud, buf, r, ic.tc);
|
||||
}
|
||||
|
||||
if (FD_ISSET(mud_fd, &rfds)) {
|
||||
struct ip_common ic;
|
||||
const int r = mud_recv(mud, buf, bufsize);
|
||||
|
||||
if (r <= 0) {
|
||||
if (r == -1 && errno != EAGAIN)
|
||||
perror("mud_recv");
|
||||
} else if ((!ip_get_common(&ic, buf, r)) &&
|
||||
(tun_write(tun_fd, buf, r) == -1)) {
|
||||
if (errno != EAGAIN)
|
||||
perror("tun_write");
|
||||
}
|
||||
if (!ip_get_common(&ic, buf, r))
|
||||
tun_write(tun_fd, buf, r);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
|
||||
6
src/ip.h
6
src/ip.h
@@ -13,16 +13,16 @@ ip_get_version(const uint8_t *data)
|
||||
return data[0] >> 4;
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
static inline int
|
||||
ip_read16(const uint8_t *src)
|
||||
{
|
||||
uint16_t ret = src[1];
|
||||
ret |= ((uint16_t)src[0]) << 8;
|
||||
return ret;
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
static inline int
|
||||
ip_get_common(struct ip_common *ic, const uint8_t *data, size_t size)
|
||||
ip_get_common(struct ip_common *ic, const uint8_t *data, int size)
|
||||
{
|
||||
if (size < 20)
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user