Commit 1f43ee67 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update LADN Indication

parent ca60fb3d
...@@ -113,6 +113,7 @@ constexpr uint8_t kIeiRejectedNssaiRr = 0x69; ...@@ -113,6 +113,7 @@ constexpr uint8_t kIeiRejectedNssaiRr = 0x69;
constexpr uint8_t kIeiEpsNasMessageContainer = 0x70; constexpr uint8_t kIeiEpsNasMessageContainer = 0x70;
constexpr uint8_t kIeiNasMessageContainer = 0x71; constexpr uint8_t kIeiNasMessageContainer = 0x71;
constexpr uint8_t kIeiLadnIndication = 0x74;
constexpr uint8_t kIei5gGuti = 0x77; constexpr uint8_t kIei5gGuti = 0x77;
constexpr uint8_t kIeiImeisv = 0x77; constexpr uint8_t kIeiImeisv = 0x77;
constexpr uint8_t kIeiNonImeisvPei = 0x78; constexpr uint8_t kIeiNonImeisvPei = 0x78;
......
...@@ -23,87 +23,93 @@ ...@@ -23,87 +23,93 @@
#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"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
LADN_Indication::LADN_Indication(uint8_t iei) { LadnIndication::LadnIndication() : Type6NasIe(kIeiLadnIndication) {
_iei = iei;
length = 0;
LADN = {}; LADN = {};
SetIeName(kLadnIndicationIeName);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
LADN_Indication::LADN_Indication(const uint8_t iei, std::vector<bstring> ladn) { LadnIndication::LadnIndication(const std::vector<bstring>& ladn)
_iei = iei; : Type6NasIe(kIeiLadnIndication) {
length = 3; int length = 0;
LADN.assign(ladn.begin(), ladn.end()); LADN.assign(ladn.begin(), ladn.end());
for (int i = 0; i < ladn.size(); i++) { for (int i = 0; i < ladn.size(); i++) {
length = length + blength(ladn.at(i)); length = length + blength(ladn.at(i));
} }
SetLengthIndicator(length);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
LADN_Indication::LADN_Indication() : _iei(), length(), LADN() {} LadnIndication::~LadnIndication() {}
//------------------------------------------------------------------------------
LADN_Indication::~LADN_Indication() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void LADN_Indication::setValue(uint8_t iei) { void LadnIndication::GetValue(std::vector<bstring>& ladn) {
_iei = iei;
}
//------------------------------------------------------------------------------
void LADN_Indication::getValue(std::vector<bstring>& ladn) {
ladn.assign(LADN.begin(), LADN.end()); ladn.assign(LADN.begin(), LADN.end());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int LADN_Indication::Encode(uint8_t* buf, int len) { int LadnIndication::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding LADN_Indication (IEI 0x%x)", _iei); Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
int ie_len = GetIeLength();
if ((len < length + 3) or (len < kLadnIndicationMinimumLength)) { 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"); "Size of the buffer is not enough to store this IE (IE len %d)",
ie_len);
return KEncodeDecodeError; return KEncodeDecodeError;
} }
int encoded_size = 0; int encoded_size = 0;
if (_iei) {
ENCODE_U8(buf + encoded_size, _iei, encoded_size);
}
ENCODE_U16(buf + encoded_size, length, encoded_size); // IEI and Length (later)
int len_pos = 0;
int encoded_header_size =
Type6NasIe::Encode(buf + encoded_size, len, len_pos);
if (encoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
encoded_size += encoded_header_size;
for (int i = 0; i < LADN.size(); i++) { for (int i = 0; i < LADN.size(); i++) {
ENCODE_U8(buf + encoded_size, blength(LADN.at(i)), encoded_size); ENCODE_U8(buf + encoded_size, blength(LADN.at(i)), encoded_size);
encoded_size += encoded_size +=
encode_bstring(LADN.at(i), (buf + encoded_size), len - encoded_size); encode_bstring(LADN.at(i), (buf + encoded_size), len - encoded_size);
} }
Logger::nas_mm().debug("Encoded LADN_Indication (len %d)", encoded_size); // Encode length
int encoded_len_ie = 0;
ENCODE_U16(buf + len_pos, encoded_size - GetHeaderLength(), encoded_len_ie);
Logger::nas_mm().debug(
"Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int LADN_Indication::Decode(uint8_t* buf, int len, bool is_option) { int LadnIndication::Decode(uint8_t* buf, int len, bool is_iei) {
Logger::nas_mm().debug("Decoding LADN_Indication"); Logger::nas_mm().debug("Decoding EPS_NAS_Message_Container");
int decoded_size = 0; int decoded_size = 0;
if (is_option) {
DECODE_U8(buf + decoded_size, _iei, decoded_size); // IEI and Length
} uint16_t ie_len = 0;
length = 0; int decoded_header_size = Type6NasIe::Decode(buf + decoded_size, len, is_iei);
DECODE_U16(buf + decoded_size, length, decoded_size); if (decoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
Logger::nas_mm().debug("Decoded LADN_Indication (len %d)", length); decoded_size += decoded_header_size;
int len_ie = length; ie_len = GetLengthIndicator();
uint8_t len_dnn = 0;
bstring dnn; uint8_t dnn_len = 0;
while (len_ie) { bstring dnn = {};
DECODE_U8(buf + decoded_size, len_dnn, decoded_size); while (ie_len) {
len_ie--; DECODE_U8(buf + decoded_size, dnn_len, decoded_size);
decode_bstring(&dnn, len_dnn, (buf + decoded_size), len - decoded_size); ie_len--;
decoded_size += len_dnn; decode_bstring(&dnn, dnn_len, (buf + decoded_size), len - decoded_size);
len_ie -= len_dnn; decoded_size += dnn_len;
ie_len -= dnn_len;
LADN.insert(LADN.end(), dnn); LADN.insert(LADN.end(), dnn);
} }
...@@ -115,6 +121,7 @@ int LADN_Indication::Decode(uint8_t* buf, int len, bool is_option) { ...@@ -115,6 +121,7 @@ int LADN_Indication::Decode(uint8_t* buf, int len, bool is_option) {
} }
} }
Logger::nas_mm().debug("Decoded LADN_Indication (len %d)", decoded_size); Logger::nas_mm().debug(
"Decoded EPS_NAS_Message_Container (len %d)", decoded_size);
return decoded_size; return decoded_size;
} }
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#ifndef _LADN_Indication_H_ #ifndef _LADN_Indication_H_
#define _LADN_Indication_H_ #define _LADN_Indication_H_
#include "Type6NasIe.hpp"
#include <stdint.h> #include <stdint.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
...@@ -35,23 +37,23 @@ using namespace std; ...@@ -35,23 +37,23 @@ using namespace std;
constexpr uint8_t kLadnIndicationMinimumLength = 3; constexpr uint8_t kLadnIndicationMinimumLength = 3;
constexpr uint16_t kLadnIndicationMaximumLength = 1715; constexpr uint16_t kLadnIndicationMaximumLength = 1715;
constexpr auto kLadnIndicationIeName = "LADN Indication";
namespace nas { namespace nas {
class LADN_Indication { class LadnIndication : Type6NasIe {
public: public:
LADN_Indication(); LadnIndication();
LADN_Indication(uint8_t iei); LadnIndication(const std::vector<bstring>& ladn);
LADN_Indication(const uint8_t iei, std::vector<bstring> ladn); ~LadnIndication();
~LADN_Indication();
void setValue(uint8_t iei); // void SetValue(const std::vector<bstring>& ladn);
void GetValue(std::vector<bstring>& ladn);
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_option);
void getValue(std::vector<bstring>& ladn);
private: private:
uint8_t _iei;
uint16_t length;
std::vector<bstring> LADN; std::vector<bstring> LADN;
}; };
......
...@@ -411,13 +411,13 @@ bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) { ...@@ -411,13 +411,13 @@ bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RegistrationRequest::setLADN_Indication(std::vector<bstring> ladnValue) { void RegistrationRequest::setLADN_Indication(std::vector<bstring> ladnValue) {
ie_ladn_indication = std::make_optional<LADN_Indication>(0x74, ladnValue); ie_ladn_indication = std::make_optional<LadnIndication>(ladnValue);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) { bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) {
if (ie_ladn_indication.has_value()) { if (ie_ladn_indication.has_value()) {
ie_ladn_indication.value().getValue(ladnValue); ie_ladn_indication.value().GetValue(ladnValue);
return true; return true;
} else { } else {
return false; return false;
...@@ -1036,11 +1036,11 @@ int RegistrationRequest::Decode(uint8_t* buf, int len) { ...@@ -1036,11 +1036,11 @@ int RegistrationRequest::Decode(uint8_t* buf, int len) {
} break; } break;
case 0x74: { // TODO: verify IEI value (spec Ox79) case 0x74: { // TODO: verify IEI value (spec Ox79)
Logger::nas_mm().debug("Decoding IEI(0x74)"); Logger::nas_mm().debug("Decoding IEI(0x74)");
LADN_Indication ie_ladn_indication_tmp = {}; LadnIndication ie_ladn_indication_tmp = {};
decoded_size += ie_ladn_indication_tmp.Decode( decoded_size += ie_ladn_indication_tmp.Decode(
buf + decoded_size, len - decoded_size, true); buf + decoded_size, len - decoded_size, true);
ie_ladn_indication = ie_ladn_indication =
std::optional<LADN_Indication>(ie_ladn_indication_tmp); std::optional<LadnIndication>(ie_ladn_indication_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;
......
...@@ -168,7 +168,7 @@ class RegistrationRequest : public NasMmPlainHeader { ...@@ -168,7 +168,7 @@ class RegistrationRequest : public NasMmPlainHeader {
std::optional<_5GS_DRX_Parameters> ie_5gs_drx_parameters; // Optional std::optional<_5GS_DRX_Parameters> ie_5gs_drx_parameters; // Optional
std::optional<EPS_NAS_Message_Container> std::optional<EPS_NAS_Message_Container>
ie_eps_nas_message_container; // Optional ie_eps_nas_message_container; // Optional
std::optional<LADN_Indication> ie_ladn_indication; // Optional std::optional<LadnIndication> ie_ladn_indication; // Optional
std::optional<Payload_Container_Type> ie_payload_container_type; // Optional std::optional<Payload_Container_Type> ie_payload_container_type; // Optional
std::optional<Payload_Container> ie_payload_container; // Optional std::optional<Payload_Container> ie_payload_container; // Optional
std::optional<NetworkSlicingIndication> std::optional<NetworkSlicingIndication>
......
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