using namespace snort;
-#ifndef _WIN64
-unsigned THREAD_LOCAL Inspector::slot = 0;
-#endif
-
//-------------------------------------------------------------------------
// packet handler stuff
//-------------------------------------------------------------------------
}
void Inspector::add_ref()
-{ ++ref_count[get_slot()]; }
+{ ++ref_count[get_instance_id()]; }
void Inspector::rem_ref()
-{ --ref_count[get_slot()]; }
+{ --ref_count[get_instance_id()]; }
void Inspector::add_global_ref()
{ ++ref_count[0]; }
}
void Inspector::set_thread_specific_data(void* tsd)
-{ thread_specific_data->data[get_slot()] = tsd; }
+{ thread_specific_data->data[get_instance_id()] = tsd; }
void* Inspector::get_thread_specific_data() const
-{ return thread_specific_data->data[get_slot()]; }
+{ return thread_specific_data->data[get_instance_id()]; }
static const char* InspectorTypeNames[IT_MAX] =
{
struct Packet;
// this is the current version of the api
-#define INSAPI_VERSION ((BASE_API_VERSION << 16) | 1)
+#define INSAPI_VERSION ((BASE_API_VERSION << 16) | 2)
struct InspectionBuffer
{
virtual const uint8_t* adjust_log_packet(Packet*, uint16_t&)
{ return nullptr; }
- static unsigned get_slot()
-#ifndef _WIN64
- { return slot; }
-#else
- { return get_instance_id(); }
-#endif
-
protected:
// main thread functions
Inspector(); // internal init only at this point
const char* alias_name = nullptr;
uint64_t network_policy_user_id = 0;
bool network_policy_user_id_set = false;
-
-#ifndef _WIN64
-private:
- friend class InspectorManager;
- static THREAD_LOCAL unsigned slot;
-#endif
};
// at present there is no sequencing among like types except that appid
void InspectorList::tterm_removed()
{
for ( auto& ri : removed_ilist )
- ri.instance->tterm(ri.handlers[Inspector::get_slot()]);
+ ri.instance->tterm(ri.handlers[get_instance_id()]);
}
static PHInstance* get_instance(InspectorList* il, const char* keyword);
PHObjectList* TrafficPolicy::get_specific_handlers()
{
- unsigned slot = Inspector::get_slot();
+ unsigned slot = get_instance_id();
assert(ts_handlers);
PHObjectList* handlers = ts_handlers->olists[slot];
if (!handlers)
void SingleInstanceInspectorPolicy::tterm_removed()
{
if (removed_instance)
- removed_instance->tterm(s_tl_handlers[Inspector::get_slot()]);
+ removed_instance->tterm(s_tl_handlers[get_instance_id()]);
}
void SingleInstanceInspectorPolicy::print_config(SnortConfig* sc, const char* title)
void InspectorManager::thread_init(const SnortConfig* sc)
{
SnortConfig::update_thread_reload_id();
-#ifndef _WIN64
- Inspector::slot = get_instance_id();
-#endif
// Initial build out of this thread's configured plugin registry
PHObjectList* g_handlers = new PHObjectList;
- s_tl_handlers[Inspector::get_slot()] = g_handlers;
+ s_tl_handlers[get_instance_id()] = g_handlers;
for ( auto* p : sc->framework_config->clist )
{
PHObject& phg = get_thread_local_plugin(p->api, g_handlers);
sc->policy_map->set_inspector_tinit_complete(instance_id, true);
// Update this thread's configured plugin registry with any newly configured inspectors
- PHObjectList* g_handlers = s_tl_handlers[Inspector::get_slot()];
+ PHObjectList* g_handlers = s_tl_handlers[get_instance_id()];
for ( auto* p : sc->framework_config->clist )
{
PHObject& phg = get_thread_local_plugin(p->api, g_handlers);
void InspectorManager::thread_stop(const SnortConfig* sc)
{
// If thread_init() was never called, we have nothing to do.
- PHObjectList* g_handlers = s_tl_handlers[Inspector::get_slot()];
+ PHObjectList* g_handlers = s_tl_handlers[get_instance_id()];
if ( !g_handlers )
return;
void InspectorManager::thread_term()
{
// If thread_init() was never called, we have nothing to do.
- PHObjectList* handlers = s_tl_handlers[Inspector::get_slot()];
+ PHObjectList* handlers = s_tl_handlers[get_instance_id()];
if ( !handlers )
return;
phg.api.tterm();
}
delete handlers;
- s_tl_handlers[Inspector::get_slot()] = nullptr;
+ s_tl_handlers[get_instance_id()] = nullptr;
}
//-------------------------------------------------------------------------