Commit 33c36186 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_guti_identity' into 'develop'

Fix issue for GUTI identity

See merge request oai/cn5g/oai-cn5g-amf!112
parents c2fa450b 5dc001ad
......@@ -2551,7 +2551,7 @@ void amf_n1::security_mode_complete_handle(
std::string guti = mcc + mnc + amf_cfg.guami.regionID +
amf_cfg.guami.AmfSetID + amf_cfg.guami.AmfPointer +
std::to_string(tmsi);
conv::tmsi_to_string(tmsi);
Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str());
// TODO: remove hardcoded values
......
......@@ -120,6 +120,18 @@ std::string conv::mncToString(
return s;
}
//------------------------------------------------------------------------------
std::string conv::tmsi_to_string(const uint32_t tmsi) {
std::string s = {};
std::string tmsi_str = std::to_string(tmsi);
uint8_t length = 4 - tmsi_str.size();
for (uint8_t i = 0; i < length; i++) {
s.append("0");
}
s.append(std::to_string(tmsi));
return s;
}
//------------------------------------------------------------------------------
struct in_addr conv::fromString(const std::string addr4) {
unsigned char buf[sizeof(struct in6_addr)] = {};
......
......@@ -63,6 +63,7 @@ class conv {
const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mncToString(
const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string tmsi_to_string(const uint32_t tmsi);
static void msg_str_2_msg_hex(std::string msg, bstring& b);
static char* bstring2charString(bstring b);
......
......@@ -31,6 +31,7 @@
#include <math.h>
#include "3gpp_ts24501.hpp"
#include "conversions.hpp"
#include "String2Value.hpp"
#include "logger.hpp"
......@@ -164,7 +165,7 @@ int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Octet 0x%x", octet);
digit[3] = octet;
tmsi |= octet << 24;
_5g_s_tmsi->_5g_tmsi = (const string)(std::to_string(tmsi));
_5g_s_tmsi->_5g_tmsi = conv::tmsi_to_string(tmsi);
return decoded_size;
}
......
......@@ -31,8 +31,10 @@
#include <string>
#include "3gpp_ts24501.hpp"
#include "String2Value.hpp"
#include "conversions.hpp"
#include "logger.hpp"
#include "String2Value.hpp"
using namespace nas;
//------------------------------------------------------------------------------
......@@ -135,7 +137,7 @@ std::string DeregistrationRequest::get_5g_guti() {
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);
conv::tmsi_to_string(guti._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str;
} else {
......
......@@ -29,6 +29,7 @@
#include "RegistrationRequest.hpp"
#include "3gpp_ts24501.hpp"
#include "conversions.hpp"
#include "String2Value.hpp"
#include "logger.hpp"
using namespace nas;
......@@ -145,7 +146,7 @@ std::string RegistrationRequest::get_5g_guti() {
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);
conv::tmsi_to_string(guti._5g_tmsi);
Logger::nas_mm().debug("5G GUTI %s", guti_str.c_str());
return guti_str;
} else {
......
......@@ -95,7 +95,7 @@ class RegistrationRequest {
bool get5GSRegistrationType(bool& is_for, uint8_t& reg_type /*3bits*/);
bool getngKSI(uint8_t& ng_ksi);
uint8_t getMobilityIdentityType();
std::string get_5g_guti(); //"error" for missing IE GUTI
std::string get_5g_guti();
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi);
uint8_t getNonCurrentNativeNasKSI();
uint8_t get5GMMCapability();
......
......@@ -27,6 +27,7 @@
*/
#include "FiveGSTmsi.hpp"
#include "conversions.hpp"
using namespace ngap;
......@@ -46,7 +47,7 @@ bool FiveGSTmsi::decodefrompdu(Ngap_FiveG_S_TMSI_t pdu) {
amfSetid.getAMFSetID(setId);
amfPointer.getAMFPointer(pointer);
_5g_s_tmsi = setId + pointer + std::to_string(tmsi);
tmsi_value = std::to_string(tmsi);
tmsi_value = conv::tmsi_to_string(tmsi);
return true;
}
......
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