Commit 560c1dfb authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Deregistration Request (UE originating)

parent 2db5addf
...@@ -3011,8 +3011,9 @@ void amf_n1::ue_initiate_de_registration_handle( ...@@ -3011,8 +3011,9 @@ void amf_n1::ue_initiate_de_registration_handle(
} }
// Decode NAS message // Decode NAS message
auto dereg_request = std::make_unique<DeregistrationRequest>(); auto dereg_request = std::make_unique<DeregistrationRequest>(
dereg_request->Decode(NULL, (uint8_t*) bdata(nas), blength(nas)); true); // UE originating de-registration
dereg_request->Decode((uint8_t*) bdata(nas), blength(nas));
// TODO: validate 5G Mobile Identity // TODO: validate 5G Mobile Identity
uint8_t mobile_id_type = 0; uint8_t mobile_id_type = 0;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "Type1NasIeFormatTv.hpp" #include "Type1NasIeFormatTv.hpp"
#include <stdint.h>
constexpr auto k5gsRegistrationTypeName = "5GS Registration Type"; constexpr auto k5gsRegistrationTypeName = "5GS Registration Type";
namespace nas { namespace nas {
......
...@@ -18,14 +18,6 @@ ...@@ -18,14 +18,6 @@
* For more information about the OpenAirInterface (OAI) Software Alliance: * For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "_5GSDeregistrationType.hpp" #include "_5GSDeregistrationType.hpp"
#include "3gpp_24.501.hpp" #include "3gpp_24.501.hpp"
...@@ -34,13 +26,23 @@ ...@@ -34,13 +26,23 @@
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType() { _5GSDeregistrationType::_5GSDeregistrationType() : Type1NasIeFormatTv() {
u1.b = 0; u1.b = 0;
SetIeName(k5gsDeregistrationTypeIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType(uint8_t type) { _5GSDeregistrationType::_5GSDeregistrationType(uint8_t iei)
u1.b = type; : Type1NasIeFormatTv(iei) {
u1.bf.iei = iei;
SetIeName(k5gsDeregistrationTypeIeName);
}
//------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType(uint8_t iei, uint8_t value) {
u1.b = (iei << 4) | (value && 0x0f);
SetValue(value && 0x0f);
SetIeName(k5gsDeregistrationTypeIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType( _5GSDeregistrationType::_5GSDeregistrationType(
...@@ -50,11 +52,29 @@ _5GSDeregistrationType::_5GSDeregistrationType( ...@@ -50,11 +52,29 @@ _5GSDeregistrationType::_5GSDeregistrationType(
u1.bf.re_registration_required = type.re_registration_required; u1.bf.re_registration_required = type.re_registration_required;
u1.bf.access_type = type.access_type; u1.bf.access_type = type.access_type;
u1.bf.iei = type.iei; u1.bf.iei = type.iei;
if (type.iei != 0) {
SetIei(type.iei);
}
SetValue(u1.b && 0x0f);
SetIeName(k5gsDeregistrationTypeIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
_5GSDeregistrationType::~_5GSDeregistrationType() {} _5GSDeregistrationType::~_5GSDeregistrationType() {}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::setValue() {
Type1NasIeFormatTv::SetValue(u1.b && 0x0f);
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::getValue() {
u1.b = Type1NasIeFormatTv::GetValue() && 0x0f;
if (iei_.has_value()) {
u1.b |= iei_.value() && 0xf0;
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) { void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
u1.b = 0; u1.b = 0;
...@@ -62,6 +82,10 @@ void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) { ...@@ -62,6 +82,10 @@ void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
u1.bf.re_registration_required = type.re_registration_required; u1.bf.re_registration_required = type.re_registration_required;
u1.bf.access_type = type.access_type; u1.bf.access_type = type.access_type;
u1.bf.iei = type.iei; u1.bf.iei = type.iei;
if (type.iei != 0) {
SetIei(type.iei);
}
SetValue(u1.b && 0x0f);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -82,6 +106,7 @@ void _5GSDeregistrationType::get(uint8_t& type) { ...@@ -82,6 +106,7 @@ void _5GSDeregistrationType::get(uint8_t& type) {
type = u1.b; type = u1.b;
} }
/*
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int _5GSDeregistrationType::Encode(uint8_t* buf, int len) { int _5GSDeregistrationType::Encode(uint8_t* buf, int len) {
Logger::nas_mm().error("Encoding 5GSDeregistrationType IE"); Logger::nas_mm().error("Encoding 5GSDeregistrationType IE");
...@@ -102,3 +127,4 @@ int _5GSDeregistrationType::Decode(uint8_t* buf, int len) { ...@@ -102,3 +127,4 @@ int _5GSDeregistrationType::Decode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoded 5GSDeRegistrationType"); Logger::nas_mm().debug("Decoded 5GSDeRegistrationType");
return 0; return 0;
} }
*/
...@@ -19,17 +19,10 @@ ...@@ -19,17 +19,10 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GS_DEREGISTRATION_TYPE_H_ #ifndef _5GS_DEREGISTRATION_TYPE_H_
#define _5GS_DEREGISTRATION_TYPE_H_ #define _5GS_DEREGISTRATION_TYPE_H_
#include <stdint.h> #include "Type1NasIeFormatTv.hpp"
namespace nas { namespace nas {
typedef struct _5gs_deregistration_type_s { typedef struct _5gs_deregistration_type_s {
...@@ -39,21 +32,32 @@ typedef struct _5gs_deregistration_type_s { ...@@ -39,21 +32,32 @@ typedef struct _5gs_deregistration_type_s {
uint8_t access_type : 2; uint8_t access_type : 2;
} _5gs_deregistration_type_t; } _5gs_deregistration_type_t;
class _5GSDeregistrationType { constexpr auto k5gsDeregistrationTypeIeName = "5GS De-registration Type";
class _5GSDeregistrationType : public Type1NasIeFormatTv {
public: public:
_5GSDeregistrationType(); _5GSDeregistrationType();
_5GSDeregistrationType(uint8_t type); _5GSDeregistrationType(uint8_t iei);
_5GSDeregistrationType(uint8_t iei, uint8_t value);
_5GSDeregistrationType(_5gs_deregistration_type_t type); _5GSDeregistrationType(_5gs_deregistration_type_t type);
~_5GSDeregistrationType(); ~_5GSDeregistrationType();
int Decode(uint8_t* buf, int len);
int Encode(uint8_t* buf, int len); // int Decode(uint8_t* buf, int len);
// int Encode(uint8_t* buf, int len);
void set(_5gs_deregistration_type_t type); void set(_5gs_deregistration_type_t type);
void get(_5gs_deregistration_type_t& type); void get(_5gs_deregistration_type_t& type);
void set(uint8_t type);
void get(uint8_t& type);
public: void set(uint8_t value);
void get(uint8_t& value);
void set(uint8_t iei, uint8_t value);
void get(uint8_t& iei, uint8_t value);
private:
void setValue();
void getValue();
union { union {
struct { struct {
uint8_t iei : 4; uint8_t iei : 4;
......
This diff is collapsed.
...@@ -27,13 +27,16 @@ ...@@ -27,13 +27,16 @@
using namespace std; using namespace std;
namespace nas { namespace nas {
class DeregistrationRequest { class DeregistrationRequest : public NasMmPlainHeader {
public: public:
DeregistrationRequest(); DeregistrationRequest(bool is_ue_originating);
~DeregistrationRequest(); ~DeregistrationRequest();
int Encode(uint8_t* buf, int len); 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 SetHeader(uint8_t security_header_type);
void setDeregistrationType(uint8_t dereg_type); void setDeregistrationType(uint8_t dereg_type);
void setDeregistrationType(_5gs_deregistration_type_t type); void setDeregistrationType(_5gs_deregistration_type_t type);
void SetNgKsi(uint8_t tsc, uint8_t key_set_id); void SetNgKsi(uint8_t tsc, uint8_t key_set_id);
...@@ -57,10 +60,9 @@ class DeregistrationRequest { ...@@ -57,10 +60,9 @@ class DeregistrationRequest {
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi); bool getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi);
public: public:
NasMmPlainHeader* plain_header; _5GSDeregistrationType ie_deregistrationtype; // Mandatory
_5GSDeregistrationType* ie_deregistrationtype; NasKeySetIdentifier ie_ngKSI; // Mandatory
NasKeySetIdentifier* ie_ngKSI; _5GSMobileIdentity ie_5gs_mobility_id; // Mandatory
_5GSMobileIdentity* ie_5gs_mobility_id;
}; };
} // namespace nas } // namespace nas
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------
NasMmPlainHeader::NasMmPlainHeader(const uint8_t& epd) : epd_(epd) {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
NasMmPlainHeader::NasMmPlainHeader(const uint8_t& epd, const uint8_t& msg_type) NasMmPlainHeader::NasMmPlainHeader(const uint8_t& epd, const uint8_t& msg_type)
: epd_(epd), msg_type_(msg_type) {} : epd_(epd), msg_type_(msg_type) {}
......
...@@ -33,6 +33,7 @@ namespace nas { ...@@ -33,6 +33,7 @@ namespace nas {
class NasMmPlainHeader { class NasMmPlainHeader {
public: public:
NasMmPlainHeader(){}; NasMmPlainHeader(){};
NasMmPlainHeader(const uint8_t& epd);
NasMmPlainHeader(const uint8_t& epd, const uint8_t& msg_type); NasMmPlainHeader(const uint8_t& epd, const uint8_t& msg_type);
virtual ~NasMmPlainHeader(); virtual ~NasMmPlainHeader();
......
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