Go to the documentation of this file.
88 static inline void DetectRulePacketRules(
ThreadVars *
const tv,
127 DetectRunInspectIPOnly(th_v,
de_ctx, det_ctx, pflow, p);
130 DetectRunGetRuleGroup(
de_ctx, p, pflow, &scratch);
133 if (scratch.
sgh == NULL) {
134 SCLogDebug(
"no sgh for this packet, nothing to match against");
139 DetectRunPrefilterPkt(th_v,
de_ctx, det_ctx, p, &scratch);
143 DetectRulePacketRules(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
148 if (p->
proto == IPPROTO_TCP) {
152 DetectRunFrames(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
155 }
else if (p->
proto == IPPROTO_UDP) {
156 DetectRunFrames(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
160 DetectRunTx(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
165 DetectRunPostRules(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
167 DetectRunCleanup(det_ctx, p, pflow);
180 SCLogDebug(
"running match functions, sm %p", smd);
213 }
else if (p->
proto == 0) {
227 if (
proto == IPPROTO_TCP) {
229 SCLogDebug(
"tcp toserver %p, tcp toclient %p: going to use %p",
231 uint16_t port = f ? p->
dp : p->
sp;
236 SCLogDebug(
"TCP list %p, port %u, direction %s, sghport %p, sgh %p",
237 list, port, f ?
"toserver" :
"toclient", sghport, sgh);
238 }
else if (
proto == IPPROTO_UDP) {
240 uint16_t port = f ? p->
dp : p->
sp;
244 SCLogDebug(
"UDP list %p, port %u, direction %s, sghport %p, sgh %p",
245 list, port, f ?
"toserver" :
"toclient", sghport, sgh);
276 final_ptr = nonmpm_ptr;
281 nonmpm = *nonmpm_ptr;
295 if (
likely(
id != previous_id)) {
301 final_ptr = nonmpm_ptr;
307 }
else if (mpm > nonmpm) {
312 if (
likely(
id != previous_id)) {
322 nonmpm = *nonmpm_ptr;
328 while (--m_cnt != 0) {
339 final_ptr = ++nonmpm_ptr;
354 nonmpm = *nonmpm_ptr;
360 while (final_cnt-- > 0) {
365 if (
likely(
id != previous_id)) {
379 static inline void DetectPrefilterBuildNonPrefilterList(
387 if ((rule_mask & mask) == rule_mask &&
388 (rule_alproto == 0 || AppProtoEquals(rule_alproto, alproto))) {
408 SCLogDebug(
"sgh non_pf ptr %p cnt %u (syn %p/%u, other %p/%u)",
420 DetectPostInspectFileFlagsUpdate(
Flow *f,
const SigGroupHead *sgh, uint8_t direction)
425 SCLogDebug(
"requesting disabling all file features for flow");
429 SCLogDebug(
"requesting disabling filestore for flow");
433 if (!(sgh->
flags & SIG_GROUP_HEAD_HAVEFILEMAGIC)) {
434 SCLogDebug(
"requesting disabling magic for flow");
439 SCLogDebug(
"requesting disabling md5 for flow");
443 SCLogDebug(
"requesting disabling sha1 for flow");
447 SCLogDebug(
"requesting disabling sha256 for flow");
451 SCLogDebug(
"requesting disabling filesize for flow");
455 if (flow_file_flags != 0) {
471 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.client");
476 DetectPostInspectFileFlagsUpdate(pflow,
486 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.server");
491 DetectPostInspectFileFlagsUpdate(pflow,
496 static inline void DetectRunGetRuleGroup(
504 bool use_flow_sgh =
false;
511 SCLogDebug(
"sgh = pflow->sgh_toserver; => %p", sgh);
515 SCLogDebug(
"sgh = pflow->sgh_toclient; => %p", sgh);
521 if (!(use_flow_sgh)) {
534 DetectRunPostGetFirstRuleGroup(p, pflow, sgh);
562 SCLogDebug(
"testing against \"ip-only\" signatures");
582 static inline int DetectRunInspectRuleHeader(
586 const uint32_t sflags,
587 const uint8_t s_proto_flags)
599 SCLogDebug(
"skipping sig as the flow has no flowvars and sig "
600 "has SIG_FLAG_REQUIRE_FLOWVAR flag set.");
640 SCLogDebug(
"port-less protocol and sig needs ports");
671 static inline void DetectRunPrefilterPkt(
679 DetectPrefilterSetNonPrefilterList(p, det_ctx, scratch);
688 DetectPrefilterBuildNonPrefilterList(det_ctx, scratch->
pkt_mask, scratch->
alproto);
702 DetectPrefilterMergeSort(
de_ctx, det_ctx);
717 static inline void DetectRulePacketRules(
735 (uint64_t)match_cnt);
746 uint32_t sflags, next_sflags = 0;
748 next_s = *match_array++;
749 next_sflags = next_s->
flags;
751 while (match_cnt--) {
753 uint8_t alert_flags = 0;
758 sflags = next_sflags;
760 next_s = *match_array++;
761 next_sflags = next_s->
flags;
781 if (SigDsizePrefilter(p, s, sflags))
792 if (DetectRunInspectRuleHeader(p, pflow, s, sflags, s_proto_flags) == 0) {
803 DetectRunPostMatch(
tv, det_ctx, p, s);
807 DetectVarProcessList(det_ctx, pflow, p);
808 DetectReplaceFree(det_ctx);
822 uint8_t flow_flags = 0;
823 bool app_decoder_events =
false;
842 det_ctx->pkt_stream_add_cnt++;
851 flow_flags = STREAM_TOSERVER;
854 flow_flags = STREAM_TOCLIENT;
860 flow_flags |= STREAM_EOF;
891 (p->
proto == IPPROTO_UDP) ||
896 alproto = FlowGetAppProtocol(pflow);
903 SCLogDebug(
"packet doesn't have established flag set (proto %d)", p->
proto);
914 static inline void DetectRunPostRules(
971 FatalError(
"failed to allocate %" PRIu64
" bytes",
975 SCLogDebug(
"array initialized to %u elements (%"PRIu64
" bytes)",
998 uint32_t new_size = needed;
1001 FatalError(
"failed to expand to %" PRIu64
" bytes",
1007 SCLogDebug(
"array expanded from %u to %u elements (%"PRIu64
" bytes -> %"PRIu64
" bytes)",
1020 DetectRunTxSortHelper(
const void *a,
const void *b)
1024 if (s1->
id == s0->
id) {
1031 return s0->
id > s1->
id ? 1 : -1;
1035 #define TRACE_SID_TXS(sid,txs,...) \
1037 char _trace_buf[2048]; \
1038 snprintf(_trace_buf, sizeof(_trace_buf), __VA_ARGS__); \
1039 SCLogNotice("%p/%"PRIu64"/%u: %s", txs->tx_ptr, txs->tx_id, sid, _trace_buf); \
1042 #define TRACE_SID_TXS(sid,txs,...)
1062 const uint8_t in_flow_flags,
1066 uint32_t *stored_flags,
1070 uint8_t flow_flags = in_flow_flags;
1071 const int direction = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1072 uint32_t inspect_flags = stored_flags ? *stored_flags : 0;
1073 int total_matches = 0;
1074 uint16_t file_no_match = 0;
1075 bool retval =
false;
1076 bool mpm_before_progress =
false;
1077 bool mpm_in_progress =
false;
1079 TRACE_SID_TXS(s->
id, tx,
"starting %s", direction ?
"toclient" :
"toserver");
1082 if (
likely(stored_flags == NULL)) {
1084 if (DetectRunInspectRuleHeader(p, f, s, s->
flags, s->
proto.
flags) == 0) {
1100 while (engine != NULL) {
1101 TRACE_SID_TXS(s->
id, tx,
"engine %p inspect_flags %x", engine, inspect_flags);
1102 if (!(inspect_flags &
BIT_U32(engine->
id)) &&
1103 direction == engine->
dir)
1109 engine = engine->
next;
1116 SCLogDebug(
"tx progress %d < engine progress %d",
1123 "engine->mpm: t->tx_progress %u > engine->progress %u, so set "
1124 "mpm_before_progress",
1126 mpm_before_progress =
true;
1129 "engine->mpm: t->tx_progress %u == engine->progress %u, so set "
1132 mpm_in_progress =
true;
1140 TRACE_SID_TXS(s->
id, tx,
"stream skipped, stored result %d used instead", match);
1150 TRACE_SID_TXS(s->
id, tx,
"stream ran, store result %d for next tx (if any)", match);
1155 engine = engine->
next;
1162 engine = engine->
next;
1174 if (engine->
mpm && mpm_before_progress) {
1180 engine = engine->
next;
1182 TRACE_SID_TXS(s->
id, tx,
"inspect_flags %x, total_matches %u, engine %p",
1183 inspect_flags, total_matches, engine);
1185 if (engine == NULL && total_matches) {
1192 *stored_flags = inspect_flags;
1193 TRACE_SID_TXS(s->
id, tx,
"continue inspect flags %08x", inspect_flags);
1200 if (file_no_match) {
1211 inspect_flags, flow_flags, file_no_match);
1215 "mpm won't trigger for it anymore");
1219 "we may have to revisit anyway");
1221 inspect_flags, flow_flags, file_no_match);
1225 "mpm will revisit it");
1229 inspect_flags, flow_flags, file_no_match);
1238 NULL, 0, NULL, NULL, 0, 0, 0, 0, 0, \
1246 void *alstate,
const uint64_t tx_id,
void *tx_ptr,
const int tx_end_state,
1247 const uint8_t flow_flags)
1254 uint64_t detect_flags =
1255 (flow_flags & STREAM_TOSERVER) ? txd->detect_flags_ts : txd->detect_flags_tc;
1257 SCLogDebug(
"%"PRIu64
" tx already fully inspected for %s. Flags %016"PRIx64,
1258 tx_id, flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1264 SCLogDebug(
"%" PRIu64
" tx should not be inspected in direction %s. Flags %016" PRIx64,
1265 tx_id, flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", detect_flags);
1271 const int dir_int = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1281 .de_state = tx_dir_state,
1282 .detect_flags = detect_flags,
1283 .prefilter_flags = prefilter_flags,
1284 .prefilter_flags_orig = prefilter_flags,
1285 .tx_progress = tx_progress,
1286 .tx_end_state = tx_end_state,
1291 static inline void StoreDetectFlags(
DetectTransaction *tx,
const uint8_t flow_flags,
1292 const uint8_t ipproto,
const AppProto alproto,
const uint64_t detect_flags)
1295 if (
likely(txd != NULL)) {
1296 if (flow_flags & STREAM_TOSERVER) {
1297 txd->detect_flags_ts = detect_flags;
1299 txd->detect_flags_tc = detect_flags;
1311 const uint8_t flow_flags = scratch->
flow_flags;
1313 void *
const alstate = f->
alstate;
1314 const uint8_t ipproto = f->
proto;
1323 memset(&state, 0,
sizeof(state));
1326 AppLayerGetTxIterTuple ires = IterFunc(ipproto, alproto, alstate, tx_id_min, total_txs, &state);
1327 if (ires.tx_ptr == NULL)
1331 alstate, ires.tx_id, ires.tx_ptr, tx_end_state, flow_flags);
1333 SCLogDebug(
"%p/%"PRIu64
" no transaction to inspect",
1339 tx_id_min = tx.
tx_id + 1;
1341 bool do_sort =
false;
1342 uint32_t array_idx = 0;
1352 SCLogDebug(
"%p/%"PRIu64
" rules added from prefilter: %u candidates",
1356 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
1357 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1371 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
1372 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1377 uint32_t x = array_idx;
1388 SCLogDebug(
"%p/%"PRIu64
" rule %u (%u) added from 'match' list",
1392 do_sort = (array_idx > x);
1398 const uint32_t old = array_idx;
1403 if (have_new_file) {
1404 SCLogDebug(
"%p/%"PRIu64
" destate: need to consider new file",
1411 for (; tx_store != NULL; tx_store = tx_store->
next) {
1417 store_cnt++, state_cnt++)
1434 do_sort |= (old && old != array_idx);
1440 DetectRunTxSortHelper);
1452 for (uint32_t i = 0; i < array_idx; i++) {
1459 for (uint32_t i = 0; i < array_idx; i++) {
1469 while ((i + 1) < array_idx &&
1471 SCLogDebug(
"%p/%" PRIu64
" inspecting SKIP NEXT: sid %u (%u), flags %08x",
1476 SCLogDebug(
"%p/%"PRIu64
" inspecting: sid %u (%u), flags %08x",
1479 if (inspect_flags) {
1481 SCLogDebug(
"%p/%"PRIu64
" inspecting: sid %u (%u), flags %08x ALREADY COMPLETE",
1487 if (inspect_flags) {
1497 const int r = DetectRunTxInspectRule(
tv,
de_ctx, det_ctx, p, f, flow_flags,
1498 alstate, &tx, s, inspect_flags, can, scratch);
1501 DetectRunPostMatch(
tv, det_ctx, p, s);
1507 DetectVarProcessList(det_ctx, p->
flow, p);
1517 uint64_t new_detect_flags = 0;
1521 SCLogDebug(
"%p/%"PRIu64
" tx is done for direction %s. Flag %016"PRIx64,
1523 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1529 SCLogDebug(
"%p/%"PRIu64
" updated prefilter flags %016"PRIx64
" "
1530 "(was: %016"PRIx64
") for direction %s. Flag %016"PRIx64,
1532 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1535 if (new_detect_flags != 0 &&
1540 SCLogDebug(
"%p/%"PRIu64
" Storing new flags %016"PRIx64
" (was %016"PRIx64
")",
1543 StoreDetectFlags(&tx, flow_flags, ipproto, alproto, new_detect_flags);
1560 if (frames_container == NULL) {
1565 frames = &frames_container->
toserver;
1567 frames = &frames_container->
toclient;
1570 for (uint32_t idx = 0; idx < frames->
cnt; idx++) {
1573 if (frame == NULL) {
1578 uint32_t array_idx = 0;
1586 SCLogDebug(
"%p/%" PRIi64
" rules added from prefilter: %u candidates", frame, frame->
id,
1591 if (!(RuleMatchCandidateTxArrayHasSpace(
1592 det_ctx, total_rules))) {
1593 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1608 uint32_t x = array_idx;
1619 SCLogDebug(
"%p/%" PRIi64
" rule %u (%u) added from 'match' list", frame, frame->
id,
1623 SCLogDebug(
"%p/%" PRIi64
" rules added from 'match' list: %u", frame, frame->
id,
1628 for (uint32_t i = 0; i < array_idx; i++) {
1635 while ((i + 1) < array_idx &&
1639 SCLogDebug(
"%p/%" PRIi64
" inspecting: sid %u (%u)", frame, frame->
id, s->
id, s->
num);
1642 SCLogDebug(
"%p/%" PRIi64
" Start sid %u", frame, frame->
id, s->
id);
1646 int r = DetectRunInspectRuleHeader(p, f, s, s->
flags, s->
proto.
flags);
1651 DetectRunPostMatch(
tv, det_ctx, p, s);
1653 const uint8_t alert_flags =
1658 "%p/%" PRIi64
" sig %u (%u) matched", frame, frame->
id, s->
id, s->
num);
1662 DetectVarProcessList(det_ctx, p->
flow, p);
1673 "frame->inspect_progress: %" PRIu64
" -> not updated", frame->
inspect_progress);
1676 SCLogDebug(
"%p/%" PRIi64
" rules inspected, running cleanup", frame, frame->
id);
1707 SCLogDebug(
"p->pcap %"PRIu64
": no detection on packet, "
1708 "PKT_NOPACKET_INSPECTION is set", p->
pcap_cnt);
1719 (void)DetectRun(
tv,
de_ctx, det_ctx, p);
1751 if (det_ctx == NULL) {
1752 printf(
"ERROR: Detect has no thread ctx\n");
1758 SCLogDebug(
"Detect Engine using new det_ctx - %p",
1769 if (tenant_id > 0 && tenant_id < det_ctx->mt_det_ctxs_cnt) {
1772 if (det_ctx == NULL)
1780 SCLogDebug(
"MT de_ctx %p det_ctx %p (tenant %u)",
de_ctx, det_ctx, tenant_id);
1791 DetectFlow(
tv,
de_ctx, det_ctx, p);
1793 DetectNoFlow(
tv,
de_ctx, det_ctx, p);
1796 #ifdef PROFILE_RULES
1799 SCProfilingRuleThreatAggregate(det_ctx);
1814 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOSERVER);
1815 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOCLIENT);
1826 DetectFlow(
tv,
de_ctx, det_ctx, p);
1828 DetectNoFlow(
tv,
de_ctx, det_ctx, p);
uint32_t non_pf_syn_store_cnt
bool PacketCheckAction(const Packet *p, const uint8_t a)
#define FLOWFILE_NO_MD5_TS
SignatureNonPrefilterStore * non_pf_store_ptr
void RulesDumpTxMatchArray(const DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, const Packet *p, const uint64_t tx_id, const uint32_t rule_cnt, const uint32_t pkt_prefilter_cnt)
#define SIG_GROUP_HEAD_HAVEFILEMD5
#define FLOWFILE_NO_MD5_TC
PrefilterEngine * tx_engines
struct AppLayerTxData * tx_data_ptr
#define DE_STATE_CHUNK_SIZE
#define FLOWFILE_NO_SIZE_TS
uint64_t inspect_progress
uint16_t alert_queue_size
#define FLOWFILE_NO_SIZE_TC
DetectMatchAddressIPv6 * addr_src_match6
#define PACKET_ALERT_FLAG_TX
struct SigGroupHead_ * decoder_event_sgh
int FlowGetPacketDirection(const Flow *f, const Packet *p)
determine the direction of the packet compared to the flow
DetectEngineLookupFlow flow_gh[FLOW_STATES]
#define DE_STATE_FLAG_SIG_CANT_MATCH
uint16_t counter_match_list
struct DetectEngineAppInspectionEngine_ * next
#define DETECT_PROTO_IPV6
void Prefilter(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t flags)
uint32_t rule_id_array_cnt
Container for matching data for a signature group.
#define SIG_GROUP_HEAD_HAVEFILESIZE
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
#define KEYWORD_PROFILING_SET_LIST(ctx, list)
int DetectAddressMatchIPv4(const DetectMatchAddressIPv4 *addrs, uint16_t addrs_cnt, const Address *a)
Match a packets address against a signatures addrs array.
#define FLOW_SGH_TOCLIENT
void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate, void *alstate, const uint8_t flags, bool tag_txs_as_inspected)
AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto, const AppProto alproto)
struct HtpBodyChunk_ * next
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
#define FLOWFILE_NO_MAGIC_TS
#define ICMPV4_DEST_UNREACH_IS_VALID(p)
#define SIG_GROUP_HEAD_HAVEFILESHA1
main detection engine ctx
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
struct DetectRunScratchpad DetectRunScratchpad
#define APP_LAYER_TX_SKIP_INSPECT_FLAG
DetectEngineStateDirection dir_state[2]
Frame * FrameGetByIndex(Frames *frames, const uint32_t idx)
#define FLOW_PKT_TOSERVER
#define APP_LAYER_TX_INSPECTED_FLAG
#define SIG_GROUP_HEAD_HAVERAWSTREAM
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
SigMatchData * sm_arrays[DETECT_SM_LIST_MAX]
struct SigGroupHead_ * sh
#define PACKET_PROFILING_DETECT_END(p, id)
TmEcode Detect(ThreadVars *tv, Packet *p, void *data)
Detection engine thread wrapper.
#define FLOW_PKT_TOCLIENT_IPONLY_SET
#define KEYWORD_PROFILING_START
uint16_t counter_fnonmpm_list
void DisableDetectFlowFileFlags(Flow *f)
disable file features we don't need Called if we have no detection engine.
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction)
uint16_t counter_nonmpm_list
void DetectRunPrefilterFrame(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const Frames *frames, const Frame *frame, const AppProto alproto)
PacketEngineEvents events
DetectEngineFrameInspectionEngine * frame_inspect
const uint64_t prefilter_flags_orig
void PacketCreateMask(Packet *p, SignatureMask *mask, AppProto alproto, bool app_decoder_events)
#define SIG_FLAG_APPLAYER
#define KEYWORD_PROFILING_END(ctx, type, m)
HashTable * mt_det_ctxs_hash
bool DetectEnginePktInspectionRun(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, uint8_t *alert_flags)
const struct SigGroupHead_ * sgh_toserver
uint16_t counter_alerts_suppressed
void DetectRunStoreStateTx(const SigGroupHead *sgh, Flow *f, void *tx, uint64_t tx_id, const Signature *s, uint32_t inspect_flags, uint8_t flow_flags, const uint16_t file_no_match)
AppLayerParserState * alparser
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH_FILES
#define FLOWFILE_NO_SHA1_TC
@ DETECT_SM_LIST_POSTMATCH
RuleMatchCandidateTx * tx_candidates
DetectMatchAddressIPv4 * addr_src_match4
uint16_t counter_alerts_overflow
#define DETECT_ENGINE_THREAD_CTX_FRAME_ID_SET
#define PKT_IS_TOSERVER(p)
#define DEBUG_VALIDATE_PACKET(p)
#define FLOWFILE_NO_STORE_TS
uint32_t tx_candidates_size
#define FLOW_PKT_TOSERVER_IPONLY_SET
#define STREAM_FLAGS_FOR_PACKET(p)
struct SigGroupHead_ * sgh[256]
void * HashTableLookup(HashTable *ht, void *data, uint16_t datalen)
Per thread variable structure.
struct DeStateStore_ * next
#define FLOWFILE_NO_SHA256_TS
#define DETECT_ENGINE_INSPECT_SIG_MATCH
#define PKT_DETECT_HAS_STREAMDATA
bool StreamReassembleRawHasDataReady(TcpSession *ssn, Packet *p)
does the stream engine have data to inspect?
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Port structure for detection engine.
DetectEngineAppInspectionEngine * app_inspect
const struct SigGroupHead_ * sgh_toclient
#define SIG_FLAG_REQUIRE_FLOWVAR
uint64_t raw_stream_progress
void FileUpdateFlowFileFlags(Flow *f, uint16_t set_file_flags, uint8_t direction)
set a flow's file flags
void AlertQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, uint64_t tx_id, uint8_t alert_flags)
Append signature to local packet alert queue for later preprocessing.
void RuleMatchCandidateTxArrayFree(DetectEngineThreadCtx *det_ctx)
FramesContainer * AppLayerFramesGetContainer(Flow *f)
InspectEngineFuncPtr2 Callback
#define APP_LAYER_TX_PREFILTER_MASK
void FlowSetIPOnlyFlag(Flow *f, int direction)
Set the IPOnly scanned flag for 'direction'.
#define FLOW_TOSERVER_IPONLY_SET
#define RULE_PROFILING_END(a, b, c, p)
#define RULE_PROFILING_START(p)
#define SCReturnPtr(x, type)
DetectEngineStateDirection * de_state
Data structures and function prototypes for keeping state for the detection engine.
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
void RulesDumpMatchArray(const DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, const Packet *p)
uint16_t addr_dst_match6_cnt
#define FLOW_PKT_TOCLIENT
PrefilterEngine * frame_engines
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH
#define DETECT_ENGINE_STATE_FLAG_FILE_NEW
#define SCRealloc(ptr, sz)
#define FLOWFILE_NO_SHA256_TC
#define DETECT_ENGINE_INSPECT_SIG_MATCH_MORE_FILES
struct AppLayerTxData AppLayerTxData
#define DETECT_PROTO_IPV4
int DetectAddressMatchIPv6(const DetectMatchAddressIPv6 *addrs, uint16_t addrs_cnt, const Address *a)
Match a packets address against a signatures addrs array.
void DetectEngineStateResetTxs(Flow *f)
Reset de state for active tx' To be used on detect engine reload.
#define FLOWFILE_NO_MAGIC_TC
SignatureNonPrefilterStore * non_pf_other_store_array
#define FLOW_TOCLIENT_IPONLY_SET
#define APP_LAYER_TX_RESERVED_FLAGS
uint32_t non_pf_other_store_cnt
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
uint64_t frame_inspect_progress
uint32_t profile_match_logging_threshold
AppLayerTxData * AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
#define FLOWFILE_NO_STORE_TC
SigIntId * non_pf_id_array
uint16_t addr_src_match6_cnt
void StreamReassembleRawUpdateProgress(TcpSession *ssn, Packet *p, const uint64_t progress)
update stream engine after detection
void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
Adds a value of type uint64_t to the local counter.
struct DetectEngineAppInspectionEngine_::@83 v2
#define FLOWFILE_NO_SHA1_TS
const bool app_decoder_events
#define PACKET_PROFILING_DETECT_START(p, id)
#define PACKET_ALERT_FLAG_FRAME
uint32_t non_pf_store_cnt
#define FLOW_SGH_TOSERVER
#define SGH_PROFILING_RECORD(det_ctx, sgh)
void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
Check the threshold of the sigs that match, set actions, break on pass action This function iterate t...
DetectMatchAddressIPv6 * addr_dst_match6
DeStateStoreItem store[DE_STATE_CHUNK_SIZE]
#define IP_GET_IPPROTO(p)
void InspectionBufferClean(DetectEngineThreadCtx *det_ctx)
#define TRACE_SID_TXS(sid, txs,...)
#define FLOW_PKT_ESTABLISHED
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
#define STREAMTCP_FLAG_APP_LAYER_DISABLED
void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineIPOnlyCtx *io_ctx, Packet *p)
Match a packet against the IP Only detection engine contexts.
SignatureNonPrefilterStore * non_pf_syn_store_array
#define PKT_NOPACKET_INSPECTION
#define DE_STATE_FLAG_FULL_INSPECT
#define STREAMTCP_STREAM_FLAG_DISABLE_RAW
AppLayerGetTxIterTuple(* AppLayerGetTxIteratorFunc)(const uint8_t ipproto, const AppProto alproto, void *alstate, uint64_t min_tx_id, uint64_t max_tx_id, AppLayerGetTxIterState *state)
tx iterator prototype
#define DE_STATE_FLAG_FILE_INSPECT
#define FLOW_NOPACKET_INSPECTION
DetectEngineIPOnlyCtx io_ctx
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
DetectMatchAddressIPv4 * addr_dst_match4
uint8_t FlowGetDisruptionFlags(const Flow *f, uint8_t flags)
get 'disruption' flags: GAP/DEPTH/PASS
uint16_t addr_src_match4_cnt
void GenericVarFree(GenericVar *gv)
uint16_t addr_dst_match4_cnt
AppProto alproto
application level protocol
#define SIG_GROUP_HEAD_HAVEFILESHA256
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
#define PACKET_ALERT_FLAG_STATE_MATCH
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
#define DEBUG_VALIDATE_BUG_ON(exp)
const uint64_t detect_flags
@ PKT_DROP_REASON_FLOW_DROP
uint16_t counter_mpm_list
const SigGroupHead * SigMatchSignaturesGetSgh(const DetectEngineCtx *de_ctx, const Packet *p)
Get the SigGroupHead for a packet.
void DetectRunPrefilterTx(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t ipproto, const uint8_t flow_flags, const AppProto alproto, void *alstate, DetectTransaction *tx)
run prefilter engines on a transaction
void RuleMatchCandidateTxArrayInit(DetectEngineThreadCtx *det_ctx, uint32_t size)
DetectPort * DetectPortLookupGroup(DetectPort *dp, uint16_t port)
Function that find the group matching address in a group head.
uint32_t(* TenantGetId)(const void *, const Packet *p)
int DetectRunFrameInspectRule(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, const Frames *frames, const Frame *frame)
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto