netsniff-ng: Move variable definition
[netsniff-ng.git] / ring_rx.h
blob60a0eebf5f590d8f85aeb28090e4d5dcbcea837f
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
5 */
7 #ifndef RX_RING_H
8 #define RX_RING_H
10 #include <stdbool.h>
12 #include "ring.h"
14 extern void ring_rx_setup(struct ring *ring, int sock, size_t size, int ifindex,
15 struct pollfd *poll, bool v3, bool jumbo_support,
16 bool verbose);
17 extern void destroy_rx_ring(int sock, struct ring *ring);
18 extern void sock_rx_net_stats(int sock, unsigned long seen);
20 static inline int user_may_pull_from_rx(struct tpacket2_hdr *hdr)
22 return ((hdr->tp_status & TP_STATUS_USER) == TP_STATUS_USER);
25 static inline void kernel_may_pull_from_rx(struct tpacket2_hdr *hdr)
27 hdr->tp_status = TP_STATUS_KERNEL;
30 #ifdef HAVE_TPACKET3
31 static inline int user_may_pull_from_rx_block(struct block_desc *pbd)
33 return ((pbd->h1.block_status & TP_STATUS_USER) == TP_STATUS_USER);
36 static inline void kernel_may_pull_from_rx_block(struct block_desc *pbd)
38 pbd->h1.block_status = TP_STATUS_KERNEL;
40 #endif /* HAVE_TPACKETV3 */
42 #endif /* RX_RING_H */