Commit 9ff8652c authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_mobile_identity' into 'develop'

Fix encode/decode 5G GUTI

See merge request oai/cn5g/oai-cn5g-amf!104
parents 0b1b79c7 71b1af34
......@@ -1040,9 +1040,10 @@ void amf_n1::registration_request_handle(
case _5G_GUTI: {
guti = registration_request->get_5g_guti();
Logger::amf_n1().debug("Decoded GUTI from registration request message");
if (!guti.compare("error")) {
if (guti.empty()) {
Logger::amf_n1().warn("No GUTI IE");
}
if (nc.get()) {
nc.get()->is_5g_guti_present = true;
nc.get()->to_be_register_by_new_suci = true;
......@@ -2949,6 +2950,7 @@ void amf_n1::ue_initiate_de_registration_handle(
// Remove NC context
remove_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id);
remove_imsi_2_nas_context(supi);
remove_guti_2_nas_context(dereg_request->get_5g_guti());
// TODO: AMF to AN: N2 UE Context Release Request
......
......@@ -684,30 +684,12 @@ int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
decoded_size++;
_5g_guti->amf_pointer = *(buf + decoded_size);
decoded_size++;
uint32_t tmsi = 0;
uint8_t digit[4];
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[0] = octet;
tmsi |= octet;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[1] = octet;
tmsi |= octet << 8;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[2] = octet;
tmsi |= octet << 16;
octet = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[3] = octet;
tmsi |= octet << 24;
_5g_guti->_5g_tmsi = tmsi;
Logger::nas_mm().debug("decoding 5GSMobilityIdentity 5G-GUTI");
// TMSI, 4 octets
DECODE_U32(buf + decoded_size, _5g_guti->_5g_tmsi, decoded_size);
Logger::nas_mm().debug("TMSI 0x%x", _5g_guti->_5g_tmsi);
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity 5G-GUTI");
return decoded_size;
}
......
......@@ -132,10 +132,14 @@ std::string DeregistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti;
ie_5gs_mobility_id->get5GGUTI(guti);
std::string str; //= guti.toString();
return str;
std::string guti_str =
guti.mcc + guti.mnc + std::to_string(guti.amf_region_id) +
std::to_string(guti.amf_set_id) + std::to_string(guti.amf_pointer) +
std::to_string(guti._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str;
} else {
return "error";
return "";
}
}
......
......@@ -142,9 +142,14 @@ std::string RegistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti;
ie_5gs_mobility_id->get5GGUTI(guti);
return "1234567890";
} else {
return "error";
std::string guti_str =
guti.mcc + guti.mnc + std::to_string(guti.amf_region_id) +
std::to_string(guti.amf_set_id) + std::to_string(guti.amf_pointer) +
std::to_string(guti._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str;
} else {
return "";
}
}
......
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