summaryrefslogtreecommitdiff
path: root/tun.c
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2019-03-19 10:29:40 +0000
committerFrediano Ziglio <fziglio@redhat.com>2019-03-19 10:29:59 +0000
commit30bccaecced94f6d92f4516b3ac85897e03fdee2 (patch)
treeafee1d4c236c8849633488c0ba5ec53fda854cbe /tun.c
parent0024a3850c28ddb78f83d2914f3ea71d115566e2 (diff)
Check TCP/UDP packet field presence
Some system uses "th_sum" and "uh_sum" for checksum fields while other use "check". Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'tun.c')
-rw-r--r--tun.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tun.c b/tun.c
index 2711ba3..2b7f95b 100644
--- a/tun.c
+++ b/tun.c
@@ -1,4 +1,5 @@
#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,6 +30,20 @@
#include "utils.h"
#include "pcap.h"
+#ifndef HAVE_STRUCT_TCPHDR_TH_SUM
+#ifndef HAVE_STRUCT_TCPHDR_CHECK
+#error No checksum field found in tcphdr
+#endif
+#define th_sum check
+#endif
+
+#ifndef HAVE_STRUCT_UDPHDR_UH_SUM
+#ifndef HAVE_STRUCT_UDPHDR_CHECK
+#error No checksum field found in udphdr
+#endif
+#define uh_sum check
+#endif
+
static int tun_fd = -1;
static int tun_fd_back = -1;
static int remote_sock = -1;