Commit c892f4d6 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Identity Response

parent 30c34599
......@@ -705,17 +705,17 @@ void amf_n1::identity_response_handle(
bstring plain_msg) {
auto identity_response = std::make_unique<IdentityResponse>();
if (!identity_response->Decode(
NULL, (uint8_t*) bdata(plain_msg), blength(plain_msg))) {
(uint8_t*) bdata(plain_msg), blength(plain_msg))) {
Logger::amf_n1().error("Decode Identity Response error");
return;
}
string supi = {};
if (identity_response->ie_mobility_id) {
nas::SUCI_imsi_t imsi;
identity_response->ie_mobility_id->GetSuciWithSupiImsi(imsi);
supi = imsi.mcc + imsi.mnc + imsi.msin;
Logger::amf_n1().debug("Identity Response: SUCI (%s)", supi.c_str());
}
//_5GSMobileIdentity mobile_identity = {};
// TODO: avoid accessing member function directly
nas::SUCI_imsi_t imsi = {};
identity_response->ie_mobile_identity.GetSuciWithSupiImsi(imsi);
supi = imsi.mcc + imsi.mnc + imsi.msin;
Logger::amf_n1().debug("Identity Response: SUCI (%s)", supi.c_str());
string ue_context_key = "app_ue_ranid_" + to_string(ran_ue_ngap_id) +
":amfid_" + to_string(amf_ue_ngap_id);
......@@ -2540,7 +2540,7 @@ void amf_n1::security_mode_complete_handle(
// TODO:
return;
}
registration_accept->set5G_GUTI(
registration_accept->Set5gGuti(
mcc, mnc, amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID,
amf_cfg.guami.AmfPointer, tmsi);
......@@ -3373,7 +3373,7 @@ void amf_n1::run_mobility_registration_update_procedure(
return;
}
reg_accept->set5G_GUTI(
reg_accept->Set5gGuti(
amf_cfg.guami.mcc, amf_cfg.guami.mnc, amf_cfg.guami.regionID,
amf_cfg.guami.AmfSetID, amf_cfg.guami.AmfPointer, uc->tmsi);
......@@ -3457,7 +3457,7 @@ void amf_n1::run_periodic_registration_update_procedure(
return;
}
reg_accept->set5G_GUTI(
reg_accept->Set5gGuti(
amf_cfg.guami.mcc, amf_cfg.guami.mnc, amf_cfg.guami.regionID,
amf_cfg.guami.AmfSetID, amf_cfg.guami.AmfPointer, uc->tmsi);
......@@ -3525,7 +3525,7 @@ void amf_n1::run_periodic_registration_update_procedure(
return;
}
reg_accept->set5G_GUTI(
reg_accept->Set5gGuti(
amf_cfg.guami.mcc, amf_cfg.guami.mnc, amf_cfg.guami.regionID,
amf_cfg.guami.AmfSetID, amf_cfg.guami.AmfPointer, uc->tmsi);
......
......@@ -97,7 +97,7 @@ bool DeregistrationRequest::getngKSI(uint8_t& ng_ksi) {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(
void DeregistrationRequest::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin) {
if (protection_sch_id != NULL_SCHEME) {
......@@ -151,15 +151,15 @@ std::string DeregistrationRequest::get_5g_guti() {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(
void DeregistrationRequest::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin) {}
//------------------------------------------------------------------------------
void DeregistrationRequest::set5G_GUTI() {}
void DeregistrationRequest::Set5gGuti() {}
//------------------------------------------------------------------------------
void DeregistrationRequest::setIMEI_IMEISV() {}
void DeregistrationRequest::SetImeiImeisv() {}
//------------------------------------------------------------------------------
void DeregistrationRequest::Set5gSTmsi() {}
......
......@@ -46,14 +46,14 @@ class DeregistrationRequest {
void SetNgKsi(uint8_t tsc, uint8_t key_set_id);
void setMobilityIdentityType(uint8_t type);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void Set5gGuti();
void SetImeiImeisv();
void Set5gSTmsi();
void getDeregistrationType(uint8_t& dereg_type);
......
......@@ -35,7 +35,9 @@ class IdentityRequest : public NasMmPlainHeader {
int Decode(uint8_t* buf, int len);
void SetHeader(uint8_t security_header_type);
void Set5gsIdentityType(uint8_t value);
// TODO: Get
public:
_5gsIdentityType _5gs_identity_type_; // Mandatory
......
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "IdentityResponse.hpp"
#include "3gpp_24.501.hpp"
......@@ -34,88 +27,109 @@
using namespace nas;
//------------------------------------------------------------------------------
IdentityResponse::IdentityResponse() {
Logger::nas_mm().debug("initiating class IdentityResponse");
plain_header = NULL;
ie_mobility_id = NULL;
}
IdentityResponse::IdentityResponse()
: NasMmPlainHeader(EPD_5GS_MM_MSG, IDENTITY_RESPONSE) {}
//------------------------------------------------------------------------------
IdentityResponse::~IdentityResponse() {}
//------------------------------------------------------------------------------
void IdentityResponse::SetHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->SetHeader(
EPD_5GS_MM_MSG, security_header_type, IDENTITY_RESPONSE);
NasMmPlainHeader::SetSecurityHeaderType(security_header_type);
}
//------------------------------------------------------------------------------
void IdentityResponse::setSUCI_SUPI_format_IMSI(
void IdentityResponse::Get5gsMobileIdentity(
_5GSMobileIdentity& mobile_identity) const {
mobile_identity = ie_mobile_identity;
}
//------------------------------------------------------------------------------
void IdentityResponse::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin) {
if (protection_sch_id != NULL_SCHEME) {
Logger::nas_mm().error(
"encoding suci and supi format for imsi error, please choose right "
"Encoding suci and supi format for imsi error, please choose right "
"interface");
return;
} else {
ie_mobility_id = new _5GSMobileIdentity();
ie_mobility_id->SetSuciWithSupiImsi(
ie_mobile_identity.SetSuciWithSupiImsi(
mcc, mnc, routingInd, protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
void IdentityResponse::setSUCI_SUPI_format_IMSI(
void IdentityResponse::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin) {}
uint8_t protection_sch_id, uint8_t hnpki, const string msin) {
// TODO:
}
//------------------------------------------------------------------------------
void IdentityResponse::set5G_GUTI() {}
void IdentityResponse::Set5gGuti() {
// TODO:
}
//------------------------------------------------------------------------------
void IdentityResponse::setIMEI_IMEISV() {}
void IdentityResponse::SetImeiImeisv() {
// TODO:
}
//------------------------------------------------------------------------------
void IdentityResponse::Set5gSTmsi() {}
void IdentityResponse::Set5gSTmsi() {
// TODO:
}
//------------------------------------------------------------------------------
int IdentityResponse::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding IdentityResponse message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
int encoded_size = 0;
int encoded_ie_size = 0;
// Header
if ((encoded_ie_size = NasMmPlainHeader::Encode(buf, len)) ==
KEncodeDecodeError) {
Logger::nas_mm().error("Encoding NAS Header error");
return KEncodeDecodeError;
}
if (!(plain_header->Encode(buf, len))) return 0;
encoded_size += 3;
if (!ie_mobility_id) {
Logger::nas_mm().warn("IE ie_mobility_id is not available");
encoded_size += encoded_ie_size;
// Mobile Identity
int size = ie_mobile_identity.Encode(buf + encoded_size, len - encoded_size);
if (size != KEncodeDecodeError) {
encoded_size += size;
} else {
if (int size =
ie_mobility_id->Encode(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_mobility_id error");
return 0;
}
Logger::nas_mm().error("encoding ie_mobile_identity error");
return KEncodeDecodeError;
}
Logger::nas_mm().debug(
"encoded IdentityResponse message len(%d)", encoded_size);
return 1;
"encoded IdentityResponse message len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int IdentityResponse::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
Logger::nas_mm().debug("decoding IdentityResponse message");
int decoded_size = 3;
plain_header = header;
ie_mobility_id = new _5GSMobileIdentity();
decoded_size +=
ie_mobility_id->Decode(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
int IdentityResponse::Decode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding IdentityResponse message");
int decoded_size = 0;
int decoded_result = 0;
// Header
decoded_result = NasMmPlainHeader::Decode(buf, len);
if (decoded_result == KEncodeDecodeError) {
Logger::nas_mm().error("Decoding NAS Header error");
return KEncodeDecodeError;
}
decoded_size += decoded_result;
// Mobile Identity
decoded_result =
ie_mobile_identity.Decode(buf + decoded_size, len - decoded_size, false);
if (decoded_result == KEncodeDecodeError) return KEncodeDecodeError;
decoded_size += decoded_result;
Logger::nas_mm().debug(
"decoded IdentityResponse message len(%d)", decoded_size);
return true;
return decoded_size;
}
......@@ -19,40 +19,37 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _IdentityResponse_H_
#define _IdentityResponse_H_
#ifndef _IDENTITY_RESPONSE_H_
#define _IDENTITY_RESPONSE_H_
#include "NasIeHeader.hpp"
namespace nas {
class IdentityResponse {
class IdentityResponse : public NasMmPlainHeader {
public:
IdentityResponse();
~IdentityResponse();
int Encode(uint8_t* buf, int len);
int Decode(NasMmPlainHeader* header, uint8_t* buf, int len);
int Decode(uint8_t* buf, int len);
void SetHeader(uint8_t security_header_type);
void setSUCI_SUPI_format_IMSI(
void Get5gsMobileIdentity(_5GSMobileIdentity& mobile_identity) const;
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void Set5gGuti();
void SetImeiImeisv();
void Set5gSTmsi();
/*** belongs to _5GSMobileIdentity**/
public:
NasMmPlainHeader* plain_header;
_5GSMobileIdentity* ie_mobility_id;
_5GSMobileIdentity ie_mobile_identity; // Mandatory
};
} // namespace nas
......
......@@ -82,7 +82,7 @@ void RegistrationAccept::set5GSRegistrationResult(
}
//------------------------------------------------------------------------------
void RegistrationAccept::setSUCI_SUPI_format_IMSI(
void RegistrationAccept::SetSuciSupiFormatImsi(
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, const uint8_t& protection_sch_id,
const std::string& msin) {
......@@ -101,7 +101,7 @@ void RegistrationAccept::setSUCI_SUPI_format_IMSI(
}
//------------------------------------------------------------------------------
void RegistrationAccept::setSUCI_SUPI_format_IMSI(
void RegistrationAccept::SetSuciSupiFormatImsi(
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, const uint8_t& protection_sch_id,
const uint8_t& hnpki, const std::string& msin) {
......@@ -109,7 +109,7 @@ void RegistrationAccept::setSUCI_SUPI_format_IMSI(
}
//------------------------------------------------------------------------------
void RegistrationAccept::set5G_GUTI(
void RegistrationAccept::Set5gGuti(
const std::string& mcc, const std::string& mnc,
const std::string& amfRegionId, const std::string& amfSetId,
const std::string& amfPointer, const uint32_t& tmsi) {
......@@ -124,7 +124,7 @@ void RegistrationAccept::set5G_GUTI(
}
//------------------------------------------------------------------------------
void RegistrationAccept::setIMEI_IMEISV() {}
void RegistrationAccept::SetImeiImeisv() {}
//------------------------------------------------------------------------------
void RegistrationAccept::Set5gSTmsi() {}
......
......@@ -43,20 +43,20 @@ class RegistrationAccept : public NasMmPlainHeader {
// TODO: Get
// 5GSMobileIdentity
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, const uint8_t& protection_sch_id,
const std::string& msin);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const std::string& mcc, const std::string& mnc,
const std::string& routingInd, const uint8_t& protection_sch_id,
const uint8_t& hnpki, const std::string& msin);
void set5G_GUTI(
void Set5gGuti(
const std::string& mcc, const std::string& mnc,
const std::string& amfRegionId, const std::string& amfSetId,
const std::string& amfPointer, const uint32_t& tmsi);
void setIMEI_IMEISV(); // TODO:
void Set5gSTmsi(); // TODO:
void SetImeiImeisv(); // TODO:
void Set5gSTmsi(); // TODO:
// TODO: Get
// Equivalent PLMNs
......
......@@ -90,7 +90,7 @@ bool RegistrationRequest::getngKSI(uint8_t& ng_ksi) {
}
//------------------------------------------------------------------------------
void RegistrationRequest::setSUCI_SUPI_format_IMSI(
void RegistrationRequest::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin) {
if (protection_sch_id != NULL_SCHEME) {
......@@ -157,15 +157,15 @@ bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) {
}
//------------------------------------------------------------------------------
void RegistrationRequest::setSUCI_SUPI_format_IMSI(
void RegistrationRequest::SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin) {}
//------------------------------------------------------------------------------
void RegistrationRequest::set5G_GUTI() {}
void RegistrationRequest::Set5gGuti() {}
//------------------------------------------------------------------------------
void RegistrationRequest::setIMEI_IMEISV() {}
void RegistrationRequest::SetImeiImeisv() {}
//------------------------------------------------------------------------------
void RegistrationRequest::Set5gSTmsi() {}
......
......@@ -53,18 +53,18 @@ class RegistrationRequest : public NasMmPlainHeader {
uint8_t getMobileIdentityType();
// TODO: SetMobileIdentityType(uint8_t);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(
void SetSuciSupiFormatImsi(
const string mcc, const string mnc, const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki, const string msin);
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi);
void set5G_GUTI();
void Set5gGuti();
std::string get_5g_guti();
void setIMEI_IMEISV();
void SetImeiImeisv();
void Set5gSTmsi();
void setAdditional_GUTI_SUCI_SUPI_format_IMSI(
const string mcc, const string mnc, uint8_t amf_region_id,
......
......@@ -338,7 +338,7 @@ int ULNASTransport::Decode(uint8_t* buf, int len) {
decoded_size++; // 1/2 octet for PayloadContainerType, 1/2 octet for spare
// Payload Container
decoded_result += ie_payload_container.Decode(
decoded_result = ie_payload_container.Decode(
buf + decoded_size, len - decoded_size, false,
ie_payload_container_type.GetValue());
if (decoded_result == KEncodeDecodeError) return KEncodeDecodeError;
......
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