Commit 1b0cacb0 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code refactor for 5GSMobileIdentity

parent 5d3d05e5
......@@ -85,6 +85,7 @@ enum class RegistrationTypeEnum {
EMERGENCY_REGISTRATION = 0b100,
RESERVED = 0b111
};
#define INITIAL_REGISTRATION 0b001
#define MOBILITY_REGISTRATION_UPDATING 0b010
#define PERIODIC_REGISTRATION_UPDATING 0b011
......@@ -98,12 +99,22 @@ enum class RegistrationTypeEnum {
/********* 5GSMobilityIdentity **********/
enum class _5GSMobilityIdentityEnum {
NO_IDENTITY = 0b000,
SUCI = 0b001,
_5G_GUTI = 0b010,
IMEI = 0b011,
_5G_S_TMSI = 0b100,
IMEISV = 0b101,
MAC_ADDRESS = 0b110
};
#define NO_IDENTITY 0b000
#define SUCI 0b001
#define _5G_GUTI 0b010
#define IMEI 0b011
#define _5G_S_TMSI 0b100
#define IMEISVI 0b101
#define IMEISV 0b101
#define MAC_ADDRESS 0b110
#define EVEN_IENTITY 0
......
......@@ -19,9 +19,9 @@
* contact@openairinterface.org
*/
#include "../ies/5GSMobileIdentity.hpp"
#include "NasMmPlainHeader.hpp"
#include "5GMMCapability.hpp"
#include "5GSMobilityIdentity.hpp"
#include "5GSRegistrationType.hpp"
#include "ABBA.hpp"
#include "Additional_5G_Security_Information.hpp"
......
......@@ -19,14 +19,7 @@
* contact@openairinterface.org
*/
/*! \file 5GSMobilityIdentity.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "5GSMobilityIdentity.hpp"
#include "5GSMobileIdentity.hpp"
#include <math.h>
......@@ -38,7 +31,7 @@
using namespace nas;
//------------------------------------------------------------------------------
_5GSMobilityIdentity::_5GSMobilityIdentity() {
_5GSMobileIdentity::_5GSMobileIdentity() {
iei = 0;
_5g_guti = nullptr;
imei_imeisv = nullptr;
......@@ -51,7 +44,7 @@ _5GSMobilityIdentity::_5GSMobilityIdentity() {
}
//------------------------------------------------------------------------------
_5GSMobilityIdentity::_5GSMobilityIdentity(
_5GSMobileIdentity::_5GSMobileIdentity(
uint8_t _iei, const uint16_t amfSetId, const uint8_t amfPointer,
const string tmsi) {
iei = _iei;
......@@ -71,7 +64,7 @@ _5GSMobilityIdentity::_5GSMobilityIdentity(
}
//------------------------------------------------------------------------------
_5GSMobilityIdentity::_5GSMobilityIdentity(
_5GSMobileIdentity::_5GSMobileIdentity(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin) {
iei = 0;
......@@ -94,15 +87,15 @@ _5GSMobilityIdentity::_5GSMobilityIdentity(
}
//------------------------------------------------------------------------------
_5GSMobilityIdentity::~_5GSMobilityIdentity() {}
_5GSMobileIdentity::~_5GSMobileIdentity() {}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::setIEI(uint8_t _iei) {
void _5GSMobileIdentity::setIEI(uint8_t _iei) {
iei = _iei;
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_s_tmsi_encode2buffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::_5g_s_tmsi_encode2buffer(uint8_t* buf, int len) {
int encoded_size = 0;
if (iei) {
*buf = iei;
......@@ -132,7 +125,7 @@ int _5GSMobilityIdentity::_5g_s_tmsi_encode2buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
int decoded_size = 0;
if (!_5g_s_tmsi) _5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t));
decoded_size++; // type of identity
......@@ -170,7 +163,7 @@ int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
bool _5GSMobilityIdentity::get5G_S_TMSI(
bool _5GSMobileIdentity::get5G_S_TMSI(
uint16_t& amfSetId, uint8_t& amfPointer, string& tmsi) {
if (!_5g_s_tmsi) return false;
amfSetId = _5g_s_tmsi->amf_set_id;
......@@ -180,7 +173,7 @@ bool _5GSMobilityIdentity::get5G_S_TMSI(
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::set5GGUTI(
void _5GSMobileIdentity::set5GGUTI(
const string mcc, const string mnc, uint8_t amf_region_id,
uint16_t amf_set_id, uint8_t amf_pointer, const uint32_t _5g_tmsi) {
typeOfIdentity = _5G_GUTI;
......@@ -196,7 +189,7 @@ void _5GSMobilityIdentity::set5GGUTI(
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::setSuciWithSupiImsi(
void _5GSMobileIdentity::setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, const string& msin_digits) {
if (supi_format_imsi == nullptr)
......@@ -211,7 +204,7 @@ void _5GSMobilityIdentity::setSuciWithSupiImsi(
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::setSuciWithSupiImsi(
void _5GSMobileIdentity::setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, uint8_t home_pki, const string& msin_digits) {
if (supi_format_imsi == nullptr)
......@@ -222,12 +215,12 @@ void _5GSMobilityIdentity::setSuciWithSupiImsi(
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::getSuciWithSupiImsi(SUCI_imsi_t& ptr) {
void _5GSMobileIdentity::getSuciWithSupiImsi(SUCI_imsi_t& ptr) {
ptr = *supi_format_imsi;
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::get5GGUTI(_5G_GUTI_t& ptr) {
void _5GSMobileIdentity::get5GGUTI(_5G_GUTI_t& ptr) {
// ptr = *_5g_guti;
ptr.mcc = _5g_guti->mcc;
ptr.mnc = _5g_guti->mnc;
......@@ -238,8 +231,8 @@ void _5GSMobilityIdentity::get5GGUTI(_5G_GUTI_t& ptr) {
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::setIMEISV(IMEISV_t imeisv) {
typeOfIdentity = IMEISVI;
void _5GSMobileIdentity::setIMEISV(IMEISV_t imeisv) {
typeOfIdentity = IMEISV;
// imei_imeisv->odd_even_indic = 1;
// imei_imeisv->identity = ((uint8_t*)imeisv.identity->data[0] & 0xf0) >> 4;
length = blength(imeisv.identity) - 1 + 4;
......@@ -248,12 +241,12 @@ void _5GSMobilityIdentity::setIMEISV(IMEISV_t imeisv) {
}
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::getIMEISV(IMEISV_t& imeisv) {
void _5GSMobileIdentity::getIMEISV(IMEISV_t& imeisv) {
imeisv.identity = bstrcpy(_IMEISV.identity);
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::encode2Buffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::encode2Buffer(uint8_t* buf, int len) {
switch (typeOfIdentity) {
case SUCI: {
return suci_encode2buffer(buf, len);
......@@ -261,7 +254,7 @@ int _5GSMobilityIdentity::encode2Buffer(uint8_t* buf, int len) {
case _5G_GUTI: {
return _5g_guti_encode2buffer(buf, len);
} break;
case IMEISVI: {
case IMEISV: {
return imeisv_encode2buffer(buf, len);
} break;
case _5G_S_TMSI: {
......@@ -272,10 +265,11 @@ int _5GSMobilityIdentity::encode2Buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::suci_encode2buffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::suci_encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding SUCI IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("error: len is less than %d", length);
int encoded_size = 0;
if (iei) {
Logger::nas_mm().debug(
......@@ -318,7 +312,7 @@ int _5GSMobilityIdentity::suci_encode2buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_guti_encode2buffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::_5g_guti_encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding 5G-GUTI IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("Error: len is less than %d", length);
......@@ -377,7 +371,7 @@ int _5GSMobilityIdentity::_5g_guti_encode2buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::encodeMssMnc2buffer(
int _5GSMobileIdentity::encodeMssMnc2buffer(
string mccstr, string mncstr, uint8_t* buf) {
int encoded_size = 0;
int mcc = fromString<int>(mccstr);
......@@ -409,7 +403,7 @@ int _5GSMobilityIdentity::encodeMssMnc2buffer(
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::encodeRoutid2buffer(string routidstr, uint8_t* buf) {
int _5GSMobileIdentity::encodeRoutid2buffer(string routidstr, uint8_t* buf) {
Logger::nas_mm().debug("routid(%s)", routidstr.c_str());
int encoded_size = 0;
if (routidstr == (const string)("none")) {
......@@ -453,12 +447,12 @@ int _5GSMobilityIdentity::encodeRoutid2buffer(string routidstr, uint8_t* buf) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::encodeMSIN2buffer(string msinstr, uint8_t* buf) {
int _5GSMobileIdentity::encodeMSIN2buffer(string msinstr, uint8_t* buf) {
return 1;
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::imeisv_encode2buffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::imeisv_encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding IMEISV IE IEI 0x%x", iei);
if (len < length)
Logger::nas_mm().debug("Error: len is less than %d", length);
......@@ -472,7 +466,7 @@ int _5GSMobilityIdentity::imeisv_encode2buffer(uint8_t* buf, int len) {
int size = encode_bstring(
_IMEISV.identity, (buf + encoded_size), len - encoded_size);
encoded_size += size;
*(buf + 3) |= (0x01 << 3) | IMEISVI;
*(buf + 3) |= (0x01 << 3) | IMEISV;
} else {
}
if (!iei) {
......@@ -485,7 +479,7 @@ int _5GSMobilityIdentity::imeisv_encode2buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::decodeFromBuffer(
int _5GSMobileIdentity::decodeFromBuffer(
uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity");
int decoded_size = 0;
......@@ -515,8 +509,8 @@ int _5GSMobilityIdentity::decodeFromBuffer(
_5g_guti_decodefrombuffer(buf + decoded_size, len - decoded_size);
return decoded_size;
} break;
case IMEISVI: {
typeOfIdentity = IMEISVI;
case IMEISV: {
typeOfIdentity = IMEISV;
decoded_size += imeisv_decodefrombuffer(buf + decoded_size, length);
return decoded_size;
} break;
......@@ -531,7 +525,7 @@ int _5GSMobilityIdentity::decodeFromBuffer(
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::suci_decodefrombuffer(
int _5GSMobileIdentity::suci_decodefrombuffer(
uint8_t* buf, int len, int ie_len) {
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity SUCI");
int decoded_size = 0;
......@@ -638,7 +632,7 @@ int _5GSMobilityIdentity::suci_decodefrombuffer(
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding 5GSMobilityIdentity 5G-GUTI");
int decoded_size = 0;
uint8_t octet = 0;
......@@ -695,7 +689,7 @@ int _5GSMobilityIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::imeisv_decodefrombuffer(uint8_t* buf, int len) {
int _5GSMobileIdentity::imeisv_decodefrombuffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("decoding 5GSMobilityIdentity IMEISV");
int decoded_size = 0;
decode_bstring(
......
......@@ -19,19 +19,11 @@
* contact@openairinterface.org
*/
/*! \file 5GSMobilityIdentity.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GS_MOBILE_IDENTITY_H_
#define _5GS_MOBILE_IDENTITY_H_
#ifndef _5GSMobilityIdentity_H_
#define _5GSMobilityIdentity_H_
#include <stdint.h>
#include <iostream>
#include "struct.hpp"
extern "C" {
#include "TLVDecoder.h"
......@@ -42,6 +34,7 @@ using namespace std;
namespace nas {
// 5G-GUTI
typedef struct _5G_GUTI_s {
string mcc;
string mnc;
......@@ -49,9 +42,9 @@ typedef struct _5G_GUTI_s {
uint8_t amf_set_id;
uint16_t amf_pointer;
uint32_t _5g_tmsi;
} _5G_GUTI_t;
// IMEI or IMEISV
typedef struct IMEI_or_IMEISV_s {
uint8_t typeOfIdentity : 3;
bool odd_even_indic; // for imei, even means bits 5 to 8 of last octet is
......@@ -60,6 +53,7 @@ typedef struct IMEI_or_IMEISV_s {
string identity; // "46011000001"
} IMEI_IMEISV_t;
// SUCI and SUPI format IMSI
typedef struct SUCI_imsi_s {
uint8_t supi_format : 3;
string mcc;
......@@ -70,25 +64,34 @@ typedef struct SUCI_imsi_s {
string msin; // two types of coding; BCD & hexadecimal
} SUCI_imsi_t; // SUPI format "IMSI"
// don't define suci and supi format "Network specific identifier"
// TODO: SUCI and SUPI format "Network specific identifier"
// 5G-S-TMSI
typedef struct _5G_S_TMSI_s {
uint16_t amf_set_id;
uint8_t amf_pointer;
string _5g_tmsi;
} _5G_S_TMSI_t;
class _5GSMobilityIdentity {
// TODO: 5GS mobile identity information element for type of identity "MAC
// address"
class _5GSMobileIdentity {
public:
_5GSMobilityIdentity(
_5GSMobileIdentity(
uint8_t _iei, const uint16_t amfSetId, const uint8_t amfPointer,
const string tmsi);
_5GSMobilityIdentity(
const string tmsi); // 5G-S-TMSI
_5GSMobileIdentity(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin);
_5GSMobilityIdentity();
~_5GSMobilityIdentity();
uint8_t protection_sch_id,
const string msin); // SUCI and SUPI format IMSI
_5GSMobileIdentity();
~_5GSMobileIdentity();
uint8_t getTypeOfIdentity() const { return typeOfIdentity; };
void setIEI(uint8_t _iei);
int encode2Buffer(uint8_t* buf, int len);
int suci_encode2buffer(uint8_t* buf, int len);
int _5g_guti_encode2buffer(uint8_t* buf, int len);
......@@ -98,12 +101,18 @@ class _5GSMobilityIdentity {
int _5g_s_tmsi_encode2buffer(uint8_t* buf, int len);
int _5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len);
int imeisv_encode2buffer(uint8_t* buf, int len);
int imeisv_decodefrombuffer(uint8_t* buf, int len);
int decodeFromBuffer(uint8_t* buf, int len, bool is_option);
int suci_decodefrombuffer(uint8_t* buf, int len, int length);
int _5g_guti_decodefrombuffer(uint8_t* buf, int len);
void set5GGUTI(
const string mcc, const string mnc, uint8_t amf_region_id,
uint16_t amf_set_id, uint8_t amf_pointer, const uint32_t _5g_tmsi);
void get5GGUTI(_5G_GUTI_t&);
void setSuciWithSupiImsi(
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, uint8_t home_pki, const string& msin_digits);
......@@ -111,24 +120,22 @@ class _5GSMobilityIdentity {
const string& mcc, const string& mnc, const string& routingInd,
uint8_t protecSchId, const string& msin_digits);
void getSuciWithSupiImsi(SUCI_imsi_t&);
void get5GGUTI(_5G_GUTI_t&);
uint8_t gettypeOfIdentity() { return typeOfIdentity; };
bool get5G_S_TMSI(uint16_t& amfSetId, uint8_t& amfPointer, string& tmsi);
void setIMEISV(IMEISV_t imeisv);
void getIMEISV(IMEISV_t& imeisv);
int imeisv_encode2buffer(uint8_t* buf, int len);
int imeisv_decodefrombuffer(uint8_t* buf, int len);
private:
uint8_t iei;
uint16_t length;
uint8_t typeOfIdentity : 3;
_5G_GUTI_t* _5g_guti;
IMEI_IMEISV_t* imei_imeisv;
SUCI_imsi_t* supi_format_imsi;
_5G_S_TMSI_t* _5g_s_tmsi;
bool is_no_identity;
uint16_t length;
uint8_t typeOfIdentity : 3;
IMEISV_t _IMEISV;
};
......
......@@ -47,7 +47,10 @@ NasKeySetIdentifier::NasKeySetIdentifier(
}
//------------------------------------------------------------------------------
int NasKeySetIdentifier::encode2Buffer(uint8_t* buf, int len) {
NasKeySetIdentifier::~NasKeySetIdentifier(){};
//------------------------------------------------------------------------------
int NasKeySetIdentifier::encode2Buffer(uint8_t* buf, const int& len) {
Logger::nas_mm().debug("Encoding NasKeySetIdentifier IE (IEI 0x%x)", iei_);
if (len < kType1IeSize) {
Logger::nas_mm().error(
......@@ -73,7 +76,7 @@ int NasKeySetIdentifier::encode2Buffer(uint8_t* buf, int len) {
//------------------------------------------------------------------------------
int NasKeySetIdentifier::decodeFromBuffer(
uint8_t* buf, int len, bool is_option, bool is_high) {
uint8_t* buf, const int& len, bool is_option, bool is_high) {
Logger::nas_mm().debug("Decoding NasKeySetIdentifier IE");
if (len < kType1IeSize) {
......@@ -109,21 +112,21 @@ int NasKeySetIdentifier::decodeFromBuffer(
}
//------------------------------------------------------------------------------
void NasKeySetIdentifier::setTypeOfSecurityContext(uint8_t type) {
void NasKeySetIdentifier::setTypeOfSecurityContext(const uint8_t& type) {
tsc_ = 0x01 & type;
}
//------------------------------------------------------------------------------
void NasKeySetIdentifier::setNasKeyIdentifier(uint8_t id) {
void NasKeySetIdentifier::setNasKeyIdentifier(const uint8_t& id) {
key_id_ = 0x07 & id;
}
//------------------------------------------------------------------------------
uint8_t NasKeySetIdentifier::getTypeOfSecurityContext() {
uint8_t NasKeySetIdentifier::getTypeOfSecurityContext() const {
return tsc_;
}
//------------------------------------------------------------------------------
uint8_t NasKeySetIdentifier::getasKeyIdentifier() {
uint8_t NasKeySetIdentifier::getNasKeyIdentifier() const {
return key_id_;
}
......@@ -34,13 +34,14 @@ class NasKeySetIdentifier {
NasKeySetIdentifier(const uint8_t& tsc, const uint8_t& key_id);
~NasKeySetIdentifier();
int encode2Buffer(uint8_t* buf, int len);
int decodeFromBuffer(uint8_t* buf, int len, bool is_option, bool is_high);
void setTypeOfSecurityContext(uint8_t type);
void setNasKeyIdentifier(uint8_t id);
uint8_t getTypeOfSecurityContext();
uint8_t getasKeyIdentifier();
int encode2Buffer(uint8_t* buf, const int& len);
int decodeFromBuffer(
uint8_t* buf, const int& len, bool is_option, bool is_high);
void setTypeOfSecurityContext(const uint8_t& type);
void setNasKeyIdentifier(const uint8_t& id);
uint8_t getTypeOfSecurityContext() const;
uint8_t getNasKeyIdentifier() const;
private:
uint8_t iei_;
......
......@@ -86,8 +86,8 @@ void DeregistrationRequest::getDeregistrationType(
//------------------------------------------------------------------------------
bool DeregistrationRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
ng_ksi = (ie_ngKSI->getTypeOfSecurityContext()) |
ie_ngKSI->getNasKeyIdentifier();
return true;
} else {
// ng_ksi = 0;
......@@ -106,14 +106,14 @@ void DeregistrationRequest::setSUCI_SUPI_format_IMSI(
return;
} else {
ie_5gs_mobility_id =
new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
new _5GSMobileIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getMobilityIdentityType(uint8_t& type) {
if (ie_5gs_mobility_id) {
type = ie_5gs_mobility_id->gettypeOfIdentity();
type = ie_5gs_mobility_id->getTypeOfIdentity();
} else {
type = 0;
}
......@@ -219,7 +219,7 @@ int DeregistrationRequest::decodeFromBuffer(
decoded_size += ie_ngKSI->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false, true);
decoded_size++;
ie_5gs_mobility_id = new _5GSMobilityIdentity();
ie_5gs_mobility_id = new _5GSMobileIdentity();
decoded_size += ie_5gs_mobility_id->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug(
......
......@@ -67,7 +67,7 @@ class DeregistrationRequest {
NasMmPlainHeader* plain_header;
_5GSDeregistrationType* ie_deregistrationtype;
NasKeySetIdentifier* ie_ngKSI;
_5GSMobilityIdentity* ie_5gs_mobility_id;
_5GSMobileIdentity* ie_5gs_mobility_id;
};
} // namespace nas
......
......@@ -61,7 +61,7 @@ void IdentityResponse::setSUCI_SUPI_format_IMSI(
return;
} else {
ie_mobility_id =
new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
new _5GSMobileIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
}
}
......@@ -111,7 +111,7 @@ int IdentityResponse::decodeFromBuffer(
Logger::nas_mm().debug("decoding IdentityResponse message");
int decoded_size = 3;
plain_header = header;
ie_mobility_id = new _5GSMobilityIdentity();
ie_mobility_id = new _5GSMobileIdentity();
decoded_size += ie_mobility_id->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
......
......@@ -49,10 +49,10 @@ class IdentityResponse {
void set5G_GUTI();
void setIMEI_IMEISV();
void set5G_S_TMSI();
/*** belongs to _5GSMobilityIdentity**/
/*** belongs to _5GSMobileIdentity**/
public:
NasMmPlainHeader* plain_header;
_5GSMobilityIdentity* ie_mobility_id;
_5GSMobileIdentity* ie_mobility_id;
};
} // namespace nas
......
......@@ -95,7 +95,7 @@ void RegistrationAccept::setSUCI_SUPI_format_IMSI(
return;
} else {
ie_5g_guti =
new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
new _5GSMobileIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
ie_5g_guti->setIEI(0x77);
}
}
......@@ -109,7 +109,7 @@ void RegistrationAccept::setSUCI_SUPI_format_IMSI(
void RegistrationAccept::set5G_GUTI(
const string mcc, const string mnc, const string amfRegionId,
const string amfSetId, const string amfPointer, const uint32_t tmsi) {
ie_5g_guti = new _5GSMobilityIdentity();
ie_5g_guti = new _5GSMobileIdentity();
int regionId = fromString<int>(amfRegionId);
int setId = fromString<int>(amfSetId);
int pointer = fromString<int>(amfPointer);
......@@ -661,7 +661,7 @@ int RegistrationAccept::decodeFromBuffer(
switch (octet) {
case 0x77: {
Logger::nas_mm().debug("Decoding IEI (0x77)");
ie_5g_guti = new _5GSMobilityIdentity();
ie_5g_guti = new _5GSMobileIdentity();
decoded_size += ie_5g_guti->decodeFromBuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
......
......@@ -43,7 +43,7 @@ class RegistrationAccept {
void setSOR_Transparent_Container(uint8_t header, uint8_t* value);
void set_5GS_Registration_Result(
bool emergency, bool nssaa, bool sms, uint8_t value);
/*** belongs to _5GSMobilityIdentity**/
/*** belongs to _5GSMobileIdentity**/
void setSUCI_SUPI_format_IMSI(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin);
......@@ -55,7 +55,7 @@ class RegistrationAccept {
const string amfSetId, const string amfPointer, const uint32_t tmsi);
void setIMEI_IMEISV();
void set5G_S_TMSI();
/*** belongs to _5GSMobilityIdentity**/
/*** belongs to _5GSMobileIdentity**/
void setEquivalent_PLMNs(
uint8_t MNC_MCC1, uint8_t MNC_MCC2, uint8_t MNC_MCC3);
void setALLOWED_NSSAI(std::vector<struct SNSSAI_s> nssai);
......@@ -87,7 +87,7 @@ class RegistrationAccept {
public:
NasMmPlainHeader* plain_header;
_5GS_Registration_Result* ie_5gs_registration_result;
_5GSMobilityIdentity* ie_5g_guti;
_5GSMobileIdentity* ie_5g_guti;
PLMN_List* ie_equivalent_plmns;
NSSAI* ie_allowed_nssai;
Rejected_NSSAI* ie_rejected_nssai;
......
......@@ -39,7 +39,7 @@ RegistrationRequest::RegistrationRequest()
: NasMmPlainHeader(EPD_5GS_MM_MSG, REGISTRATION_REQUEST) {
// plain_header = nullptr;
// ie_5gsregistrationtype = nullptr;
ie_ngKSI = nullptr;
// ie_ngKSI = nullptr;
ie_5gs_mobility_id = nullptr;
ie_non_current_native_nas_ksi = nullptr;
ie_5g_mm_capability = nullptr;
......@@ -90,19 +90,15 @@ bool RegistrationRequest::get5GSRegistrationType(
//------------------------------------------------------------------------------
void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
ie_ngKSI = new NasKeySetIdentifier(tsc, key_set_id);
ie_ngKSI.setNasKeyIdentifier(key_set_id);
ie_ngKSI.setTypeOfSecurityContext(tsc);
}
//------------------------------------------------------------------------------
bool RegistrationRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
(ie_ngKSI.getTypeOfSecurityContext()) | ie_ngKSI.getNasKeyIdentifier();
return true;
} else {
// ng_ksi = 0;
return false;
}
}
//------------------------------------------------------------------------------
......@@ -116,14 +112,14 @@ void RegistrationRequest::setSUCI_SUPI_format_IMSI(
return;
} else {
ie_5gs_mobility_id =
new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
new _5GSMobileIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
uint8_t RegistrationRequest::getMobilityIdentityType() {
if (ie_5gs_mobility_id) {
return ie_5gs_mobility_id->gettypeOfIdentity();
return ie_5gs_mobility_id->getTypeOfIdentity();
} else {
return 0;
}
......@@ -165,7 +161,7 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
choose right interface"); return;
}
else {*/
ie_additional_guti = new _5GSMobilityIdentity();
ie_additional_guti = new _5GSMobileIdentity();
ie_additional_guti->setIEI(0x77);
uint32_t tmsi = fromString<uint32_t>(_5g_tmsi);
ie_additional_guti->set5GGUTI(
......@@ -208,7 +204,7 @@ uint8_t RegistrationRequest::getNonCurrentNativeNasKSI() {
if (ie_non_current_native_nas_ksi) {
uint8_t a = 0;
a |= (ie_non_current_native_nas_ksi->getTypeOfSecurityContext()) |
(ie_non_current_native_nas_ksi->getasKeyIdentifier());
(ie_non_current_native_nas_ksi->getNasKeyIdentifier());
return a;
} else {
return 0;
......@@ -557,10 +553,11 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
return 0;
}
*/
if (!ie_ngKSI) {
/*if (!ie_ngKSI) {
Logger::nas_mm().error("Mandatory IE missing ie_ngKSI");
return 0;
}
}*/
if (!ie_5gs_mobility_id) {
Logger::nas_mm().error("Mandatory IE missing ie_5gs_mobility_id");
return 0;
......@@ -569,21 +566,21 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
encoded_size += 3;
if (!(ie_5gsregistrationtype.encode2Buffer(
buf + encoded_size, len - encoded_size))) {
if (!(ie_ngKSI->encode2Buffer(buf + encoded_size, len - encoded_size))) {
if (!(ie_ngKSI.encode2Buffer(buf + encoded_size, len - encoded_size))) {
encoded_size += 1;
} else {
Logger::nas_mm().error("encoding ie ie_ngKSI error");
Logger::nas_mm().error("Encoding IE ie_ngKSI error");
return 0;
}
} else {
Logger::nas_mm().error("encoding ie 5gsregistrationtype error");
Logger::nas_mm().error("Encoding IE 5gsregistrationtype error");
return 0;
}
if (int size = ie_5gs_mobility_id->encode2Buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie ie_5gs_mobility_id error");
Logger::nas_mm().error("Encoding IE ie_5gs_mobility_id error");
return 0;
}
if (!ie_non_current_native_nas_ksi) {
......@@ -593,7 +590,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
buf + encoded_size, len - encoded_size) == 1) {
encoded_size++;
} else {
Logger::nas_mm().error("encoding ie_non_current_native_nas_ksi error");
Logger::nas_mm().error("Encoding IE_non_current_native_nas_ksi error");
}
}
if (!ie_5g_mm_capability) {
......@@ -843,11 +840,10 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
// ie_5gsregistrationtype = new _5GSRegistrationType();
decoded_size += ie_5gsregistrationtype.decodeFromBuffer(
buf + decoded_size, len - decoded_size, false);
ie_ngKSI = new NasKeySetIdentifier();
decoded_size += ie_ngKSI->decodeFromBuffer(
decoded_size += ie_ngKSI.decodeFromBuffer(
buf + decoded_size, len - decoded_size, false, true);
decoded_size++;
ie_5gs_mobility_id = new _5GSMobilityIdentity();
ie_5gs_mobility_id = new _5GSMobileIdentity();
decoded_size += ie_5gs_mobility_id->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false);
uint8_t octet = *(buf + decoded_size);
......@@ -958,7 +954,7 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
} break;
case 0x77: {
Logger::nas_mm().debug("Decoding IEI (0x77)");
ie_additional_guti = new _5GSMobilityIdentity();
ie_additional_guti = new _5GSMobileIdentity();
decoded_size += ie_additional_guti->decodeFromBuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
......
......@@ -148,8 +148,8 @@ class RegistrationRequest : public NasMmPlainHeader {
public:
// NasMmPlainHeader* plain_header;
_5GSRegistrationType ie_5gsregistrationtype; // Mandatory
NasKeySetIdentifier* ie_ngKSI; // Mandatory
_5GSMobilityIdentity* ie_5gs_mobility_id; // Mandatory
NasKeySetIdentifier ie_ngKSI; // Mandatory
_5GSMobileIdentity* ie_5gs_mobility_id; // Mandatory
NasKeySetIdentifier* ie_non_current_native_nas_ksi; // Optional
_5GMMCapability* ie_5g_mm_capability; // Optional
......@@ -162,7 +162,7 @@ class RegistrationRequest : public NasMmPlainHeader {
PDU_Session_Status* ie_PDU_session_status; // Optional
MICO_Indication* ie_MICO_indicationl; // Optional
UE_Status* ie_ue_status; // Optional
_5GSMobilityIdentity* ie_additional_guti; // Optional
_5GSMobileIdentity* ie_additional_guti; // Optional
Allowed_PDU_Session_Status* ie_allowed_PDU_session_status; // Optional
UES_Usage_Setting* ie_ues_usage_setting; // Optional
_5GS_DRX_arameters* ie_5gs_drx_parameters; // Optional
......
......@@ -54,7 +54,7 @@ void SecurityModeComplete::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void SecurityModeComplete::setIMEISV(IMEISV_t imeisv) {
ie_imeisv = new _5GSMobilityIdentity();
ie_imeisv = new _5GSMobileIdentity();
ie_imeisv->setIEI(0x77);
ie_imeisv->setIMEISV(imeisv);
}
......@@ -66,7 +66,7 @@ void SecurityModeComplete::setNAS_Message_Container(bstring value) {
//------------------------------------------------------------------------------
void SecurityModeComplete::setNON_IMEISV(IMEISV_t imeisv) {
ie_non_imeisvpei = new _5GSMobilityIdentity();
ie_non_imeisvpei = new _5GSMobileIdentity();
ie_non_imeisvpei->setIEI(0x78);
ie_non_imeisvpei->setIMEISV(imeisv);
}
......@@ -164,7 +164,7 @@ int SecurityModeComplete::decodeFromBuffer(
switch (octet) {
case 0x77: {
Logger::nas_mm().debug("Decoding IEI (0x77)");
ie_imeisv = new _5GSMobilityIdentity();
ie_imeisv = new _5GSMobileIdentity();
decoded_size += ie_imeisv->decodeFromBuffer(
buf + decoded_size, len - decoded_size, true);
} break;
......@@ -176,7 +176,7 @@ int SecurityModeComplete::decodeFromBuffer(
} break;
case 0x78: {
Logger::nas_mm().debug("Decoding IEI (0x78)");
ie_non_imeisvpei = new _5GSMobilityIdentity();
ie_non_imeisvpei = new _5GSMobileIdentity();
decoded_size += ie_non_imeisvpei->decodeFromBuffer(
buf + decoded_size, len - decoded_size, true);
} break;
......
......@@ -51,9 +51,9 @@ class SecurityModeComplete {
public:
NasMmPlainHeader* plain_header;
_5GSMobilityIdentity* ie_imeisv;
_5GSMobileIdentity* ie_imeisv;
NAS_Message_Container* ie_nas_message_container;
_5GSMobilityIdentity* ie_non_imeisvpei;
_5GSMobileIdentity* ie_non_imeisvpei;
};
} // namespace nas
......
......@@ -68,7 +68,7 @@ void ServiceRequest::setServiceType(uint8_t stp) {
//------------------------------------------------------------------------------
void ServiceRequest::set5G_S_TMSI(
uint16_t amfSetId, uint8_t amfPointer, string tmsi) {
ie_5g_s_tmsi = new _5GSMobilityIdentity(0x00, amfSetId, amfPointer, tmsi);
ie_5g_s_tmsi = new _5GSMobileIdentity(0x00, amfSetId, amfPointer, tmsi);
}
//------------------------------------------------------------------------------
......@@ -198,7 +198,7 @@ int ServiceRequest::decodeFromBuffer(
decoded_size += ie_service_type->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false, true);
decoded_size++;
ie_5g_s_tmsi = new _5GSMobilityIdentity();
ie_5g_s_tmsi = new _5GSMobileIdentity();
decoded_size += ie_5g_s_tmsi->decodeFromBuffer(
buf + decoded_size, len - decoded_size, false);
uint8_t octet = *(buf + decoded_size);
......@@ -248,8 +248,8 @@ int ServiceRequest::decodeFromBuffer(
//------------------------------------------------------------------------------
bool ServiceRequest::getngKSI(uint8_t& ng_ksi) {
if (ie_ngKSI) {
ng_ksi =
(ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
ng_ksi = (ie_ngKSI->getTypeOfSecurityContext()) |
ie_ngKSI->getNasKeyIdentifier();
return true;
} else {
return false;
......
......@@ -68,7 +68,7 @@ class ServiceRequest {
NasMmPlainHeader* plain_header;
NasKeySetIdentifier* ie_ngKSI;
ServiceType* ie_service_type;
_5GSMobilityIdentity* ie_5g_s_tmsi;
_5GSMobileIdentity* ie_5g_s_tmsi;
UplinkDataStatus* ie_uplink_data_status;
PDU_Session_Status* ie_PDU_session_status;
Allowed_PDU_Session_Status* ie_allowed_PDU_session_status;
......
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