Go to the documentation of this file.
67 const int list_id,
const bool eof);
70 const uint32_t input_len,
const uint64_t input_offset);
83 SCLogDebug(
"frame %p engine %p", frame, engine);
103 static int FrameStreamDataPrefilterFunc(
104 void *cb_data,
const uint8_t *input,
const uint32_t input_len,
const uint64_t input_offset)
107 SCLogDebug(
"prefilter: fsd %p { det_ctx:%p, transforms:%p, frame:%p, list_id:%d, idx:%u, "
108 "data_offset:%" PRIu64
"}, input: %p, input_len:%u, input_offset:%" PRIu64,
115 if (buffer == NULL) {
120 const int more_chunks = BufferSetup(fsd, buffer, input, input_len, input_offset);
123 const uint8_t *data = buffer->
inspect;
153 SCLogDebug(
"packet:%" PRIu64
", prefilter running on list %d -> frame field type %u",
155 if (
p->
proto == IPPROTO_UDP) {
166 const uint8_t *data = buffer->
inspect;
176 }
else if (
p->
proto == IPPROTO_TCP) {
188 memset(&fsd, 0,
sizeof(fsd));
191 if (SetupStreamCallbackData(&fsd, ssn, stream,
det_ctx,
ctx->transforms, frames,
frame,
192 ctx->list_id, eof)) {
200 ", prefilter done running on list %d -> frame field type %u; have %u matches",
204 static void PrefilterMpmFrameFree(
void *ptr)
222 mpm_reg->
frame_v1.type, pectx, PrefilterMpmFrameFree, mpm_reg->
pname);
247 SCLogDebug(
"sid %u: e %p Callback returned false",
s->
id, e);
250 "sid %u: e %p not for frame type %u (want %u)",
s->
id, e,
frame->
type, e->type);
272 const uint32_t data_len = frame_len;
274 SCLogDebug(
"packet %" PRIu64
" -> frame %p/%" PRIi64
"/%s offset %" PRIu64
275 " type %u len %" PRIi64,
282 buffer->
flags = ci_flags;
325 const uint32_t input_len,
const uint64_t input_offset)
329 const uint64_t so_input_re = input_offset + input_len;
330 const uint64_t so_frame_re =
333 const uint8_t *data = input;
334 uint8_t ci_flags = 0;
338 uint64_t fo_inspect_offset = 0;
351 data_len = input_len;
355 const uint64_t so_inspect_offset =
MAX(input_offset, so_frame_inspect_offset);
356 fo_inspect_offset = so_inspect_offset -
frame->
offset;
363 if (fo_inspect_offset >= (uint64_t)
frame->
len) {
364 SCLogDebug(
"data entirely past frame (%" PRIu64
" > %" PRIi64
")",
373 const uint32_t in_data_offset = (uint32_t)(so_inspect_offset - input_offset);
374 data += in_data_offset;
376 uint32_t in_data_excess = 0;
377 if (so_input_re >= so_frame_re) {
381 in_data_excess = (uint32_t)(so_input_re - so_frame_re);
383 data_len = input_len - in_data_offset - in_data_excess;
388 const uint32_t in_data_offset = (uint32_t)(so_inspect_offset - input_offset);
389 data += in_data_offset;
390 data_len = input_len - in_data_offset;
396 SCLogDebug(
"inspect_offset %" PRIu64, fo_inspect_offset);
398 buffer->
flags = ci_flags;
400 if (
frame->
len >= 0 && so_input_re >= so_frame_re) {
401 SCLogDebug(
"have the full frame, we can set progress accordingly (%" PRIu64
" > %" PRIu64
403 so_input_re, so_frame_re);
422 const bool ret = (
frame->
len >= 0 && so_input_re >= so_frame_re);
427 static int FrameStreamDataInspectFunc(
428 void *cb_data,
const uint8_t *input,
const uint32_t input_len,
const uint64_t input_offset)
431 SCLogDebug(
"inspect: fsd %p { det_ctx:%p, transforms:%p, s:%p, s->id:%u, frame:%p, list_id:%d, "
433 "requested_stream_offset:%" PRIu64
434 "}, input: %p, input_len:%u, input_offset:%" PRIu64,
441 if (buffer == NULL) {
449 more_chunks = BufferSetup(fsd, buffer, input, input_len, input_offset);
457 const uint8_t *data = buffer->
inspect;
466 const uint8_t ci_flags = buffer->
flags;
467 SCLogDebug(
"frame %p offset %" PRIu64
" type %u len %" PRIi64
468 " ci_flags %02x (start:%s, end:%s)",
472 SCLogDebug(
"buffer %p offset %" PRIu64
" len %u ci_flags %02x (start:%s, end:%s)", buffer,
482 p->
flow, data, data_len, data_offset, buffer->
flags,
485 SCLogDebug(
"DETECT_ENGINE_INSPECT_SIG_MATCH");
488 SCLogDebug(
"DETECT_ENGINE_INSPECT_SIG_NO_MATCH");
496 const int list_id,
const bool eof)
498 SCLogDebug(
"frame %" PRIi64
", len %" PRIi64
", offset %" PRIu64
", inspect_progress %" PRIu64,
503 if (usable <= frame_offset)
524 const uint64_t have = usable;
525 if (!ips && have < want) {
526 SCLogDebug(
"wanted %" PRIu64
" bytes, got %" PRIu64, want, have);
531 SCLogDebug(
"check inspection for having 2500 bytes: %" PRIu64, available_data);
532 if (!ips && !eof && available_data < 2500 &&
534 SCLogDebug(
"skip inspection until we have 2500 bytes (have %" PRIu64
")", available_data);
573 if (
p->
proto == IPPROTO_UDP) {
578 SCLogDebug(
"packet:%" PRIu64
", frame->id:%" PRIu64
579 ", list:%d, transforms:%p, s:%p, s->id:%u, engine:%p",
593 memset(&fsd, 0,
sizeof(fsd));
599 if (!SetupStreamCallbackData(
struct PrefilterMpmFrameCtx PrefilterMpmFrameCtx
uint64_t inspect_progress
union PrefilterEngine_::@110 ctx
#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
struct DetectEngineFrameInspectionEngine::@92 v1
const DetectEngineTransforms * transforms
#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.
#define DETECT_ENGINE_INSPECT_SIG_MATCH
const DetectEngineTransforms * transforms
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 uint64_t stream_start_offset, const uint8_t flags, const enum DetectContentInspectionType inspection_mode)
wrapper around DetectEngineContentInspectionInternal to return true/false only
#define DETECT_CI_FLAGS_END
PrefilterFrameFn PrefilterFrame
union PrefilterEngine_::@111 cb
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
PrefilterEngine * frame_engines
struct DetectBufferMpmRegistry_::@96::@100 frame_v1
#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
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
void InspectionBufferSetupMultiEmpty(InspectionBuffer *buffer)
setup the buffer empty
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)
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