aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-08-02 21:10:09 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-09 22:09:34 +0200
commit63ebccdfe350d7e75bbb8e5511bcde26a7e300ad (patch)
tree700acfb1b9138c72d43866636270f20cb60d53a1 /lib
parentd12eab9c4e375e1669637dd34674c8b8208cf867 (diff)
lib/tun.h: Remove non-endian-safe redefinition of IP header
We can simply use 'struct iphdr' from netinet/ip.h to achieve the same goal (and be portable). Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32
Diffstat (limited to 'lib')
-rw-r--r--lib/tun.h40
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/tun.h b/lib/tun.h
index ce7b91c..c50bdf9 100644
--- a/lib/tun.h
+++ b/lib/tun.h
@@ -17,21 +17,31 @@
#define TUN_ADDRSIZE 128
#define TUN_NLBUFSIZE 1024
-struct tun_packet_t {
- unsigned int ver:4;
- unsigned int ihl:4;
- unsigned int dscp:6;
- unsigned int ecn:2;
- unsigned int length:16;
- unsigned int id:16;
- unsigned int flags:3;
- unsigned int fragment:13;
- unsigned int ttl:8;
- unsigned int protocol:8;
- unsigned int check:16;
- unsigned int src:32;
- unsigned int dst:32;
-};
+#include "config.h"
+#ifndef HAVE_IPHDR
+struct iphdr
+ {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int ihl:4;
+ unsigned int version:4;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int version:4;
+ unsigned int ihl:4;
+#else
+# error "Please fix <bits/endian.h>"
+#endif
+ u_int8_t tos;
+ u_int16_t tot_len;
+ u_int16_t id;
+ u_int16_t frag_off;
+ u_int8_t ttl;
+ u_int8_t protocol;
+ u_int16_t check;
+ u_int32_t saddr;
+ u_int32_t daddr;
+ /*The options start here. */
+ };
+#endif /* !HAVE_IPHDR */
/* ***********************************************************
* Information storage for each tun instance