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  StreamingBufferBlock
 block of continues data More...
 
struct  StreamingBuffer_
 
struct  StreamingBufferSegment_
 

Macros

#define STREAMING_BUFFER_NOFLAGS   0
 
#define STREAMING_BUFFER_AUTOSLIDE   (1<<0)
 
#define STREAMING_BUFFER_CONFIG_INITIALIZER   { 0, 0, 0, NULL, NULL, NULL, NULL, }
 
#define STREAMING_BUFFER_INITIALIZER(cfg)   { (cfg), 0, NULL, 0, 0, { NULL }, NULL, };
 

Typedefs

typedef struct StreamingBufferConfig_ StreamingBufferConfig
 
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)
 
void StreamingBufferFree (StreamingBuffer *sb)
 
void StreamingBufferSlide (StreamingBuffer *sb, uint32_t slide)
 
void StreamingBufferSlideToOffset (StreamingBuffer *sb, uint64_t offset)
 slide to absolute offset More...
 
StreamingBufferSegment * StreamingBufferAppendRaw (StreamingBuffer *sb, const uint8_t *data, uint32_t data_len) __attribute__((warn_unused_result))
 
int StreamingBufferAppend (StreamingBuffer *sb, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len) __attribute__((warn_unused_result))
 
int StreamingBufferAppendNoTrack (StreamingBuffer *sb, const uint8_t *data, uint32_t data_len) __attribute__((warn_unused_result))
 add data w/o tracking a segment More...
 
int StreamingBufferInsertAt (StreamingBuffer *sb, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len, uint64_t offset) __attribute__((warn_unused_result))
 
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_AUTOSLIDE

#define STREAMING_BUFFER_AUTOSLIDE   (1<<0)

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

◆ STREAMING_BUFFER_CONFIG_INITIALIZER

#define STREAMING_BUFFER_CONFIG_INITIALIZER   { 0, 0, 0, NULL, NULL, NULL, NULL, }

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

◆ STREAMING_BUFFER_INITIALIZER

#define STREAMING_BUFFER_INITIALIZER (   cfg)    { (cfg), 0, NULL, 0, 0, { NULL }, NULL, };

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

◆ STREAMING_BUFFER_NOFLAGS

#define STREAMING_BUFFER_NOFLAGS   0

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

Typedef Documentation

◆ StreamingBuffer

◆ StreamingBufferConfig

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,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len 
)

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

References StreamingBuffer_::buf, and BUG_ON.

Referenced by UTHAddStreamToFlow().

Here is the caller graph for this function:

◆ StreamingBufferAppendNoTrack()

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

add data w/o tracking a segment

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

References StreamingBuffer_::buf.

◆ StreamingBufferAppendRaw()

StreamingBufferSegment* StreamingBufferAppendRaw ( StreamingBuffer sb,
const uint8_t *  data,
uint32_t  data_len 
)

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

References StreamingBuffer_::buf.

◆ StreamingBufferClear()

void StreamingBufferClear ( StreamingBuffer sb)

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

References StreamingBuffer_::buf_size, 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 889 of file util-streaming-buffer.c.

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

Referenced by StreamTcpCheckStreamContents().

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

◆ StreamingBufferFree()

void StreamingBufferFree ( StreamingBuffer sb)

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

References StreamingBuffer_::cfg, 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 
)

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

References StreamingBuffer_::buf, StreamingBuffer_::buf_offset, stream_offset, and StreamingBuffer_::stream_offset.

Referenced by StreamingBufferCompareRawData().

Here is the caller graph for this function:

◆ StreamingBufferGetDataAtOffset()

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

◆ StreamingBufferInit()

◆ StreamingBufferInsertAt()

int StreamingBufferInsertAt ( StreamingBuffer sb,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len,
uint64_t  offset 
)
Parameters
offsetoffset relative to StreamingBuffer::stream_offset

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

References StreamingBuffer_::buf, BUG_ON, and stream_offset.

◆ StreamingBufferRegisterTests()

void StreamingBufferRegisterTests ( void  )

Definition at line 1477 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 
)

◆ StreamingBufferSBBGetDataAtOffset()

void StreamingBufferSBBGetDataAtOffset ( const StreamingBuffer sb,
const StreamingBufferBlock sbb,
const uint8_t **  data,
uint32_t *  data_len,
uint64_t  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 833 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 
)

◆ StreamingBufferSegmentIsBeforeWindow()

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

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

References StreamingBuffer_::stream_offset.

Referenced by HtpBodyPrune().

Here is the caller graph for this function:

◆ StreamingBufferSlide()

void StreamingBufferSlide ( StreamingBuffer sb,
uint32_t  slide 
)

◆ StreamingBufferSlideToOffset()

void StreamingBufferSlideToOffset ( StreamingBuffer sb,
uint64_t  offset 
)

slide to absolute offset

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

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

References StreamingBuffer_::buf, StreamingBuffer_::buf_offset, offset, SCLogDebug, stream_offset, and StreamingBuffer_::stream_offset.

Referenced by HtpBodyPrune().

Here is the caller graph for this function:

Variable Documentation

◆ len

uint32_t len

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

◆ offset

◆ segment_len

uint32_t segment_len

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

Referenced by StreamingBufferSegmentGetData().

◆ stream_offset

uint64_t stream_offset