Commit 16ea304a authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Mobile Identity

parent 1b0cacb0
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define _5GS_MOBILE_IDENTITY_H_ #define _5GS_MOBILE_IDENTITY_H_
#include <stdint.h> #include <stdint.h>
#include <optional>
#include "struct.hpp" #include "struct.hpp"
extern "C" { extern "C" {
...@@ -95,7 +96,10 @@ class _5GSMobileIdentity { ...@@ -95,7 +96,10 @@ class _5GSMobileIdentity {
int encode2Buffer(uint8_t* buf, int len); int encode2Buffer(uint8_t* buf, int len);
int suci_encode2buffer(uint8_t* buf, int len); int suci_encode2buffer(uint8_t* buf, int len);
int _5g_guti_encode2buffer(uint8_t* buf, int len); int _5g_guti_encode2buffer(uint8_t* buf, int len);
int encodeMssMnc2buffer(string mcc, string mnc, uint8_t* buf);
int encodeMssMnc2buffer(
const std::string& mcc_str, const std::string& mnc_str, uint8_t* buf);
int encodeRoutid2buffer(string routid, uint8_t* buf); int encodeRoutid2buffer(string routid, uint8_t* buf);
int encodeMSIN2buffer(string msinstr, uint8_t* buf); int encodeMSIN2buffer(string msinstr, uint8_t* buf);
int _5g_s_tmsi_encode2buffer(uint8_t* buf, int len); int _5g_s_tmsi_encode2buffer(uint8_t* buf, int len);
...@@ -105,13 +109,15 @@ class _5GSMobileIdentity { ...@@ -105,13 +109,15 @@ class _5GSMobileIdentity {
int imeisv_decodefrombuffer(uint8_t* buf, int len); int imeisv_decodefrombuffer(uint8_t* buf, int len);
int decodeFromBuffer(uint8_t* buf, int len, bool is_option); int decodeFromBuffer(uint8_t* buf, int len, bool is_option);
int suci_decodefrombuffer(uint8_t* buf, int len, int length); int suci_decodefrombuffer(uint8_t* buf, int len, int length);
int _5g_guti_decodefrombuffer(uint8_t* buf, int len); int _5g_guti_decodefrombuffer(uint8_t* buf, int len);
void set5GGUTI( void set5GGUTI(
const string mcc, const string mnc, uint8_t amf_region_id, const string& mcc, const string& mnc, const uint8_t& amf_region_id,
uint16_t amf_set_id, uint8_t amf_pointer, const uint32_t _5g_tmsi); const uint16_t& amf_set_id, const uint8_t& amf_pointer,
void get5GGUTI(_5G_GUTI_t&); const uint32_t& _5g_tmsi);
void get5GGUTI(std::optional<_5G_GUTI_t>&) const;
void setSuciWithSupiImsi( void setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd, const string& mcc, const string& mnc, const string& routingInd,
...@@ -131,7 +137,7 @@ class _5GSMobileIdentity { ...@@ -131,7 +137,7 @@ class _5GSMobileIdentity {
uint16_t length; uint16_t length;
uint8_t typeOfIdentity : 3; uint8_t typeOfIdentity : 3;
_5G_GUTI_t* _5g_guti; std::optional<_5G_GUTI_t> _5g_guti;
IMEI_IMEISV_t* imei_imeisv; IMEI_IMEISV_t* imei_imeisv;
SUCI_imsi_t* supi_format_imsi; SUCI_imsi_t* supi_format_imsi;
_5G_S_TMSI_t* _5g_s_tmsi; _5G_S_TMSI_t* _5g_s_tmsi;
......
...@@ -104,7 +104,7 @@ int _5GSRegistrationType::decodeFromBuffer( ...@@ -104,7 +104,7 @@ int _5GSRegistrationType::decodeFromBuffer(
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded 5GSRegistrationType IE (%d octet)", decoded_size); "Decoded 5GSRegistrationType IE (%d octet)", decoded_size);
return decoded_size; return 0; // to read NAS Key Set Identifier (1/2 octet)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -132,12 +132,15 @@ bool DeregistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) { ...@@ -132,12 +132,15 @@ bool DeregistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string DeregistrationRequest::get_5g_guti() { std::string DeregistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) { if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti; std::optional<nas::_5G_GUTI_t> guti = std::nullopt;
ie_5gs_mobility_id->get5GGUTI(guti); ie_5gs_mobility_id->get5GGUTI(guti);
std::string guti_str = if (!guti.has_value()) return {};
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::string guti_str = guti.value().mcc + guti.value().mnc +
conv::tmsi_to_string(guti._5g_tmsi); std::to_string(guti.value().amf_region_id) +
std::to_string(guti.value().amf_set_id) +
std::to_string(guti.value().amf_pointer) +
conv::tmsi_to_string(guti.value()._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str()); Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str; return guti_str;
} else { } else {
......
...@@ -138,12 +138,15 @@ bool RegistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) { ...@@ -138,12 +138,15 @@ bool RegistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::string RegistrationRequest::get_5g_guti() { std::string RegistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) { if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti; std::optional<nas::_5G_GUTI_t> guti = std::nullopt;
ie_5gs_mobility_id->get5GGUTI(guti); ie_5gs_mobility_id->get5GGUTI(guti);
std::string guti_str = if (!guti.has_value()) return {};
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::string guti_str = guti.value().mcc + guti.value().mnc +
conv::tmsi_to_string(guti._5g_tmsi); std::to_string(guti.value().amf_region_id) +
std::to_string(guti.value().amf_set_id) +
std::to_string(guti.value().amf_pointer) +
conv::tmsi_to_string(guti.value()._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str()); Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str; return guti_str;
} else { } else {
...@@ -172,7 +175,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI( ...@@ -172,7 +175,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) { bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) {
if (ie_additional_guti) { if (ie_additional_guti) {
std::optional<nas::_5G_GUTI_t> guti = std::nullopt;
ie_additional_guti->get5GGUTI(guti); ie_additional_guti->get5GGUTI(guti);
if (!guti.has_value()) return false;
return true; return true;
} else { } else {
return false; return false;
......
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