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

This buffer allows to search, replace or remove data in the packets buffered as in a contiguous flow. It also allows to determine if a pattern could be starting at the end of the last packet in the buffer and thus if buffering more packets is required to make a decision. More...

#include <flowbuffer.hh>

Public Member Functions

 FlowBuffer ()
 Construct a FlowBuffer The FlowBuffer must be initialized.
 
 ~FlowBuffer ()
 Destruct a FlowBuffer.
 
MemoryPool< struct flowBufferEntry > * getMemoryPool ()
 Return a pointer to the MemoryPool used by this FlowBuffer.
 
void enqueue (Packet *packet)
 Enqueue a packet at the end of the buffer.
 
Packet * dequeue ()
 Dequeue a packet from the beginning of the buffer @returnt The dequeued packet.
 
PacketBatch * dequeueAll ()
 Dequeue all packets @returnt The dequeued packet.
 
PacketBatch * dequeueUpTo (Packet *)
 Dequeue packet up to the given one, not included @returnt The dequeued packet.
 
int getSize ()
 Return the size of the buffer.
 
FlowBufferIter begin ()
 Return an iterator pointing to the first packet of the buffer.
 
FlowBufferIter end ()
 Return an iterator pointing to the end of the buffer.
 
int searchInFlow (const char *pattern)
 Search a pattern in the buffer.
 
int removeInFlow (const char *pattern, const int pattern_length, CTXElement *remove)
 Remove a pattern in the buffer.
 
int replaceInFlow (FlowBufferContentIter pos, const int pattern_length, const char *replacement, const int replacement_length, const bool repeat, CTXElement *owner)
 Replace a pattern in the buffer.
 
FlowBufferContentIter contentBegin (int posInFirstPacket=0)
 Return a content iterator pointing to the first byte of content in the buffer.
 
FlowBufferContentIter contentEnd ()
 Return a content iterator pointing after the end of the content in the buffer.
 
void enqueueAll (PacketBatch *batch)
 Ensure a flow buffer is initialized and enqueue all packets.
 
FlowBufferContentIter enqueueAllIter (PacketBatch *batch)
 
FlowBufferChunkIter enqueueAllChunkIter (PacketBatch *batch)
 
FlowBufferContentIter search (FlowBufferContentIter start, const char *pattern, int *feedback)
 Search a pattern in the buffer.
 
FlowBufferContentIter isearch (FlowBufferContentIter start, const char *pattern, int *feedback)
 
FlowBufferContentIter searchSSE (FlowBufferContentIter start, const char *pattern, const int pattern_length, int *feedback)
 
void remove (const FlowBufferContentIter start, uint32_t length, CTXElement *owner)
 Remove data in the flow (across the packets)
 

Detailed Description

This buffer allows to search, replace or remove data in the packets buffered as in a contiguous flow. It also allows to determine if a pattern could be starting at the end of the last packet in the buffer and thus if buffering more packets is required to make a decision.

Constructor & Destructor Documentation

◆ FlowBuffer()

FlowBuffer::FlowBuffer ( )

Construct a FlowBuffer The FlowBuffer must be initialized.

◆ ~FlowBuffer()

FlowBuffer::~FlowBuffer ( )

Destruct a FlowBuffer.

Don't forget to call this operator when the FCB is released

Member Function Documentation

◆ getMemoryPool()

MemoryPool< struct flowBufferEntry > * FlowBuffer::getMemoryPool ( )

Return a pointer to the MemoryPool used by this FlowBuffer.

Returns
A pointer to the MemoryPool used by this FlowBuffer

◆ enqueue()

void FlowBuffer::enqueue ( Packet *  packet)

Enqueue a packet at the end of the buffer.

Parameters
packetThe packet to enqueue

◆ dequeue()

Packet * FlowBuffer::dequeue ( )

Dequeue a packet from the beginning of the buffer @returnt The dequeued packet.

◆ dequeueAll()

PacketBatch * FlowBuffer::dequeueAll ( )

Dequeue all packets @returnt The dequeued packet.

◆ dequeueUpTo()

PacketBatch * FlowBuffer::dequeueUpTo ( Packet *  packet)

Dequeue packet up to the given one, not included @returnt The dequeued packet.

◆ getSize()

int FlowBuffer::getSize ( )

Return the size of the buffer.

Returns
The number of packets in the buffer

◆ begin()

FlowBufferIter FlowBuffer::begin ( )

Return an iterator pointing to the first packet of the buffer.

Returns
An iterator pointing to the first packet of the buffer

◆ end()

FlowBufferIter FlowBuffer::end ( )

Return an iterator pointing to the end of the buffer.

Returns
An iterator pointing to the end of the buffer

◆ searchInFlow()

int FlowBuffer::searchInFlow ( const char *  pattern)

Search a pattern in the buffer.

Parameters
patternThe pattern to search
Returns
1 if the pattern has been found, -1 if the pattern has not been found and cannot start in the last packet of the buffer, 0 if the pattern has not been found but the pattern could start at the end of the last packet in the buffer and thus enqueuing the next packet could result in a match.

◆ removeInFlow()

int FlowBuffer::removeInFlow ( const char *  pattern,
const int  pattern_length,
CTXElement *  remove 
)

Remove a pattern in the buffer.

Parameters
fcbA pointer to the FCB of this flow
Thepattern to remove
Returns
1 if the pattern has been found and the first occurrence has been removed -1 if the pattern has not been found and cannot start in the last packet of the buffer 0 if the pattern has not been found but the pattern could start at the end of the last packet in the buffer and thus enqueuing the next packet could result in a match.

◆ replaceInFlow()

int FlowBuffer::replaceInFlow ( FlowBufferContentIter  pos,
const int  pattern_length,
const char *  replacement,
const int  replacement_length,
const bool  repeat,
CTXElement *  owner 
)

Replace a pattern in the buffer.

Parameters
fcbA pointer to the FCB of this flow
Thepattern to replace
Thenew data that will replace the old one
Returns
1 if the pattern has been found and the first occurrence has been replaced -1 if the pattern has not been found and cannot start in the last packet of the buffer 0 if the pattern has not been found but the pattern could start at the end of the last packet in the buffer and thus enqueuing the next packet could result in a match.

◆ contentBegin()

FlowBufferContentIter FlowBuffer::contentBegin ( int  posInFirstPacket = 0)

Return a content iterator pointing to the first byte of content in the buffer.

Returns
A content iterator pointing to the first byte of content in the buffer

◆ contentEnd()

FlowBufferContentIter FlowBuffer::contentEnd ( )

Return a content iterator pointing after the end of the content in the buffer.

Returns
A content iterator pointing after the end of the content in the buffer

◆ enqueueAll()

void FlowBuffer::enqueueAll ( PacketBatch *  batch)

Ensure a flow buffer is initialized and enqueue all packets.

◆ search()

FlowBufferContentIter FlowBuffer::search ( FlowBufferContentIter  start,
const char *  pattern,
int *  feedback 
)

Search a pattern in the buffer.

Parameters
startContent iterator indicating where to start the search
patternThe pattern to search
feedbackAn int in which the result of the search will be put (1 if found, -1 if not found, 0 if not found but could start at the end of the last packet)
Returns
An iterator pointing to the beginning of the pattern in the flow if found or after the end of the content if not found

◆ remove()

void FlowBuffer::remove ( const FlowBufferContentIter  start,
uint32_t  length,
CTXElement *  owner 
)

Remove data in the flow (across the packets)

Parameters
fcbA pointer to the FCB of the flow
startA content iterator pointing to the first byte to remove
lengthThe number of bytes to remove

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