netsniff-ng 0.5.9-rc2
[netsniff-ng.git] / ring_rx.h
blob02c65bc777e9563a1ab1a3dc6ff9d34b931d0bed
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 int user_may_pull_from_rx_block(struct block_desc *pbd)
27 return ((pbd->h1.block_status & TP_STATUS_USER) == TP_STATUS_USER);
30 static inline void kernel_may_pull_from_rx(struct tpacket2_hdr *hdr)
32 hdr->tp_status = TP_STATUS_KERNEL;
35 static inline void kernel_may_pull_from_rx_block(struct block_desc *pbd)
37 pbd->h1.block_status = TP_STATUS_KERNEL;
40 #endif /* RX_RING_H */