build: move trafgen_stddef.h to stddef.h
[netsniff-ng.git] / ring_rx.h
blob8bf439b0a7eb9d3abbd10c2e34a7c24a5c1ad463
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"
13 #include "built_in.h"
15 extern void destroy_rx_ring(int sock, struct ring *ring);
16 extern void create_rx_ring(int sock, struct ring *ring, int verbose);
17 extern void mmap_rx_ring(int sock, struct ring *ring);
18 extern void alloc_rx_ring_frames(int sock, struct ring *ring);
19 extern void bind_rx_ring(int sock, struct ring *ring, int ifindex);
20 extern void setup_rx_ring_layout(int sock, struct ring *ring,
21 unsigned int size, bool jumbo_support, bool v3);
22 extern void sock_rx_net_stats(int sock, unsigned long seen);
24 static inline int user_may_pull_from_rx(struct tpacket2_hdr *hdr)
26 return ((hdr->tp_status & TP_STATUS_USER) == TP_STATUS_USER);
29 static inline int user_may_pull_from_rx_block(struct block_desc *pbd)
31 return ((pbd->h1.block_status & TP_STATUS_USER) == TP_STATUS_USER);
34 static inline void kernel_may_pull_from_rx(struct tpacket2_hdr *hdr)
36 hdr->tp_status = TP_STATUS_KERNEL;
39 static inline void kernel_may_pull_from_rx_block(struct block_desc *pbd)
41 pbd->h1.block_status = TP_STATUS_KERNEL;
44 #endif /* RX_RING_H */