all: Use macros for printf/scanf format specifiers
[netsniff-ng.git] / ring_tx.h
blobba8407a9470fa33651c591e4f11acb5a317d54d6
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"
14 /* Give userland 10 us time to push packets to the ring */
15 #define TX_KERNEL_PULL_INT 10
17 extern void destroy_tx_ring(int sock, struct ring *ring);
18 extern void create_tx_ring(int sock, struct ring *ring, bool verbose);
19 extern void mmap_tx_ring(int sock, struct ring *ring);
20 extern void alloc_tx_ring_frames(int sock, struct ring *ring);
21 extern void bind_tx_ring(int sock, struct ring *ring, int ifindex);
22 extern void setup_tx_ring_layout(int sock, struct ring *ring, size_t size,
23 bool jumbo_support);
24 extern void set_packet_loss_discard(int sock);
26 static inline int user_may_pull_from_tx(struct tpacket2_hdr *hdr)
28 return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
31 static inline void kernel_may_pull_from_tx(struct tpacket2_hdr *hdr)
33 hdr->tp_status = TP_STATUS_SEND_REQUEST;
36 static inline int pull_and_flush_tx_ring(int sock)
38 return sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
41 static inline int pull_and_flush_tx_ring_wait(int sock)
43 return sendto(sock, NULL, 0, 0, NULL, 0);
46 #endif /* TX_RING_H */