Squashed commit of the following:
commit
e0c2723bd9c1e6c9b0c9b2830df5aaa57b615a5b
Author: davis mcpherson <davmcphe.cisco.com>
Date: Wed May 17 08:50:53 2017 -0400
refactor appid to instantiate a single instance of the SIP event handler with THREAD_LOCAL variables to hold the pointer to the client/service SIP detectors instantiated in each packet thread. Subscription to the SIP events moved to the appid inspector configure function that is called from the main thread
get_data_bus().subscribe(HTTP_RESPONSE_HEADER_EVENT_KEY, new HttpEventHandler(
HttpEventHandler::RESPONSE_EVENT));
+ SipEventHandler::get_instance().subscribe();
+
return active_config->init_appid();
// FIXIT-M some of this stuff may be needed in some fashion...
};
static THREAD_LOCAL DetectorSipConfig detector_sip_config;
-std::mutex SipEventHandler::db_sub_mutex;
static void clean_sip_ua()
{
{ APP_ID_SIP, APPINFO_FLAG_CLIENT_ADDITIONAL | APPINFO_FLAG_CLIENT_USER },
};
- sip_event_handler = &SipEventHandler::get_instance();
- sip_event_handler->set_client(this);
- sip_event_handler->subscribe();
+ SipEventHandler::get_instance().set_client(this);
handler->register_detector(name, this, proto);
}
// create an RTCP flow as well
fp2 = AppIdSession::create_future_session(pkt, cliIp, cliPort + 1, srvIp, srvPort + 1, proto,
- app_id,
- APPID_EARLY_SESSION_FLAG_FW_RULE);
+ app_id, APPID_EARLY_SESSION_FLAG_FW_RULE);
if ( fp2 )
{
fp2->client_app_id = asd->client_app_id;
return APPID_INPROCESS;
}
+THREAD_LOCAL SipUdpClientDetector* SipEventHandler::client = nullptr;
+THREAD_LOCAL SipServiceDetector* SipEventHandler::service = nullptr;
+
void SipEventHandler::handle(DataEvent& event, Flow* flow)
{
AppIdSession* asd = nullptr;
asd->set_session_flags(APPID_SESSION_CLIENT_GETS_SERVER_PACKETS);
}
- if ( fd->owner != client && fd->owner != client )
- return;
-
int direction = (sip_event.get_packet()->is_from_client()) ?
APP_ID_FROM_INITIATOR : APP_ID_FROM_RESPONDER;
static int sipUaPatternAdd(AppId, const char* clientVersion, const char* uaPattern);
static int sipServerPatternAdd(AppId, const char* clientVersion, const char* uaPattern);
static int finalize_sip_ua();
-
-private:
- SipEventHandler* sip_event_handler = nullptr;
};
class SipTcpClientDetector : public ClientDetector
~SipEventHandler() { }
static SipEventHandler& get_instance()
{
- static THREAD_LOCAL SipEventHandler* seh = nullptr;
- if (!seh)
+ static SipEventHandler* seh = nullptr;
+ if(!seh)
seh = new SipEventHandler;
return *seh;
}
- void set_client(SipUdpClientDetector* cd) { client = cd; }
- void set_service(SipServiceDetector* sd) { service = sd; }
+ void set_client(SipUdpClientDetector* cd) { SipEventHandler::client = cd; }
+ void set_service(SipServiceDetector* sd) { SipEventHandler::service = sd; }
void subscribe()
{
- std::lock_guard<std::mutex> lock(SipEventHandler::db_sub_mutex);
get_data_bus().subscribe(SIP_EVENT_TYPE_SIP_DIALOG_KEY, this);
}
void client_handler(SipEvent&, AppIdSession*);
void service_handler(SipEvent&, AppIdSession*);
- SipUdpClientDetector* client = nullptr;
- SipServiceDetector* service = nullptr;
- static std::mutex db_sub_mutex;
+ static THREAD_LOCAL SipUdpClientDetector* client;
+ static THREAD_LOCAL SipServiceDetector* service;
};
#endif