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

Update GPRS_Timer_2

parent c6446db8
...@@ -125,6 +125,10 @@ constexpr uint8_t kIeiGprsTimer3T3447 = 0x6C; ...@@ -125,6 +125,10 @@ constexpr uint8_t kIeiGprsTimer3T3447 = 0x6C;
constexpr uint8_t kIeiGprsTimer3T3512 = 0x5E; constexpr uint8_t kIeiGprsTimer3T3512 = 0x5E;
constexpr uint8_t kIeiGprsTimer3BackOffTimer = 0x37; constexpr uint8_t kIeiGprsTimer3BackOffTimer = 0x37;
constexpr uint8_t kIeiGprsTimer2Non3gppDeregistration = 0x5D;
constexpr uint8_t kIeiGprsTimer2T3502 = 0x16;
constexpr uint8_t kIeiGprsTimer2T3546 = 0x5F;
constexpr uint8_t kIeiEpsNasMessageContainer = 0x70; constexpr uint8_t kIeiEpsNasMessageContainer = 0x70;
constexpr uint8_t kIeiNasMessageContainer = 0x71; constexpr uint8_t kIeiNasMessageContainer = 0x71;
constexpr uint8_t kIeiPduSessionReactivationResultErrorCause = 0x72; constexpr uint8_t kIeiPduSessionReactivationResultErrorCause = 0x72;
......
...@@ -21,83 +21,80 @@ ...@@ -21,83 +21,80 @@
#include "GPRS_Timer_2.hpp" #include "GPRS_Timer_2.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
GPRS_Timer_2::GPRS_Timer_2(uint8_t iei) { GPRS_Timer_2::GPRS_Timer_2(uint8_t iei) : Type4NasIe(iei), value_() {
_iei = iei; SetLengthIndicator(1);
length = 1; SetIeName(kGprsTimer2IeName);
_value = 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
GPRS_Timer_2::GPRS_Timer_2(const uint8_t iei, uint8_t value) { GPRS_Timer_2::GPRS_Timer_2(const uint8_t iei, uint8_t value) : Type4NasIe(iei) {
_iei = iei; value_ = value;
_value = value; SetLengthIndicator(1);
length = 1; SetIeName(kGprsTimer2IeName);
} }
//------------------------------------------------------------------------------
GPRS_Timer_2::GPRS_Timer_2() : _iei(), _value(), length(1) {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
GPRS_Timer_2::~GPRS_Timer_2() {} GPRS_Timer_2::~GPRS_Timer_2() {}
//------------------------------------------------------------------------------
void GPRS_Timer_2::setIEI(uint8_t iei) {
_iei = iei;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void GPRS_Timer_2::setValue(uint8_t value) { void GPRS_Timer_2::setValue(uint8_t value) {
_value = value; value_ = value;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t GPRS_Timer_2::getValue() { uint8_t GPRS_Timer_2::getValue() const {
return _value; return value_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int GPRS_Timer_2::Encode(uint8_t* buf, int len) { int GPRS_Timer_2::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding GPRS_Timer_2"); Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
if (len < kGprsTimer2Length) { int ie_len = GetIeLength();
Logger::nas_mm().error(
"Buffer length is less than the length of this IE (%d octet)", if (len < ie_len) {
kGprsTimer2Length); Logger::nas_mm().error("Len is less than %d", 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;
// Length encoded_size += encoded_header_size;
length = 1;
ENCODE_U8(buf + encoded_size, length, encoded_size);
// Value
ENCODE_U8(buf + encoded_size, _value, encoded_size);
Logger::nas_mm().debug("encoded GPRS_Timer_2, value 0x%x", _value); // Octet 3
ENCODE_U8(buf + encoded_size, value_, encoded_size);
Logger::nas_mm().debug("encoded GPRS_Timer_2 ( len %d)", encoded_size); Logger::nas_mm().debug(
"Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int GPRS_Timer_2::Decode(uint8_t* buf, int len, bool is_option) { int GPRS_Timer_2::Decode(uint8_t* buf, int len, bool is_iei) {
Logger::nas_mm().debug("Decoding GPRS_Timer_2"); if (len < kGprsTimer2Length) {
int decoded_size = 0; Logger::nas_mm().error(
if (is_option) { "Buffer length is less than the minimum length of this IE (%d octet)",
DECODE_U8(buf + decoded_size, _iei, decoded_size); kGprsTimer2Length);
return KEncodeDecodeError;
} }
DECODE_U8(buf + decoded_size, length, decoded_size);
DECODE_U8(buf + decoded_size, _value, decoded_size); 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);
if (decoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
decoded_size += decoded_header_size;
DECODE_U8(buf + decoded_size, value_, decoded_size);
Logger::nas_mm().debug("Decoded %s, Value 0x%x", GetIeName().c_str(), value_);
Logger::nas_mm().debug( Logger::nas_mm().debug(
"Decoded GPRS_Timer_2, value 0x%x, IEI 0x%x", _value, _iei); "Decoded %s, len (%d)", GetIeName().c_str(), decoded_size);
Logger::nas_mm().debug("decoded GPRS_Timer_2 (len %d)", decoded_size);
return decoded_size; return decoded_size;
} }
...@@ -19,30 +19,32 @@ ...@@ -19,30 +19,32 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#ifndef __GPRS_Timer_2_H_ #ifndef _GPRS_TIMER_2_H_
#define __GPRS_Timer_2_H_ #define _GPRS_TIMER_2_H_
#include "Type4NasIe.hpp"
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kGprsTimer2Length = 3; constexpr uint8_t kGprsTimer2Length = 3;
constexpr auto kGprsTimer2IeName = "GPRS Timer 2";
namespace nas { namespace nas {
class GPRS_Timer_2 { class GPRS_Timer_2 : public Type4NasIe {
public: public:
GPRS_Timer_2();
GPRS_Timer_2(uint8_t iei); GPRS_Timer_2(uint8_t iei);
GPRS_Timer_2(const uint8_t iei, uint8_t value); GPRS_Timer_2(const uint8_t iei, uint8_t value);
~GPRS_Timer_2(); ~GPRS_Timer_2();
void setIEI(uint8_t iei);
int Encode(uint8_t* buf, int len); int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option); int Decode(uint8_t* buf, int len, bool is_iei);
void setValue(uint8_t value); void setValue(uint8_t value);
uint8_t getValue(); uint8_t getValue() const;
private: private:
uint8_t _iei; uint8_t value_;
uint8_t length;
uint8_t _value;
}; };
} // namespace nas } // namespace nas
......
...@@ -215,13 +215,13 @@ void RegistrationAccept::setT3512_Value(uint8_t unit, uint8_t value) { ...@@ -215,13 +215,13 @@ void RegistrationAccept::setT3512_Value(uint8_t unit, uint8_t value) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RegistrationAccept::setNon_3GPP_de_registration_timer_value( void RegistrationAccept::setNon_3GPP_de_registration_timer_value(
uint8_t value) { uint8_t value) {
ie_Non_3GPP_de_registration_timer_value = ie_Non_3GPP_de_registration_timer_value = std::make_optional<GPRS_Timer_2>(
std::make_optional<GPRS_Timer_2>(0x5D, value); kIeiGprsTimer2Non3gppDeregistration, value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RegistrationAccept::setT3502_value(uint8_t value) { void RegistrationAccept::setT3502_value(uint8_t value) {
ie_T3502_value = std::make_optional<GPRS_Timer_2>(0x16, value); ie_T3502_value = std::make_optional<GPRS_Timer_2>(kIeiGprsTimer2T3502, value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -799,9 +799,11 @@ int RegistrationAccept::Decode(uint8_t* buf, int len) { ...@@ -799,9 +799,11 @@ int RegistrationAccept::Decode(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 0x5D: { case kIeiGprsTimer2Non3gppDeregistration: {
Logger::nas_mm().debug("Decoding IEI (0x5D)"); Logger::nas_mm().debug(
GPRS_Timer_2 ie_Non_3GPP_de_registration_timer_value_tmp = {}; "Decoding IEI 0x%x", kIeiGprsTimer2Non3gppDeregistration);
GPRS_Timer_2 ie_Non_3GPP_de_registration_timer_value_tmp(
kIeiGprsTimer2Non3gppDeregistration);
decoded_size += ie_Non_3GPP_de_registration_timer_value_tmp.Decode( decoded_size += ie_Non_3GPP_de_registration_timer_value_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_Non_3GPP_de_registration_timer_value = std::optional<GPRS_Timer_2>( ie_Non_3GPP_de_registration_timer_value = std::optional<GPRS_Timer_2>(
...@@ -809,9 +811,9 @@ int RegistrationAccept::Decode(uint8_t* buf, int len) { ...@@ -809,9 +811,9 @@ int RegistrationAccept::Decode(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 0x16: { case kIeiGprsTimer2T3502: {
Logger::nas_mm().debug("Decoding IEI (0x16)"); Logger::nas_mm().debug("Decoding IEI 0x%x", kIeiGprsTimer2T3502);
GPRS_Timer_2 ie_T3502_value_tmp = {}; GPRS_Timer_2 ie_T3502_value_tmp(kIeiGprsTimer2T3502);
decoded_size += ie_T3502_value_tmp.Decode( decoded_size += ie_T3502_value_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_T3502_value = std::optional<GPRS_Timer_2>(ie_T3502_value_tmp); ie_T3502_value = std::optional<GPRS_Timer_2>(ie_T3502_value_tmp);
......
...@@ -168,7 +168,6 @@ class RegistrationAccept : public NasMmPlainHeader { ...@@ -168,7 +168,6 @@ class RegistrationAccept : public NasMmPlainHeader {
ie_network_slicing_indication; // Optional ie_network_slicing_indication; // Optional
// TODO: Service Area List // TODO: Service Area List
std::optional<GPRS_Timer_3> ie_T3512_value; // Optional std::optional<GPRS_Timer_3> ie_T3512_value; // Optional
std::optional<GPRS_Timer_2> std::optional<GPRS_Timer_2>
ie_Non_3GPP_de_registration_timer_value; // Optional ie_Non_3GPP_de_registration_timer_value; // Optional
std::optional<GPRS_Timer_2> ie_T3502_value; // Optional std::optional<GPRS_Timer_2> ie_T3502_value; // Optional
......
...@@ -154,7 +154,7 @@ int RegistrationReject::Decode( ...@@ -154,7 +154,7 @@ int RegistrationReject::Decode(
switch (octet) { switch (octet) {
case kT3346Value: { case kT3346Value: {
Logger::nas_mm().debug("Decoding IEI 0x5F: T3346 Value"); Logger::nas_mm().debug("Decoding IEI 0x5F: T3346 Value");
GPRS_Timer_2 ie_T3346_value_tmp = {}; GPRS_Timer_2 ie_T3346_value_tmp(kT3346Value);
decoded_size += ie_T3346_value_tmp.Decode( decoded_size += ie_T3346_value_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_T3346_value = std::optional<GPRS_Timer_2>(ie_T3346_value_tmp); ie_T3346_value = std::optional<GPRS_Timer_2>(ie_T3346_value_tmp);
...@@ -163,7 +163,7 @@ int RegistrationReject::Decode( ...@@ -163,7 +163,7 @@ int RegistrationReject::Decode(
} break; } break;
case kT3502Value: { case kT3502Value: {
Logger::nas_mm().debug("Decoding IEI 0x16: T3502 Value"); Logger::nas_mm().debug("Decoding IEI 0x16: T3502 Value");
GPRS_Timer_2 ie_T3502_value_tmp = {}; GPRS_Timer_2 ie_T3502_value_tmp(kT3502Value);
decoded_size += ie_T3502_value_tmp.Decode( decoded_size += ie_T3502_value_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_T3502_value = std::optional<GPRS_Timer_2>(ie_T3502_value_tmp); ie_T3502_value = std::optional<GPRS_Timer_2>(ie_T3502_value_tmp);
......
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