trafgen: icmpv4: Update csum at runtime if needed
[netsniff-ng-new.git] / ring_tx.h
blobeaff414f90898974854a8ce34a1a1cc849d115cb
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 return sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
36 static inline int pull_and_flush_tx_ring_wait(int sock)
38 return sendto(sock, NULL, 0, 0, NULL, 0);
41 #endif /* TX_RING_H */