*/
#include "suricata-common.h"
+#include "suricata.h"
#include "detect.h"
#include "detect-engine-alert.h"
static inline void PacketAlertFinalizeProcessQueue(
const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
{
- const bool have_fw_rules = (de_ctx->flags & DE_HAS_FIREWALL) != 0;
+ const bool have_fw_rules = EngineModeIsFirewall();
if (det_ctx->alert_queue_size > 1) {
/* sort the alert queue before thresholding and appending to Packet */
qsort(det_ctx->alert_queue, det_ctx->alert_queue_size, sizeof(PacketAlert),
- (de_ctx->flags & DE_HAS_FIREWALL) ? AlertQueueSortHelperFirewall
- : AlertQueueSortHelper);
+ have_fw_rules ? AlertQueueSortHelperFirewall : AlertQueueSortHelper);
}
bool dropped = false;
int32_t skipped_sigs = 0;
SCLogNotice("fw: rule file full path \"%s\"", de_ctx->firewall_rule_file_exclusive);
- de_ctx->flags |= DE_HAS_FIREWALL;
int ret = DetectLoadSigFile(de_ctx, de_ctx->firewall_rule_file_exclusive, &good_sigs,
&bad_sigs, &skipped_sigs, true);
de_ctx->sig_stat.good_sigs_total += good_sigs;
}
}
- de_ctx->flags |= DE_HAS_FIREWALL;
-
return 0;
}
{
uint8_t action = 0;
bool fw_verdict = false;
- const bool have_fw_rules = (de_ctx->flags & DE_HAS_FIREWALL) != 0;
+ const bool have_fw_rules = EngineModeIsFirewall();
const Signature *next_s = NULL;
/* inspect the sigs against the packet */
/* firewall: "fail" closed if we don't have an ACCEPT. This can happen
* if there was no rule group. */
// TODO review packet src types here
- if (de_ctx->flags & DE_HAS_FIREWALL && !(p->action & ACTION_ACCEPT) &&
- p->pkt_src == PKT_SRC_WIRE && scratch->default_action == ACTION_DROP) {
+ if (EngineModeIsFirewall() && !(p->action & ACTION_ACCEPT) && p->pkt_src == PKT_SRC_WIRE &&
+ scratch->default_action == ACTION_DROP) {
SCLogDebug("packet %" PRIu64 ": droppit as no ACCEPT set %02x (pkt %s)", p->pcap_cnt,
p->action, PktSrcToString(p->pkt_src));
PacketDrop(p, ACTION_DROP, PKT_DROP_REASON_DEFAULT_PACKET_POLICY);
thread_local Signature default_accept;
static inline void DetectRunAppendDefaultAccept(DetectEngineThreadCtx *det_ctx, Packet *p)
{
- if (det_ctx->de_ctx->flags & DE_HAS_FIREWALL) {
+ if (EngineModeIsFirewall()) {
memset(&default_accept, 0, sizeof(default_accept));
default_accept.action = ACTION_ACCEPT;
default_accept.action_scope = ACTION_SCOPE_PACKET;
uint32_t fw_verdicted = 0;
uint32_t tx_inspected = 0;
- const bool have_fw_rules = (de_ctx->flags & DE_HAS_FIREWALL) != 0;
+ const bool have_fw_rules = EngineModeIsFirewall();
SCLogDebug("packet %" PRIu64, p->pcap_cnt);
/* in firewall mode, we still need to run the fw rulesets even for exception policy pass */
bool skip = false;
- if (de_ctx->flags & DE_HAS_FIREWALL) {
+ if (EngineModeIsFirewall()) {
skip = (f->flags & (FLOW_ACTION_ACCEPT));
} else {
#define FILE_SIG_NEED_SIZE 0x80
/* Detection Engine flags */
-#define DE_QUIET 0x01 /**< DE is quiet (esp for unittests) */
-#define DE_HAS_FIREWALL 0x02 /**< firewall rules loaded, default policies active */
+#define DE_QUIET 0x01 /**< DE is quiet (esp for unittests) */
typedef struct IPOnlyCIDRItem_ {
/* address data for this item */