Commit 28bf3fa1 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Add LADN Information

parent 15fdf156
......@@ -45,6 +45,7 @@
#include "GprsTimer3.hpp"
#include "ImeisvRequest.hpp"
#include "LADN_Indication.hpp"
#include "LadnInformation.hpp"
#include "MaPduSessionInformation.hpp"
#include "NasMessageContainer.hpp"
#include "NasSecurityAlgorithms.hpp"
......
......@@ -35,6 +35,12 @@ DNN::DNN(bstring dnn) : Type4NasIe(kIeiDnn) {
SetLengthIndicator(blength(dnn));
}
//------------------------------------------------------------------------------
DNN::DNN(bool iei) : Type4NasIe(), _DNN() {
if (iei) SetIei(kIeiDnn);
SetLengthIndicator(1);
}
//------------------------------------------------------------------------------
DNN::~DNN() {}
......
......@@ -34,6 +34,7 @@ class DNN : public Type4NasIe {
public:
DNN();
DNN(bstring dnn);
DNN(bool iei);
~DNN();
static std::string GetIeName() { return kDnnIeName; }
......
......@@ -19,13 +19,13 @@
* contact@openairinterface.org
*/
#ifndef _LADN_Indication_H_
#define _LADN_Indication_H_
#ifndef _LADN_INDICATION_H_
#define _LADN_INDICATION_H_
#include "Type6NasIe.hpp"
constexpr uint8_t kLadnIndicationMinimumLength = 3;
constexpr uint16_t kLadnIndicationMaximumLength = 1715;
constexpr uint16_t kLadnIndicationMaximumLength = 811;
constexpr auto kLadnIndicationIeName = "LADN Indication";
namespace nas {
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "Ladn.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "Ie_Const.hpp"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
ladn::ladn() : dnn(false), ta_list(false) {}
//------------------------------------------------------------------------------
ladn::~ladn() {}
//------------------------------------------------------------------------------
void ladn::Set(const DNN& value) {
dnn = value;
}
//------------------------------------------------------------------------------
void ladn::Set(const _5GSTrackingAreaIdList& value) {
ta_list = value;
}
//------------------------------------------------------------------------------
uint32_t ladn::GetLength() const {
return (dnn.GetIeLength() + ta_list.GetIeLength());
}
//------------------------------------------------------------------------------
int ladn::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding LADN");
int ie_len = dnn.GetIeLength();
ie_len += ta_list.GetIeLength();
if (len < ie_len) { // Length of the content + IEI/Len
Logger::nas_mm().error(
"Size of the buffer is not enough to store this IE (IE len %d)",
ie_len);
return KEncodeDecodeError;
}
int encoded_size = 0;
int encoded_ie_size = 0;
encoded_ie_size = dnn.Encode(buf + encoded_size, len);
if (encoded_ie_size == KEncodeDecodeError) return KEncodeDecodeError;
encoded_size += encoded_ie_size;
encoded_ie_size = ta_list.Encode(buf + encoded_size, len);
if (encoded_ie_size == KEncodeDecodeError) return KEncodeDecodeError;
encoded_size += encoded_ie_size;
Logger::nas_mm().debug("Encoded LADN, len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int ladn::Decode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding LADN");
int decoded_size = 0;
// TODO:
Logger::nas_mm().debug("Decoded LADN (len %d)", decoded_size);
return decoded_size;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _LADN_H_
#define _LADN_H_
#include "DNN.hpp"
#include "_5GSTrackingAreaIdList.hpp"
#include "Type6NasIe.hpp"
namespace nas {
class ladn {
public:
ladn();
~ladn();
void Set(const DNN& value);
void Set(const _5GSTrackingAreaIdList& value);
uint32_t GetLength() const;
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len);
private:
DNN dnn;
_5GSTrackingAreaIdList ta_list;
};
} // namespace nas
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "LadnInformation.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "Ie_Const.hpp"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
LadnInformation::LadnInformation() : Type6NasIe(kIeiLadnInformation) {
SetLengthIndicator(0);
}
//------------------------------------------------------------------------------
LadnInformation::~LadnInformation() {}
//------------------------------------------------------------------------------
void LadnInformation::Set(const vector<ladn>& value) {
ladn_list.assign(value.begin(), value.end());
}
//------------------------------------------------------------------------------
void LadnInformation::Add(const ladn& value) {
// TODO: Check maximum items - 8
ladn_list.push_back(value);
int ie_len = GetIeLength();
ie_len += value.GetLength();
}
//------------------------------------------------------------------------------
int LadnInformation::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
int ie_len = GetIeLength();
if (len < ie_len) { // Length of the content + IEI/Len
Logger::nas_mm().error(
"Size of the buffer is not enough to store this IE (IE len %d)",
ie_len);
return KEncodeDecodeError;
}
int encoded_size = 0;
/*
// 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++) {
ENCODE_U8(buf + encoded_size, blength(LADN.at(i)), encoded_size);
encoded_size +=
encode_bstring(LADN.at(i), (buf + encoded_size), len - 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;
}
//------------------------------------------------------------------------------
int LadnInformation::Decode(uint8_t* buf, int len, bool is_iei) {
Logger::nas_mm().debug("Decoding EPS_NAS_Message_Container");
int decoded_size = 0;
// IEI and Length
uint16_t ie_len = 0;
int decoded_header_size = Type6NasIe::Decode(buf + decoded_size, len, is_iei);
if (decoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
decoded_size += decoded_header_size;
ie_len = GetLengthIndicator();
/*
uint8_t dnn_len = 0;
bstring dnn = {};
while (ie_len) {
DECODE_U8(buf + decoded_size, dnn_len, decoded_size);
ie_len--;
decode_bstring(&dnn, dnn_len, (buf + decoded_size), len - decoded_size);
decoded_size += dnn_len;
ie_len -= dnn_len;
LADN.insert(LADN.end(), dnn);
}
for (int i = 0; i < LADN.size(); i++) {
for (int j = 0; j < blength(LADN.at(i)); j++) {
Logger::nas_mm().debug(
"Decoded LadnInformation value (0x%x)",
(uint8_t) LADN.at(i)->data[j]);
}
}
*/
Logger::nas_mm().debug(
"Decoded EPS_NAS_Message_Container (len %d)", decoded_size);
return decoded_size;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _LADN_INFORMATION_H_
#define _LADN_INFORMATION_H_
#include "DNN.hpp"
#include "_5GSTrackingAreaIdList.hpp"
#include "Ladn.hpp"
#include "Type6NasIe.hpp"
constexpr uint8_t kLadnInformationMinimumLength = 3;
constexpr uint16_t kLadnInformationMaximumLength = 1715;
constexpr auto kLadnInformationIeName = "LADN Information";
namespace nas {
class LadnInformation : Type6NasIe {
public:
LadnInformation();
~LadnInformation();
static std::string GetIeName() { return kLadnInformationIeName; }
void Set(const vector<ladn>& value);
void Add(const ladn& value);
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
private:
std::vector<ladn> ladn_list;
};
} // namespace nas
#endif
......@@ -36,6 +36,18 @@ _5GSTrackingAreaIdList::_5GSTrackingAreaIdList()
k5gsTrackingAreaIdListMinimumLength -
2); // Minimim length - 2 bytes for header
}
//------------------------------------------------------------------------------
_5GSTrackingAreaIdList::_5GSTrackingAreaIdList(bool iei)
: Type4NasIe(), m_tai_list() {
if (iei) {
SetIei(kIei5gsTrackingAreaIdentityList);
}
SetLengthIndicator(
k5gsTrackingAreaIdListMinimumLength -
2); // Minimim length - 2 bytes for header
}
//------------------------------------------------------------------------------
_5GSTrackingAreaIdList::_5GSTrackingAreaIdList(
const std::vector<p_tai_t>& tai_list)
......
......@@ -36,6 +36,7 @@ namespace nas {
class _5GSTrackingAreaIdList : public Type4NasIe {
public:
_5GSTrackingAreaIdList();
_5GSTrackingAreaIdList(bool iei);
_5GSTrackingAreaIdList(const std::vector<p_tai_t>& tai_list);
int Encode(uint8_t* buf, int len);
......
......@@ -164,7 +164,7 @@ class RegistrationAccept : public NasMmPlainHeader {
ie_pdu_session_reactivation_result; // Optional
std::optional<PDU_Session_Reactivation_Result_Error_Cause>
ie_pdu_session_reactivation_result_error_cause; // Optional
// TODO: std::optional<LadnInformation> ie_ladn_information; //
std::optional<LadnInformation> ie_ladn_information; //
// Optional
std::optional<MicoIndication> ie_mico_indication; // Optional
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