Active_SetEnabled(1);
}
-void RejectAction::exec(Packet*)
+void RejectAction::exec(Packet* p)
{
- printf("ACT Now!");
+ if ( PacketIsRebuilt(p) )
+ return;
+
Active_QueueReject();
}
// FIXIT some or all of these can be migrated to user defined actions
otn_trigger_actions(otn, p);
- if ( !EventTrace_IsEnabled() )
- return;
-
- EventTrace_Log(p, otn, action);
+ if ( EventTrace_IsEnabled() )
+ EventTrace_Log(p, otn, action);
// user defined actions are done here
if ( rtn->listhead->action )
struct RuleListNode
{
- ListHead *RuleList; /* The rule list associated with this node */
- RuleType mode; /* the rule mode */
- int rval; /* 0 == no detection, 1 == detection event */
- int evalIndex; /* eval index for this rule set */
- char *name; /* name of this rule list (for debugging) */
- RuleListNode *next; /* the next RuleListNode */
+ ListHead *RuleList; /* The rule list associated with this node */
+ RuleType mode; /* the rule mode */
+ int rval; /* 0 == no detection, 1 == detection event */
+ int evalIndex; /* eval index for this rule set */
+ char* name; /* name of this rule list */
+ RuleListNode* next; /* the next RuleListNode */
};
struct RuleState
}
void ActionManager::instantiate(
- const ActionApi* api, Module*, SnortConfig* sc)
+ const ActionApi* api, Module* m, SnortConfig* sc)
{
- CreateRuleType(sc, api->base.name, api->type, 0, nullptr);
+ IpsAction* act = api->ctor(m);
+
+ if ( act )
+ {
+ ListHead* lh = CreateRuleType(sc, api->base.name, api->type, 0, nullptr);
+ assert(lh);
+ lh->action = act;
+ }
}
#if 0
static void config_inline(SnortConfig* sc, const char*)
{
- LogMessage("Enabling inline operation\n");
sc->run_flags |= RUN_FLAG__INLINE;
}
static void config_inline_test(SnortConfig* sc, const char*)
{
- LogMessage("Enable Inline Test Mode\n");
sc->run_flags |= RUN_FLAG__INLINE_TEST;
}
return rt;
}
-ListHead* get_rule_list(SnortConfig* sc, RuleType type)
+ListHead* get_rule_list(SnortConfig* sc, const char* s)
{
- switch ( type )
- {
- case RULE_TYPE__ALERT:
- return &sc->Alert;
-
- case RULE_TYPE__LOG:
- return &sc->Log;
-
- case RULE_TYPE__PASS:
- return &sc->Pass;
+ const RuleListNode* p = sc->rule_lists;
- case RULE_TYPE__DROP:
- return &sc->Drop;
-
- case RULE_TYPE__SDROP:
- return &sc->SDrop;
-
- default:
- break;
- }
- return nullptr;
+ while ( p && strcmp(p->name, s) )
+ p = p->next;
+
+ return p ? p->RuleList : nullptr;
}
// FIXIT find this a better home
void add_service_to_otn(SnortConfig*, OptTreeNode*, const char*);
RuleType get_rule_type(const char*);
-ListHead* get_rule_list(SnortConfig*, RuleType);
+ListHead* get_rule_list(SnortConfig*, const char*);
#define ERR_PAIR_COUNT \
"%s has incorrect argument count; should be %d pairs.", ERR_KEY
s_ignore = true;
else
- rtn.listhead = get_rule_list(sc, (RuleType)rtn.type);
+ rtn.listhead = get_rule_list(sc, s);
}
void parse_rule_proto(SnortConfig* sc, const char* s, RuleTreeNode& rtn)