trafgen: remove timer-based trigger model
[netsniff-ng.git] / ring_tx.h
blobadfe2a4362ed70025202e2d8fcc88982489f14c6
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
5 */
7 #ifndef TX_RING_H
8 #define TX_RING_H
10 #include <stdbool.h>
12 #include "ring.h"
13 #include "built_in.h"
15 /* Give userland 10 us time to push packets to the ring */
16 #define TX_KERNEL_PULL_INT 10
18 extern void destroy_tx_ring(int sock, struct ring *ring);
19 extern void create_tx_ring(int sock, struct ring *ring, int verbose);
20 extern void mmap_tx_ring(int sock, struct ring *ring);
21 extern void alloc_tx_ring_frames(int sock, struct ring *ring);
22 extern void bind_tx_ring(int sock, struct ring *ring, int ifindex);
23 extern void setup_tx_ring_layout(int sock, struct ring *ring,
24 unsigned int size, bool jumbo_support);
25 extern void set_packet_loss_discard(int sock);
27 static inline int user_may_pull_from_tx(struct tpacket2_hdr *hdr)
29 return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
32 static inline void kernel_may_pull_from_tx(struct tpacket2_hdr *hdr)
34 hdr->tp_status = TP_STATUS_SEND_REQUEST;
37 static inline int pull_and_flush_tx_ring(int sock)
39 return sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
42 static inline int pull_and_flush_tx_ring_wait(int sock)
44 return sendto(sock, NULL, 0, 0, NULL, 0);
47 #endif /* TX_RING_H */