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

Update UE Status

parent 670c2dcf
...@@ -91,6 +91,8 @@ constexpr uint8_t kIeiNetworkSlicingIndication = 0x09; // 9-(4 higher bits) ...@@ -91,6 +91,8 @@ constexpr uint8_t kIeiNetworkSlicingIndication = 0x09; // 9-(4 higher bits)
constexpr uint8_t kIeiMicoIndication = 0x0B; // B-(4 higher bits) constexpr uint8_t kIeiMicoIndication = 0x0B; // B-(4 higher bits)
constexpr uint8_t kIei5gmmCapability = 0x10; constexpr uint8_t kIei5gmmCapability = 0x10;
constexpr uint8_t kIeiUeStatus = 0x2b;
constexpr uint8_t kIeiUeSecurityCapability = 0x2e; constexpr uint8_t kIeiUeSecurityCapability = 0x2e;
constexpr uint8_t kIeiUeNetworkCapability = 0x17; constexpr uint8_t kIeiUeNetworkCapability = 0x17;
......
...@@ -21,106 +21,104 @@ ...@@ -21,106 +21,104 @@
#include "3gpp_24.501.hpp" #include "3gpp_24.501.hpp"
#include "common_defs.h" #include "common_defs.h"
#include "Ie_Const.hpp"
#include "logger.hpp" #include "logger.hpp"
#include "UEStatus.hpp" #include "UEStatus.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UEStatus::UEStatus(uint8_t iei) { UEStatus::UEStatus() : Type4NasIe(kIeiUeStatus) {
_iei = iei; s1_ = false;
length = 1; n1_ = false;
S1 = false; SetLengthIndicator(1);
N1 = false; SetIeName(kUeStatusIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UEStatus::UEStatus(const uint8_t iei, bool n1, bool s1) { UEStatus::UEStatus(bool n1, bool s1) : Type4NasIe(kIeiUeStatus) {
_iei = iei; s1_ = s1;
length = 1; n1_ = n1;
S1 = s1; SetLengthIndicator(1);
N1 = n1; SetIeName(kUeStatusIeName);
}
//------------------------------------------------------------------------------
UEStatus::UEStatus() {
_iei = 0;
length = 1;
S1 = false;
N1 = false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
UEStatus::~UEStatus() {} UEStatus::~UEStatus() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UEStatus::setS1(bool value) { void UEStatus::SetS1(bool value) {
S1 = value; s1_ = value;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UEStatus::setN1(bool value) { bool UEStatus::GetS1() const {
N1 = value; return s1_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool UEStatus::getS1() { void UEStatus::SetN1(bool value) {
return S1; n1_ = value;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool UEStatus::getN1() { bool UEStatus::GetN1() const {
return N1; return n1_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int UEStatus::encode2Buffer(uint8_t* buf, int len) { int UEStatus::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding UE Status (IEI 0x%x)", _iei); Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
int ie_len = GetIeLength();
if ((len < kUEStatusIELength) or (len < length + 2)) { if (len < ie_len) { // Length of the content + IEI/Len
Logger::nas_mm().error( Logger::nas_mm().error(
"Buffer length is less than the minimum length of this IE (%d octet)", "Size of the buffer is not enough to store this IE (IE len %d)",
kUEStatusIELength); ie_len);
return KEncodeDecodeError; return KEncodeDecodeError;
} }
int encoded_size = 0; int encoded_size = 0;
if (_iei) { // IEI and Length
ENCODE_U8(buf + encoded_size, _iei, encoded_size); int encoded_header_size = Type4NasIe::Encode(buf + encoded_size, len);
} if (encoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
encoded_size += encoded_header_size;
ENCODE_U8(buf + encoded_size, length, encoded_size); uint8_t octet = 0x03 & (s1_ | (n1_ << 1));
uint8_t octet = 0x03 & (S1 | (N1 << 1));
ENCODE_U8(buf + encoded_size, octet, encoded_size); ENCODE_U8(buf + encoded_size, octet, encoded_size);
Logger::nas_mm().debug("Encoded UE Status ( len %d)", encoded_size); Logger::nas_mm().debug(
"Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int UEStatus::decodeFromBuffer(uint8_t* buf, int len, bool is_option) { int UEStatus::Decode(uint8_t* buf, int len, bool is_iei) {
Logger::nas_mm().debug("Decoding UE Status"); Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
if ((len < kUEStatusIELength) or (len < length + 2)) { if (len < kUeStatusIeLength) {
Logger::nas_mm().error( Logger::nas_mm().error(
"Buffer length is less than the minimum length of this IE (%d octet)", "Buffer length is less than the minimum length of this IE (%d octet)",
kUEStatusIELength); kUeStatusIeLength);
return KEncodeDecodeError; return KEncodeDecodeError;
} }
int decoded_size = 0; int decoded_size = 0;
if (is_option) { // IEI and Length
DECODE_U8(buf + decoded_size, _iei, decoded_size); int decoded_header_size = Type4NasIe::Decode(buf + decoded_size, len, is_iei);
} // decoded_size += Type4NasIe::Decode(buf + decoded_size, len, is_iei);
DECODE_U8(buf + decoded_size, length, decoded_size); if (decoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
decoded_size += decoded_header_size;
uint8_t octet = 0; uint8_t octet = 0;
DECODE_U8(buf + decoded_size, octet, decoded_size); DECODE_U8(buf + decoded_size, octet, decoded_size);
N1 = octet & 0x02; n1_ = octet & 0x02;
S1 = octet & 0x01; s1_ = octet & 0x01;
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded UE Status, N1 0x%x, S1 0x%x, len %d", N1, S1, decoded_size); "Decoded %s, len (%d)", GetIeName().c_str(), decoded_size);
Logger::nas_mm().debug("N1 0x%x, S1 0x%x", n1_, s1_);
return decoded_size; return decoded_size;
} }
...@@ -19,36 +19,35 @@ ...@@ -19,36 +19,35 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#ifndef _UE_Status_H_ #ifndef _UE_STATUS_H_
#define _UE_Status_H_ #define _UE_STATUS_H_
#include "Type4NasIe.hpp"
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kUEStatusIELength = 3; constexpr uint8_t kUeStatusIeLength = 3;
constexpr auto kUeStatusIeName = "UE Status";
namespace nas { namespace nas {
class UEStatus { class UEStatus : public Type4NasIe {
public: public:
UEStatus(); UEStatus();
UEStatus(uint8_t iei); UEStatus(bool n1, bool s1);
UEStatus(const uint8_t iei, bool n1, bool s1);
~UEStatus(); ~UEStatus();
int encode2Buffer(uint8_t* buf, int len); int Encode(uint8_t* buf, int len);
int decodeFromBuffer(uint8_t* buf, int len, bool is_option); int Decode(uint8_t* buf, int len, bool is_iei);
void setN1(bool value); void SetN1(bool value);
bool getN1(); bool GetN1() const;
void setS1(bool value); void SetS1(bool value);
bool getS1(); bool GetS1() const;
private: private:
uint8_t _iei; bool n1_;
uint8_t length; bool s1_;
bool N1;
bool S1;
}; };
} // namespace nas } // namespace nas
......
...@@ -336,14 +336,14 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) { ...@@ -336,14 +336,14 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RegistrationRequest::setUEStatus(bool n1, bool s1) { void RegistrationRequest::setUEStatus(bool n1, bool s1) {
ie_ue_status = std::make_optional<UEStatus>(0x2B, n1, s1); ie_ue_status = std::make_optional<UEStatus>(n1, s1);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) { bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) {
if (ie_ue_status.has_value()) { if (ie_ue_status.has_value()) {
n1ModeReg = ie_ue_status.value().getN1(); n1ModeReg = ie_ue_status.value().GetN1();
s1ModeReg = ie_ue_status.value().getS1(); s1ModeReg = ie_ue_status.value().GetS1();
return true; return true;
} else { } else {
return false; return false;
...@@ -682,7 +682,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) { ...@@ -682,7 +682,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
if (!ie_ue_status.has_value()) { if (!ie_ue_status.has_value()) {
Logger::nas_mm().warn("IE ie_ue_status is not available"); Logger::nas_mm().warn("IE ie_ue_status is not available");
} else { } else {
if (int size = ie_ue_status.value().encode2Buffer( if (int size = ie_ue_status.value().Encode(
buf + encoded_size, len - encoded_size)) { buf + encoded_size, len - encoded_size)) {
encoded_size += size; encoded_size += size;
} else { } else {
...@@ -975,10 +975,10 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) { ...@@ -975,10 +975,10 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI 0x%x", octet); Logger::nas_mm().debug("Next IEI 0x%x", octet);
} break; } break;
case 0x2B: { case kIeiUeStatus: {
Logger::nas_mm().debug("Decoding IEI (0x2B)"); Logger::nas_mm().debug("Decoding IEI (0x2B)");
UEStatus ie_ue_status_tmp = {}; UEStatus ie_ue_status_tmp = {};
decoded_size += ie_ue_status_tmp.decodeFromBuffer( decoded_size += ie_ue_status_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_ue_status = std::optional<UEStatus>(ie_ue_status_tmp); ie_ue_status = std::optional<UEStatus>(ie_ue_status_tmp);
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
......
...@@ -159,8 +159,8 @@ class RegistrationRequest : public NasMmPlainHeader { ...@@ -159,8 +159,8 @@ class RegistrationRequest : public NasMmPlainHeader {
std::optional<UENetworkCapability> ie_s1_ue_network_capability; // Optional std::optional<UENetworkCapability> ie_s1_ue_network_capability; // Optional
std::optional<UplinkDataStatus> ie_uplink_data_status; // Optional std::optional<UplinkDataStatus> ie_uplink_data_status; // Optional
std::optional<PDUSessionStatus> ie_PDU_session_status; // Optional std::optional<PDUSessionStatus> ie_PDU_session_status; // Optional
std::optional<MicoIndication> ie_MICO_indication; // Optional std::optional<MicoIndication> ie_MICO_indication; // Optional
std::optional<UEStatus> ie_ue_status; // Optional std::optional<UEStatus> ie_ue_status; // Optional
std::optional<_5GSMobileIdentity> ie_additional_guti; // Optional std::optional<_5GSMobileIdentity> ie_additional_guti; // Optional
std::optional<AllowedPDUSessionStatus> std::optional<AllowedPDUSessionStatus>
......
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