suricata
util-streaming-buffer.h File Reference
#include "tree.h"
Include dependency graph for util-streaming-buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StreamingBufferConfig_
 
struct  StreamingBufferRegion_
 
struct  StreamingBufferBlock
 block of continues data More...
 
struct  StreamingBuffer_
 
struct  StreamingBufferSegment_
 

Macros

#define STREAMING_BUFFER_REGION_GAP_DEFAULT   262144
 
#define STREAMING_BUFFER_CONFIG_INITIALIZER
 
#define STREAMING_BUFFER_REGION_INIT
 
#define STREAMING_BUFFER_INITIALIZER
 

Typedefs

typedef struct StreamingBufferConfig_ StreamingBufferConfig
 
typedef struct StreamingBufferRegion_ StreamingBufferRegion
 
typedef struct StreamingBuffer_ StreamingBuffer
 

Functions

struct StreamingBufferBlock __attribute__ ((__packed__)) StreamingBufferBlock
 block of continues data More...
 
 RB_ENTRY (StreamingBufferBlock) rb
 
int SBBCompare (struct StreamingBufferBlock *a, struct StreamingBufferBlock *b)
 
 RB_HEAD (SBB, StreamingBufferBlock)
 
 RB_PROTOTYPE (SBB, StreamingBufferBlock, rb, SBBCompare)
 
StreamingBufferBlockSBB_RB_FIND_INCLUSIVE (struct SBB *head, StreamingBufferBlock *elm)
 
StreamingBufferStreamingBufferInit (const StreamingBufferConfig *cfg)
 
void StreamingBufferClear (StreamingBuffer *sb, const StreamingBufferConfig *cfg)
 
void StreamingBufferFree (StreamingBuffer *sb, const StreamingBufferConfig *cfg)
 
void StreamingBufferSlideToOffset (StreamingBuffer *sb, const StreamingBufferConfig *cfg, uint64_t offset)
 slide to absolute offset More...
 
int StreamingBufferAppend (StreamingBuffer *sb, const StreamingBufferConfig *cfg, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len) WARN_UNUSED
 
int StreamingBufferAppendNoTrack (StreamingBuffer *sb, const StreamingBufferConfig *cfg, const uint8_t *data, uint32_t data_len) WARN_UNUSED
 add data w/o tracking a segment More...
 
int StreamingBufferInsertAt (StreamingBuffer *sb, const StreamingBufferConfig *cfg, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len, uint64_t offset) WARN_UNUSED
 
void StreamingBufferSegmentGetData (const StreamingBuffer *sb, const StreamingBufferSegment *seg, const uint8_t **data, uint32_t *data_len)
 
void StreamingBufferSBBGetData (const StreamingBuffer *sb, const StreamingBufferBlock *sbb, const uint8_t **data, uint32_t *data_len)
 get the data for one SBB More...
 
void StreamingBufferSBBGetDataAtOffset (const StreamingBuffer *sb, const StreamingBufferBlock *sbb, const uint8_t **data, uint32_t *data_len, uint64_t offset)
 get the data for one SBB More...
 
int StreamingBufferSegmentCompareRawData (const StreamingBuffer *sb, const StreamingBufferSegment *seg, const uint8_t *rawdata, uint32_t rawdata_len)
 
int StreamingBufferCompareRawData (const StreamingBuffer *sb, const uint8_t *rawdata, uint32_t rawdata_len)
 
int StreamingBufferGetData (const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t *stream_offset)
 
int StreamingBufferGetDataAtOffset (const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t offset)
 
int StreamingBufferSegmentIsBeforeWindow (const StreamingBuffer *sb, const StreamingBufferSegment *seg)
 
void StreamingBufferRegisterTests (void)
 

Variables

uint64_t offset
 
uint32_t len
 
uint32_t segment_len
 
uint64_t stream_offset
 

Macro Definition Documentation

◆ STREAMING_BUFFER_CONFIG_INITIALIZER

#define STREAMING_BUFFER_CONFIG_INITIALIZER
Value:
{ \
2048, 8, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL, \
}

Definition at line 75 of file util-streaming-buffer.h.

