Commit 436db8a8 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Fix issue for NsmfEventExposure

parent 592f594d
......@@ -1680,21 +1680,23 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
//---------------------------------------------------------------------------------------------
void smf_app::add_event_subscription(evsub_id_t sub_id, smf_event_t ev, std::shared_ptr<smf_subscription> ss) {
Logger::smf_app().debug("Add an Event subscription (Sub ID %d, Event %d)", sub_id, (uint8_t) ev);
std::unique_lock lock(m_smf_event_subscriptions);
smf_event_subscriptions.emplace(std::make_pair(sub_id,ev), ss);
}
//---------------------------------------------------------------------------------------------
void smf_app::get_ee_subscriptions(smf_event_t ev, std::vector<std::shared_ptr<smf_subscription>> subscriptions) {
void smf_app::get_ee_subscriptions(smf_event_t ev, std::vector<std::shared_ptr<smf_subscription>> &subscriptions) {
for (auto const& i : smf_event_subscriptions) {
if (i.first.second == ev){
subscriptions.push_back(i.second);
if ((uint8_t)std::get<1> (i.first) == (uint8_t) ev){
Logger::smf_app().debug("Found an event subscription (Event ID %d, Event %d)", (uint8_t) std::get<0>(i.first), (uint8_t) ev);
subscriptions.push_back(i.second);
}
}
}
//---------------------------------------------------------------------------------------------
void smf_app::get_ee_subscriptions(evsub_id_t sub_id, std::vector<std::shared_ptr<smf_subscription>> subscriptions) {
void smf_app::get_ee_subscriptions(evsub_id_t sub_id, std::vector<std::shared_ptr<smf_subscription>> &subscriptions) {
for (auto const& i : smf_event_subscriptions) {
if (i.first.first == sub_id){
subscriptions.push_back(i.second);
......@@ -1704,7 +1706,7 @@ void smf_app::get_ee_subscriptions(evsub_id_t sub_id, std::vector<std::shared_pt
//---------------------------------------------------------------------------------------------
//std::vector<std::shared_ptr<smf_subscription>> subscriptions
void smf_app::get_ee_subscriptions(smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id, std::shared_ptr<smf_subscription> subscription) {
void smf_app::get_ee_subscriptions(smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id, std::shared_ptr<smf_subscription> &subscription) {
for (auto const& i : smf_event_subscriptions) {
if ((i.first.second == ev) && (i.second->supi == supi) && (i.second->pdu_session_id == pdu_session_id)){
subscription = i.second;
......
......@@ -698,10 +698,10 @@ class smf_app {
* @param [std::vector<std::shared_ptr<smf_subscription>>] subscriptions: list of the subscription associated with this event type
* @return vector
*/
void get_ee_subscriptions(smf_event_t ev, std::vector<std::shared_ptr<smf_subscription>> subscriptions);
void get_ee_subscriptions(evsub_id_t sub_id, std::vector<std::shared_ptr<smf_subscription>> subscriptions);
void get_ee_subscriptions(smf_event_t ev, std::vector<std::shared_ptr<smf_subscription>> &subscriptions);
void get_ee_subscriptions(evsub_id_t sub_id, std::vector<std::shared_ptr<smf_subscription>> &subscriptions);
void get_ee_subscriptions(smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id, std::shared_ptr<smf_subscription> subscription);
void get_ee_subscriptions(smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id, std::shared_ptr<smf_subscription> &subscription);
......
......@@ -109,6 +109,7 @@ boost::signals2::connection smf_event::subscribe_ee_pdu_session_release(
void smf_event::trigger_ee_pdu_session_release(supi64_t supi,
pdu_session_id_t pdu_session_id,
uint8_t http_version) {
Logger::smf_app().debug("Trigger Event Exposure PDU Session Release event notification");
pdu_session_release_sig(supi, pdu_session_id, http_version);
}
......@@ -118,7 +119,7 @@ void smf_event::send_ee_pdu_session_release(supi64_t supi,
uint8_t http_version) {
Logger::smf_app().debug("Send request to N11 to triger PDU Session Release Notification, SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", supi, pdu_session_id, http_version);
std::vector < std::shared_ptr < smf_subscription >> subscriptions;
std::vector < std::shared_ptr < smf_subscription >> subscriptions = {};
smf_app_inst->get_ee_subscriptions(smf_event_t::SMF_EVENT_PDU_SES_REL, subscriptions);
if (subscriptions.size() > 0) {
......@@ -148,5 +149,7 @@ void smf_event::send_ee_pdu_session_release(supi64_t supi,
"Could not send ITTI message %s to task TASK_SMF_N11",
itti_msg->get_msg_name());
}
} else {
Logger::smf_app().debug("No suscription available for this event");
}
}
......@@ -531,6 +531,24 @@ void smf_n11::notify_subscribed_event(
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
std::vector<std::string> bodys = {}; //store body for all the request
for (auto i: msg->event_notifs) {
//Fill the json part
nlohmann::json json_data = {};
json_data["notifId"] = i.get_notif_id();
auto event_notifs = nlohmann::json::array();
nlohmann::json event_notif = {};
event_notif["event"] = i.get_smf_event();
event_notif["pduSeId"] = i.get_pdu_session_id();
event_notif["timeStamp"] = "timestamp"; //TODO: remove hardcoded
event_notifs.push_back(event_notif);
json_data["eventNotifs"] = event_notifs;
std::string body = json_data.dump();
bodys.push_back(body);
}
int index = 0;
//create and add an easy handle to a multi curl request
for (auto i: msg->event_notifs) {
//CURL *temp = curl_create_handle(i.get_notif_uri(), &data );
......@@ -540,17 +558,20 @@ void smf_n11::notify_subscribed_event(
CURL *curl = curl_easy_init();
if (curl){
std::string url = i.get_notif_uri() ;
Logger::smf_n11().debug("Send notification to NF with URI: %s", url);
Logger::smf_n11().debug("Send notification to NF with URI: %s", url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );
curl_easy_setopt(curl, CURLOPT_HTTPGET,1);
curl_easy_setopt(curl, CURLOPT_HTTPPOST,1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100L);
// Hook up data handling function.
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, bodys.at(index).length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, bodys.at(index).c_str());
}
curl_multi_add_handle(m_curl_multi, curl);
index++;
}
curl_multi_perform(m_curl_multi, &still_running);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment