Go to the documentation of this file.
58 #ifndef SURICATA_UTIL_STREAMING_BUFFER_H
59 #define SURICATA_UTIL_STREAMING_BUFFER_H
63 #define STREAMING_BUFFER_REGION_GAP_DEFAULT 262144
69 void *(*Calloc)(
size_t n,
size_t size);
70 void *(*Realloc)(
void *ptr,
size_t orig_size,
size_t size);
71 void (*
Free)(
void *ptr,
size_t size);
74 #define STREAMING_BUFFER_CONFIG_INITIALIZER \
76 2048, 8, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL, \
79 #define STREAMING_BUFFER_REGION_INIT \
81 NULL, 0, 0, 0ULL, NULL, \
116 uint32_t buf_size_max;
126 static inline uint64_t StreamingBufferGetConsecutiveDataRightEdge(
const StreamingBuffer *sb)
131 static inline uint64_t StreamingBufferGetOffset(
const StreamingBuffer *sb)
137 #define STREAMING_BUFFER_INITIALIZER \
139 STREAMING_BUFFER_REGION_INIT, \
147 #define STREAMING_BUFFER_INITIALIZER { STREAMING_BUFFER_REGION_INIT, { NULL }, NULL, 0, 1, 1, 0 };
163 StreamingBufferSegment *seg,
const uint8_t *data, uint32_t data_len)
WARN_UNUSED;
165 const uint8_t *data, uint32_t data_len)
WARN_UNUSED;
167 StreamingBufferSegment *seg,
const uint8_t *data, uint32_t data_len,
171 const StreamingBufferSegment *seg,
172 const uint8_t **data, uint32_t *data_len);
176 const uint8_t **data, uint32_t *data_len);
180 const uint8_t **data, uint32_t *data_len,
184 const StreamingBufferSegment *seg,
185 const uint8_t *rawdata, uint32_t rawdata_len);
187 const uint8_t *rawdata, uint32_t rawdata_len);
190 const uint8_t **data, uint32_t *data_len,
194 const uint8_t **data, uint32_t *data_len,
198 const StreamingBufferSegment *seg);
int StreamingBufferSegmentIsBeforeWindow(const StreamingBuffer *sb, const StreamingBufferSegment *seg)
RB_PROTOTYPE(SBB, StreamingBufferBlock, rb, SBBCompare)
StreamingBufferBlock * SBB_RB_FIND_INCLUSIVE(struct SBB *head, StreamingBufferBlock *elm)
int SBBCompare(struct StreamingBufferBlock *a, struct StreamingBufferBlock *b)
int StreamingBufferAppendNoTrack(StreamingBuffer *sb, const StreamingBufferConfig *cfg, const uint8_t *data, uint32_t data_len) WARN_UNUSED
add data w/o tracking a segment
StreamingBufferBlock * head
struct StreamingBufferRegion_ * next
int StreamingBufferGetDataAtOffset(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t offset)
struct StreamingBufferBlock __attribute__((__packed__)) StreamingBufferBlock
block of continues data
void StreamingBufferFree(StreamingBuffer *sb, const StreamingBufferConfig *cfg)
StreamingBuffer * StreamingBufferInit(const StreamingBufferConfig *cfg)
void StreamingBufferSBBGetData(const StreamingBuffer *sb, const StreamingBufferBlock *sbb, const uint8_t **data, uint32_t *data_len)
get the data for one SBB
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
void StreamingBufferRegisterTests(void)
void StreamingBufferSlideToOffset(StreamingBuffer *sb, const StreamingBufferConfig *cfg, uint64_t offset)
slide to absolute offset
int StreamingBufferSegmentCompareRawData(const StreamingBuffer *sb, const StreamingBufferSegment *seg, const uint8_t *rawdata, uint32_t rawdata_len)
RB_ENTRY(StreamingBufferBlock) rb
int StreamingBufferInsertAt(StreamingBuffer *sb, const StreamingBufferConfig *cfg, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len, uint64_t offset) WARN_UNUSED
struct StreamingBuffer_ StreamingBuffer
struct StreamingBufferRegion_ StreamingBufferRegion
int StreamingBufferGetData(const StreamingBuffer *sb, const uint8_t **data, uint32_t *data_len, uint64_t *stream_offset)
int StreamingBufferAppend(StreamingBuffer *sb, const StreamingBufferConfig *cfg, StreamingBufferSegment *seg, const uint8_t *data, uint32_t data_len) WARN_UNUSED
struct StreamingBufferConfig_ StreamingBufferConfig
RB_HEAD(SBB, StreamingBufferBlock)
int StreamingBufferCompareRawData(const StreamingBuffer *sb, const uint8_t *rawdata, uint32_t rawdata_len)
void(* Free)(void *ptr, size_t size)
void StreamingBufferSegmentGetData(const StreamingBuffer *sb, const StreamingBufferSegment *seg, const uint8_t **data, uint32_t *data_len)
void StreamingBufferClear(StreamingBuffer *sb, const StreamingBufferConfig *cfg)
StreamingBufferRegion region