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