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