AUTHORS: drop e-mail addresses, update with latest contributors
[netsniff-ng-new.git] / ring_tx.h
blobf794aa2356f6a42e929d09e69403a3a353c24afb
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 void ring_tx_setup(struct ring *ring, int sock, size_t size, int ifindex,
18 bool jumbo_support, bool verbose);
19 extern void destroy_tx_ring(int sock, struct ring *ring);
21 static inline int user_may_pull_from_tx(struct tpacket2_hdr *hdr)
23 return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
26 static inline void kernel_may_pull_from_tx(struct tpacket2_hdr *hdr)
28 hdr->tp_status = TP_STATUS_SEND_REQUEST;
31 static inline int pull_and_flush_tx_ring(int sock)
33 int ret;
35 do {
36 ret = sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
37 } while (ret == -1 && errno == EINTR);
39 return ret;
42 static inline int pull_and_flush_tx_ring_wait(int sock)
44 int ret;
46 do {
47 ret = sendto(sock, NULL, 0, 0, NULL, 0);
48 } while (ret == -1 && errno == EINTR);
50 return ret;
53 #endif /* TX_RING_H */