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

Update 5GS Update Type

parent 520b0ee6
......@@ -78,7 +78,7 @@
#include "_5GS_Network_Feature_Support.hpp"
#include "_5GS_Registration_Result.hpp"
#include "_5GSTrackingAreaIdentity.hpp"
#include "_5GS_Update_Type.hpp"
#include "_5gsUpdateType.hpp"
#include "struct.hpp"
#include "Ie_Const.hpp"
#include "NetworkName.hpp"
......@@ -19,133 +19,138 @@
* contact@openairinterface.org
*/
#include "_5GS_Update_Type.hpp"
#include "_5gsUpdateType.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "Ie_Const.hpp"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
_5GS_Update_Type::_5GS_Update_Type(uint8_t iei) {
_iei = iei;
EPS_PNB_CIoT = 0;
_5GS_PNB_CIoT = 0;
NG_RAN = false;
SMS = false;
length = 0;
_5gsUpdateType::_5gsUpdateType() : Type4NasIe(kIei5gsUpdateType) {
eps_pnb_ciot_ = 0;
_5gs_pnb_ciot_ = 0;
ng_ran_ = false;
sms_ = false;
SetLengthIndicator(1);
SetIeName(k5gsUpdateTypeIeName);
}
//------------------------------------------------------------------------------
_5GS_Update_Type::_5GS_Update_Type() {
_iei = 0;
EPS_PNB_CIoT = 0;
_5GS_PNB_CIoT = 0;
NG_RAN = false;
SMS = false;
length = 0;
_5gsUpdateType::_5gsUpdateType(
uint8_t eps_PNB_CIoT, uint8_t _5gs_PNB_CIoT, bool ng_RAN, bool sms)
: Type4NasIe(kIei5gsUpdateType) {
eps_pnb_ciot_ = eps_PNB_CIoT;
_5gs_pnb_ciot_ = _5gs_PNB_CIoT;
ng_ran_ = ng_RAN;
sms_ = sms;
SetLengthIndicator(1);
SetIeName(k5gsUpdateTypeIeName);
}
//------------------------------------------------------------------------------
_5GS_Update_Type::~_5GS_Update_Type() {}
_5gsUpdateType::~_5gsUpdateType() {}
//------------------------------------------------------------------------------
_5GS_Update_Type::_5GS_Update_Type(
const uint8_t iei, uint8_t eps_PNB_CIoT, uint8_t _5gs_PNB_CIoT, bool ng_RAN,
bool sms) {
_iei = iei;
EPS_PNB_CIoT = eps_PNB_CIoT;
_5GS_PNB_CIoT = _5gs_PNB_CIoT;
NG_RAN = ng_RAN;
SMS = sms;
length = k5gsUpdateTypeLength;
void _5gsUpdateType::SetEpsPnbCiot(uint8_t value) {
eps_pnb_ciot_ = value & 0x03; // 2 bits
}
//------------------------------------------------------------------------------
void _5GS_Update_Type::setEPS_PNB_CIoT(uint8_t value) {
EPS_PNB_CIoT = value & 0x03; // 2 bits
void _5gsUpdateType::Set5gsPnbCiot(uint8_t value) {
_5gs_pnb_ciot_ = value & 0x03; // 2 bits
}
//------------------------------------------------------------------------------
void _5GS_Update_Type::set_5GS_PNB_CIoT(uint8_t value) {
_5GS_PNB_CIoT = value & 0x03; // 2 bits
void _5gsUpdateType::SetNgRan(uint8_t value) {
ng_ran_ = value & 0x01; // 1 bit
}
//------------------------------------------------------------------------------
void _5GS_Update_Type::setNG_RAN(uint8_t value) {
NG_RAN = value & 0x01; // 1 bit
void _5gsUpdateType::SetSms(uint8_t value) {
sms_ = value & 0x01; // 1 bit
}
//------------------------------------------------------------------------------
void _5GS_Update_Type::setSMS(uint8_t value) {
SMS = value & 0x01; // 1 bit
uint8_t _5gsUpdateType::GetEpsPnbCiot() {
return eps_pnb_ciot_;
}
//------------------------------------------------------------------------------
uint8_t _5GS_Update_Type::getEPS_PNB_CIoT() {
return EPS_PNB_CIoT;
uint8_t _5gsUpdateType::Get5gsPnbCiot() {
return _5gs_pnb_ciot_;
}
//------------------------------------------------------------------------------
uint8_t _5GS_Update_Type::get_5GS_PNB_CIoT() {
return _5GS_PNB_CIoT;
bool _5gsUpdateType::GetNgRan() {
return ng_ran_;
}
//------------------------------------------------------------------------------
bool _5GS_Update_Type::getNG_RAN() {
return NG_RAN;
bool _5gsUpdateType::GetSms() {
return sms_;
}
//------------------------------------------------------------------------------
bool _5GS_Update_Type::getSMS() {
return SMS;
}
int _5gsUpdateType::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
int ie_len = GetIeLength();
//------------------------------------------------------------------------------
int _5GS_Update_Type::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding _5GS_Update_Type");
if (len < k5gsUpdateTypeLength) {
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)",
k5gsUpdateTypeLength);
"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);
}
ENCODE_U8(buf + encoded_size, length, 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;
uint8_t octet = 0;
octet = (EPS_PNB_CIoT << 4) | (_5GS_PNB_CIoT << 2) | (NG_RAN << 1) | SMS;
octet = (eps_pnb_ciot_ << 4) | (_5gs_pnb_ciot_ << 2) | (ng_ran_ << 1) | sms_;
ENCODE_U8(buf + encoded_size, octet, encoded_size);
Logger::nas_mm().debug("encoded _5GS_Update_Type (len %d)", encoded_size);
Logger::nas_mm().debug(
"Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int _5GS_Update_Type::Decode(uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("Decoding _5GS_Update_Type");
int decoded_size = 0;
if (is_option) {
DECODE_U8(buf + decoded_size, _iei, decoded_size);
int _5gsUpdateType::Decode(uint8_t* buf, int len, bool is_iei) {
if (len < k5gsUpdateTypeLength) {
Logger::nas_mm().error(
"Buffer length is less than the minimum length of this IE (%d octet)",
k5gsUpdateTypeLength);
return KEncodeDecodeError;
}
// Length
DECODE_U8(buf + decoded_size, length, decoded_size);
uint8_t octet = 0;
uint8_t decoded_size = 0;
uint8_t octet = 0;
Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
// 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;
DECODE_U8(buf + decoded_size, octet, decoded_size);
EPS_PNB_CIoT = (octet & 0x30) >> 4;
_5GS_PNB_CIoT = (octet & 0x0c) >> 2;
NG_RAN = (octet & 0x02) >> 1;
SMS = (octet & 0x01);
eps_pnb_ciot_ = (octet & 0x30) >> 4;
_5gs_pnb_ciot_ = (octet & 0x0c) >> 2;
ng_ran_ = (octet & 0x02) >> 1;
sms_ = (octet & 0x01);
Logger::nas_mm().debug(
"EPS_PNB_CIoT 0x%x, _5GS_PNB_CIoT 0x%x, NG RAN 0x%x, SMS 0x%x",
eps_pnb_ciot_, _5gs_pnb_ciot_, ng_ran_, sms_);
Logger::nas_mm().debug(
"decoded _5GS_Update_Type, "
"EPS_PNB_CIoT 0x%x, _5GS_PNB_CIoT 0x%x, NG_RAN 0x%x, SMS 0x%x",
EPS_PNB_CIoT, _5GS_PNB_CIoT, NG_RAN, SMS);
Logger::nas_mm().debug("Decoded _5GS_Update_Type (len %d)", decoded_size);
"Decoded %s, len (%d)", GetIeName().c_str(), decoded_size);
return decoded_size;
}
......@@ -19,40 +19,41 @@
* contact@openairinterface.org
*/
#ifndef _5GS_Update_Type_H
#define _5GS_Update_Type_H
#ifndef _5GS_UPDATE_TYPE_H
#define _5GS_UPDATE_TYPE_H
#include "Type4NasIe.hpp"
#include <stdint.h>
constexpr uint8_t k5gsUpdateTypeLength = 3;
constexpr auto k5gsUpdateTypeIeName = "5GS Update Type";
namespace nas {
class _5GS_Update_Type {
class _5gsUpdateType : public Type4NasIe {
public:
_5GS_Update_Type();
_5GS_Update_Type(uint8_t iei);
~_5GS_Update_Type();
_5GS_Update_Type(
const uint8_t iei, uint8_t eps_PNB_CIoT, uint8_t _5gs_PNB_CIoT,
bool ng_RAN, bool sms);
void setEPS_PNB_CIoT(uint8_t value);
void set_5GS_PNB_CIoT(uint8_t value);
void setNG_RAN(uint8_t value);
void setSMS(uint8_t value);
uint8_t getEPS_PNB_CIoT();
uint8_t get_5GS_PNB_CIoT();
bool getNG_RAN();
bool getSMS();
_5gsUpdateType();
_5gsUpdateType(
uint8_t eps_PNB_CIoT, uint8_t _5gs_PNB_CIoT, bool ng_RAN, bool sms);
~_5gsUpdateType();
void SetEpsPnbCiot(uint8_t value);
void Set5gsPnbCiot(uint8_t value);
void SetNgRan(uint8_t value);
void SetSms(uint8_t value);
uint8_t GetEpsPnbCiot();
uint8_t Get5gsPnbCiot();
bool GetNgRan();
bool GetSms();
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
private:
uint8_t _iei;
uint8_t length;
uint8_t EPS_PNB_CIoT; // bit 4,5
uint8_t _5GS_PNB_CIoT; // bit 2,3
bool NG_RAN; // bit 1
bool SMS; // bit 0
uint8_t eps_pnb_ciot_; // bit 4,5
uint8_t _5gs_pnb_ciot_; // bit 2,3
bool ng_ran_; // bit 1
bool sms_; // bit 0
};
} // namespace nas
......
......@@ -477,8 +477,8 @@ bool RegistrationRequest::getNetworkSlicingIndication(
//------------------------------------------------------------------------------
void RegistrationRequest::set_5GS_Update_Type(
uint8_t eps_pnb_ciot, uint8_t _5gs_pnb_ciot, bool ng_ran, bool sms) {
ie_5gs_update_type = std::make_optional<_5GS_Update_Type>(
kIei5gsUpdateType, eps_pnb_ciot, _5gs_pnb_ciot, ng_ran, sms);
ie_5gs_update_type = std::make_optional<_5gsUpdateType>(
eps_pnb_ciot, _5gs_pnb_ciot, ng_ran, sms);
}
//------------------------------------------------------------------------------
......@@ -486,10 +486,10 @@ bool RegistrationRequest::get5GSUpdateType(
uint8_t& eps_pnb_ciot, uint8_t& _5gs_pnb_ciot, bool& ng_ran_rcu,
bool& sms_requested) {
if (ie_5gs_update_type.has_value()) {
eps_pnb_ciot = ie_5gs_update_type.value().getEPS_PNB_CIoT();
_5gs_pnb_ciot = ie_5gs_update_type.value().get_5GS_PNB_CIoT();
ng_ran_rcu = ie_5gs_update_type.value().getNG_RAN();
sms_requested = ie_5gs_update_type.value().getSMS();
eps_pnb_ciot = ie_5gs_update_type.value().GetEpsPnbCiot();
_5gs_pnb_ciot = ie_5gs_update_type.value().Get5gsPnbCiot();
ng_ran_rcu = ie_5gs_update_type.value().GetNgRan();
sms_requested = ie_5gs_update_type.value().GetSms();
return true;
} else {
return false;
......@@ -1057,11 +1057,11 @@ int RegistrationRequest::Decode(uint8_t* buf, int len) {
} break;
case 0x53: {
Logger::nas_mm().debug("Decoding IEI(0x53)");
_5GS_Update_Type ie_5gs_update_type_tmp = {};
_5gsUpdateType ie_5gs_update_type_tmp = {};
decoded_size += ie_5gs_update_type_tmp.Decode(
buf + decoded_size, len - decoded_size, true);
ie_5gs_update_type =
std::optional<_5GS_Update_Type>(ie_5gs_update_type_tmp);
std::optional<_5gsUpdateType>(ie_5gs_update_type_tmp);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
} break;
......
......@@ -172,8 +172,8 @@ class RegistrationRequest : public NasMmPlainHeader {
std::optional<PayloadContainerType> ie_payload_container_type; // Optional
std::optional<Payload_Container> ie_payload_container; // Optional
std::optional<NetworkSlicingIndication>
ie_network_slicing_indication; // Optional
std::optional<_5GS_Update_Type> ie_5gs_update_type; // Optional
ie_network_slicing_indication; // Optional
std::optional<_5gsUpdateType> ie_5gs_update_type; // Optional
// TODO: Mobile station classmark 2
// TODO: Supported codecs
std::optional<NAS_Message_Container> ie_nas_message_container; // Optional
......
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