summaryrefslogtreecommitdiff
path: root/ring.h
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-05-26 15:10:33 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-08-14 08:48:15 +0200
commit97e6f994785ce5f3f486f8eddb62df964119d121 (patch)
treed8452eb956ec0eb98b13c0a931dd5abce71c3400 /ring.h
parentfa32dcaddab2363cb01acc81bddf7dc3d42ab5b1 (diff)
netsniff-ng: Restore tpacket v2 capturing
Some older systems (e.g. RHEL 6) don't have tpacket v3 available, but only tpacket v2. However, since commit d8cdc6a ("ring: netsniff-ng: migrate capture only to TPACKET_V3") we solely rely on tpacket v3 for capturing packets. This patch restores the possibility to capture using tpacket v2. For now this is just a fallback if the configure script doesn't detect tpacket v3 (and thus HAVE_TPACKET3 isn't set). Thus, on most modern systems this shouldn't change anything and they will continue using tpacket v3. For now this fix contains quite a bit of ugly #ifdefery which should be cleaned up in the future. Fixes #76 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ring.h')
-rw-r--r--ring.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/ring.h b/ring.h
index acf5d59..3b02c76 100644
--- a/ring.h
+++ b/ring.h
@@ -35,6 +35,14 @@ union tpacket_uhdr {
void *raw;
};
+#ifdef HAVE_TPACKET3
+#define tpacket_uhdr(hdr, member, v3) \
+ ((v3) ? ((hdr).h3)->member : ((hdr).h2)->member)
+#else
+#define tpacket_uhdr(hdr, member, v3) \
+ (((hdr).h2)->member)
+#endif /* HAVE_TPACKET3 */
+
struct frame_map {
struct tpacket2_hdr tp_h __aligned_tpacket;
struct sockaddr_ll s_ll __align_tpacket(sizeof(struct tpacket2_hdr));
@@ -132,12 +140,12 @@ static inline void set_sockopt_tpacket_v2(int sock)
__set_sockopt_tpacket(sock, TPACKET_V2);
}
+#ifdef HAVE_TPACKET3
static inline void set_sockopt_tpacket_v3(int sock)
{
-#ifdef HAVE_TPACKET3
__set_sockopt_tpacket(sock, TPACKET_V3);
-#endif
}
+#endif
static inline int get_sockopt_tpacket(int sock)
{