Click
Loading...
Searching...
No Matches
batchbuilder.hh
1#ifndef CLICK_BATCHBUILDER_HH
2#define CLICK_BATCHBUILDER_HH
3#include <click/config.h>
4#include <click/string.hh>
5#include <click/vector.hh>
6#include <click/ipflowid.hh>
7
8CLICK_DECLS
9class DPDKDevice;
10
11
12struct PacketList {
13 PacketList() : first(0), count(0) {
14
15 };
16
17 Packet* first;
18 Packet* tail;
19 int count;
20
26 inline PacketBatch* finish() {
27 if (!first)
28 return 0;
29 return PacketBatch::make_from_simple_list(first,tail,count);
30 }
31
32
38 inline PacketBatch* pop_all() {
39 if (!first)
40 return 0;
42 first = 0;
43 count = 0;
44 return b;
45 }
46
47 inline void append(Packet* p) {
48 count++;
49 if (first) {
50 tail->set_next(p);
51 tail = p;
52 } else {
53 first = p;
54 tail = p;
55 }
56 }
57
58 inline bool empty() const {
59 return first == 0;
60 }
61
62 inline Packet* front() const {
63 return first;
64 }
65
66 inline Packet* pop_front() {
67 Packet* f = first;
68 first = f->next();
69 count--;
70 return f;
71 }
72};
73
74struct BatchBuilder : PacketList {
75 BatchBuilder() : last(-1), last_id() {
76
77 };
78
79 int last;
80 IPFlow5ID last_id;
81
82 inline void init() {
83 count = 0;
84 first = 0;
85 }
86};
87
88
89CLICK_ENDDECLS
90#endif
Definition packetbatch.hh:415
static PacketBatch * make_from_simple_list(Packet *head, Packet *tail, unsigned int size)
Definition packetbatch.hh:633
A network packet.
Definition packet.hh:68
void set_next(Packet *p)
Set the next packet annotation.
Definition packet.hh:1351
Packet * next() const
Return the next packet annotation.
Definition packet.hh:1327
Click's String class.
Click's vector container template.