Commit 99931b44 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Adding 5GMM state into NAS context

parent 8e7bd952
......@@ -506,18 +506,18 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
Logger::amf_n1().info("Try to find ue_context in amf_app using ran_amf_id %s", ue_context_key.c_str());
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
ue_info_t ueItem;
//update_ue_information_statics(ueItem, "CM-CONNECTED", "REGISTRATION-INITIATING", ran_ue_ngap_id, amf_ue_ngap_id, nc.get()->imsi, "", uc.get()->cgi.mcc, uc.get()->cgi.mnc, uc.get()->cgi.nrCellID);
ueItem.connStatus = "5GMM-CONNECTED";//"CM-CONNECTED";
ueItem.registerStatus = "5GMM-REG-INITIATED"; //5GMM-COMMON-PROCEDURE-INITIATED
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
ueItem.mcc = uc.get()->cgi.mcc;
ueItem.mnc = uc.get()->cgi.mnc;
ueItem.cellId = uc.get()->cgi.nrCellID;
stacs.update_ue_info(ueItem);
nc.get()->is_stacs_available = true;
ueItem.connStatus = "5GMM-CONNECTED";//"CM-CONNECTED";
ueItem.registerStatus = "5GMM-REG-INITIATED"; //5GMM-COMMON-PROCEDURE-INITIATED
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
ueItem.mcc = uc.get()->cgi.mcc;
ueItem.mnc = uc.get()->cgi.mnc;
ueItem.cellId = uc.get()->cgi.nrCellID;
stacs.update_ue_info(ueItem);
set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED);
nc.get()->is_stacs_available = true;
}
//nc.get()->imsi = //need interface to transfer SUCI_imsi_t to string
}
......@@ -1309,19 +1309,9 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, long amf_ue_
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
Logger::amf_n1().info("UE (IMSI %s, GUTI %s, current RAN ID %d, current AMF ID %d) has been registered to the network", nc.get()->imsi.c_str(), guti.c_str(), ran_ue_ngap_id, amf_ue_ngap_id);
if (nc.get()->is_stacs_available) {
/*
ue_info_t ueItem;
ueItem.connStatus = "5GMM-CONNECTED";
ueItem.registerStatus = "5GMM-REGISTERED";
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.guti = guti;
ueItem.imsi = nc.get()->imsi;
ueItem.cellId = 0;
stacs.update_ue_info(ueItem);
*/
stacs.update_5gmm_state(nc.get()->imsi,"5GMM-REGISTERED");
}
set_5gmm_state(nc, _5GMM_REGISTERED);
set_guti_2_nas_context(guti, nc);
nc.get()->is_common_procedure_for_security_mode_control_running = false;
......@@ -1538,22 +1528,9 @@ void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id, long am
bstring b = blk2bstr(buffer, encoded_size);
itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id);
//TODO: Update FSM
//TODO: Update statistic
if (nc.get()->is_stacs_available) {
/* ue_info_t ueItem;
ueItem.connStatus = "";
ueItem.registerStatus = "5GMM-DEREGISTERED";
ueItem.ranid = nc.get()->ran_ue_ngap_id;
ueItem.amfid = nc.get()->amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
ueItem.mcc = uc.get()->cgi.mcc;
ueItem.mnc = uc.get()->cgi.mnc;
ueItem.cellId = uc.get()->cgi.nrCellID;
stacs.update_ue_info(ueItem);
*/
set_5gmm_state(nc, _5GMM_DEREGISTERED);
if (nc.get()->is_stacs_available) {
stacs.update_5gmm_state(nc.get()->imsi,"5GMM-DEREGISTERED");
}
......@@ -1793,3 +1770,18 @@ void amf_n1::run_mobility_registration_update_procedure(std::shared_ptr<nas_cont
Logger::amf_n1().error("Could not send ITTI message %s to task TASK_AMF_N2", i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void amf_n1::set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state) {
Logger::amf_n1().debug("Set 5GMM state to %s", _5gmm_state_e2str[state]);
std::unique_lock lock(m_nas_context);
nc.get()->_5gmm_state = state;
//TODO:
}
//------------------------------------------------------------------------------
void amf_n1::get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state) {
//TODO:
state = nc.get()->_5gmm_state;
}
......@@ -81,6 +81,8 @@ class amf_n1 {
std::map<std::string, long> supi2amfId;
std::map<std::string, uint32_t> supi2ranId;
mutable std::shared_mutex m_nas_context;
std::map<std::string, std::shared_ptr<nas_context>> guti2nas_context;
mutable std::shared_mutex m_guti2nas_context;
bool is_guti_2_nas_context(const std::string &guti) const;
......@@ -122,6 +124,9 @@ class amf_n1 {
void annex_a_4_33501(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], std::string serving_network, uint8_t *output);
void send_itti_to_smf_services_consumer(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type, uint8_t pdu_session_id, bstring dnn, bstring sm_msg);
void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state);
void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state);
private: //nas message handlers
void ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas);
void registration_request_handle(bool isNasSig, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, std::string snn, bstring reg);
......
......@@ -61,6 +61,7 @@ typedef struct ue_info_s {
uint32_t cellId;
} ue_info_t;
class statistics {
public:
void display();
......
......@@ -37,6 +37,27 @@
#include "security_def.hpp"
#include "authentication_algorithms_with_5gaka.hpp"
typedef enum {
_5GMM_STATE_MIN = 0,
_5GMM_STATE_INVALID = _5GMM_STATE_MIN,
_5GMM_DEREGISTERED,
_5GMM_REGISTERED,
_5GMM_DEREGISTERED_INITIATED,
_5GMM_COMMON_PROCEDURE_INITIATED,
_5GMM_STATE_MAX
} _5gmm_state_t;
static const std::vector<std::string> _5gmm_state_e2str = {
"_5GMM_STATE_INVALID",
"_5GMM_DEREGISTERED",
"_5GMM_REGISTERED",
"_5GMM_DEREGISTERED_INITIATED",
"_5GMM_COMMON_PROCEDURE_INITIATED",
"_5GMM_STATE_MAX"
};
class nas_context {
public:
nas_context();
......@@ -46,6 +67,7 @@ class nas_context {
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
std::string nas_status;
_5gmm_state_t _5gmm_state;
/************ parameters from Registration request *************/
uint8_t registration_type :3;
......
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