suricata
detect-engine-inspect-buffer.h
Go to the documentation of this file.
1/* Copyright (C) 2025 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_DETECT_ENGINE_INSPECT_BUFFER_H
25#define SURICATA_DETECT_ENGINE_INSPECT_BUFFER_H
26
27/* inspection buffer is a simple structure that is passed between prefilter,
28 * transformation functions and inspection functions.
29 * Initially setup with 'orig' ptr and len, transformations can then take
30 * then and fill the 'buf'. Multiple transformations can update the buffer,
31 * both growing and shrinking it.
32 * Prefilter and inspection will only deal with 'inspect'. */
33
34typedef struct InspectionBuffer {
35 const uint8_t *inspect; /**< active pointer, points either to ::buf or ::orig */
37 uint32_t inspect_len; /**< size of active data. See to ::len or ::orig_len */
38 bool initialized; /**< is initialized. ::inspect might be NULL if transform lead to 0 size */
39 uint8_t flags; /**< DETECT_CI_FLAGS_* for use with DetectEngineContentInspection */
40#ifdef DEBUG_VALIDATION
41 bool multi;
42#endif
43 uint32_t len; /**< how much is in use */
44 uint8_t *buf;
45 uint32_t size; /**< size of the memory allocation */
46
47 uint32_t orig_len;
48 const uint8_t *orig;
50
51// Forward declarations for types from detect.h
54typedef struct SigMatch_ SigMatch;
55
56void InspectionBufferInit(InspectionBuffer *buffer, uint32_t initial_size);
57void InspectionBufferSetup(DetectEngineThreadCtx *det_ctx, const int list_id,
58 InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len);
60 InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len,
61 const DetectEngineTransforms *transforms);
63uint8_t *SCInspectionBufferCheckAndExpand(InspectionBuffer *buffer, uint32_t min_size);
64void SCInspectionBufferTruncate(InspectionBuffer *buffer, uint32_t buf_len);
65void InspectionBufferCopy(InspectionBuffer *buffer, uint8_t *buf, uint32_t buf_len);
67 const DetectEngineTransforms *transforms);
72 const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len);
74 DetectEngineThreadCtx *det_ctx, const int list_id, uint32_t local_id);
75
76#endif /* SURICATA_DETECT_ENGINE_INSPECT_BUFFER_H */
void InspectionBufferFree(InspectionBuffer *buffer)
void InspectionBufferSetupMultiEmpty(InspectionBuffer *buffer)
setup the buffer empty
void InspectionBufferCopy(InspectionBuffer *buffer, uint8_t *buf, uint32_t buf_len)
void InspectionBufferClean(DetectEngineThreadCtx *det_ctx)
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 InspectionBufferApplyTransforms(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const DetectEngineTransforms *transforms)
void InspectionBufferSetupAndApplyTransforms(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 InspectionBufferInit(InspectionBuffer *buffer, uint32_t initial_size)
InspectionBuffer * InspectionBufferGet(DetectEngineThreadCtx *det_ctx, const int list_id)
InspectionBuffer * InspectionBufferMultipleForListGet(DetectEngineThreadCtx *det_ctx, const int list_id, uint32_t local_id)
for a InspectionBufferMultipleForList get a InspectionBuffer
void SCInspectionBufferTruncate(InspectionBuffer *buffer, uint32_t buf_len)
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 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
a single match condition for a signature
Definition detect.h:356