/*
 * netsniff-ng - the packet sniffing beast
 * Copyright 2009, 2010 Daniel Borkmann.
 * Subject to the GPL, version 2.
 */

#ifndef TX_RING_H
#define TX_RING_H

#include <stdbool.h>

#include "ring.h"

/* Give userland 10 us time to push packets to the ring */
#define TX_KERNEL_PULL_INT	10

void ring_tx_setup(struct ring *ring, int sock, size_t size, int ifindex,
		   bool jumbo_support, bool verbose);
extern void destroy_tx_ring(int sock, struct ring *ring);

static inline int user_may_pull_from_tx(struct tpacket2_hdr *hdr)
{
	return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
}

static inline void kernel_may_pull_from_tx(struct tpacket2_hdr *hdr)
{
	hdr->tp_status = TP_STATUS_SEND_REQUEST;
}

static inline int pull_and_flush_tx_ring(int sock)
{
	return sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
}

static inline int pull_and_flush_tx_ring_wait(int sock)
{
	return sendto(sock, NULL, 0, 0, NULL, 0);
}

#endif /* TX_RING_H */
10037608996d3f6a3f'/><select name='h' onchange='this.form.submit();'>
<option value='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=9172d2a026f95f217da81610037608996d3f6a3f'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/tools/virtio/virtio-trace/trace-agent.c'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/tools/virtio/virtio-trace/trace-agent.c?id=9172d2a026f95f217da81610037608996d3f6a3f'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/tools/virtio/virtio-trace/trace-agent.c?id=9172d2a026f95f217da81610037608996d3f6a3f'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/tools/virtio/virtio-trace/trace-agent.c?id=9172d2a026f95f217da81610037608996d3f6a3f'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/tools/virtio/virtio-trace/trace-agent.c'>
<input type='hidden' name='id' value='9172d2a026f95f217da81610037608996d3f6a3f'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=9172d2a026f95f217da81610037608996d3f6a3f'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools?id=9172d2a026f95f217da81610037608996d3f6a3f'>tools</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/virtio?id=9172d2a026f95f217da81610037608996d3f6a3f'>virtio</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/virtio/virtio-trace?id=9172d2a026f95f217da81610037608996d3f6a3f'>virtio-trace</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/virtio/virtio-trace/trace-agent.c?id=9172d2a026f95f217da81610037608996d3f6a3f'>trace-agent.c</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/tools/virtio/virtio-trace/trace-agent.c?id=9172d2a026f95f217da81610037608996d3f6a3f&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>