summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-05-30 17:12:17 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-05-30 17:20:42 +0200
commit1b32f3d1d33bf02d5e10ef3178075421c592b5f6 (patch)
treed6749266bb018958cba8ffc56e9727e909aa90b8
parent11eb8de6fbd8578305c57082139d72c4f46c0864 (diff)
ring: add set_sockopt_tpacket_v3 and refactor others
Add set_sockopt_tpacket_v3() in preparation for TPACKET_V3. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r--ring.h16
1 files 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 */