Commit a23d88a7 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup for Event Exposure

parent 8def4bba
...@@ -3990,6 +3990,28 @@ bool smf_context::get_pdu_session_info( ...@@ -3990,6 +3990,28 @@ bool smf_context::get_pdu_session_info(
return true; return true;
} }
//------------------------------------------------------------------------------
bool smf_context::get_pdu_session_info(
const scid_t& scid, supi64_t& supi, std::shared_ptr<smf_pdu_session>& sp) {
Logger::smf_app().debug(
"Get PDU Session information related to SMF Context ID " SCID_FMT " ",
scid);
pdu_session_id_t pdu_session_id = {};
if (!get_pdu_session_info(scid, supi, pdu_session_id)) {
return false;
}
if (!find_pdu_session(pdu_session_id, sp)) {
Logger::smf_app().warn(
"Could not retrieve the PDU Session Info with PDU Session ID %d!",
pdu_session_id);
return false;
}
return true;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_context::handle_sm_context_status_change( void smf_context::handle_sm_context_status_change(
scid_t scid, const std::string& status, uint8_t http_version) { scid_t scid, const std::string& status, uint8_t http_version) {
...@@ -4172,8 +4194,9 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) { ...@@ -4172,8 +4194,9 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) {
scid); scid);
supi64_t supi64 = {}; supi64_t supi64 = {};
pdu_session_id_t pdu_session_id = {}; // get smf_pdu_session
if (!get_pdu_session_info(scid, supi64, pdu_session_id)) { std::shared_ptr<smf_pdu_session> sp = {};
if (!get_pdu_session_info(scid, supi64, sp)) {
Logger::smf_app().debug( Logger::smf_app().debug(
"Could not retrieve info with " "Could not retrieve info with "
"SMF Context ID " SCID_FMT " ", "SMF Context ID " SCID_FMT " ",
...@@ -4181,18 +4204,10 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) { ...@@ -4181,18 +4204,10 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) {
return; return;
} }
// get smf_pdu_session
std::shared_ptr<smf_pdu_session> sp = {};
if (!find_pdu_session(pdu_session_id, sp)) {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF PDU Session context!");
return;
}
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger FlexCN (Event " "Send request to N11 to triger FlexCN (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d",
supi, pdu_session_id, http_version); supi, sp->get_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_app_inst->get_ee_subscriptions(
...@@ -4209,7 +4224,7 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) { ...@@ -4209,7 +4224,7 @@ void smf_context::handle_ue_ip_change(scid_t scid, uint8_t http_version) {
for (auto i : subscriptions) { for (auto i : subscriptions) {
event_notification ev_notif = {}; event_notification ev_notif = {};
ev_notif.set_supi(supi64); // SUPI ev_notif.set_supi(supi64); // SUPI
ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID ev_notif.set_pdu_session_id(sp->get_pdu_session_id()); // PDU session ID
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_UE_IP_CH); ev_notif.set_smf_event(smf_event_t::SMF_EVENT_UE_IP_CH);
ev_notif.set_notif_uri(i.get()->notif_uri); ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id); ev_notif.set_notif_id(i.get()->notif_id);
...@@ -4264,16 +4279,17 @@ void smf_context::handle_qos_monitoring( ...@@ -4264,16 +4279,17 @@ void smf_context::handle_qos_monitoring(
"SMF Context-related SEID " SEID_FMT, "SMF Context-related SEID " SEID_FMT,
seid); seid);
supi64_t supi64 = {}; // Get the smf context
pdu_session_id_t pdu_session_id = {}; std::shared_ptr<smf_context> pc = {};
if (!get_pdu_session_info(scid, supi64, pdu_session_id)) { if (!smf_app_inst->seid_2_smf_context(seid, pc)) {
Logger::smf_app().debug( Logger::smf_app().warn(
"Could not retrieve info with " "Context associated with this SEID " SEID_FMT " does not exit!", seid);
"SMF Context ID " SCID_FMT " ",
scid);
return; return;
} }
supi_t supi = pc.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
smf_event_t::SMF_EVENT_QOS_MON, subscriptions); smf_event_t::SMF_EVENT_QOS_MON, subscriptions);
...@@ -4333,8 +4349,9 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) { ...@@ -4333,8 +4349,9 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) {
scid); scid);
supi64_t supi64 = {}; supi64_t supi64 = {};
pdu_session_id_t pdu_session_id = {}; // get smf_pdu_session
if (!get_pdu_session_info(scid, supi64, pdu_session_id)) { std::shared_ptr<smf_pdu_session> sp = {};
if (!get_pdu_session_info(scid, supi64, sp)) {
Logger::smf_app().debug( Logger::smf_app().debug(
"Could not retrieve info with " "Could not retrieve info with "
"SMF Context ID " SCID_FMT " ", "SMF Context ID " SCID_FMT " ",
...@@ -4342,19 +4359,22 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) { ...@@ -4342,19 +4359,22 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) {
return; return;
} }
// get smf_pdu_session // Get SMF Context
std::shared_ptr<smf_pdu_session> sp = {}; std::shared_ptr<smf_context> sc = {};
if (smf_app_inst->is_supi_2_smf_context(supi64)) {
if (!find_pdu_session(pdu_session_id, sp)) { sc = smf_app_inst->supi_2_smf_context(supi64);
} else {
Logger::smf_app().warn( Logger::smf_app().warn(
"Could not retrieve the corresponding SMF PDU Session context!"); "Could not retrieve the corresponding SMF context with "
"Supi " SUPI_64_FMT "!",
supi64);
return; return;
} }
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger FlexCN (Event " "Send request to N11 to triger FlexCN (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d",
supi, pdu_session_id, http_version); supi, sp->get_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_app_inst->get_ee_subscriptions(
...@@ -4371,7 +4391,7 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) { ...@@ -4371,7 +4391,7 @@ void smf_context::handle_flexcn_event(scid_t scid, uint8_t http_version) {
for (auto i : subscriptions) { for (auto i : subscriptions) {
event_notification ev_notif = {}; event_notification ev_notif = {};
ev_notif.set_supi(supi64); // SUPI ev_notif.set_supi(supi64); // SUPI
ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID ev_notif.set_pdu_session_id(sp->get_pdu_session_id()); // PDU session ID
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_FLEXCN); ev_notif.set_smf_event(smf_event_t::SMF_EVENT_FLEXCN);
ev_notif.set_notif_uri(i.get()->notif_uri); ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id); ev_notif.set_notif_id(i.get()->notif_id);
...@@ -4475,8 +4495,9 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) { ...@@ -4475,8 +4495,9 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) {
scid); scid);
supi64_t supi64 = {}; supi64_t supi64 = {};
pdu_session_id_t pdu_session_id = {}; // get smf_pdu_session
if (!get_pdu_session_info(scid, supi64, pdu_session_id)) { std::shared_ptr<smf_pdu_session> sp = {};
if (!get_pdu_session_info(scid, supi64, sp)) {
Logger::smf_app().debug( Logger::smf_app().debug(
"Could not retrieve info with " "Could not retrieve info with "
"SMF Context ID " SCID_FMT " ", "SMF Context ID " SCID_FMT " ",
...@@ -4484,19 +4505,10 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) { ...@@ -4484,19 +4505,10 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) {
return; return;
} }
// get smf_pdu_session
std::shared_ptr<smf_pdu_session> sp = {};
if (!find_pdu_session(pdu_session_id, sp)) {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF PDU Session context!");
return;
}
Logger::smf_app().debug( Logger::smf_app().debug(
"Send request to N11 to triger PDU_SES_EST (Event " "Send request to N11 to triger PDU_SES_EST (Event "
"Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", "Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d",
supi, pdu_session_id, http_version); supi, sp->get_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_app_inst->get_ee_subscriptions(
...@@ -4513,7 +4525,7 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) { ...@@ -4513,7 +4525,7 @@ void smf_context::handle_pdusesest(scid_t scid, uint8_t http_version) {
for (auto i : subscriptions) { for (auto i : subscriptions) {
event_notification ev_notif = {}; event_notification ev_notif = {};
ev_notif.set_supi(supi64); // SUPI ev_notif.set_supi(supi64); // SUPI
ev_notif.set_pdu_session_id(pdu_session_id); // PDU session ID ev_notif.set_pdu_session_id(sp->get_pdu_session_id()); // PDU session ID
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PDUSESEST); ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PDUSESEST);
ev_notif.set_notif_uri(i.get()->notif_uri); ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id); ev_notif.set_notif_id(i.get()->notif_id);
...@@ -4573,6 +4585,7 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -4573,6 +4585,7 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
"Send request to N11 to triger FlexCN, " "Send request to N11 to triger FlexCN, "
"SMF Context ID " SCID_FMT " ", "SMF Context ID " SCID_FMT " ",
scid); scid);
supi64_t supi64 = {}; supi64_t supi64 = {};
pdu_session_id_t pdu_session_id = {}; pdu_session_id_t pdu_session_id = {};
if (!get_pdu_session_info(scid, supi64, pdu_session_id)) { if (!get_pdu_session_info(scid, supi64, pdu_session_id)) {
...@@ -4583,6 +4596,18 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) { ...@@ -4583,6 +4596,18 @@ void smf_context::handle_plmn_change(scid_t scid, uint8_t http_version) {
return; return;
} }
// Get SMF Context
std::shared_ptr<smf_context> sc = {};
if (smf_app_inst->is_supi_2_smf_context(supi64)) {
sc = smf_app_inst->supi_2_smf_context(supi64);
} else {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF context with "
"Supi " SUPI_64_FMT "!",
supi64);
return;
}
std::vector<std::shared_ptr<smf_subscription>> subscriptions = {}; std::vector<std::shared_ptr<smf_subscription>> subscriptions = {};
smf_app_inst->get_ee_subscriptions( smf_app_inst->get_ee_subscriptions(
smf_event_t::SMF_EVENT_FLEXCN, subscriptions); smf_event_t::SMF_EVENT_FLEXCN, subscriptions);
......
...@@ -1184,6 +1184,18 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -1184,6 +1184,18 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
bool get_pdu_session_info( bool get_pdu_session_info(
const scid_t& scid, supi64_t& supi, pdu_session_id_t& pdu_session_id); const scid_t& scid, supi64_t& supi, pdu_session_id_t& pdu_session_id);
/*
* Get PDU related information
* @param [const scid_t&] scid: SMF Context ID
* @param [supi64_t&] supi: SUPI
* @param [std::shared_ptr<smf_pdu_session>&] sp: Pointer to the PDU Session
* Info
* @return true if this Context ID exist and can get related info, otherwise,
* return false
*/
bool get_pdu_session_info(
const scid_t& scid, supi64_t& supi, std::shared_ptr<smf_pdu_session>& sp);
/* /*
* Handle SM Context Status Change (Send notification AMF) * Handle SM Context Status Change (Send notification AMF)
* @param [scid_t] scid: SMF Context ID * @param [scid_t] scid: SMF Context ID
......
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