示例#1
0
文件: vlan_pop.c 项目: apanda/bess
static void process_batch(struct module *m, struct pkt_batch *batch)
{
	for (int i = 0; i < batch->cnt; i++) {
		struct snbuf *pkt = batch->pkts[i];
		char *ptr = snb_head_data(pkt);

		memmove(ptr + 4, ptr, 12);
		snb_adj(pkt, 4);
	}
		
	run_next_module(m, batch);
}
示例#2
0
文件: port_inc.c 项目: keonjang/bess
static struct task_result
port_inc_run_task(struct module *m, void *arg)
{
	struct port_inc_priv *priv = get_priv(m);
	struct port *p = priv->port;

	const queue_t qid = 0;	/* XXX */

	struct pkt_batch batch;
	struct task_result ret;

	uint64_t received_bytes = 0;

	const int pkt_burst = MAX_PKT_BURST;
	const int pkt_overhead = 24;

	batch.cnt = p->driver->recv_pkts(p, qid, batch.pkts, pkt_burst);

	if (batch.cnt == 0) {
		ret.packets = 0;
		ret.bits = 0;
		return ret;
	}

	for (int i = 0; i < batch.cnt; i++)
		received_bytes += snb_total_len(batch.pkts[i]);

	ret.packets = batch.cnt;
	ret.bits = (received_bytes + pkt_overhead * batch.cnt) * 8;

	p->queue_stats[PACKET_DIR_INC][qid].packets += batch.cnt;
	p->queue_stats[PACKET_DIR_INC][qid].bytes += received_bytes;

	run_next_module(m, &batch);

	return ret;
}