◆ STREAMING_BUFFER_INITIALIZER

#define STREAMING_BUFFER_INITIALIZER
Value:
{ \
STREAMING_BUFFER_REGION_INIT, \
{ NULL }, \
NULL, \
0, \
1, \
1, \
};

Definition at line 138 of file util-streaming-buffer.h.

◆ STREAMING_BUFFER_REGION_GAP_DEFAULT

#define STREAMING_BUFFER_REGION_GAP_DEFAULT   262144

Definition at line 64 of file util-streaming-buffer.h.

◆ STREAMING_BUFFER_REGION_INIT

#define STREAMING_BUFFER_REGION_INIT
Value:
{ \
NULL, 0, 0, 0ULL, NULL, \
}

Definition at line 80 of file util-streaming-buffer.h.

Typedef Documentation

◆ StreamingBuffer

◆ StreamingBufferConfig

◆ StreamingBufferRegion

Function Documentation

◆ RB_ENTRY()

__attribute__::RB_ENTRY ( StreamingBufferBlock  )

◆ RB_HEAD()

RB_HEAD ( SBB  ,
StreamingBufferBlock   
)

◆ RB_PROTOTYPE()

RB_PROTOTYPE ( SBB  ,
StreamingBufferBlock  ,
rb  ,
SBBCompare   
)

◆ SBB_RB_FIND_INCLUSIVE()

StreamingBufferBlock* SBB_RB_FIND_INCLUSIVE ( struct SBB *  head,
StreamingBufferBlock elm 
)

◆ SBBCompare()

int SBBCompare ( struct StreamingBufferBlock a,
struct StreamingBufferBlock b 
)

◆ StreamingBufferAppend()

int StreamingBufferAppend ( StreamingBuffer sb,
const StreamingBufferConfig cfg,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len 
)

Definition at line 1081 of file util-streaming-buffer.c.

References BIT_U32, StreamingBufferRegion_::buf, DEBUG_VALIDATE_BUG_ON, and StreamingBuffer_::region.

Referenced by HtpBodyAppendChunk(), and UTHAddStreamToFlow().

Here is the caller graph for this function:

◆ StreamingBufferAppendNoTrack()

int StreamingBufferAppendNoTrack ( StreamingBuffer sb,
const StreamingBufferConfig cfg,
const uint8_t *  data,
uint32_t  data_len 
)

add data w/o tracking a segment

Definition at line 1125 of file util-streaming-buffer.c.

References BIT_U32, StreamingBufferRegion_::buf, DEBUG_VALIDATE_BUG_ON, and StreamingBuffer_::region.

◆ StreamingBufferClear()

void StreamingBufferClear ( StreamingBuffer sb,
const StreamingBufferConfig cfg 
)

Definition at line 274 of file util-streaming-buffer.c.

References StreamingBufferRegion_::buf_size, StreamingBuffer_::region, and SCLogDebug.

Referenced by StreamingBufferFree(), StreamTcpPruneSession(), and StreamTcpStreamCleanup().

Here is the caller graph for this function:

◆ StreamingBufferCompareRawData()

int StreamingBufferCompareRawData ( const StreamingBuffer sb,
const uint8_t *  rawdata,
uint32_t  rawdata_len 
)
Return values
1data is the same
0data is different

Definition at line 1825 of file util-streaming-buffer.c.

References offset, PrintRawDataFp(), SCLogDebug, and StreamingBufferGetData().

Here is the call graph for this function:

◆ StreamingBufferFree()

void StreamingBufferFree ( StreamingBuffer sb,
const StreamingBufferConfig cfg 
)

Definition at line 297 of file util-streaming-buffer.c.

References FREE, and StreamingBufferClear().

Referenced by HtpBodyFree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StreamingBufferGetData()

int StreamingBufferGetData ( const StreamingBuffer sb,
const uint8_t **  data,
uint32_t *  data_len,
uint64_t *  stream_offset 
)

◆ StreamingBufferGetDataAtOffset()

int StreamingBufferGetDataAtOffset ( const StreamingBuffer sb,
const uint8_t **  data,
uint32_t *  data_len,
uint64_t  offset 
)

