26static int DetectFlowPktsMatch(
29 if (p->
flow == NULL) {
33 const DetectFlowPkts *df = (
const DetectFlowPkts *)
ctx;
34 if (df->dir == DETECT_FLOW_TOSERVER) {
36 }
else if (df->dir == DETECT_FLOW_TOCLIENT) {
38 }
else if (df->dir == DETECT_FLOW_TOEITHER) {
50 SCDetectFlowPktsFree(ptr);
56 DetectFlowPkts *df = SCDetectFlowPktsParseDir(rawstr, DETECT_FLOW_TOSERVER);
63 DetectFlowPktsFree(
de_ctx, df);
73 DetectFlowPkts *df = SCDetectFlowPktsParseDir(rawstr, DETECT_FLOW_TOCLIENT);
79 DetectFlowPktsFree(
de_ctx, df);
89 DetectFlowPkts *df = SCDetectFlowPktsParse(rawstr);
95 DetectFlowPktsFree(
de_ctx, df);
106 const DetectFlowPkts *df = smctx;
107 const DetectUintData_u32 *data = &df->pkt_data;
108 v->
u8[0] = data->mode;
109 v->
u8[1] = (uint8_t)df->dir;
110 v->u32[1] = data->arg1;
111 v->u32[2] = data->arg2;
116 const DetectFlowPkts *df = smctx;
117 if (v.
u8[0] == df->pkt_data.mode && v.
u8[1] == df->dir && v.
u32[1] == df->pkt_data.arg1 &&
118 v.
u32[2] == df->pkt_data.arg2) {
124static void PrefilterPacketFlowPktsMatch(
128 if (!PrefilterPacketHeaderExtraMatch(
ctx, p))
132 DetectUintData_u32 data = {
133 .mode =
ctx->v1.u8[0], .arg1 =
ctx->v1.u32[1], .arg2 =
ctx->v1.u32[2]
136 df.dir =
ctx->v1.u8[1];
138 if (DetectFlowPktsMatch(det_ctx, p, NULL, (
const SigMatchCtx *)&df)) {
139 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
146 PrefilterPacketFlowPktsSet, PrefilterPacketFlowPktsCompare,
147 PrefilterPacketFlowPktsMatch);
150static bool PrefilterFlowPktsIsPrefilterable(
const Signature *s)
171 "match number of packets in a flow in to server direction";
184 "match number of packets in a flow in to client direction";
193static int DetectFlowBytesMatch(
196 if (p->
flow == NULL) {
200 const DetectFlowBytes *df = (
const DetectFlowBytes *)
ctx;
201 if (df->dir == DETECT_FLOW_TOSERVER) {
203 }
else if (df->dir == DETECT_FLOW_TOCLIENT) {
205 }
else if (df->dir == DETECT_FLOW_TOEITHER) {
217 SCDetectFlowBytesFree(ptr);
223 DetectFlowBytes *df = SCDetectFlowBytesParseDir(rawstr, DETECT_FLOW_TOSERVER);
230 DetectFlowBytesFree(
de_ctx, df);
240 DetectFlowBytes *df = SCDetectFlowBytesParseDir(rawstr, DETECT_FLOW_TOCLIENT);
247 DetectFlowBytesFree(
de_ctx, df);
257 DetectFlowBytes *df = SCDetectFlowBytesParse(rawstr);
263 DetectFlowBytesFree(
de_ctx, df);
285 "match number of bytes in a flow in to server dir";
296 "match number of bytes in a flow in to client dir";
int PrefilterSetupPacketHeader(DetectEngineCtx *de_ctx, SigGroupHead *sgh, int sm_type, SignatureMask mask, void(*Set)(PrefilterPacketHeaderValue *v, void *), bool(*Compare)(PrefilterPacketHeaderValue v, void *), void(*Match)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx))
@ DETECT_FLOW_PKTS_TO_SERVER
@ DETECT_FLOW_BYTES_TO_CLIENT
@ DETECT_FLOW_BYTES_TO_SERVER
@ DETECT_FLOW_PKTS_TO_CLIENT
int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)
void DetectFlowBytesToServerRegister(void)
void DetectFlowPktsRegister(void)
void DetectFlowBytesRegister(void)
void DetectFlowBytesToClientRegister(void)
void DetectFlowPktsToClientRegister(void)
void DetectFlowPktsToServerRegister(void)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
SigTableElmt * sigmatch_table
#define SIG_MASK_REQUIRE_FLOW
#define SIG_FLAG_REQUIRE_PACKET
main detection engine ctx
Container for matching data for a signature group.
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
void(* Free)(DetectEngineCtx *, void *)
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
bool(* SupportsPrefilter)(const Signature *s)