Go to the documentation of this file.
48 for (uint32_t x = 0; x <= mbuffer->
max; x++) {
91 if (local_id >= fb->
size) {
92 uint32_t old_size = fb->
size;
93 uint32_t new_size = local_id + 1;
94 uint32_t grow_by = new_size - old_size;
95 SCLogDebug(
"size is %u, need %u, so growing by %u", old_size, new_size, grow_by);
103 SCLogDebug(
"ptr %p to_zero %p", ptr, to_zero);
112 #ifdef DEBUG_VALIDATION
113 buffer->multi =
true;
136 InspectionBufferApplyTransformsInternal(det_ctx, buffer, transforms);
141 memset(buffer, 0,
sizeof(*buffer));
142 buffer->
buf =
SCCalloc(initial_size,
sizeof(uint8_t));
143 if (buffer->
buf != NULL) {
144 buffer->
size = initial_size;
151 #ifdef DEBUG_VALIDATION
165 #ifdef DEBUG_VALIDATION
173 InspectionBufferApplyTransformsInternal(det_ctx, buffer, transforms);
179 #ifdef DEBUG_VALIDATION
189 if (det_ctx && list_id != -1)
209 InspectionBufferSetupInternal(det_ctx, list_id, buffer, data, data_len);
217 InspectionBufferSetupInternal(det_ctx, list_id, buffer, data, data_len);
218 InspectionBufferApplyTransformsInternal(det_ctx, buffer, transforms);
223 if (buffer->
buf != NULL) {
226 memset(buffer, 0,
sizeof(*buffer));
238 uint32_t new_size = (buffer->
size == 0) ? 4096 : buffer->
size;
239 while (new_size < min_size) {
241 if (new_size > UINT32_MAX / 2) {
251 buffer->
size = new_size;
272 uint32_t copy_size =
MIN(buf_len, buffer->
size);
273 memcpy(buffer->
buf, buf, copy_size);
290 static int InspectionBufferSetupOverflowUtest(
void)
330 UtRegisterTest(
"InspectionBufferSetupOverflowUtest", InspectionBufferSetupOverflowUtest);
void InspectionBufferApplyTransforms(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const DetectEngineTransforms *transforms)
struct DetectEngineThreadCtx_::@101 inspect
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
SigTableElmt * sigmatch_table
InspectionBuffer * SCInspectionBufferGet(DetectEngineThreadCtx *det_ctx, const int list_id)
void InspectionBufferCopy(InspectionBuffer *buffer, uint8_t *buf, uint32_t buf_len)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void InspectionBufferClean(DetectEngineThreadCtx *det_ctx)
void SCInspectionBufferSetupAndApplyTransforms(DetectEngineThreadCtx *det_ctx, const int list_id, InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len, const DetectEngineTransforms *transforms)
setup the buffer with our initial data
void InspectionBufferSetup(DetectEngineThreadCtx *det_ctx, const int list_id, InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
void DetectEngineInspectBufferRegisterTests(void)
void DetectEngineSetEvent(DetectEngineThreadCtx *det_ctx, uint8_t e)
#define DETECT_TRANSFORMS_MAX
bool SCInspectionBufferInPlace(const InspectionBuffer *buffer)
struct DetectEngineThreadCtx_::@102 multi_inspect
void InspectionBufferFree(InspectionBuffer *buffer)
#define PASS
Pass the test.
@ DETECT_EVENT_TOO_MANY_BUFFERS
InspectionBuffer * buffers
#define SCRealloc(ptr, sz)
uint32_t * to_clear_queue
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
void InspectionBufferInit(InspectionBuffer *buffer, uint32_t initial_size)
void InspectionBufferSetupMultiEmpty(InspectionBuffer *buffer)
setup the buffer empty
uint8_t * SCInspectionBufferCheckAndExpand(InspectionBuffer *buffer, uint32_t min_size)
make sure that the buffer has at least 'min_size' bytes Expand the buffer if necessary
void(* Transform)(DetectEngineThreadCtx *, InspectionBuffer *, const void *context)
InspectionBuffer * inspection_buffers
#define DEBUG_VALIDATE_BUG_ON(exp)
void InspectionBufferSetupMulti(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
InspectionBuffer * InspectionBufferMultipleForListGet(DetectEngineThreadCtx *det_ctx, const int list_id, const uint32_t local_id)
for a InspectionBufferMultipleForList get a InspectionBuffer
void SCInspectionBufferTruncate(InspectionBuffer *buffer, uint32_t buf_len)