From 4ccd2c359c413100e23f24c31a72f52c1933b581 Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" Date: Wed, 18 Dec 2024 14:28:25 +0100 Subject: [PATCH] Improve detection of `struct bpf_timeval` Not all system with `net/bpf.h` has `struct bpf_timeval`. Fixes: https://github.com/simsong/tcpflow/issues/267 --- configure.ac | 13 +++++++++++++ src/tcpflow.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 09a362d..27934b8 100644 --- configure.ac +++ configure.ac @@ -490,6 +490,19 @@ AC_CHECK_TYPES([sa_family_t], [], [], ]] ) +AC_CHECK_HEADERS([net/bpf.h]) +AC_CHECK_TYPES([struct bpf_timeval], [], [], +[[ +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_NET_BPF_H +#include +#endif +]] +) + ############## drop optimization flags if requested ################ # Should we disable optimization? diff --git a/src/tcpflow.h b/src/tcpflow.h index 627e277..6d191ab 100644 --- src/tcpflow.h +++ src/tcpflow.h @@ -297,7 +297,7 @@ inline const timeval &tvshift(struct timeval &tv,const struct timeval &tv_) return tv; } -#if __has_include("net/bpf.h") +#ifdef HAVE_STRUCT_BPF_TIMEVAL inline const timeval &tvshift(struct timeval &tv,const struct bpf_timeval &tv_) { tv.tv_sec = tv_.tv_sec + datalink_tdelta;