26 static 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) {
124 static 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);
150 static 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";
193 static 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";