Go to the documentation of this file.
87 static inline void DetectRulePacketRules(
ThreadVars *
const tv,
126 DetectRunInspectIPOnly(th_v,
de_ctx, det_ctx, pflow, p);
129 DetectRunGetRuleGroup(
de_ctx, p, pflow, &scratch);
132 if (scratch.
sgh == NULL) {
133 SCLogDebug(
"no sgh for this packet, nothing to match against");
138 DetectRunPrefilterPkt(th_v,
de_ctx, det_ctx, p, &scratch);
142 DetectRulePacketRules(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
147 if (p->
proto == IPPROTO_TCP) {
160 DetectRunFrames(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
169 }
else if (p->
proto == IPPROTO_UDP) {
170 DetectRunFrames(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
174 DetectRunTx(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
184 DetectRunPostRules(th_v,
de_ctx, det_ctx, p, pflow, &scratch);
186 DetectRunCleanup(det_ctx, p, pflow);
199 SCLogDebug(
"running match functions, sm %p", smd);
230 }
else if (p->
proto == 0) {
231 if (!(PacketIsIPv4(p) || PacketIsIPv6(p))) {
240 int proto = PacketGetIPProto(p);
241 if (
proto == IPPROTO_TCP) {
245 const uint16_t port = dir ? p->
dp : p->
sp;
250 SCLogDebug(
"TCP list %p, port %u, direction %s, sghport %p, sgh %p", list, port,
251 dir ?
"toserver" :
"toclient", sghport, sgh);
252 }
else if (
proto == IPPROTO_UDP) {
254 uint16_t port = dir ? p->
dp : p->
sp;
258 SCLogDebug(
"UDP list %p, port %u, direction %s, sghport %p, sgh %p", list, port,
259 dir ?
"toserver" :
"toclient", sghport, sgh);
290 final_ptr = nonmpm_ptr;
295 nonmpm = *nonmpm_ptr;
309 if (
likely(
id != previous_id)) {
315 final_ptr = nonmpm_ptr;
321 }
else if (mpm > nonmpm) {
326 if (
likely(
id != previous_id)) {
336 nonmpm = *nonmpm_ptr;
342 while (--m_cnt != 0) {
353 final_ptr = ++nonmpm_ptr;
368 nonmpm = *nonmpm_ptr;
374 while (final_cnt-- > 0) {
379 if (
likely(
id != previous_id)) {
393 static inline void DetectPrefilterBuildNonPrefilterList(
401 if ((rule_mask & mask) == rule_mask &&
402 (rule_alproto == 0 || AppProtoEquals(rule_alproto, alproto))) {
415 if ((p->
proto == IPPROTO_TCP) && PacketIsTCP(p) && (PacketGetTCP(p)->th_flags &
TH_SYN)) {
422 SCLogDebug(
"sgh non_pf ptr %p cnt %u (syn %p/%u, other %p/%u)",
434 DetectPostInspectFileFlagsUpdate(
Flow *f,
const SigGroupHead *sgh, uint8_t direction)
439 SCLogDebug(
"requesting disabling all file features for flow");
443 SCLogDebug(
"requesting disabling filestore for flow");
447 if (!(sgh->
flags & SIG_GROUP_HEAD_HAVEFILEMAGIC)) {
448 SCLogDebug(
"requesting disabling magic for flow");
453 SCLogDebug(
"requesting disabling md5 for flow");
457 SCLogDebug(
"requesting disabling sha1 for flow");
461 SCLogDebug(
"requesting disabling sha256 for flow");
465 SCLogDebug(
"requesting disabling filesize for flow");
469 if (flow_file_flags != 0) {
485 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.client");
490 DetectPostInspectFileFlagsUpdate(pflow,
500 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.server");
505 DetectPostInspectFileFlagsUpdate(pflow,
510 static inline void DetectRunGetRuleGroup(
518 bool use_flow_sgh =
false;
521 if (PacketGetIPProto(p) == pflow->
proto) {
525 SCLogDebug(
"sgh = pflow->sgh_toserver; => %p", sgh);
529 SCLogDebug(
"sgh = pflow->sgh_toclient; => %p", sgh);
535 if (!(use_flow_sgh)) {
548 DetectRunPostGetFirstRuleGroup(p, pflow, sgh);
576 SCLogDebug(
"testing against \"ip-only\" signatures");
598 static inline bool DetectRunInspectRuleHeader(
const Packet *p,
const Flow *f,
const Signature *s,
599 const uint32_t sflags,
const uint8_t s_proto_flags)
608 const bool fv = f->
flowvar != NULL;
610 SCLogDebug(
"skipping sig as the flow has no flowvars and sig "
611 "has SIG_FLAG_REQUIRE_FLOWVAR flag set.");
651 SCLogDebug(
"port-less protocol and sig needs ports");
657 if (PacketIsIPv4(p)) {
660 }
else if (PacketIsIPv6(p)) {
667 if (PacketIsIPv4(p)) {
670 }
else if (PacketIsIPv6(p)) {
682 static inline void DetectRunPrefilterPkt(
690 DetectPrefilterSetNonPrefilterList(p, det_ctx, scratch);
699 DetectPrefilterBuildNonPrefilterList(det_ctx, scratch->
pkt_mask, scratch->
alproto);
713 DetectPrefilterMergeSort(
de_ctx, det_ctx);
728 static inline void DetectRulePacketRules(
745 (uint64_t)match_cnt);
756 uint32_t sflags, next_sflags = 0;
758 next_s = *match_array++;
759 next_sflags = next_s->
flags;
761 while (match_cnt--) {
763 uint8_t alert_flags = 0;
768 sflags = next_sflags;
770 next_s = *match_array++;
771 next_sflags = next_s->
flags;
791 if (SigDsizePrefilter(p, s, sflags))
802 if (DetectRunInspectRuleHeader(p, pflow, s, sflags, s_proto_flags) ==
false) {
813 DetectRunPostMatch(
tv, det_ctx, p, s);
832 txd->stream_logged++;
838 DetectVarProcessList(det_ctx, pflow, p);
839 DetectReplaceFree(det_ctx);
851 uint8_t flow_flags = 0;
852 bool app_decoder_events =
false;
871 det_ctx->pkt_stream_add_cnt++;
880 flow_flags = STREAM_TOSERVER;
883 flow_flags = STREAM_TOCLIENT;
889 flow_flags |= STREAM_EOF;
920 (p->
proto == IPPROTO_UDP) ||
925 alproto = FlowGetAppProtocol(pflow);
932 SCLogDebug(
"packet doesn't have established flag set (proto %d)", p->
proto);
943 static inline void DetectRunPostRules(
992 FatalError(
"failed to allocate %" PRIu64
" bytes",
996 SCLogDebug(
"array initialized to %u elements (%"PRIu64
" bytes)",
1008 const uint32_t need)
1019 uint32_t new_size = needed;
1022 FatalError(
"failed to expand to %" PRIu64
" bytes",
1028 SCLogDebug(
"array expanded from %u to %u elements (%"PRIu64
" bytes -> %"PRIu64
" bytes)",
1041 DetectRunTxSortHelper(
const void *a,
const void *b)
1045 if (s1->
id == s0->
id) {
1052 return s0->
id > s1->
id ? 1 : -1;
1056 #define TRACE_SID_TXS(sid,txs,...) \
1058 char _trace_buf[2048]; \
1059 snprintf(_trace_buf, sizeof(_trace_buf), __VA_ARGS__); \
1060 SCLogNotice("%p/%"PRIu64"/%u: %s", txs->tx_ptr, txs->tx_id, sid, _trace_buf); \
1063 #define TRACE_SID_TXS(sid,txs,...)
1072 tx_ptr = SCDoH2GetDnsTx(tx_ptr, flow_flags);
1077 }
else if (engine_alproto != alproto) {
1101 const uint8_t in_flow_flags,
1105 uint32_t *stored_flags,
1109 const uint8_t flow_flags = in_flow_flags;
1110 const int direction = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1111 uint32_t inspect_flags = stored_flags ? *stored_flags : 0;
1112 int total_matches = 0;
1113 uint16_t file_no_match = 0;
1114 bool retval =
false;
1115 bool mpm_before_progress =
false;
1116 bool mpm_in_progress =
false;
1118 TRACE_SID_TXS(s->
id, tx,
"starting %s", direction ?
"toclient" :
"toserver");
1121 if (
likely(stored_flags == NULL)) {
1123 if (DetectRunInspectRuleHeader(p, f, s, s->
flags, s->
proto.
flags) ==
false) {
1140 TRACE_SID_TXS(s->
id, tx,
"engine %p inspect_flags %x", engine, inspect_flags);
1141 if (!(inspect_flags &
BIT_U32(engine->
id)) &&
1142 direction == engine->
dir)
1145 if (tx_ptr == NULL) {
1149 engine = engine->
next;
1159 SCLogDebug(
"tx progress %d < engine progress %d",
1166 "engine->mpm: t->tx_progress %u > engine->progress %u, so set "
1167 "mpm_before_progress",
1169 mpm_before_progress =
true;
1172 "engine->mpm: t->tx_progress %u == engine->progress %u, so set "
1175 mpm_in_progress =
true;
1183 TRACE_SID_TXS(s->
id, tx,
"stream skipped, stored result %d used instead", match);
1188 de_ctx, det_ctx, engine, s, f, flow_flags, alstate, tx_ptr, tx->
tx_id);
1193 TRACE_SID_TXS(s->
id, tx,
"stream ran, store result %d for next tx (if any)", match);
1198 engine = engine->
next;
1205 engine = engine->
next;
1217 if (engine->
mpm && mpm_before_progress) {
1223 engine = engine->
next;
1224 }
while (engine != NULL);
1225 TRACE_SID_TXS(s->
id, tx,
"inspect_flags %x, total_matches %u, engine %p",
1226 inspect_flags, total_matches, engine);
1228 if (engine == NULL && total_matches) {
1235 *stored_flags = inspect_flags;
1236 TRACE_SID_TXS(s->
id, tx,
"continue inspect flags %08x", inspect_flags);
1243 if (file_no_match) {
1254 inspect_flags, flow_flags, file_no_match);
1258 "mpm won't trigger for it anymore");
1262 "we may have to revisit anyway");
1264 inspect_flags, flow_flags, file_no_match);
1268 "mpm will revisit it");
1269 }
else if (inspect_flags != 0 || file_no_match != 0) {
1272 inspect_flags, flow_flags, file_no_match);
1281 NULL, 0, NULL, NULL, 0, 0, 0, 0, 0, \
1289 void *alstate,
const uint64_t tx_id,
void *tx_ptr,
const int tx_end_state,
1290 const uint8_t flow_flags)
1297 uint64_t detect_flags =
1298 (flow_flags & STREAM_TOSERVER) ? txd->detect_flags_ts : txd->detect_flags_tc;
1300 SCLogDebug(
"%"PRIu64
" tx already fully inspected for %s. Flags %016"PRIx64,
1301 tx_id, flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1307 SCLogDebug(
"%" PRIu64
" tx should not be inspected in direction %s. Flags %016" PRIx64,
1308 tx_id, flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", detect_flags);
1314 const int dir_int = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1324 .de_state = tx_dir_state,
1325 .detect_flags = detect_flags,
1326 .prefilter_flags = prefilter_flags,
1327 .prefilter_flags_orig = prefilter_flags,
1328 .tx_progress = tx_progress,
1329 .tx_end_state = tx_end_state,
1334 static inline void StoreDetectFlags(
DetectTransaction *tx,
const uint8_t flow_flags,
1335 const uint8_t ipproto,
const AppProto alproto,
const uint64_t detect_flags)
1338 if (
likely(txd != NULL)) {
1339 if (flow_flags & STREAM_TOSERVER) {
1340 txd->detect_flags_ts = detect_flags;
1342 txd->detect_flags_tc = detect_flags;
1349 static inline void RuleMatchCandidateMergeStateRules(
1367 uint32_t j = *array_idx;
1376 uint32_t k = *array_idx;
1398 if (s->
num <= s0->
id) {
1429 const uint8_t flow_flags = scratch->
flow_flags;
1431 void *
const alstate = f->
alstate;
1432 const uint8_t ipproto = f->
proto;
1443 AppLayerGetTxIterTuple ires = IterFunc(ipproto, alproto, alstate, tx_id_min, total_txs, &state);
1444 if (ires.tx_ptr == NULL)
1448 alstate, ires.tx_id, ires.tx_ptr, tx_end_state, flow_flags);
1450 SCLogDebug(
"%p/%"PRIu64
" no transaction to inspect",
1456 tx_id_min = tx.
tx_id + 1;
1458 bool do_sort =
false;
1459 uint32_t array_idx = 0;
1469 SCLogDebug(
"%p/%"PRIu64
" rules added from prefilter: %u candidates",
1473 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
1474 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1488 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
1489 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1495 uint32_t x = array_idx;
1497 RuleMatchCandidateMergeStateRules(det_ctx, &array_idx);
1501 const uint32_t old = array_idx;
1506 if (have_new_file) {
1507 SCLogDebug(
"%p/%"PRIu64
" destate: need to consider new file",
1514 for (; tx_store != NULL; tx_store = tx_store->
next) {
1520 store_cnt++, state_cnt++)
1537 do_sort |= (old && old != array_idx);
1543 DetectRunTxSortHelper);
1555 for (uint32_t i = 0; i < array_idx; i++) {
1562 for (uint32_t i = 0; i < array_idx; i++) {
1572 while ((i + 1) < array_idx &&
1574 SCLogDebug(
"%p/%" PRIu64
" inspecting SKIP NEXT: sid %u (%u), flags %08x",
1579 SCLogDebug(
"%p/%"PRIu64
" inspecting: sid %u (%u), flags %08x",
1582 if (inspect_flags) {
1584 SCLogDebug(
"%p/%"PRIu64
" inspecting: sid %u (%u), flags %08x ALREADY COMPLETE",
1590 if (inspect_flags) {
1600 const int r = DetectRunTxInspectRule(
tv,
de_ctx, det_ctx, p, f, flow_flags,
1601 alstate, &tx, s, inspect_flags, can, scratch);
1604 DetectRunPostMatch(
tv, det_ctx, p, s);
1610 DetectVarProcessList(det_ctx, p->
flow, p);
1620 uint64_t new_detect_flags = 0;
1624 SCLogDebug(
"%p/%"PRIu64
" tx is done for direction %s. Flag %016"PRIx64,
1626 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1632 SCLogDebug(
"%p/%"PRIu64
" updated prefilter flags %016"PRIx64
" "
1633 "(was: %016"PRIx64
") for direction %s. Flag %016"PRIx64,
1635 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
1638 if (new_detect_flags != 0 &&
1643 SCLogDebug(
"%p/%"PRIu64
" Storing new flags %016"PRIx64
" (was %016"PRIx64
")",
1646 StoreDetectFlags(&tx, flow_flags, ipproto, alproto, new_detect_flags);
1667 SCLogDebug(
"pcap_cnt %" PRIu64
": %s: skip frame inspection for TCP w/o APP UPDATE",
1672 if (frames_container == NULL) {
1677 frames = &frames_container->
toserver;
1679 frames = &frames_container->
toclient;
1682 for (uint32_t idx = 0; idx < frames->
cnt; idx++) {
1685 if (frame == NULL) {
1690 uint32_t array_idx = 0;
1698 SCLogDebug(
"%p/%" PRIi64
" rules added from prefilter: %u candidates", frame, frame->
id,
1703 if (!(RuleMatchCandidateTxArrayHasSpace(
1704 det_ctx, total_rules))) {
1705 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
1720 uint32_t x = array_idx;
1731 SCLogDebug(
"%p/%" PRIi64
" rule %u (%u) added from 'match' list", frame, frame->
id,
1735 SCLogDebug(
"%p/%" PRIi64
" rules added from 'match' list: %u", frame, frame->
id,
1740 for (uint32_t i = 0; i < array_idx; i++) {
1747 while ((i + 1) < array_idx &&
1751 SCLogDebug(
"%p/%" PRIi64
" inspecting: sid %u (%u)", frame, frame->
id, s->
id, s->
num);
1754 SCLogDebug(
"%p/%" PRIi64
" Start sid %u", frame, frame->
id, s->
id);
1758 bool r = DetectRunInspectRuleHeader(p, f, s, s->
flags, s->
proto.
flags);
1763 DetectRunPostMatch(
tv, det_ctx, p, s);
1768 "%p/%" PRIi64
" sig %u (%u) matched", frame, frame->
id, s->
id, s->
num);
1775 DetectVarProcessList(det_ctx, p->
flow, p);
1786 "frame->inspect_progress: %" PRIu64
" -> not updated", frame->
inspect_progress);
1789 SCLogDebug(
"%p/%" PRIi64
" rules inspected, running cleanup", frame, frame->
id);
1820 SCLogDebug(
"p->pcap %"PRIu64
": no detection on packet, "
1821 "PKT_NOPACKET_INSPECTION is set", p->
pcap_cnt);
1834 (void)DetectRun(
tv,
de_ctx, det_ctx, p);
1865 if (det_ctx == NULL) {
1866 printf(
"ERROR: Detect has no thread ctx\n");
1872 SCLogDebug(
"Detect Engine using new det_ctx - %p",
1883 if (tenant_id > 0 && tenant_id < det_ctx->mt_det_ctxs_cnt) {
1886 if (det_ctx == NULL)
1894 SCLogDebug(
"MT de_ctx %p det_ctx %p (tenant %u)",
de_ctx, det_ctx, tenant_id);
1905 DetectFlow(
tv,
de_ctx, det_ctx, p);
1907 DetectNoFlow(
tv,
de_ctx, det_ctx, p);
1910 #ifdef PROFILE_RULES
1913 gettimeofday(&
ts, NULL);
1914 if (
ts.tv_sec != det_ctx->rule_perf_last_sync) {
1915 SCProfilingRuleThreatAggregate(det_ctx);
1916 det_ctx->rule_perf_last_sync =
ts.tv_sec;
1930 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOSERVER);
1931 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOCLIENT);
1942 DetectFlow(
tv,
de_ctx, det_ctx, p);
1944 DetectNoFlow(
tv,
de_ctx, det_ctx, p);
#define PKT_IS_TOCLIENT(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
#define PACKET_ALERT_FLAG_STREAM_MATCH
DetectMatchAddressIPv6 * addr_src_match6
SigTableElmt * sigmatch_table
#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
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
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.
InspectEngineFuncPtr Callback
#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
uint8_t stream_tx_log_limit
#define FLOWFILE_NO_MAGIC_TS
#define ICMPV4_DEST_UNREACH_IS_VALID(p)
#define SIG_GROUP_HEAD_HAVEFILESHA1
#define FLOW_TC_APP_UPDATED
main detection engine ctx
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
struct DetectRunScratchpad DetectRunScratchpad
#define APP_LAYER_TX_SKIP_INSPECT_FLAG
struct DetectEngineAppInspectionEngine_::@79 v2
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 PKT_NOPAYLOAD_INSPECTION
#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
bool DetectRunFrameInspectRule(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, const Frames *frames, const Frame *frame)
#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 PKT_IS_TOSERVER(p)
void Prefilter(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t flags, const SignatureMask mask)
#define DEBUG_VALIDATE_PACKET(p)
#define FLOWFILE_NO_STORE_TS
uint32_t tx_candidates_size
#define FLOW_PKT_TOSERVER_IPONLY_SET
#define FRAME_FLAG_TX_ID_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)
#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 PACKET_ALERT_NOTX
#define APP_LAYER_PARSER_NO_INSPECTION
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
#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
uint8_t app_update_direction
uint64_t frame_inspect_progress
uint32_t profile_match_logging_threshold
#define FLOW_TS_APP_UPDATED
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.
#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]
void InspectionBufferClean(DetectEngineThreadCtx *det_ctx)
#define TRACE_SID_TXS(sid, txs,...)
#define FLOW_PKT_ESTABLISHED
#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
void * DetectGetInnerTx(void *tx_ptr, AppProto alproto, AppProto engine_alproto, uint8_t flow_flags)
#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
uint16_t AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
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
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 port in a group head.
uint32_t(* TenantGetId)(const void *, const Packet *p)
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto