Click
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
PacketBatch Class Reference

#include <packetbatch.hh>

Public Member Functions

Packet * first ()
 
void set_tail (Packet *p)
 
Packet * tail ()
 
void append_simple_list (Packet *lhead, Packet *ltail, int lcount)
 
void append_batch (PacketBatch *head)
 
void append_packet (Packet *p)
 
unsigned count ()
 
PacketBatch * make_tail (Packet *last, unsigned int count)
 Finish a batch started with start_head()
 
void set_count (unsigned int c)
 
void cut (Packet *middle, int first_batch_count, PacketBatch *&second)
 Cut a batch in two batches.
 
void split (int first_batch_count, PacketBatch *&second, const bool &safe=false)
 Cut a batch in two batches.
 
PacketBatch * split (int first_batch_count)
 
PacketBatch * pop_front ()
 
Packet * begin ()
 
Packet * end ()
 
void kill ()
 
PacketBatch * clone_batch (const bool duplicate=false, const bool duplicate_data_only=false)
 
void fast_kill ()
 
void fast_kill_nonatomic ()
 

Static Public Member Functions

static PacketBatch * start_head (Packet *p)
 Start a new batch.
 
static PacketBatch * make_from_tailed_list (Packet *head, unsigned int size)
 
static PacketBatch * make_from_simple_list (Packet *head, Packet *tail, unsigned int size)
 
static PacketBatch * make_from_simple_list (Packet *head)
 
static PacketBatch * make_from_packet (Packet *p)
 

Detailed Description

Batch of Packet. This class has no field member and can be cast to or from Packet. It is only there as a way to remember what we are handling and provide useful functions for managing packets as a batch.

Internally, the head contains all the information usefull for the batch. The prev annotation points to the tail, the next to the next packet. It is implemented by a simply linked list. The BATCH_COUNT annotation is set on the first packet of the batch to remember the number of packets in the batch.

Batches must not mix cloned and unique packets. Use cut to split batches and have part of them cloned.

Member Function Documentation

◆ count()

unsigned PacketBatch::count ( )
inline

Return the number of packets in this batch

◆ start_head()

static PacketBatch * PacketBatch::start_head ( Packet *  p)
inlinestatic

Start a new batch.

Parameters
pA packet

Creates a new batch, with p as the first packet. Batch is NOT valid until you call make_tail(). If the Packet is null, returns no batch.

◆ make_tail()

PacketBatch * PacketBatch::make_tail ( Packet *  last,
unsigned int  count 
)
inline

Finish a batch started with start_head()

Parameters
lastThe last packet of the batch
countThe number of packets in the batch
Returns
The whole packet batch

This will set up the batch with the last packet. set_next() have to be called for each packet from the head to the last packet !

◆ set_count()

void PacketBatch::set_count ( unsigned int  c)
inline

Set the number of packets in this batch

◆ cut()

void PacketBatch::cut ( Packet *  middle,
int  first_batch_count,
PacketBatch *&  second 
)
inline

Cut a batch in two batches.

Parameters
middleThe last packet of the first batch
first_batch_countThe number of packets in the first batch
secondReference to set the head of the second batch

◆ split()

void PacketBatch::split ( int  first_batch_count,
PacketBatch *&  second,
const bool &  safe = false 
)
inline

Cut a batch in two batches.

Parameters
first_batch_countThe number of packets in the first batch
secondReference to set the head of the second batch
safeSet to true for optimization if you're sure there is enough packets to cut, and first_batch_count is not 0

◆ pop_front()

PacketBatch * PacketBatch::pop_front ( )
inline

Remove the first packet

Returns
the new batch without front. Do not use "this" afterwards!

◆ make_from_tailed_list()

static PacketBatch * PacketBatch::make_from_tailed_list ( Packet *  head,
unsigned int  size 
)
inlinestatic

Build a batch from a linked list of packet for which head->prev is the tail and tail->next is already 0

Parameters
headThe first packet of the batch
sizeNumber of packets in the linkedlist
Precondition
The "prev" annotation of the first packet must point to the last packet of the linked list
The tail->next() packet must be zero

◆ make_from_simple_list() [1/2]

static PacketBatch * PacketBatch::make_from_simple_list ( Packet *  head,
Packet *  tail,
unsigned int  size 
)
inlinestatic

Build a batch from a linked list of packet

Parameters
headThe first packet of the batch
tailThe last packet of the batch
sizeNumber of packets in the linkedlist

◆ make_from_simple_list() [2/2]

static PacketBatch * PacketBatch::make_from_simple_list ( Packet *  head)
inlinestatic

Build a batch from a linked list of packet ending by a next==0 pointer. O(n).

Parameters
headThe first packet of the batch

◆ make_from_packet()

static PacketBatch * PacketBatch::make_from_packet ( Packet *  p)
inlinestatic

Make a batch composed of a single packet

◆ begin()

Packet * PacketBatch::begin ( )
inline

Return the first packet of this batch

◆ end()

Packet * PacketBatch::end ( )
inline

Return the last packet of this batch

◆ kill()

void PacketBatch::kill ( )
inline

Kill all packets in the batch

Recycle a whole batch

◆ clone_batch()

PacketBatch * PacketBatch::clone_batch ( const bool  duplicate = false,
const bool  duplicate_data_only = false 
)
inline

Clone the batch


The documentation for this class was generated from the following file: