diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2019-03-19 10:29:40 +0000 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2019-03-19 10:29:59 +0000 |
commit | 30bccaecced94f6d92f4516b3ac85897e03fdee2 (patch) | |
tree | afee1d4c236c8849633488c0ba5ec53fda854cbe | |
parent | 0024a3850c28ddb78f83d2914f3ea71d115566e2 (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>
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | tun.c | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index fcf640f..c578994 100644 --- a/configure.ac +++ b/configure.ac @@ -4,5 +4,10 @@ AC_PROG_CC AM_PROG_AR AC_PROG_RANLIB AC_CONFIG_HEADERS([config.h]) +AC_CHECK_MEMBERS( + [struct tcphdr.th_sum, struct tcphdr.check, struct udphdr.uh_sum, struct udphdr.check], + [], [], + [[#include <netinet/udp.h> +#include <netinet/tcp.h>]]) AC_CONFIG_FILES([Makefile tests/Makefile latency.spec]) AC_OUTPUT @@ -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; |