Commit 74a81963 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Additional Information

parent 414f19d6
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "5GSRegistrationType.hpp" #include "5GSRegistrationType.hpp"
#include "ABBA.hpp" #include "ABBA.hpp"
#include "Additional5gSecurityInformation.hpp" #include "Additional5gSecurityInformation.hpp"
#include "Additional_Information.hpp" #include "AdditionalInformation.hpp"
#include "AllowedPDUSessionStatus.hpp" #include "AllowedPDUSessionStatus.hpp"
#include "Authentication_Failure_Parameter.hpp" #include "Authentication_Failure_Parameter.hpp"
#include "Authentication_Parameter_AUTN.hpp" #include "Authentication_Parameter_AUTN.hpp"
......
...@@ -19,91 +19,90 @@ ...@@ -19,91 +19,90 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file #include "AdditionalInformation.hpp"
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "Additional_Information.hpp"
#include "logger.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Additional_Information::Additional_Information(uint8_t iei) { AdditionalInformation::AdditionalInformation()
_iei = iei; : Type4NasIe(kIeiAdditionalInformation), value_() {
length = 0; SetLengthIndicator(1); // Minimum 3 octets (-2 for header)
_value = 0; SetIeName(kAdditionalInformationIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Additional_Information::Additional_Information( AdditionalInformation::AdditionalInformation(const bstring& value) {
const uint8_t iei, uint8_t _length, uint8_t value) { value_ = bstrcpy(value);
_iei = iei; SetLengthIndicator(blength(value));
_value = value; SetIeName(kAdditionalInformationIeName);
length = _length;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Additional_Information::Additional_Information() : _iei(), length(), _value() {} AdditionalInformation::~AdditionalInformation() {}
//------------------------------------------------------------------------------
Additional_Information::~Additional_Information() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Additional_Information::setValue(uint8_t iei, uint8_t value) { void AdditionalInformation::SetValue(const bstring& value) {
_iei = iei; value_ = bstrcpy(value);
_value = value;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t Additional_Information::getValue() { void AdditionalInformation::GetValue(bstring& value) const {
return _value; value = bstrcpy(value_);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int Additional_Information::Encode(uint8_t* buf, int len) { int AdditionalInformation::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding Additional_Information iei(0x%x)", _iei); Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
if (len < length) { int ie_len = GetIeLength();
Logger::nas_mm().error("len is less than %d", length);
return 0; if (len < ie_len) {
Logger::nas_mm().error("Len is less than %d", ie_len);
return KEncodeDecodeError;
} }
int encoded_size = 0; int encoded_size = 0;
if (_iei) { // IEI and Length
*(buf + encoded_size) = _iei; int encoded_header_size = Type4NasIe::Encode(buf + encoded_size, len);
encoded_size++; if (encoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
*(buf + encoded_size) = (length - 2); encoded_size += encoded_header_size;
encoded_size++;
*(buf + encoded_size) = _value; // Value
encoded_size++; int size = encode_bstring(value_, (buf + encoded_size), len - encoded_size);
encoded_size += size;
} else {
*(buf + encoded_size) = (length - 1);
encoded_size++;
*(buf + encoded_size) = _value;
encoded_size++;
}
Logger::nas_mm().debug( Logger::nas_mm().debug(
"encoded Additional_Information len(%d)", encoded_size); "Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int Additional_Information::Decode(uint8_t* buf, int len, bool is_option) { int AdditionalInformation::Decode(uint8_t* buf, int len, bool is_iei) {
Logger::nas_mm().debug("decoding Additional_Information iei(0x%x)", *buf); if (len < kAdditionalInformationMinimumLength) {
int decoded_size = 0; Logger::nas_mm().error(
if (is_option) { "Buffer length is less than the minimum length of this IE (%d octet)",
decoded_size++; kAdditionalInformationMinimumLength);
return KEncodeDecodeError;
} }
_value = 0x00;
length = *(buf + decoded_size); uint8_t decoded_size = 0;
decoded_size++; uint8_t octet = 0;
_value = *(buf + decoded_size); Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
decoded_size++;
Logger::nas_mm().debug("decoded Additional_Information value(0x%x)", _value); // 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;
// Value
uint8_t ie_len = GetLengthIndicator();
decode_bstring(&value_, ie_len, (buf + decoded_size), len - decoded_size);
decoded_size += ie_len;
for (int i = 0; i < ie_len; i++) {
Logger::nas_mm().debug("Decoded value 0x%x", (uint8_t) value_->data[i]);
}
Logger::nas_mm().debug( Logger::nas_mm().debug(
"decoded Additional_Information len(%d)", decoded_size); "Decoded %s, len (%d)", GetIeName().c_str(), decoded_size);
return decoded_size; return decoded_size;
} }
...@@ -19,35 +19,31 @@ ...@@ -19,35 +19,31 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file #ifndef _ADDITIONAL_INFORMATION_H_
\brief #define _ADDITIONAL_INFORMATION_H_
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef __Additional_Information_H_ #include "Type4NasIe.hpp"
#define __Additional_Information_H_
#include <stdint.h> constexpr uint8_t kAdditionalInformationMinimumLength = 3;
constexpr uint16_t kAdditionalInformationMaximumLength = 257;
constexpr auto kAdditionalInformationIeName = "Additional Information";
namespace nas { namespace nas {
class Additional_Information { class AdditionalInformation : public Type4NasIe {
public: public:
Additional_Information(); AdditionalInformation();
Additional_Information(uint8_t iei); AdditionalInformation(const bstring& value);
Additional_Information(const uint8_t iei, uint8_t _length, uint8_t value); ~AdditionalInformation();
~Additional_Information();
void setValue(uint8_t iei, uint8_t value);
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);
uint8_t getValue();
void SetValue(const bstring& dnn);
void GetValue(bstring& dnn) const;
private: private:
uint8_t _iei; bstring value_;
uint8_t length;
uint8_t _value;
}; };
} // namespace nas } // namespace nas
......
...@@ -37,7 +37,7 @@ class DNN : public Type4NasIe { ...@@ -37,7 +37,7 @@ class DNN : public Type4NasIe {
~DNN(); ~DNN();
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(const bstring& dnn); void SetValue(const bstring& dnn);
void GetValue(bstring& dnn) const; void GetValue(bstring& dnn) const;
......
...@@ -71,8 +71,8 @@ void DLNASTransport::SetPduSessionId(uint8_t value) { ...@@ -71,8 +71,8 @@ void DLNASTransport::SetPduSessionId(uint8_t value) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void DLNASTransport::SetAdditionalInformation(uint8_t _length, uint8_t value) { void DLNASTransport::SetAdditionalInformation(const bstring& value) {
ie_additional_information = new Additional_Information(0x24, _length, value); ie_additional_information = new AdditionalInformation(value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -196,7 +196,7 @@ int DLNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) { ...@@ -196,7 +196,7 @@ int DLNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
} break; } break;
case 0x24: { case 0x24: {
Logger::nas_mm().debug("Decoding IEI (0x24)"); Logger::nas_mm().debug("Decoding IEI (0x24)");
ie_additional_information = new Additional_Information(); ie_additional_information = new AdditionalInformation();
decoded_size += ie_additional_information->Decode( decoded_size += ie_additional_information->Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
......
...@@ -42,7 +42,7 @@ class DLNASTransport { ...@@ -42,7 +42,7 @@ class DLNASTransport {
void SetPayloadContainer(uint8_t* buf, int len); void SetPayloadContainer(uint8_t* buf, int len);
void SetPduSessionId(uint8_t value); void SetPduSessionId(uint8_t value);
void SetAdditionalInformation(uint8_t _length, uint8_t value); void SetAdditionalInformation(const bstring& value);
void Set5gmmCause(uint8_t value); void Set5gmmCause(uint8_t value);
void SetBackOffTimerValue(uint8_t unit, uint8_t value); void SetBackOffTimerValue(uint8_t unit, uint8_t value);
...@@ -51,7 +51,7 @@ class DLNASTransport { ...@@ -51,7 +51,7 @@ class DLNASTransport {
PayloadContainerType* ie_payload_container_type; PayloadContainerType* ie_payload_container_type;
Payload_Container* ie_payload_container; Payload_Container* ie_payload_container;
PduSessionIdentity2* ie_pdu_session_identity_2; PduSessionIdentity2* ie_pdu_session_identity_2;
Additional_Information* ie_additional_information; AdditionalInformation* ie_additional_information;
_5GMM_Cause* ie_5gmm_cause; _5GMM_Cause* ie_5gmm_cause;
GprsTimer3* ie_back_off_timer_value; GprsTimer3* ie_back_off_timer_value;
}; };
......
...@@ -152,9 +152,8 @@ bool ULNASTransport::getDnn(bstring& dnn) { ...@@ -152,9 +152,8 @@ bool ULNASTransport::getDnn(bstring& dnn) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ULNASTransport::SetAdditionalInformation(uint8_t _length, uint8_t value) { void ULNASTransport::SetAdditionalInformation(const bstring& value) {
ie_additional_information = ie_additional_information = std::make_optional<AdditionalInformation>(value);
std::make_optional<Additional_Information>(0x24, _length, value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -435,7 +434,7 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) { ...@@ -435,7 +434,7 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, 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 0x25: { case kIeiDnn: {
Logger::nas_mm().debug("Decoding IEI (0x25)"); Logger::nas_mm().debug("Decoding IEI (0x25)");
DNN ie_dnn_tmp = {}; DNN ie_dnn_tmp = {};
if ((decoded_result = ie_dnn_tmp.Decode( if ((decoded_result = ie_dnn_tmp.Decode(
...@@ -448,16 +447,16 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) { ...@@ -448,16 +447,16 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, 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 0x24: { case kIeiAdditionalInformation: {
Logger::nas_mm().debug("Decoding IEI (0x24)"); Logger::nas_mm().debug("Decoding IEI 0x%x", kIeiAdditionalInformation);
Additional_Information ie_additional_information_tmp = {}; AdditionalInformation ie_additional_information_tmp = {};
if ((decoded_result = ie_additional_information_tmp.Decode( if ((decoded_result = ie_additional_information_tmp.Decode(
buf + decoded_size, len - decoded_size, true)) == buf + decoded_size, len - decoded_size, true)) ==
KEncodeDecodeError) KEncodeDecodeError)
return decoded_result; return decoded_result;
decoded_size += decoded_result; decoded_size += decoded_result;
ie_additional_information = std::optional<Additional_Information>( ie_additional_information =
ie_additional_information_tmp); std::optional<AdditionalInformation>(ie_additional_information_tmp);
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;
......
...@@ -58,7 +58,7 @@ class ULNASTransport : public NasMmPlainHeader { ...@@ -58,7 +58,7 @@ class ULNASTransport : public NasMmPlainHeader {
void setDNN(bstring dnn); void setDNN(bstring dnn);
bool getDnn(bstring& dnn); bool getDnn(bstring& dnn);
void SetAdditionalInformation(uint8_t _length, uint8_t value); void SetAdditionalInformation(const bstring& value);
void SetMaPduSessionInformation(uint8_t value); void SetMaPduSessionInformation(uint8_t value);
...@@ -73,7 +73,7 @@ class ULNASTransport : public NasMmPlainHeader { ...@@ -73,7 +73,7 @@ class ULNASTransport : public NasMmPlainHeader {
std::optional<RequestType> ie_request_type; // Optional std::optional<RequestType> ie_request_type; // Optional
std::optional<S_NSSAI> ie_s_nssai; // Optional std::optional<S_NSSAI> ie_s_nssai; // Optional
std::optional<DNN> ie_dnn; // Optional std::optional<DNN> ie_dnn; // Optional
std::optional<Additional_Information> ie_additional_information; // Optional std::optional<AdditionalInformation> ie_additional_information; // Optional
std::optional<MA_PDU_Session_Information> std::optional<MA_PDU_Session_Information>
ie_ma_pdu_session_information; // Optional ie_ma_pdu_session_information; // Optional
std::optional<Release_Assistance_Indication> std::optional<Release_Assistance_Indication>
......
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