From: Joel Cornett Date: Thu, 27 Aug 2015 20:06:04 +0000 (-0400) Subject: added const qualifiers to OptTreeNode structs in fp_detect X-Git-Tag: 3.0.0-233~850^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4a4d989ffd90ca5b78b55e9bc8c2c5b779b87ec;p=thirdparty%2Fsnort3.git added const qualifiers to OptTreeNode structs in fp_detect --- diff --git a/src/actions/actions.cc b/src/actions/actions.cc index d656eeab9..db99ab080 100644 --- a/src/actions/actions.cc +++ b/src/actions/actions.cc @@ -101,7 +101,8 @@ RuleType get_action_type(const char* s) return RULE_TYPE__NONE; } -void action_execute(RuleType action, Packet* p, OptTreeNode* otn, uint16_t event_id) +void action_execute(RuleType action, Packet* p, const OptTreeNode* otn, + uint16_t event_id) { switch (action) { diff --git a/src/actions/actions.h b/src/actions/actions.h index 189ed61b8..11e686e44 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -50,7 +50,9 @@ enum RuleType const char* get_action_string(RuleType); RuleType get_action_type(const char*); -void action_execute(RuleType, struct Packet*, struct OptTreeNode*, uint16_t event_id); +void action_execute(RuleType, struct Packet*, const struct OptTreeNode*, + uint16_t event_id); + void action_apply(RuleType, struct Packet*); static inline bool pass_action(RuleType a) diff --git a/src/detection/detection_util.cc b/src/detection/detection_util.cc index d49fcc8ea..99da64f51 100644 --- a/src/detection/detection_util.cc +++ b/src/detection/detection_util.cc @@ -84,7 +84,7 @@ static void LogBuffer(const char* s, const uint8_t* p, unsigned n) } } -void EventTrace_Log(const Packet* p, OptTreeNode* otn, int action) +void EventTrace_Log(const Packet* p, const OptTreeNode* otn, int action) { const char* acts = get_action_string((RuleType)action); diff --git a/src/detection/detection_util.h b/src/detection/detection_util.h index 0eb700f93..33a028135 100644 --- a/src/detection/detection_util.h +++ b/src/detection/detection_util.h @@ -95,7 +95,7 @@ static inline void set_file_data(uint8_t* p, unsigned n) void EventTrace_Init(void); void EventTrace_Term(void); -void EventTrace_Log(const Packet*, OptTreeNode*, int action); +void EventTrace_Log(const Packet*, const OptTreeNode*, int action); static inline int EventTrace_IsEnabled(void) { diff --git a/src/detection/fp_detect.cc b/src/detection/fp_detect.cc index d098a9c31..69217e7f4 100644 --- a/src/detection/fp_detect.cc +++ b/src/detection/fp_detect.cc @@ -57,8 +57,8 @@ #include "framework/inspector.h" #include "framework/ips_action.h" #include "framework/mpse.h" -#include "perf_monitor/perf.h" -#include "perf_monitor/perf_event.h" +#include "network_inspectors/perf_monitor/perf.h" +#include "network_inspectors/perf_monitor/perf_event.h" #include "filters/sfthreshold.h" #include "filters/rate_filter.h" #include "events/event_wrapper.h" @@ -135,7 +135,7 @@ static inline void InitMatchInfo(OTNX_MATCH_DATA* o) // called by fpLogEvent(), which does the filtering etc. // this handles the non-rule-actions (responses). static inline void fpLogOther( - Packet* p, RuleTreeNode* rtn, OptTreeNode* otn, int action) + Packet* p, const RuleTreeNode* rtn, const OptTreeNode* otn, int action) { if ( EventTrace_IsEnabled() ) EventTrace_Log(p, otn, action); @@ -154,7 +154,7 @@ static inline void fpLogOther( ** function was pulled out of fpEvalSomething, so now we can log an ** event no matter where we are. */ -int fpLogEvent(RuleTreeNode* rtn, OptTreeNode* otn, Packet* p) +int fpLogEvent(const RuleTreeNode* rtn, const OptTreeNode* otn, Packet* p) { int action = -1, rateAction = -1; int override, filterEvent = 0; @@ -280,7 +280,7 @@ int fpLogEvent(RuleTreeNode* rtn, OptTreeNode* otn, Packet* p) ** int - 1 max_events variable hit, 0 successful. ** */ -int fpAddMatch(OTNX_MATCH_DATA* omd_local, int pLen, OptTreeNode* otn) +int fpAddMatch(OTNX_MATCH_DATA* omd_local, int pLen, const OptTreeNode* otn) { MATCH_INFO* pmi; int evalIndex; @@ -643,7 +643,7 @@ static int sortOrderByContentLength(const void* e1, const void* e2) ** 1 if flagged ** */ -static inline int fpAddSessionAlert(Packet* p, OptTreeNode* otn) +static inline int fpAddSessionAlert(Packet* p, const OptTreeNode* otn) { if ( !p->flow ) return 0; @@ -673,9 +673,9 @@ static inline int fpAddSessionAlert(Packet* p, OptTreeNode* otn) ** 1 if alert previously generated ** */ -static inline int fpSessionAlerted(Packet* p, OptTreeNode* otn) +static inline int fpSessionAlerted(Packet* p, const OptTreeNode* otn) { - SigInfo* si = &otn->sigInfo; + const SigInfo* si = &otn->sigInfo; if (!stream.check_session_alerted(p->flow, p, si->generator, si->id)) return 0; @@ -761,7 +761,7 @@ static inline int fpFinalSelectEvent(OTNX_MATCH_DATA* o, Packet* p) int i; int j; int k; - OptTreeNode* otn; + const OptTreeNode* otn; int tcnt = 0; EventQueueConfig* eq = snort_conf->event_queue_config; RuleTreeNode* rtn; diff --git a/src/detection/fp_detect.h b/src/detection/fp_detect.h index 0e7b26a08..cbd23edd6 100644 --- a/src/detection/fp_detect.h +++ b/src/detection/fp_detect.h @@ -54,7 +54,7 @@ extern THREAD_LOCAL ProfileStats ruleOTNEvalPerfStats; */ int fpEvalPacket(Packet* p); -int fpLogEvent(RuleTreeNode* rtn, OptTreeNode* otn, Packet* p); +int fpLogEvent(const RuleTreeNode* rtn, const OptTreeNode* otn, Packet* p); int fpEvalRTN(RuleTreeNode* rtn, Packet* p, int check_ports); /* @@ -72,7 +72,7 @@ int fpEvalRTN(RuleTreeNode* rtn, Packet* p, int check_ports); */ struct MATCH_INFO { - OptTreeNode* MatchArray[MAX_EVENT_MATCH]; + const OptTreeNode* MatchArray[MAX_EVENT_MATCH]; int iMatchCount; int iMatchIndex; int iMatchMaxLen; @@ -100,7 +100,7 @@ struct OTNX_MATCH_DATA void otnx_match_data_init(int); void otnx_match_data_term(); -int fpAddMatch(OTNX_MATCH_DATA* omd_local, int pLen, OptTreeNode* otn); +int fpAddMatch(OTNX_MATCH_DATA* omd_local, int pLen, const OptTreeNode* otn); OptTreeNode* GetOTN(uint32_t gid, uint32_t sid); /* counter for number of times we evaluate rules. Used to diff --git a/src/detection/tag.cc b/src/detection/tag.cc index 2e9638992..e4e6c9217 100644 --- a/src/detection/tag.cc +++ b/src/detection/tag.cc @@ -689,7 +689,7 @@ static int PruneTime(SFXHASH* tree, uint32_t thetime) return pruned; } -void SetTags(Packet* p, OptTreeNode* otn, uint16_t event_id) +void SetTags(Packet* p, const OptTreeNode* otn, uint16_t event_id) { DebugMessage(DEBUG_FLOW, "Setting tags\n"); diff --git a/src/detection/tag.h b/src/detection/tag.h index b50175372..552a8a9a1 100644 --- a/src/detection/tag.h +++ b/src/detection/tag.h @@ -57,7 +57,7 @@ struct TagData void InitTag(void); void CleanupTag(void); int CheckTagList(Packet*, Event*, void**); -void SetTags(Packet*, OptTreeNode*, uint16_t); +void SetTags(Packet*, const OptTreeNode*, uint16_t); void TagCacheReset(void); #endif /* TAG_H */ diff --git a/src/detection/treenodes.cc b/src/detection/treenodes.cc index fe5cd8b5b..88551823b 100644 --- a/src/detection/treenodes.cc +++ b/src/detection/treenodes.cc @@ -86,7 +86,7 @@ bool otn_set_agent(OptTreeNode* otn, IpsOption* opt) return true; } -void otn_trigger_actions(OptTreeNode* otn, Packet* p) +void otn_trigger_actions(const OptTreeNode* otn, Packet* p) { if ( otn->agent ) otn->agent->action(p); diff --git a/src/detection/treenodes.h b/src/detection/treenodes.h index def8b356f..70c78608c 100644 --- a/src/detection/treenodes.h +++ b/src/detection/treenodes.h @@ -177,7 +177,7 @@ static inline void otn_set_plugin(OptTreeNode* otn, int id) bool otn_set_agent(OptTreeNode*, IpsOption*); -void otn_trigger_actions(OptTreeNode*, Packet*); +void otn_trigger_actions(const OptTreeNode*, Packet*); #endif diff --git a/src/events/event_queue.cc b/src/events/event_queue.cc index 34cb5a3fc..0e86d834f 100644 --- a/src/events/event_queue.cc +++ b/src/events/event_queue.cc @@ -121,7 +121,7 @@ void EventQueueConfigFree(EventQueueConfig* eqc) // Return 0 if no OTN since -1 return indicates queue limit reached. See // fpFinalSelectEvent() -int SnortEventqAdd(OptTreeNode* otn) +int SnortEventqAdd(const OptTreeNode* otn) { RuleTreeNode* rtn = getRtnFromOtn(otn); diff --git a/src/events/event_queue.h b/src/events/event_queue.h index dae79eb05..3591646d1 100644 --- a/src/events/event_queue.h +++ b/src/events/event_queue.h @@ -39,8 +39,8 @@ struct EventQueueConfig struct EventNode { - struct OptTreeNode* otn; - struct RuleTreeNode* rtn; + const struct OptTreeNode* otn; + const struct RuleTreeNode* rtn; RuleType type; }; @@ -54,7 +54,7 @@ void SnortEventqReset(void); void SnortEventqResetCounts(void); SO_PUBLIC int SnortEventqLog(struct Packet*); -SO_PUBLIC int SnortEventqAdd(struct OptTreeNode*); +SO_PUBLIC int SnortEventqAdd(const struct OptTreeNode*); SO_PUBLIC int SnortEventqAdd(uint32_t gid, uint32_t sid, RuleType = RULE_TYPE__NONE); SO_PUBLIC bool event_is_enabled(uint32_t gid, uint32_t sid); diff --git a/src/filters/rate_filter.cc b/src/filters/rate_filter.cc index a82d5f53f..cd6aad941 100644 --- a/src/filters/rate_filter.cc +++ b/src/filters/rate_filter.cc @@ -115,7 +115,7 @@ int RateFilter_Create( 0 - rate threshold not reached */ int RateFilter_Test( - OptTreeNode* otn, + const OptTreeNode* otn, Packet* p) { unsigned gid = otn->sigInfo.generator; diff --git a/src/filters/rate_filter.h b/src/filters/rate_filter.h index 61adf5330..1f168d5bc 100644 --- a/src/filters/rate_filter.h +++ b/src/filters/rate_filter.h @@ -38,7 +38,7 @@ struct SnortConfig; int RateFilter_Create(SnortConfig* sc, RateFilterConfig*, tSFRFConfigNode*); void RateFilter_PrintConfig(RateFilterConfig*); -int RateFilter_Test(OptTreeNode*, Packet*); +int RateFilter_Test(const OptTreeNode*, Packet*); void RateFilter_ResetActive(void); #endif diff --git a/src/network_inspectors/perf_monitor/perf_base.h b/src/network_inspectors/perf_monitor/perf_base.h index d59e801c7..3cc5fccb9 100644 --- a/src/network_inspectors/perf_monitor/perf_base.h +++ b/src/network_inspectors/perf_monitor/perf_base.h @@ -34,7 +34,7 @@ #include "main/snort_types.h" #include "main/snort_debug.h" #include "protocols/packet.h" -#include "normalize/normalize.h" +#include "network_inspectors/normalize/normalize.h" #include "sfprocpidstats.h" #include