Definition at line 1803 of file util-streaming-buffer.c.

◆ StreamingBufferInit()

StreamingBuffer* StreamingBufferInit ( const StreamingBufferConfig cfg)

◆ StreamingBufferInsertAt()

int StreamingBufferInsertAt ( StreamingBuffer sb,
const StreamingBufferConfig cfg,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len,
uint64_t  offset 
)
Parameters
offsetoffset relative to StreamingBuffer::stream_offset
Returns
SC_OK in case of success
SC_E* errors otherwise

Definition at line 1509 of file util-streaming-buffer.c.

References BIT_U32, DEBUG_VALIDATE_BUG_ON, SC_EINVAL, and StreamingBufferRegion_::stream_offset.

◆ StreamingBufferRegisterTests()

void StreamingBufferRegisterTests ( void  )

Definition at line 2412 of file util-streaming-buffer.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ StreamingBufferSBBGetData()

void StreamingBufferSBBGetData ( const StreamingBuffer sb,
const StreamingBufferBlock sbb,
const uint8_t **  data,
uint32_t *  data_len 
)

get the data for one SBB

Definition at line 1660 of file util-streaming-buffer.c.

Referenced by UTHCheckDataAtPosition().

Here is the caller graph for this function:

◆ StreamingBufferSBBGetDataAtOffset()

void StreamingBufferSBBGetDataAtOffset ( const StreamingBuffer sb,
const StreamingBufferBlock sbb,
const uint8_t **  data,
uint32_t *  data_len,
uint64_t  offset 
)

get the data for one SBB

Definition at line 1696 of file util-streaming-buffer.c.

References DEBUG_VALIDATE_BUG_ON, StreamingBufferBlock::len, offset, and StreamingBufferBlock::offset.

◆ StreamingBufferSegmentCompareRawData()

int StreamingBufferSegmentCompareRawData ( const StreamingBuffer sb,
const StreamingBufferSegment *  seg,
const uint8_t *  rawdata,
uint32_t  rawdata_len 
)
Return values
1data is the same
0data is different

Definition at line 1770 of file util-streaming-buffer.c.

References StreamingBufferSegmentGetData().

Here is the call graph for this function:

◆ StreamingBufferSegmentGetData()

void StreamingBufferSegmentGetData ( const StreamingBuffer sb,
const StreamingBufferSegment *  seg,
const uint8_t **  data,
uint32_t *  data_len 
)

Definition at line 1737 of file util-streaming-buffer.c.

Referenced by StreamingBufferSegmentCompareRawData(), StreamTcpInlineSegmentCompare(), StreamTcpSegmentForEach(), and StreamTcpSegmentForSession().

Here is the caller graph for this function:

◆ StreamingBufferSegmentIsBeforeWindow()

int StreamingBufferSegmentIsBeforeWindow ( const StreamingBuffer sb,
const StreamingBufferSegment *  seg 
)

Definition at line 1628 of file util-streaming-buffer.c.

References StreamingBuffer_::region, and StreamingBufferRegion_::stream_offset.

Referenced by HtpBodyPrune().

Here is the caller graph for this function:

◆ StreamingBufferSlideToOffset()

void StreamingBufferSlideToOffset ( StreamingBuffer sb,
const StreamingBufferConfig cfg,
uint64_t  offset 
)

slide to absolute offset

Todo:
if sliding beyond window, we could perhaps reset?

Definition at line 1004 of file util-streaming-buffer.c.

References offset, and SCLogDebug.

Referenced by HtpBodyPrune().

Here is the caller graph for this function:

Variable Documentation

◆ len

uint32_t len

Definition at line 2 of file util-streaming-buffer.h.

◆ offset

◆ segment_len

uint32_t segment_len

Definition at line 0 of file util-streaming-buffer.h.

◆ stream_offset

uint64_t stream_offset

Definition at line 1 of file util-streaming-buffer.h.

Referenced by StreamingBufferGetData().

STREAMING_BUFFER_REGION_GAP_DEFAULT
#define STREAMING_BUFFER_REGION_GAP_DEFAULT
Definition: util-streaming-buffer.h:63