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

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

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

Referenced by RegisterNFSTCPParsers(), and RegisterNFSUDPParsers().

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

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

Referenced by StreamTcpAppLayerIsDisabled().

Typedef Documentation

Function Documentation

__attribute__::RB_ENTRY ( StreamingBufferBlock  )
RB_HEAD ( SBB  ,
StreamingBufferBlock   
)
RB_PROTOTYPE ( SBB  ,
StreamingBufferBlock  ,
rb  ,
SBBCompare   
)
int SBBCompare ( struct StreamingBufferBlock a,
struct StreamingBufferBlock b 
)
int StreamingBufferAppend ( StreamingBuffer sb,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len 
)
int StreamingBufferAppendNoTrack ( StreamingBuffer sb,
const uint8_t *  data,
uint32_t  data_len 
)
StreamingBufferSegment* StreamingBufferAppendRaw ( StreamingBuffer sb,
const uint8_t *  data,
uint32_t  data_len 
)
void StreamingBufferClear ( StreamingBuffer sb)
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 
)
StreamingBuffer* StreamingBufferInit ( const StreamingBufferConfig cfg)

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

References StreamingBufferConfig_::buf_size, StreamingBuffer_::buf_size, CALLOC, StreamingBuffer_::cfg, and FREE.

Referenced by FileOpenFile(), HtpBodyAppendChunk(), and StreamingBufferCompareRawData().

Here is the caller graph for this function:

int StreamingBufferInsertAt ( StreamingBuffer sb,
StreamingBufferSegment *  seg,
const uint8_t *  data,
uint32_t  data_len,
uint64_t  offset 
)
void StreamingBufferRegisterTests ( void  )

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

References UtRegisterTest().

Here is the call graph for this function:

void StreamingBufferSBBGetData ( const StreamingBuffer sb,
const StreamingBufferBlock sbb,
const uint8_t **  data,
uint32_t *  data_len 
)
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 769 of file util-streaming-buffer.c.

References StreamingBuffer_::buf, StreamingBuffer_::buf_size, BUG_ON, StreamingBufferBlock::len, StreamingBufferBlock::offset, and StreamingBuffer_::stream_offset.

Referenced by StreamNeedsReassembly().

Here is the caller graph for this function:

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().

Referenced by DetectPcrePayloadMatch(), and StreamingBufferCompareRawData().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamingBufferSegmentGetData ( const StreamingBuffer sb,
const StreamingBufferSegment *  seg,
const uint8_t **  data,
uint32_t *  data_len 
)
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(), StreamingBufferCompareRawData(), and StreamTcpReassembleInsertSegment().

Here is the caller graph for this function:

void StreamingBufferSlide ( StreamingBuffer sb,
uint32_t  slide 
)

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

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

Referenced by StreamingBufferCompareRawData().

Here is the caller graph for this function:

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, SCLogDebug, stream_offset, and StreamingBuffer_::stream_offset.

Referenced by FileTrackedSize(), HtpBodyPrune(), and StreamTcpPruneSession().

Here is the caller graph for this function:

Variable Documentation

uint32_t len

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

uint32_t segment_len

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

Referenced by StreamingBufferSegmentGetData().

uint64_t stream_offset