Commit 5fcec6a9 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code refactor for UE context

parent 4e3c2f4a
...@@ -204,7 +204,13 @@ long amf_app::generate_amf_ue_ngap_id() { ...@@ -204,7 +204,13 @@ long amf_app::generate_amf_ue_ngap_id() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_app::is_ran_amf_id_2_ue_context(const string& ue_context_key) const { bool amf_app::is_ran_amf_id_2_ue_context(const string& ue_context_key) const {
std::shared_lock lock(m_ue_ctx_key); std::shared_lock lock(m_ue_ctx_key);
return bool{ue_ctx_key.count(ue_context_key) > 0}; // return bool{ue_ctx_key.count(ue_context_key) > 0};
if (ue_ctx_key.count(ue_context_key) > 0) {
if (ue_ctx_key.at(ue_context_key) != nullptr) {
return true;
}
}
return false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -236,7 +242,13 @@ void amf_app::set_ran_amf_id_2_ue_context( ...@@ -236,7 +242,13 @@ void amf_app::set_ran_amf_id_2_ue_context(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_app::is_supi_2_ue_context(const string& supi) const { bool amf_app::is_supi_2_ue_context(const string& supi) const {
std::shared_lock lock(m_supi2ue_ctx); std::shared_lock lock(m_supi2ue_ctx);
return bool{supi2ue_ctx.count(supi) > 0}; // return bool{supi2ue_ctx.count(supi) > 0};
if (supi2ue_ctx.count(supi) > 0) {
if (supi2ue_ctx.at(supi) != nullptr) {
return true;
}
}
return false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -390,13 +402,12 @@ void amf_app::handle_itti_message( ...@@ -390,13 +402,12 @@ void amf_app::handle_itti_message(
// Update AMF UE NGAP ID // Update AMF UE NGAP ID
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id)) { if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n1().error( Logger::amf_n1().error(
"Could not find UE NGAP Context with ran_ue_ngap_id " "Could not find UE NGAP Context with ran_ue_ngap_id "
"(" GNB_UE_NGAP_ID_FMT ")", "(" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
} else { } else {
unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
unc->amf_ue_ngap_id = amf_ue_ngap_id; unc->amf_ue_ngap_id = amf_ue_ngap_id;
amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc); amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc);
} }
...@@ -599,21 +610,12 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) { ...@@ -599,21 +610,12 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
// Step 4. Create UE NGAP Context if necessary // Step 4. Create UE NGAP Context if necessary
// Create/Update UE NGAP Context // Create/Update UE NGAP Context
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_app().debug( Logger::amf_app().debug(
"Create a new UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT, "Create a new UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
ran_ue_ngap_id); ran_ue_ngap_id);
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context()); unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
amf_n2_inst->set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc); amf_n2_inst->set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
} else {
unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
if (!unc) {
Logger::amf_app().error(
"Failed to get UE NGAP context for "
"ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
ran_ue_ngap_id);
return;
}
} }
// Store related information into UE NGAP context // Store related information into UE NGAP context
......
...@@ -192,9 +192,9 @@ class amf_app { ...@@ -192,9 +192,9 @@ class amf_app {
uint32_t get_number_registered_ues() const; uint32_t get_number_registered_ues() const;
/* /*
* Verify if a UE context associated with an UE Context Key exist * Verify if a UE context associated with an UE Context Key exist and not null
* @param [const std::string&] ue_context_key: UE Context Key * @param [const std::string&] ue_context_key: UE Context Key
* @return true if UE context exist, otherwise false * @return true if UE context exist and not null, otherwise false
*/ */
bool is_ran_amf_id_2_ue_context(const std::string& ue_context_key) const; bool is_ran_amf_id_2_ue_context(const std::string& ue_context_key) const;
...@@ -226,9 +226,9 @@ class amf_app { ...@@ -226,9 +226,9 @@ class amf_app {
const std::string& ue_context_key, const std::shared_ptr<ue_context>& uc); const std::string& ue_context_key, const std::shared_ptr<ue_context>& uc);
/* /*
* Verify whether a UE context associated with a SUPI exist * Verify whether a UE context associated with a SUPI exist and not null
* @param [const std::string&] supi: UE SUPI * @param [const std::string&] supi: UE SUPI
* @return true if UE context exist, otherwise false * @return true if UE context exist and not null, otherwise false
*/ */
bool is_supi_2_ue_context(const string& supi) const; bool is_supi_2_ue_context(const string& supi) const;
......
...@@ -366,13 +366,16 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind& nas_data_ind) { ...@@ -366,13 +366,16 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind& nas_data_ind) {
std::string nas_context_key = conv::get_ue_context_key( std::string nas_context_key = conv::get_ue_context_key(
ran_ue_ngap_id, amf_ue_ngap_id); // key for nas_context, option 1 ran_ue_ngap_id, amf_ue_ngap_id); // key for nas_context, option 1
std::string snn = {}; std::string snn =
conv::get_serving_network_name(nas_data_ind.mnc, nas_data_ind.mcc);
/*
if (nas_data_ind.mnc.length() == 2) // TODO: remove hardcoded value if (nas_data_ind.mnc.length() == 2) // TODO: remove hardcoded value
snn = "5G:mnc0" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc + snn = "5G:mnc0" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc +
".3gppnetwork.org"; ".3gppnetwork.org";
else else
snn = "5G:mnc" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc + snn = "5G:mnc" + nas_data_ind.mnc + ".mcc" + nas_data_ind.mcc +
".3gppnetwork.org"; ".3gppnetwork.org";
*/
Logger::amf_n1().debug("Serving network name %s", snn.c_str()); Logger::amf_n1().debug("Serving network name %s", snn.c_str());
plmn_t plmn = {}; plmn_t plmn = {};
...@@ -1232,7 +1235,7 @@ void amf_n1::registration_request_handle( ...@@ -1232,7 +1235,7 @@ void amf_n1::registration_request_handle(
if (uc) uc.reset(); if (uc) uc.reset();
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n1().error( Logger::amf_n1().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
ran_ue_ngap_id); ran_ue_ngap_id);
...@@ -2585,7 +2588,7 @@ void amf_n1::security_mode_complete_handle( ...@@ -2585,7 +2588,7 @@ void amf_n1::security_mode_complete_handle(
// Find UE context // Find UE context
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n1().warn( Logger::amf_n1().warn(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
ran_ue_ngap_id); ran_ue_ngap_id);
...@@ -4748,16 +4751,23 @@ bool amf_n1::get_slice_selection_subscription_data_from_conf_file( ...@@ -4748,16 +4751,23 @@ bool amf_n1::get_slice_selection_subscription_data_from_conf_file(
// For now, use the common NSSAIs, supported by AMF and gNB, as subscribed // For now, use the common NSSAIs, supported by AMF and gNB, as subscribed
// NSSAIs // NSSAIs
// Get UE context
std::shared_ptr<ue_context> uc = {}; std::shared_ptr<ue_context> uc = {};
if (!find_ue_context(nc->ran_ue_ngap_id, nc->amf_ue_ngap_id, uc)) { if (!find_ue_context(nc->ran_ue_ngap_id, nc->amf_ue_ngap_id, uc)) {
Logger::amf_n1().warn("Cannot find the UE context"); Logger::amf_n1().warn("Cannot find the UE context");
return false; return false;
} }
// Get UE NGAP Context
std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(nc->ran_ue_ngap_id, unc)) {
Logger::amf_n1().error(
"No existed UE NGAP context associated with "
"ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
nc->ran_ue_ngap_id);
return false;
}
// Get gNB Context // Get gNB Context
std::shared_ptr<ue_ngap_context> unc =
amf_n2_inst->ran_ue_id_2_ue_ngap_context(nc->ran_ue_ngap_id);
std::shared_ptr<gnb_context> gc = {}; std::shared_ptr<gnb_context> gc = {};
if (!amf_n2_inst->is_assoc_id_2_gnb_context(unc->gnb_assoc_id, gc)) { if (!amf_n2_inst->is_assoc_id_2_gnb_context(unc->gnb_assoc_id, gc)) {
Logger::amf_n1().error( Logger::amf_n1().error(
......
...@@ -249,7 +249,7 @@ void amf_n2::handle_itti_message(itti_paging& itti_msg) { ...@@ -249,7 +249,7 @@ void amf_n2::handle_itti_message(itti_paging& itti_msg) {
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -603,7 +603,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) { ...@@ -603,7 +603,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
} }
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Create a new UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT, "Create a new UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
ran_ue_ngap_id); ran_ue_ngap_id);
...@@ -712,7 +712,7 @@ void amf_n2::handle_itti_message(itti_ul_nas_transport& ul_nas_transport) { ...@@ -712,7 +712,7 @@ void amf_n2::handle_itti_message(itti_ul_nas_transport& ul_nas_transport) {
} }
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"UE with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT "UE with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT
") is not attached to gnb with assoc_id " ") is not attached to gnb with assoc_id "
...@@ -775,7 +775,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) { ...@@ -775,7 +775,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(
dl_nas_transport.ran_ue_ngap_id, unc)) { dl_nas_transport.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
...@@ -811,8 +811,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -811,8 +811,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
Logger::amf_n2().debug("Handle Initial Context Setup Request ..."); Logger::amf_n2().debug("Handle Initial Context Setup Request ...");
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -949,8 +948,7 @@ void amf_n2::handle_itti_message( ...@@ -949,8 +948,7 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug("Handle PDU Session Resource Setup Request ..."); Logger::amf_n2().debug("Handle PDU Session Resource Setup Request ...");
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -1031,8 +1029,7 @@ void amf_n2::handle_itti_message( ...@@ -1031,8 +1029,7 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug("Handle PDU Session Resource Modify Request ..."); Logger::amf_n2().debug("Handle PDU Session Resource Modify Request ...");
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -1089,8 +1086,7 @@ void amf_n2::handle_itti_message( ...@@ -1089,8 +1086,7 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug("Handle PDU Session Resource Release Command ..."); Logger::amf_n2().debug("Handle PDU Session Resource Release Command ...");
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -1162,8 +1158,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) { ...@@ -1162,8 +1158,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
Logger::amf_n2().debug("Handling UE Context Release Command ..."); Logger::amf_n2().debug("Handling UE Context Release Command ...");
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!amf_n2_inst->is_ran_ue_id_2_ue_ngap_context( if (!amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -1433,7 +1428,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1433,7 +1428,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
gc->gnb_name.c_str(), gc->globalRanNodeId); gc->gnb_name.c_str(), gc->globalRanNodeId);
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
ran_ue_ngap_id); ran_ue_ngap_id);
...@@ -2073,7 +2068,7 @@ void amf_n2::handle_itti_message(itti_rereoute_nas& itti_msg) { ...@@ -2073,7 +2068,7 @@ void amf_n2::handle_itti_message(itti_rereoute_nas& itti_msg) {
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT, "No UE NGAP context with ran_ue_ngap_id " GNB_UE_NGAP_ID_FMT,
itti_msg.ran_ue_ngap_id); itti_msg.ran_ue_ngap_id);
...@@ -2142,7 +2137,7 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context( ...@@ -2142,7 +2137,7 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_n2::is_ran_ue_id_2_ue_ngap_context( bool amf_n2::ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, const uint32_t& ran_ue_ngap_id,
std::shared_ptr<ue_ngap_context>& unc) const { std::shared_ptr<ue_ngap_context>& unc) const {
std::shared_lock lock(m_ranid2uecontext); std::shared_lock lock(m_ranid2uecontext);
...@@ -2154,14 +2149,14 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context( ...@@ -2154,14 +2149,14 @@ bool amf_n2::is_ran_ue_id_2_ue_ngap_context(
} }
return false; return false;
} }
/*
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::shared_ptr<ue_ngap_context> amf_n2::ran_ue_id_2_ue_ngap_context( std::shared_ptr<ue_ngap_context> amf_n2::ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id) const { const uint32_t& ran_ue_ngap_id) const {
std::shared_lock lock(m_ranid2uecontext); std::shared_lock lock(m_ranid2uecontext);
return ranid2uecontext.at(ran_ue_ngap_id); return ranid2uecontext.at(ran_ue_ngap_id);
} }
*/
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context( void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, const uint32_t& ran_ue_ngap_id,
...@@ -2185,7 +2180,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id( ...@@ -2185,7 +2180,7 @@ void amf_n2::remove_ue_context_with_ran_ue_ngap_id(
// Remove NAS context if still available // Remove NAS context if still available
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
ran_ue_ngap_id); ran_ue_ngap_id);
...@@ -2383,7 +2378,7 @@ bool amf_n2::get_common_NSSAI( ...@@ -2383,7 +2378,7 @@ bool amf_n2::get_common_NSSAI(
// Get UE NGAP Context // Get UE NGAP Context
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) { if (!ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id, unc)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")", "No UE NGAP context with ran_ue_ngap_id (" GNB_UE_NGAP_ID_FMT ")",
ran_ue_ngap_id); ran_ue_ngap_id);
......
...@@ -229,26 +229,26 @@ class amf_n2 : public ngap::ngap_app { ...@@ -229,26 +229,26 @@ class amf_n2 : public ngap::ngap_app {
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID * @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @return shared pointer to the UE NGAP context * @return shared pointer to the UE NGAP context
*/ */
std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context( // std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id) const; // const uint32_t& ran_ue_ngap_id) const;
/* /*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist * Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID * @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the
* existing UE NGAP context
* @return true if exist, otherwise return false * @return true if exist, otherwise return false
*/ */
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const; bool ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id,
std::shared_ptr<ue_ngap_context>& unc) const;
/* /*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist * Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID * @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the UE
* NGAP context
* @return true if exist, otherwise return false * @return true if exist, otherwise return false
*/ */
bool is_ran_ue_id_2_ue_ngap_context( bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const;
const uint32_t& ran_ue_ngap_id,
std::shared_ptr<ue_ngap_context>& unc) const;
/* /*
* Store UE NGAP context associated with a RAN UE NGAP ID * Store UE NGAP context associated with a RAN UE NGAP ID
......
...@@ -477,3 +477,14 @@ std::string conv::get_ue_context_key( ...@@ -477,3 +477,14 @@ std::string conv::get_ue_context_key(
"app_ue_ranid_" + std::to_string(ran_ue_ngap_id) + ":amfid_" + "app_ue_ranid_" + std::to_string(ran_ue_ngap_id) + ":amfid_" +
std::to_string(amf_ue_ngap_id)); std::to_string(amf_ue_ngap_id));
} }
//------------------------------------------------------------------------------
std::string conv::get_serving_network_name(
const std::string& mnc, const std::string& mcc) {
std::string snn = {};
if (mnc.length() == 2) // TODO: remove hardcoded value
snn = "5G:mnc0" + mnc + ".mcc" + mcc + ".3gppnetwork.org";
else
snn = "5G:mnc" + mnc + ".mcc" + mcc + ".3gppnetwork.org";
return snn;
}
...@@ -91,7 +91,10 @@ class conv { ...@@ -91,7 +91,10 @@ class conv {
static bool check_bstring(const bstring& b_str); static bool check_bstring(const bstring& b_str);
static bool check_octet_string(const OCTET_STRING_t& octet_str); static bool check_octet_string(const OCTET_STRING_t& octet_str);
static std::string get_ue_context_key( static std::string get_ue_context_key(
const uint32_t ran_ue_ngap_id, long amf_ue_ngap_id); const uint32_t ran_ue_ngap_id, long amf_ue_ngap_id);
static std::string get_serving_network_name(
const std::string& mnc, const std::string& mcc);
}; };
#endif /* FILE_CONVERSIONS_HPP_SEEN */ #endif /* FILE_CONVERSIONS_HPP_SEEN */
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