tp_lib_handler.cc
tp_lib_handler.h
tp_appid_types.h
+ tp_appid_session_api.h
+ tp_appid_module_api.h
+ tp_appid_module_api.cc
)
#if (STATIC_INSPECTORS)
bool AppIdInspector::configure(SnortConfig* sc)
{
assert(!ctxt);
-
+ // cppcheck-suppress unreadVariable
+ Profile profile(appid_perf_stats);
struct rusage ru;
long prev_maxrss = -1;
#ifdef REG_TEST
//-------------------------------------------------------------------------
THREAD_LOCAL ProfileStats appid_perf_stats;
+THREAD_LOCAL ProfileStats tp_appid_perf_stats;
THREAD_LOCAL AppIdStats appid_stats;
THREAD_LOCAL bool ThirdPartyAppIdContext::tp_reload_in_progress = false;
return &appid_trace_options;
}
-ProfileStats* AppIdModule::get_profile() const
+
+
+snort::ProfileStats* AppIdModule::get_profile(
+ unsigned i, const char*& name, const char*& parent) const
{
- return &appid_perf_stats;
+ switch (i)
+ {
+
+ case 0:
+ name = get_name();
+ parent = nullptr;
+ return &appid_perf_stats;
+
+ case 1:
+ name = "tp_appid";
+ parent = get_name();
+ return &tp_appid_perf_stats;
+ }
+ return nullptr;
}
const AppIdConfig* AppIdModule::get_data()
}
extern THREAD_LOCAL snort::ProfileStats appid_perf_stats;
+extern THREAD_LOCAL snort::ProfileStats tp_appid_perf_stats;
extern THREAD_LOCAL const snort::Trace* appid_trace;
#define MOD_NAME "appid"
const snort::Command* get_commands() const override;
const PegInfo* get_pegs() const override;
PegCount* get_counts() const override;
- snort::ProfileStats* get_profile() const override;
+ snort::ProfileStats* get_profile(
+ unsigned i, const char*& name, const char*& parent) const override;
const AppIdConfig* get_data();
args.data++; /* skip the space */
}
+ // cppcheck-suppress knownConditionTrueFalse
else if ( end - args.data >= (int)sizeof(MSMSGS) &&
memcmp(args.data, MSMSGS, sizeof(MSMSGS)-1) == 0 )
{
return nullptr;
}
-snort::ProfileStats* AppIdModule::get_profile() const
+snort::ProfileStats* AppIdModule::get_profile(
+ unsigned, const char*&, const char*&) const
{
return nullptr;
}
tp_lib_handler_test.cc
../../../network_inspectors/rna/test/rna_flow_stubs.cc
../tp_lib_handler.cc
+ ../tp_appid_module_api.cc
LIBS
dl
)
const Command* AppIdModule::get_commands() const { return nullptr; }
const PegInfo* AppIdModule::get_pegs() const { return nullptr; }
PegCount* AppIdModule::get_counts() const { return nullptr; }
-ProfileStats* AppIdModule::get_profile() const { return nullptr; }
+ProfileStats* AppIdModule::get_profile(
+ unsigned i, const char*& name, const char*& parent) const { return nullptr; }
void AppIdModule::set_trace(const Trace*) const { }
const TraceOption* AppIdModule::get_trace_options() const { return nullptr; }
THREAD_LOCAL bool ThirdPartyAppIdContext::tp_reload_in_progress = false;
const snort::Command* AppIdModule::get_commands() const { return nullptr; }
const PegInfo* AppIdModule::get_pegs() const { return nullptr; }
PegCount* AppIdModule::get_counts() const { return nullptr; }
-snort::ProfileStats* AppIdModule::get_profile() const { return nullptr; }
+snort::ProfileStats* AppIdModule::get_profile(
+ unsigned, const char*&, const char*& ) const { return nullptr; }
void AppIdModule::set_trace(const Trace*) const { }
const TraceOption* AppIdModule::get_trace_options() const { return nullptr; }
#include <CppUTest/TestHarness.h>
using namespace std;
+using namespace snort;
static TPLibHandler* tph = nullptr;
static AppIdConfig config;
{ return 0; }
void appid_log(const snort::Packet*, unsigned char, char const*, ...) { }
+
+THREAD_LOCAL ProfileStats tp_appid_perf_stats;
+THREAD_LOCAL bool TimeProfilerStats::enabled = false;
+MemoryContext::MemoryContext(MemoryTracker&) { }
+MemoryContext::~MemoryContext() = default;
+THREAD_LOCAL TimeContext* ProfileContext::curr_time = nullptr;
+
+
TEST_GROUP(tp_lib_handler)
{
};
: ThirdPartyAppIdContext(ver, mname, config)
{
cerr << WhereMacro << endl;
+ // For tp_appid profiler coverage
+ data = (int*)cfg.tp_appid_profiler_functions.appid_malloc(sizeof(int));
}
~ThirdPartyAppIdContextImpl() override
{
cerr << WhereMacro << endl;
+ // For tp_appid profiler coverage
+ cfg.tp_appid_profiler_functions.appid_free(data);
}
- int tinit() override { return 0; }
- bool tfini(bool) override { return false; }
+ int tinit() override {return 0;}
+ bool tfini(bool) override {return false;}
const string& get_user_config() const override { return user_config; }
private:
const string user_config = "";
+ int* data;
};
class ThirdPartyAppIdSessionImpl : public ThirdPartyAppIdSession
--- /dev/null
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tp_appid_module_api.h"
+#include "managers/module_manager.h"
+#include "appid_module.h"
+#include "tp_lib_handler.h"
+
+
+static void* tp_appid_profiler_malloc(size_t size)
+{
+ // cppcheck-suppress unreadVariable
+ snort::Profile profile(tp_appid_perf_stats);
+ return operator new(size);
+}
+
+static void tp_appid_profiler_free(void* p)
+{
+ // cppcheck-suppress unreadVariable
+ snort::Profile profile(tp_appid_perf_stats);
+ if (p)
+ operator delete(p);
+}
+
+TPAppidProfilerFunctions get_tp_appid_profiler_functions()
+{
+ return {tp_appid_profiler_malloc,tp_appid_profiler_free};
+}
#include <vector>
#include <string>
+
#include "main/thread.h"
+#include "profiler/profiler_defs.h"
#include "tp_appid_types.h"
#define THIRD_PARTY_APPID_API_VERSION 6
+struct TPAppidProfilerFunctions
+{
+ void* (*appid_malloc) (size_t);
+ void (*appid_free) (void*);
+};
+
class ThirdPartyConfig
{
public:
std::string tp_appid_config;
bool tp_appid_stats_enable = false;
bool tp_appid_config_dump = false;
+ TPAppidProfilerFunctions tp_appid_profiler_functions = {};
};
class ThirdPartyAppIdContext
tp_config.chp_body_collection_disabled =
odp_ctxt.chp_body_collection_disabled;
tp_config.tp_allow_probes = odp_ctxt.tp_allow_probes;
+ tp_config.tp_appid_profiler_functions = get_tp_appid_profiler_functions();
ThirdPartyAppIdContext* tp_appid_ctxt = self->tp_appid_create_ctxt(tp_config);
if (tp_appid_ctxt == nullptr)
bool load_callback(const char* path);
};
+TPAppidProfilerFunctions get_tp_appid_profiler_functions();
+
#endif