summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-08-17 10:15:31 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-08-17 10:15:31 +0200
commit3384ee7119222a6230c983dbdcbaf2ac2d6f92fb (patch)
treea44eed3811d873f055e75787bf2eab425ca1b27b
parent579e8524cb9c68dab9117981966b18d2494b0787 (diff)
netsniff-ng: ring: Fix build if tp_vlan_tpid is not available in kernel header
The tp_vlan_tpid member of struct tpacket_auxdata was only added in kernel commit a0cdfcf39362 ("packet: deliver VLAN TPID to userspace"). Support building netsniff-ng also against kernel headers from earlier versions. Fixes: 579e8524 ("netsniff-ng: vlan: Show vlan info from tpacket v3") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--ring.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/ring.h b/ring.h
index c8562b8..56c305d 100644
--- a/ring.h
+++ b/ring.h
@@ -58,7 +58,7 @@ static inline uint16_t tpacket_uhdr_vlan_tci(union tpacket_uhdr *hdr, bool v3)
static inline uint16_t tpacket_uhdr_vlan_proto(union tpacket_uhdr *hdr, bool v3)
{
-#ifdef HAVE_TPACKET3
+#if defined(HAVE_TPACKET3) && defined(TP_STATUS_VLAN_TPID_VALID)
if (v3)
return hdr->h3->hv1.tp_vlan_tpid;
#endif
@@ -67,8 +67,14 @@ static inline uint16_t tpacket_uhdr_vlan_proto(union tpacket_uhdr *hdr, bool v3)
static inline bool tpacket_has_vlan_info(union tpacket_uhdr *hdr)
{
+ uint32_t valid = 0;
+
+#ifdef TP_STATUS_VLAN_TPID_VALID
+ valid = TP_STATUS_VLAN_VALID;
+#endif
+
return tpacket_uhdr(*hdr, tp_status, true) &
- (TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID);
+ (TP_STATUS_VLAN_VALID | valid);
}
struct frame_map {