From 1b32f3d1d33bf02d5e10ef3178075421c592b5f6 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Thu, 30 May 2013 17:12:17 +0200 Subject: ring: add set_sockopt_tpacket_v3 and refactor others Add set_sockopt_tpacket_v3() in preparation for TPACKET_V3. Signed-off-by: Daniel Borkmann --- ring.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ring.h b/ring.h index f0edd82..0ef42d1 100644 --- a/ring.h +++ b/ring.h @@ -102,13 +102,21 @@ static inline void prepare_polling(int sock, struct pollfd *pfd) pfd->events = POLLIN | POLLRDNORM | POLLERR; } -static inline void set_sockopt_tpacket_v2(int sock) +static inline void __set_sockopt_tpacket(int sock, int val) { - int ret, val = TPACKET_V2; - - ret = setsockopt(sock, SOL_PACKET, PACKET_VERSION, &val, sizeof(val)); + int ret = setsockopt(sock, SOL_PACKET, PACKET_VERSION, &val, sizeof(val)); if (ret) panic("Cannot set tpacketv2!\n"); } +static inline void set_sockopt_tpacket_v2(int sock) +{ + __set_sockopt_tpacket(sock, TPACKET_V2); +} + +static inline void set_sockopt_tpacket_v3(int sock) +{ + __set_sockopt_tpacket(sock, TPACKET_V3); +} + #endif /* RING_H */ -- cgit v1.2.3-54-g00ecf