Go to the documentation of this file.
66 const int list_id,
const bool eof);
69 const uint32_t input_len,
const uint64_t input_offset);
81 SCLogDebug(
"frame %p engine %p", frame, engine);
101 static int FrameStreamDataPrefilterFunc(
102 void *cb_data,
const uint8_t *input,
const uint32_t input_len,
const uint64_t input_offset)
105 SCLogDebug(
"prefilter: fsd %p { det_ctx:%p, transforms:%p, frame:%p, list_id:%d, idx:%u, "
106 "data_offset:%" PRIu64
"}, input: %p, input_len:%u, input_offset:%" PRIu64,
113 if (buffer == NULL) {
118 const int more_chunks = BufferSetup(fsd, buffer, input, input_len, input_offset);
121 const uint8_t *data = buffer->
inspect;
151 SCLogDebug(
"packet:%" PRIu64
", prefilter running on list %d -> frame field type %u",
153 if (
p->
proto == IPPROTO_UDP) {
162 BufferSetupUdp(buffer,
frame,
p,
ctx->transforms);
164 const uint8_t *data = buffer->
inspect;
174 }
else if (
p->
proto == IPPROTO_TCP) {
186 memset(&fsd, 0,
sizeof(fsd));
189 if (SetupStreamCallbackData(&fsd, ssn, stream,
det_ctx,
ctx->transforms, frames,
frame,
190 ctx->list_id, eof) ==
true) {
198 ", prefilter done running on list %d -> frame field type %u; have %u matches",
202 static void PrefilterMpmFrameFree(
void *ptr)
220 mpm_reg->
frame_v1.type, pectx, PrefilterMpmFrameFree, mpm_reg->
pname);
245 SCLogDebug(
"sid %u: e %p Callback returned false",
s->
id, e);
248 "sid %u: e %p not for frame type %u (want %u)",
s->
id, e,
frame->
type, e->type);
270 const uint32_t data_len = frame_len;
272 SCLogDebug(
"packet %" PRIu64
" -> frame %p/%" PRIi64
"/%s offset %" PRIu64
273 " type %u len %" PRIi64,
280 buffer->
flags = ci_flags;
323 const uint32_t input_len,
const uint64_t input_offset)
327 const uint64_t so_input_re = input_offset + input_len;
328 const uint64_t so_frame_re =
331 const uint8_t *data = input;
332 uint8_t ci_flags = 0;
336 uint64_t fo_inspect_offset = 0;
349 data_len = input_len;
353 const uint64_t so_inspect_offset =
MAX(input_offset, so_frame_inspect_offset);
354 fo_inspect_offset = so_inspect_offset -
frame->
offset;
361 if (fo_inspect_offset >= (uint64_t)
frame->
len) {
362 SCLogDebug(
"data entirely past frame (%" PRIu64
" > %" PRIi64
")",
369 BUG_ON(so_inspect_offset < input_offset);
370 const uint32_t in_data_offset = so_inspect_offset - input_offset;
371 data += in_data_offset;
373 uint32_t in_data_excess = 0;
374 if (so_input_re >= so_frame_re) {
377 in_data_excess = so_input_re - so_frame_re;
379 data_len = input_len - in_data_offset - in_data_excess;
382 BUG_ON(so_inspect_offset < input_offset);
383 const uint32_t in_data_offset = so_inspect_offset - input_offset;
384 data += in_data_offset;
385 data_len = input_len - in_data_offset;
391 SCLogDebug(
"inspect_offset %" PRIu64, fo_inspect_offset);
393 buffer->
flags = ci_flags;
395 if (
frame->
len >= 0 && so_input_re >= so_frame_re) {
396 SCLogDebug(
"have the full frame, we can set progress accordingly (%" PRIu64
" > %" PRIu64
398 so_input_re, so_frame_re);
417 const bool ret = (
frame->
len >= 0 && so_input_re >= so_frame_re);
422 static int FrameStreamDataInspectFunc(
423 void *cb_data,
const uint8_t *input,
const uint32_t input_len,
const uint64_t input_offset)
426 SCLogDebug(
"inspect: fsd %p { det_ctx:%p, transforms:%p, s:%p, s->id:%u, frame:%p, list_id:%d, "
428 "requested_stream_offset:%" PRIu64
429 "}, input: %p, input_len:%u, input_offset:%" PRIu64,
436 if (buffer == NULL) {
444 more_chunks = BufferSetup(fsd, buffer, input, input_len, input_offset);
452 const uint8_t *data = buffer->
inspect;
461 const uint8_t ci_flags = buffer->
flags;
462 SCLogDebug(
"frame %p offset %" PRIu64
" type %u len %" PRIi64
463 " ci_flags %02x (start:%s, end:%s)",
467 SCLogDebug(
"buffer %p offset %" PRIu64
" len %u ci_flags %02x (start:%s, end:%s)", buffer,
477 p->
flow, data, data_len, data_offset, buffer->
flags,
480 SCLogDebug(
"DETECT_ENGINE_INSPECT_SIG_MATCH");
483 SCLogDebug(
"DETECT_ENGINE_INSPECT_SIG_NO_MATCH");
491 const int list_id,
const bool eof)
493 SCLogDebug(
"frame %" PRIi64
", len %" PRIi64
", offset %" PRIu64
", inspect_progress %" PRIu64,
498 if (usable <= frame_offset)
519 const uint64_t have = usable;
520 if (!ips && have < want) {
521 SCLogDebug(
"wanted %" PRIu64
" bytes, got %" PRIu64, want, have);
526 SCLogDebug(
"check inspection for having 2500 bytes: %" PRIu64, available_data);
527 if (!ips && !eof && available_data < 2500 &&
529 SCLogDebug(
"skip inspection until we have 2500 bytes (have %" PRIu64
")", available_data);
568 if (
p->
proto == IPPROTO_UDP) {
573 SCLogDebug(
"packet:%" PRIu64
", frame->id:%" PRIu64
574 ", list:%d, transforms:%p, s:%p, s->id:%u, engine:%p",
588 memset(&fsd, 0,
sizeof(fsd));
594 if (SetupStreamCallbackData(
struct PrefilterMpmFrameCtx PrefilterMpmFrameCtx
uint64_t inspect_progress
#define DETECT_CI_FLAGS_START
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
#define PREFILTER_PROFILING_END(ctx, profile_id)
uint32_t rule_id_array_cnt
Container for matching data for a signature group.
bool StreamTcpInlineMode(void)
See if stream engine is operating in inline mode.
uint64_t requested_stream_offset
#define PREFILTER_PROFILING_START(det_ctx)
const DetectEngineTransforms * transforms
main detection engine ctx
DetectEngineThreadCtx * det_ctx
one time registration of keywords at start up
const DetectEngineFrameInspectionEngine * inspect_engine
int PrefilterGenericMpmFrameRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
bool DetectRunFrameInspectRule(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, const Frames *frames, const Frame *frame)
int PrefilterAppendFrameEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
DetectEngineTransforms transforms
void DetectRunPrefilterFrame(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const Frames *frames, const Frame *frame, const AppProto alproto)
DetectEngineFrameInspectionEngine * frame_inspect
union PrefilterEngine_::@99 cb
const DetectEngineTransforms * transforms
void InspectionBufferSetupMultiEmpty(InspectionBuffer *buffer)
setup the buffer empty
#define PKT_IS_TOSERVER(p)
const char * AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
#define STREAM_BASE_OFFSET(stream)
Per thread variable structure.
union PrefilterEngine_::@98 ctx
#define DETECT_ENGINE_INSPECT_SIG_MATCH
const DetectEngineTransforms * transforms
#define DETECT_CI_FLAGS_END
PrefilterFrameFn PrefilterFrame
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
PrefilterEngine * frame_engines
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
@ DETECT_ENGINE_CONTENT_INSPECTION_MODE_FRAME
struct DetectEngineFrameInspectionEngine * next
int DetectEngineInspectFrameBufferGeneric(DetectEngineThreadCtx *det_ctx, const DetectEngineFrameInspectionEngine *engine, const Signature *s, Packet *p, const Frames *frames, const Frame *frame)
Do the content inspection & validation for a signature.
uint64_t frame_inspect_progress
struct DetectEngineFrameInspectionEngine::@83 v1
void InspectionBufferSetupMulti(InspectionBuffer *buffer, const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len)
setup the buffer with our initial data
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
InspectionBuffer * InspectionBufferMultipleForListGet(DetectEngineThreadCtx *det_ctx, const int list_id, const uint32_t local_id)
for a InspectionBufferMultipleForList get a InspectionBuffer
struct DetectBufferMpmRegistry_::@84::@88 frame_v1
bool DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Packet *p, Flow *f, const uint8_t *buffer, const uint32_t buffer_len, const uint32_t stream_start_offset, const uint8_t flags, const enum DetectContentInspectionType inspection_mode)
wrapper around DetectEngineContentInspectionInternal to return true/false only
AppProto alproto
application level protocol
int StreamReassembleForFrame(TcpSession *ssn, TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, const uint64_t offset, const bool eof)
#define DEBUG_VALIDATE_BUG_ON(exp)