From 2f39b007d5382d01fc424e22b8e1a3681c2bc8cf Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Fri, 31 May 2013 11:18:36 +0200 Subject: ring: implement setup of tpacket v3 ring Implement ring setup routines and structures for TPACKET_V3. Signed-off-by: Daniel Borkmann --- ring.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ring.h') diff --git a/ring.h b/ring.h index f618a35..7590223 100644 --- a/ring.h +++ b/ring.h @@ -45,6 +45,7 @@ struct ring { union { struct tpacket_req layout; struct tpacket_req3 layout3; + uint8_t raw; }; }; @@ -113,6 +114,18 @@ static inline void __set_sockopt_tpacket(int sock, int val) panic("Cannot set tpacketv2!\n"); } +static inline int __get_sockopt_tpacket(int sock) +{ + int val, ret; + socklen_t len = sizeof(val); + + ret = getsockopt(sock, SOL_PACKET, PACKET_VERSION, &val, &len); + if (ret) + panic("Cannot set tpacketv2!\n"); + + return val; +} + static inline void set_sockopt_tpacket_v2(int sock) { __set_sockopt_tpacket(sock, TPACKET_V2); @@ -123,4 +136,9 @@ static inline void set_sockopt_tpacket_v3(int sock) __set_sockopt_tpacket(sock, TPACKET_V3); } +static inline int get_sockopt_tpacket(int sock) +{ + return __get_sockopt_tpacket(sock); +} + #endif /* RING_H */ -- cgit v1.2.3-54-g00ecf