Commit 30c34599 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Identity Request

parent 2581c2eb
......@@ -1678,7 +1678,7 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) {
std::unique_ptr<IdentityRequest> identity_request =
std::make_unique<IdentityRequest>();
identity_request->SetHeader(PLAIN_5GS_MSG);
identity_request->set_5GS_Identity_Type(SUCI);
identity_request->Set5gsIdentityType(SUCI);
uint8_t buffer[BUFFER_SIZE_256];
int encoded_size = identity_request->Encode(buffer, BUFFER_SIZE_256);
......
......@@ -74,7 +74,7 @@
#include "_5GSDeregistrationType.hpp"
#include "_5GSTrackingAreaIdList.hpp"
#include "_5GS_DRX_Parameters.hpp"
#include "_5GS_Identity_Type.hpp"
#include "_5gsIdentityType.hpp"
#include "_5GS_Network_Feature_Support.hpp"
#include "_5GS_Registration_Result.hpp"
#include "_5GSTrackingAreaIdentity.hpp"
......
......@@ -19,82 +19,37 @@
* contact@openairinterface.org
*/
/*! \file ___5GS_Identity_Type.cpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "_5GS_Identity_Type.hpp"
#include "_5gsIdentityType.hpp"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
_5GS_Identity_Type::_5GS_Identity_Type(uint8_t iei) {
_iei = iei;
_value = 0;
}
//------------------------------------------------------------------------------
_5GS_Identity_Type::_5GS_Identity_Type(const uint8_t iei, uint8_t value) {
_iei = iei;
_value = value;
_5gsIdentityType::_5gsIdentityType() : Type1NasIeFormatTv() {
SetIeName(k5gsIdentityTypeIeName);
}
//------------------------------------------------------------------------------
_5GS_Identity_Type::_5GS_Identity_Type() {
_iei = 0;
_value = 0;
_5gsIdentityType::_5gsIdentityType(uint8_t iei) : Type1NasIeFormatTv(iei) {
SetIeName(k5gsIdentityTypeIeName);
}
//------------------------------------------------------------------------------
_5GS_Identity_Type::~_5GS_Identity_Type() {}
//------------------------------------------------------------------------------
void _5GS_Identity_Type::setValue(uint8_t value) {
_value = value;
_5gsIdentityType::_5gsIdentityType(uint8_t iei, uint8_t value)
: Type1NasIeFormatTv(iei) {
Type1NasIeFormatTv::SetValue(value & 0x07);
SetIeName(k5gsIdentityTypeIeName);
}
//------------------------------------------------------------------------------
uint8_t _5GS_Identity_Type::getValue() {
return _value;
}
_5gsIdentityType::~_5gsIdentityType() {}
//------------------------------------------------------------------------------
int _5GS_Identity_Type::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding _5GS_Identity_Type iei(0x%x)", _iei);
if (len < 1) {
Logger::nas_mm().error("len is less than 1");
return 0;
}
int encoded_size = 0;
if (_iei) {
*(buf + encoded_size) = _value & 0x07;
encoded_size++;
} else {
*(buf + encoded_size) = _value & 0x07;
encoded_size++;
}
Logger::nas_mm().debug("encoded _5GS_Identity_Type len(%d)", encoded_size);
return encoded_size;
void _5gsIdentityType::SetValue(uint8_t value) {
Type1NasIeFormatTv::SetValue(value & 0x07);
}
//------------------------------------------------------------------------------
int _5GS_Identity_Type::Decode(uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding _5GS_Identity_Type iei(0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
_iei = *buf;
decoded_size++;
}
_value = 0x00;
// length = *(buf + decoded_size);
_value = *(buf + decoded_size) & 0x07;
decoded_size++;
Logger::nas_mm().debug(
"decoded _5GS_Identity_Type _value(0x%x),iei(0x%x)", _value, _iei);
Logger::nas_mm().debug("decoded _5GS_Identity_Type len(%d)", decoded_size);
return decoded_size;
uint8_t _5gsIdentityType::GetValue() const {
return Type1NasIeFormatTv::GetValue() & 0x07;
}
......@@ -19,34 +19,26 @@
* contact@openairinterface.org
*/
/*! \file ___5GS_Identity_Type.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GS_IDENTITY_TYPE_H_
#define _5GS_IDENTITY_TYPE_H_
#ifndef ___5GS_Identity_Type_H_
#define ___5GS_Identity_Type_H_
#include "Type1NasIeFormatTv.hpp"
#include <stdint.h>
constexpr auto k5gsIdentityTypeIeName = "5GS Identity Type";
namespace nas {
class _5GS_Identity_Type {
class _5gsIdentityType : public Type1NasIeFormatTv {
public:
_5GS_Identity_Type();
_5GS_Identity_Type(uint8_t iei);
_5GS_Identity_Type(const uint8_t iei, uint8_t value);
~_5GS_Identity_Type();
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
void setValue(uint8_t value);
uint8_t getValue();
_5gsIdentityType();
_5gsIdentityType(uint8_t iei);
_5gsIdentityType(uint8_t iei, uint8_t value);
~_5gsIdentityType();
void SetValue(uint8_t value);
uint8_t GetValue() const;
private:
uint8_t _iei;
uint8_t _value;
};
} // namespace nas
......
......@@ -71,6 +71,11 @@ class ConfigurationUpdateCommand : public NasMmPlainHeader {
// TODO: Operator-defined access category definitions
// TODO: SMS indication
// TODO: T3447 value
// TODO: CAG information list (Rel 16.4.1)
// TODO: UE radio capability ID (Rel 16.4.1)
// TODO: UE radio capability ID deletion indication (Rel 16.4.1)
// TODO: 5GS registration result (Rel 16.4.1)
// TODO: Truncated 5G-S-TMSI configuration (Rel 16.4.1)
};
} // namespace nas
......
......@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "IdentityRequest.hpp"
#include "3gpp_24.501.hpp"
......@@ -34,63 +27,75 @@
using namespace nas;
//------------------------------------------------------------------------------
IdentityRequest::IdentityRequest() {
Logger::nas_mm().debug("initiating class IdentityRequest");
plain_header = NULL;
_5gs_identity_type = NULL;
}
IdentityRequest::IdentityRequest()
: NasMmPlainHeader(EPD_5GS_MM_MSG, IDENTITY_REQUEST) {}
//------------------------------------------------------------------------------
IdentityRequest::~IdentityRequest() {}
//------------------------------------------------------------------------------
void IdentityRequest::SetHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->SetHeader(
EPD_5GS_MM_MSG, security_header_type, IDENTITY_REQUEST);
NasMmPlainHeader::SetSecurityHeaderType(security_header_type);
}
//------------------------------------------------------------------------------
void IdentityRequest::set_5GS_Identity_Type(uint8_t value) {
_5gs_identity_type = new _5GS_Identity_Type(0x00, value);
void IdentityRequest::Set5gsIdentityType(uint8_t value) {
_5gs_identity_type_.SetValue(value);
}
//------------------------------------------------------------------------------
int IdentityRequest::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding IdentityRequest 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 (!_5gs_identity_type) {
Logger::nas_mm().warn("IE _5gs_identity_type is not available");
encoded_size += encoded_ie_size;
int size = _5gs_identity_type_.Encode(buf + encoded_size, len - encoded_size);
if (size != KEncodeDecodeError) {
encoded_size += size;
} else {
if (int size = _5gs_identity_type->Encode(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding _5gs_identity_type error");
return 0;
}
Logger::nas_mm().error("Encoding _5gs_identity_type error");
return KEncodeDecodeError;
}
Logger::nas_mm().debug(
"encoded IdentityRequest message len(%d)", encoded_size);
"Encoded IdentityRequest message len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int IdentityRequest::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
Logger::nas_mm().debug("decoding IdentityRequest message");
int decoded_size = 3;
plain_header = header;
_5gs_identity_type = new _5GS_Identity_Type();
decoded_size +=
_5gs_identity_type->Decode(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
int IdentityRequest::Decode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding IdentityRequest 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;
decoded_result =
_5gs_identity_type_.Decode(buf + decoded_size, len - decoded_size, false);
if (decoded_result == KEncodeDecodeError) return KEncodeDecodeError;
if (decoded_result == 0) {
decoded_result = 1; // including 1/2 octet for Spare
}
decoded_size += decoded_result;
Logger::nas_mm().debug(
"decoded IdentityRequest message len(%d)", decoded_size);
return 1;
"Decoded IdentityRequest message len (%d)", decoded_size);
return decoded_size;
}
......@@ -19,32 +19,26 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _IdentityRequest_H_
#define _IdentityRequest_H_
#ifndef _IDENTITY_REQUEST_H_
#define _IDENTITY_REQUEST_H_
#include "NasIeHeader.hpp"
namespace nas {
class IdentityRequest {
class IdentityRequest : public NasMmPlainHeader {
public:
IdentityRequest();
~IdentityRequest();
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 set_5GS_Identity_Type(uint8_t value);
void Set5gsIdentityType(uint8_t value);
public:
NasMmPlainHeader* plain_header;
_5GS_Identity_Type* _5gs_identity_type;
_5gsIdentityType _5gs_identity_type_; // Mandatory
};
} // namespace nas
......
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