summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure8
-rw-r--r--ring.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/configure b/configure
index 4d6b284..b8d1374 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,7 @@ HAVE_LIBPCAP=0
HAVE_HWTSTAMP=0
HAVE_LIBGEOIP=0
HAVE_LIBZ=0
+HAVE_TPACKET3=0
[ -z $CC ] && CC=cc
@@ -203,6 +204,7 @@ EOF
tools_remove "netsniff-ng"
else
echo "[YES]"
+ HAVE_TPACKET3=1
fi
}
@@ -528,6 +530,7 @@ gen_config_hdr()
local _have_libgeoip=""
local _have_libz=""
local _have_hwts=""
+ local _have_tp3=""
echo "[*] Generating config.h ... "
@@ -554,6 +557,10 @@ gen_config_hdr()
_have_libz="#define HAVE_LIBZ 1"
fi
+ if [ "$HAVE_TPACKET3" == "1" ] ; then
+ _have_tp3="#define HAVE_TPACKET3 1"
+ fi
+
cat > config.h << EOF
#ifndef CONFIG_H
#define CONFIG_H
@@ -567,6 +574,7 @@ $_have_libpcap
$_have_libgeoip
$_have_libz
$_have_hwts
+$_have_tp3
#endif /* CONFIG_H */
EOF
}
diff --git a/ring.h b/ring.h
index 7ee7735..1ab81b0 100644
--- a/ring.h
+++ b/ring.h
@@ -25,11 +25,14 @@
#include "built_in.h"
#include "die.h"
#include "dev.h"
+#include "config.h"
union tpacket_uhdr {
struct tpacket_hdr *h1;
struct tpacket2_hdr *h2;
+#ifdef HAVE_TPACKET3
struct tpacket3_hdr *h3;
+#endif
void *raw;
};
@@ -38,11 +41,13 @@ struct frame_map {
struct sockaddr_ll s_ll __align_tpacket(sizeof(struct tpacket2_hdr));
};
+#ifdef HAVE_TPACKET3
struct block_desc {
uint32_t version;
uint32_t offset_to_priv;
struct tpacket_hdr_v1 h1;
};
+#endif
struct ring {
struct iovec *frames;
@@ -51,7 +56,9 @@ struct ring {
struct sockaddr_ll s_ll;
union {
struct tpacket_req layout;
+#ifdef HAVE_TPACKET3
struct tpacket_req3 layout3;
+#endif
uint8_t raw;
};
};
@@ -140,7 +147,9 @@ static inline void set_sockopt_tpacket_v2(int sock)
static inline void set_sockopt_tpacket_v3(int sock)
{
+#ifdef HAVE_TPACKET3
__set_sockopt_tpacket(sock, TPACKET_V3);
+#endif
}
static inline int get_sockopt_tpacket(int sock)