{
const PacketAlert *pa0 = a;
const PacketAlert *pa1 = b;
- if (pa1->num == pa0->num) {
- if (pa1->tx_id == PACKET_ALERT_NOTX) {
- return -1;
- } else if (pa0->tx_id == PACKET_ALERT_NOTX) {
- return 1;
+ if (pa0->s->firewall_table == pa1->s->firewall_table) {
+ if (pa1->num == pa0->num) {
+ if (pa1->tx_id == PACKET_ALERT_NOTX) {
+ return -1;
+ } else if (pa0->tx_id == PACKET_ALERT_NOTX) {
+ return 1;
+ }
+ return pa0->tx_id < pa1->tx_id ? 1 : -1;
+ } else {
+ return pa0->num < pa1->num ? -1 : 1;
}
- return pa0->tx_id < pa1->tx_id ? 1 : -1;
}
- return pa0->num > pa1->num ? 1 : -1;
+ return pa0->s->firewall_table < pa1->s->firewall_table ? -1 : 1;
}
/** \internal
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);
exit(EXIT_FAILURE);
}
- de_ctx->flags |= DE_HAS_FIREWALL;
-
if (good_sigs == 0) {
SCLogNotice("fw: No rules loaded from %s.", de_ctx->firewall_rule_file_exclusive);
} else {
return true;
}
+static void DetectFirewallRuleSetTable(Signature *s)
+{
+ enum FirewallTable table;
+ if (s->flags & SIG_FLAG_FIREWALL) {
+ if (s->type == SIG_TYPE_PKT) {
+ table = FIREWALL_TABLE_PACKET_FILTER;
+ } else if (s->type == SIG_TYPE_APP_TX) {
+ table = FIREWALL_TABLE_APP_FILTER;
+ } else {
+ BUG_ON(1);
+ }
+ } else {
+ if (s->type != SIG_TYPE_APP_TX) {
+ table = FIREWALL_TABLE_PACKET_TD;
+ } else {
+ table = FIREWALL_TABLE_APP_TD;
+ }
+ }
+
+ s->firewall_table = (uint8_t)table;
+}
+
/**
* \internal
* \brief validate a just parsed signature for internal inconsistencies
/* check what the type of this sig is */
SignatureSetType(de_ctx, sig);
+ if (de_ctx->flags & DE_HAS_FIREWALL) {
+ DetectFirewallRuleSetTable(sig);
+ }
+
if (sig->type == SIG_TYPE_IPONLY) {
/* For IPOnly */
if (IPOnlySigParseAddress(de_ctx, sig, parser.src, SIG_DIREC_SRC ^ dir) < 0)
SIGNATURE_HOOK_TYPE_APP,
};
+enum FirewallTable {
+ FIREWALL_TABLE_PACKET_FILTER,
+ FIREWALL_TABLE_PACKET_TD,
+ FIREWALL_TABLE_APP_FILTER,
+ FIREWALL_TABLE_APP_TD,
+};
+
// dns:request_complete should add DetectBufferTypeGetByName("dns:request_complete");
// TODO to json
typedef struct SignatureHook_ {
/** classification id **/
uint16_t class_id;
+ /** firewall: pseudo table this rule is part of (enum FirewallTable) */
+ uint8_t firewall_table;
+
/** firewall: progress value for this signature */
uint8_t app_progress_hook;