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) {
43 }
else if (df->dir == DETECT_FLOW_TOBOTH) {
55 SCDetectFlowPktsFree(ptr);
61 DetectFlowPkts *df = SCDetectFlowPktsParseDir(rawstr, DETECT_FLOW_TOSERVER);
68 DetectFlowPktsFree(
de_ctx, df);
78 DetectFlowPkts *df = SCDetectFlowPktsParseDir(rawstr, DETECT_FLOW_TOCLIENT);
84 DetectFlowPktsFree(
de_ctx, df);
94 DetectFlowPkts *df = SCDetectFlowPktsParse(rawstr);
100 DetectFlowPktsFree(
de_ctx, df);
111 const DetectFlowPkts *df = smctx;
112 const DetectUintData_u32 *data = &df->pkt_data;
113 v->
u8[0] = data->mode;
114 v->
u8[1] = (uint8_t)df->dir;
115 v->
u32[1] = data->arg1;
116 v->
u32[2] = data->arg2;
121 const DetectFlowPkts *df = smctx;
122 return v.
u8[0] == df->pkt_data.mode && v.
u8[1] == df->dir && v.
u32[1] == df->pkt_data.arg1 &&
123 v.
u32[2] == df->pkt_data.arg2;
126 static void PrefilterPacketFlowPktsMatch(
130 if (!PrefilterPacketHeaderExtraMatch(
ctx, p))
134 DetectUintData_u32 data = {
135 .mode =
ctx->v1.u8[0], .arg1 =
ctx->v1.u32[1], .arg2 =
ctx->v1.u32[2]
138 df.dir =
ctx->v1.u8[1];
140 if (DetectFlowPktsMatch(det_ctx, p, NULL, (
const SigMatchCtx *)&df)) {
141 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
148 PrefilterPacketFlowPktsSet, PrefilterPacketFlowPktsCompare,
149 PrefilterPacketFlowPktsMatch);
152 static bool PrefilterFlowPktsIsPrefilterable(
const Signature *s)
173 "match number of packets in a flow in to server direction";
187 "match number of packets in a flow in to client direction";
197 static int DetectFlowBytesMatch(
200 if (p->
flow == NULL) {
204 const DetectFlowBytes *df = (
const DetectFlowBytes *)
ctx;
205 if (df->dir == DETECT_FLOW_TOSERVER) {
207 }
else if (df->dir == DETECT_FLOW_TOCLIENT) {
209 }
else if (df->dir == DETECT_FLOW_TOEITHER) {
214 }
else if (df->dir == DETECT_FLOW_TOBOTH) {
226 SCDetectFlowBytesFree(ptr);
232 DetectFlowBytes *df = SCDetectFlowBytesParseDir(rawstr, DETECT_FLOW_TOSERVER);
239 DetectFlowBytesFree(
de_ctx, df);
249 DetectFlowBytes *df = SCDetectFlowBytesParseDir(rawstr, DETECT_FLOW_TOCLIENT);
256 DetectFlowBytesFree(
de_ctx, df);
266 DetectFlowBytes *df = SCDetectFlowBytesParse(rawstr);
272 DetectFlowBytesFree(
de_ctx, df);
294 "match number of bytes in a flow in to server dir";
306 "match number of bytes in a flow in to client dir";