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 1081 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 1125 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 274 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 1825 of file util-streaming-buffer.c.
References offset, PrintRawDataFp(), SCLogDebug, and StreamingBufferGetData().
void StreamingBufferFree | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg | ||
) |
Definition at line 297 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 1786 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 1803 of file util-streaming-buffer.c.
StreamingBuffer* StreamingBufferInit | ( | const StreamingBufferConfig * | cfg | ) |
Definition at line 251 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 1509 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 2412 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 1660 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 1696 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 1770 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 1737 of file util-streaming-buffer.c.
Referenced by StreamingBufferSegmentCompareRawData(), StreamTcpInlineSegmentCompare(), StreamTcpSegmentForEach(), and StreamTcpSegmentForSession().
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().
void StreamingBufferSlideToOffset | ( | StreamingBuffer * | sb, |
const StreamingBufferConfig * | cfg, | ||
uint64_t | offset | ||
) |
slide to absolute offset
Definition at line 1004 of file util-streaming-buffer.c.
References offset, and SCLogDebug.
Referenced by HtpBodyPrune().