From 6e75f4282d2c3b857b206b21eed18bdcf7d68600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Mon, 19 Mar 2018 09:53:43 +0000 Subject: [PATCH] Don't forget BSD.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- src/ip.h | 8 +++++++- src/tun.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ip.h b/src/ip.h index 6d5273d..b67d42a 100644 --- a/src/ip.h +++ b/src/ip.h @@ -7,6 +7,12 @@ struct ip_common { uint8_t proto; }; +static inline uint8_t +ip_get_version(const uint8_t *data) +{ + return data[0] >> 4; +} + static inline uint16_t ip_read16(const uint8_t *src) { @@ -21,7 +27,7 @@ ip_get_common(struct ip_common *ic, const uint8_t *data, size_t size) if (size < 20) return 1; - switch (data[0] >> 4) { + switch (ip_get_version(data)) { case 4: ic->tc = data[1]; ic->proto = data[9]; diff --git a/src/tun.c b/src/tun.c index 64153eb..65ea125 100644 --- a/src/tun.c +++ b/src/tun.c @@ -224,7 +224,7 @@ tun_write(int fd, const void *data, size_t size) #ifdef GT_BSD_TUN uint32_t family; - switch (ip_get_version(data, size)) { + switch (ip_get_version(data)) { case 4: family = htonl(AF_INET); break;