Commit 7aac5ad7 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code refactor for Mobile Identity

parent 6c897504
This diff is collapsed.
......@@ -31,7 +31,6 @@ extern "C" {
#include "TLVEncoder.h"
#include "bstrlib.h"
}
using namespace std;
namespace nas {
......@@ -51,18 +50,18 @@ typedef struct IMEI_or_IMEISV_s {
bool odd_even_indic; // for imei, even means bits 5 to 8 of last octet is
// "1111", for imeisv, bits 5 to 8 of last octet is
// "1111"
string identity; // "46011000001"
std::string identity; // "46011000001"
} IMEI_IMEISV_t;
// SUCI and SUPI format IMSI
typedef struct SUCI_imsi_s {
uint8_t supi_format : 3;
string mcc;
string mnc;
string routingIndicator; //"1234"
std::string mcc;
std::string mnc;
std::optional<std::string> routingIndicator; //"1234"
uint8_t protectionSchemeId : 4; // 0000
uint8_t homeNetworkPKI; // 00000000
string msin; // two types of coding; BCD & hexadecimal
std::string msin; // two types of coding; BCD & hexadecimal
} SUCI_imsi_t; // SUPI format "IMSI"
// TODO: SUCI and SUPI format "Network specific identifier"
......@@ -70,7 +69,7 @@ typedef struct SUCI_imsi_s {
typedef struct _5G_S_TMSI_s {
uint16_t amf_set_id;
uint8_t amf_pointer;
string _5g_tmsi;
std::string _5g_tmsi;
} _5G_S_TMSI_t;
// TODO: 5GS mobile identity information element for type of identity "MAC
......@@ -78,18 +77,13 @@ typedef struct _5G_S_TMSI_s {
class _5GSMobileIdentity {
public:
_5GSMobileIdentity(
uint8_t _iei, const uint16_t amfSetId, const uint8_t amfPointer,
const string tmsi); // 5G-S-TMSI
_5GSMobileIdentity();
_5GSMobileIdentity(uint8_t _iei);
~_5GSMobileIdentity();
// Common
uint8_t getTypeOfIdentity() const { return typeOfIdentity; };
void setIEI(uint8_t _iei);
int encode2Buffer(uint8_t* buf, int len);
int decodeFromBuffer(uint8_t* buf, int len, bool is_option);
......@@ -100,9 +94,9 @@ class _5GSMobileIdentity {
int _5g_guti_decodefrombuffer(uint8_t* buf, int len);
int _5g_guti_encode2buffer(uint8_t* buf, int len);
void set5GGUTI(
const string& mcc, const string& mnc, const uint8_t& amf_region_id,
const uint16_t& amf_set_id, const uint8_t& amf_pointer,
const uint32_t& _5g_tmsi);
const std::string& mcc, const std::string& mnc,
const uint8_t& amf_region_id, const uint16_t& amf_set_id,
const uint8_t& amf_pointer, const uint32_t& _5g_tmsi);
void get5GGUTI(std::optional<_5G_GUTI_t>&) const;
// SUCI
......@@ -110,27 +104,28 @@ class _5GSMobileIdentity {
int suci_encode2buffer(uint8_t* buf, int len);
void setSuciWithSupiImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id,
const string msin); // TODO: SetSUCI, SUCI and SUPI format IMSI
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, uint8_t protection_sch_id,
const std::string& msin); // TODO: SetSUCI, SUCI and SUPI format IMSI
void setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, uint8_t home_pki, const string& msin_digits);
/*
void setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, const string& msin_digits);
*/
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, uint8_t protecSchId, uint8_t home_pki,
const std::string& msin_digits);
bool getSuciWithSupiImsi(SUCI_imsi_t&);
int encodeRoutid2buffer(string routid, uint8_t* buf);
int encodeMSIN2buffer(string msinstr, uint8_t* buf);
int encodeRoutid2buffer(
std::optional<std::string> routing_indicator, uint8_t* buf);
int encodeMSIN2buffer(std::string msinstr, uint8_t* buf);
// TMSI
int _5g_s_tmsi_encode2buffer(uint8_t* buf, int len);
int _5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len);
bool get5G_S_TMSI(uint16_t& amfSetId, uint8_t& amfPointer, string& tmsi);
bool get5G_S_TMSI(uint16_t& amfSetId, uint8_t& amfPointer, std::string& tmsi);
void set5G_S_TMSI(
const uint16_t amfSetId, const uint8_t amfPointer,
const std::string tmsi);
// IMEISV
int imeisv_encode2buffer(uint8_t* buf, int len);
......
......@@ -68,7 +68,8 @@ void ServiceRequest::setServiceType(uint8_t stp) {
//------------------------------------------------------------------------------
void ServiceRequest::set5G_S_TMSI(
uint16_t amfSetId, uint8_t amfPointer, string tmsi) {
ie_5g_s_tmsi = new _5GSMobileIdentity(0x00, amfSetId, amfPointer, tmsi);
ie_5g_s_tmsi = new _5GSMobileIdentity(0x00);
ie_5g_s_tmsi->set5G_S_TMSI(amfSetId, amfPointer, tmsi);
}
//------------------------------------------------------------------------------
......
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