Go to the documentation of this file.
47 memset(&g_tag_signature, 0x00,
sizeof(g_tag_signature));
52 g_tag_signature.
rev = 1;
53 g_tag_signature.
prio = 2;
55 memset(&g_tag_pa, 0x00,
sizeof(g_tag_pa));
58 g_tag_pa.
s = &g_tag_signature;
80 if (!(PacketIsIPv4(p) || PacketIsIPv6(p))) {
97 if (ret == 0 || ret == 2) {
104 }
while (smd != NULL);
120 if (ret == 0 || ret == 2) {
127 }
while (smd != NULL);
145 for (uint16_t i = 0; i < p->
alerts.
cnt; i++) {
155 static inline void RuleActionToFlow(
const uint8_t action,
Flow *f)
160 SCLogDebug(
"not setting %s flow already set to %s",
171 FlowSetNoPacketInspectionFlag(f);
211 }
else if (pa->
action != 0) {
227 FatalError(
"failed to allocate %" PRIu64
" bytes for the alert queue",
247 if (
unlikely(g_eps_is_alert_queue_fail_mode))
258 SCLogDebug(
"Alert queue size doubled: %u elements, bytes: %" PRIuMAX
"",
273 pa.
flags = alert_flags;
289 p->
alerts.
drop = PacketAlertSet(det_ctx, s, tx_id, alert_flags);
290 SCLogDebug(
"Set PacketAlert drop action. s->num %" PRIu32
"", s->
num);
296 if (pos == AlertQueueExpand(det_ctx)) {
302 det_ctx->
alert_queue[pos] = PacketAlertSet(det_ctx, s, tx_id, alert_flags);
304 SCLogDebug(
"Appending sid %" PRIu32
", s->num %" PRIu32
" to alert queue", s->
id, s->
num);
315 static int AlertQueueSortHelper(
const void *a,
const void *b)
319 if (pa1->
num == pa0->
num) {
327 return pa0->
num > pa1->
num ? 1 : -1;
334 static inline void FlowApplySignatureActions(
355 SCLogDebug(
"packet %" PRIu64
" sid %u action %02x alert_flags %02x (set "
356 "PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW)",
377 AlertQueueSortHelper);
382 int res = PacketAlertHandle(
de_ctx, det_ctx, s, p, pa);
401 FlowApplySignatureActions(p, pa, s, pa->
flags);
403 SCLogDebug(
"det_ctx->alert_queue[i].action %02x (DROP %s, PASS %s)", pa->
action,
407 PacketApplySignatureActions(p, s, pa);
412 SCLogDebug(
"sid:%u: skipping alert because of thresholding (res=%d) or NOALERT (%02x)",
418 SCLogDebug(
"Appending sid %" PRIu32
" alert to Packet::alerts at pos %u", s->
id, i);
422 SCLogDebug(
"sid:%u: is a pass rule, so break out of loop", s->
id);
429 SCLogDebug(
"sid:%u: is a pass rule, so break out of loop", s->
id);
bool PacketCheckAction(const Packet *p, const uint8_t a)
@ PKT_DROP_REASON_RULES_THRESHOLD
uint16_t alert_queue_size
void FlowSetHasAlertsFlag(Flow *f)
Set flag to indicate that flow has alerts.
#define PACKET_ALERT_FLAG_STREAM_MATCH
const struct Signature_ * s
void AlertQueueFree(DetectEngineThreadCtx *det_ctx)
SigTableElmt * sigmatch_table
#define KEYWORD_PROFILING_SET_LIST(ctx, list)
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
@ DETECT_SM_LIST_THRESHOLD
main detection engine ctx
#define ACTION_REJECT_ANY
#define ACTION_DROP_REJECT
SigMatchData * sm_arrays[DETECT_SM_LIST_MAX]
#define KEYWORD_PROFILING_START
#define KEYWORD_PROFILING_END(ctx, type, m)
void AlertQueueInit(DetectEngineThreadCtx *det_ctx)
SignaturePropertyFlowAction
#define PKT_PSEUDO_STREAM_END
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.
uint16_t alert_queue_capacity
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
const struct SignatureProperties signature_properties[SIG_TYPE_MAX]
#define PACKET_ALERT_NOTX
int PacketAlertThreshold(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectThresholdData *td, Packet *p, const Signature *s, PacketAlert *pa)
Make the threshold logic for signatures.
#define SCRealloc(ptr, sz)
#define PACKET_ALERT_RATE_FILTER_MODIFIED
@ SIG_PROP_FLOW_ACTION_FLOW_IF_STATEFUL
#define PACKET_ALERT_FLAG_APPLY_ACTION_TO_FLOW
const DetectThresholdData * SigGetThresholdTypeIter(const Signature *sig, const SigMatchData **psm, int list)
Return next DetectThresholdData for signature.
void TagHandlePacket(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
Search tags for src and dst. Update entries of the tag, remove if necessary.
PacketAlert * alert_queue
#define PACKET_ALERT_FLAG_FRAME
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...
void PacketAlertTagInit(void)
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
int FlowHasAlerts(const Flow *f)
Check if flow has alerts.
uint16_t packet_alert_max
@ SIG_PROP_FLOW_ACTION_FLOW
#define PACKET_ALERT_FLAG_STATE_MATCH
@ DETECT_SM_LIST_SUPPRESS
#define DEBUG_VALIDATE_BUG_ON(exp)
enum SignaturePropertyFlowAction flow_action