suricata
|
Streaming Buffer API. More...
#include "suricata-common.h"
#include "util-streaming-buffer.h"
#include "util-unittest.h"
#include "util-print.h"
#include "util-validate.h"
#include "util-debug.h"
#include "util-error.h"
#include "app-layer-htp-mem.h"
#include "conf-yaml-loader.h"
#include "app-layer-htp.h"
Go to the source code of this file.
Macros | |
#define | DUMP_REGIONS 0 |
#define | CALLOC(cfg, n, s) (cfg)->Calloc ? (cfg)->Calloc((n), (s)) : CallocFunc((n), (s)) |
#define | REALLOC(cfg, ptr, orig_s, s) (cfg)->Realloc ? (cfg)->Realloc((ptr), (orig_s), (s)) : ReallocFunc((ptr), (s)) |
#define | FREE(cfg, ptr, s) (cfg)->Free ? (cfg)->Free((ptr), (s)) : SCFree((ptr)) |
Functions | |
RB_GENERATE (SBB, StreamingBufferBlock, rb, SBBCompare) | |
int | SBBCompare (struct StreamingBufferBlock *a, struct StreamingBufferBlock *b) |
StreamingBufferBlock * | SBB_RB_FIND_INCLUSIVE (struct SBB *head, StreamingBufferBlock *elm) |
StreamingBuffer * | StreamingBufferInit (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) |
int | StreamingBufferAppendNoTrack (StreamingBuffer *sb, const StreamingBufferConfig *cfg, const uint8_t *data, uint32_t data_len) |
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) |
int | StreamingBufferSegmentIsBeforeWindow (const StreamingBuffer *sb, const StreamingBufferSegment *seg) |
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... | |
void | StreamingBufferSegmentGetData (const StreamingBuffer *sb, const StreamingBufferSegment *seg, const uint8_t **data, uint32_t *data_len) |
int | StreamingBufferSegmentCompareRawData (const StreamingBuffer *sb, const StreamingBufferSegment *seg, 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 | StreamingBufferCompareRawData (const StreamingBuffer *sb, const uint8_t *rawdata, uint32_t rawdata_len) |
void | StreamingBufferRegisterTests (void) |
Streaming Buffer API.
Definition in file util-streaming-buffer.c.
#define CALLOC | ( | cfg, | |
n, | |||
s | |||
) | (cfg)->Calloc ? (cfg)->Calloc((n), (s)) : CallocFunc((n), (s)) |
Definition at line 64 of file util-streaming-buffer.c.
#define DUMP_REGIONS 0 |
Definition at line 33 of file util-streaming-buffer.c.
#define FREE | ( | cfg, | |
ptr, | |||
s | |||
) | (cfg)->Free ? (cfg)->Free((ptr), (s)) : SCFree((ptr)) |
Definition at line 67 of file util-streaming-buffer.c.
#define REALLOC | ( | cfg, | |
ptr, | |||
orig_s, | |||
s | |||
) | (cfg)->Realloc ? (cfg)->Realloc((ptr), (orig_s), (s)) : ReallocFunc((ptr), (s)) |
Definition at line 65 of file util-streaming-buffer.c.
RB_GENERATE | ( | SBB | , |
StreamingBufferBlock | , | ||
rb | , | ||
SBBCompare | |||
) |
StreamingBufferBlock* SBB_RB_FIND_INCLUSIVE | ( | struct SBB * | head, |
StreamingBufferBlock * | elm | ||
) |
Definition at line 104 of file util-streaming-buffer.c.
References head, StreamingBufferBlock::len, StreamingBufferBlock::offset, RB_ROOT, and SCLogDebug.
int SBBCompare | ( | struct StreamingBufferBlock * | a, |
struct StreamingBufferBlock * | b | ||
) |
Definition at line 73 of file util-streaming-buffer.c.
References StreamingBufferBlock::len, StreamingBufferBlock::offset, SCLogDebug, and SCReturnInt.
int StreamingBufferAppend | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg, | ||
StreamingBufferSegment * | seg, | ||
const uint8_t * | data, | ||
uint32_t | data_len | ||
) |
Definition at line 1086 of file util-streaming-buffer.c.
References BIT_U32, StreamingBufferRegion_::buf, DEBUG_VALIDATE_BUG_ON, and StreamingBuffer_::region.
Referenced by HtpBodyAppendChunk(), and UTHAddStreamToFlow().
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 1130 of file util-streaming-buffer.c.
References BIT_U32, StreamingBufferRegion_::buf, DEBUG_VALIDATE_BUG_ON, and StreamingBuffer_::region.
void StreamingBufferClear | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg | ||
) |
Definition at line 271 of file util-streaming-buffer.c.
References StreamingBufferRegion_::buf_size, StreamingBuffer_::region, and SCLogDebug.
Referenced by StreamingBufferFree(), StreamTcpPruneSession(), and StreamTcpStreamCleanup().
int StreamingBufferCompareRawData | ( | const StreamingBuffer * | sb, |
const uint8_t * | rawdata, | ||
uint32_t | rawdata_len | ||
) |
1 | data is the same |
0 | data is different |
Definition at line 1830 of file util-streaming-buffer.c.
References offset, PrintRawDataFp(), SCLogDebug, and StreamingBufferGetData().
void StreamingBufferFree | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg | ||
) |
Definition at line 294 of file util-streaming-buffer.c.
References FREE, and StreamingBufferClear().
Referenced by HtpBodyFree().
int StreamingBufferGetData | ( | const StreamingBuffer * | sb, |
const uint8_t ** | data, | ||
uint32_t * | data_len, | ||
uint64_t * | stream_offset | ||
) |
Definition at line 1791 of file util-streaming-buffer.c.
References StreamingBufferRegion_::buf, StreamingBufferRegion_::buf_offset, StreamingBuffer_::region, stream_offset, and StreamingBufferRegion_::stream_offset.
Referenced by StreamingBufferCompareRawData().
int StreamingBufferGetDataAtOffset | ( | const StreamingBuffer * | sb, |
const uint8_t ** | data, | ||
uint32_t * | data_len, | ||
uint64_t | offset | ||
) |
Definition at line 1808 of file util-streaming-buffer.c.
StreamingBuffer* StreamingBufferInit | ( | const StreamingBufferConfig * | cfg | ) |
Definition at line 248 of file util-streaming-buffer.c.
References StreamingBufferConfig_::buf_size, StreamingBufferRegion_::buf_size, CALLOC, StreamingBuffer_::max_regions, StreamingBuffer_::region, and StreamingBuffer_::regions.
Referenced by HtpBodyAppendChunk().
int StreamingBufferInsertAt | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg, | ||
StreamingBufferSegment * | seg, | ||
const uint8_t * | data, | ||
uint32_t | data_len, | ||
uint64_t | offset | ||
) |
offset | offset relative to StreamingBuffer::stream_offset |
Definition at line 1514 of file util-streaming-buffer.c.
References BIT_U32, DEBUG_VALIDATE_BUG_ON, SC_EINVAL, and StreamingBufferRegion_::stream_offset.
void StreamingBufferRegisterTests | ( | void | ) |
Definition at line 2417 of file util-streaming-buffer.c.
References UtRegisterTest().
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 1665 of file util-streaming-buffer.c.
Referenced by UTHCheckDataAtPosition().
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 1701 of file util-streaming-buffer.c.
References DEBUG_VALIDATE_BUG_ON, StreamingBufferBlock::len, offset, and StreamingBufferBlock::offset.
int StreamingBufferSegmentCompareRawData | ( | const StreamingBuffer * | sb, |
const StreamingBufferSegment * | seg, | ||
const uint8_t * | rawdata, | ||
uint32_t | rawdata_len | ||
) |
1 | data is the same |
0 | data is different |
Definition at line 1775 of file util-streaming-buffer.c.
References StreamingBufferSegmentGetData().
void StreamingBufferSegmentGetData | ( | const StreamingBuffer * | sb, |
const StreamingBufferSegment * | seg, | ||
const uint8_t ** | data, | ||
uint32_t * | data_len | ||
) |
Definition at line 1742 of file util-streaming-buffer.c.
Referenced by StreamingBufferSegmentCompareRawData(), StreamTcpInlineSegmentCompare(), StreamTcpSegmentForEach(), and StreamTcpSegmentForSession().
int StreamingBufferSegmentIsBeforeWindow | ( | const StreamingBuffer * | sb, |
const StreamingBufferSegment * | seg | ||
) |
Definition at line 1633 of file util-streaming-buffer.c.
References StreamingBuffer_::region, and StreamingBufferRegion_::stream_offset.
Referenced by HtpBodyPrune().
void StreamingBufferSlideToOffset | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg, | ||
uint64_t | offset | ||
) |
slide to absolute offset
Definition at line 1009 of file util-streaming-buffer.c.
References offset, and SCLogDebug.
Referenced by HtpBodyPrune().