detect: add flag when packet is first with alert

We add a flag to packet to be able to know if this packet was the
first one to get alerts on the flow.
pull/7430/head
Eric Leblond 6 years ago committed by Victor Julien
parent 412ca5d64c
commit 435557ee7f

@ -1220,6 +1220,9 @@ void DecodeUnregisterCounters(void);
* so flag it for not setting stream events */ * so flag it for not setting stream events */
#define PKT_STREAM_NO_EVENTS BIT_U32(28) #define PKT_STREAM_NO_EVENTS BIT_U32(28)
/** We had no alert on flow before this packet */
#define PKT_FIRST_ALERTS BIT_U32(29)
/** \brief return 1 if the packet is a pseudo packet */ /** \brief return 1 if the packet is a pseudo packet */
#define PKT_IS_PSEUDOPKT(p) \ #define PKT_IS_PSEUDOPKT(p) \
((p)->flags & (PKT_PSEUDO_STREAM_END|PKT_PSEUDO_DETECTLOG_FLUSH)) ((p)->flags & (PKT_PSEUDO_STREAM_END|PKT_PSEUDO_DETECTLOG_FLUSH))

@ -394,7 +394,10 @@ void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx
/* Set flag on flow to indicate that it has alerts */ /* Set flag on flow to indicate that it has alerts */
if (p->flow != NULL && p->alerts.cnt > 0) { if (p->flow != NULL && p->alerts.cnt > 0) {
FlowSetHasAlertsFlag(p->flow); if (!FlowHasAlerts(p->flow)) {
FlowSetHasAlertsFlag(p->flow);
p->flags |= PKT_FIRST_ALERTS;
}
} }
} }

Loading…
Cancel
Save