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

Refactor NG Setup Request/Response and their IEs

parent f80855ca
......@@ -265,9 +265,9 @@ void conv::bstring_2_octet_string(bstring& b_str, OCTET_STRING_t& octet_str) {
}
//------------------------------------------------------------------------------
void conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
bool conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
sd = SD_NO_VALUE;
if (sd_str.empty()) return;
if (sd_str.empty()) return false;
uint8_t base = 10;
try {
if (sd_str.size() > 2) {
......@@ -281,7 +281,57 @@ void conv::sd_string_to_int(const std::string& sd_str, uint32_t& sd) {
"Error when converting from string to int for S-NSSAI SD, error: %s",
e.what());
sd = SD_NO_VALUE;
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool conv::string_to_int(
const std::string& str, uint32_t& value, const uint8_t& base) {
if (str.empty()) return false;
if ((base != 10) or (base != 16)) {
Logger::amf_app().warn("Only support Dec or Hex string value");
return false;
}
if (base == 16) {
if (str.size() <= 2) return false;
if (!boost::iequals(str.substr(0, 2), "0x")) return false;
}
try {
value = std::stoul(str, nullptr, base);
} catch (const std::exception& e) {
Logger::amf_app().error(
"Error when converting from string to int, error: %s", e.what());
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool conv::string_to_int8(const std::string& str, uint8_t& value) {
if (str.empty()) return false;
try {
value = (uint8_t) std::stoi(str);
} catch (const std::exception& e) {
Logger::amf_app().error(
"Error when converting from string to int, error: %s", e.what());
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool conv::string_to_int32(const std::string& str, uint32_t& value) {
if (str.empty()) return false;
try {
value = (uint32_t) std::stoi(str);
} catch (const std::exception& e) {
Logger::amf_app().error(
"Error when converting from string to int, error: %s", e.what());
return false;
}
return true;
}
//------------------------------------------------------------------------------
......@@ -308,7 +358,24 @@ void conv::string_2_octet_string(
const std::string& str, OCTET_STRING_t& o_str) {
o_str.buf = (uint8_t*) calloc(1, str.length() + 1);
// o_str.buf = strcpy(new char[str.length() + 1], str.c_str());
// memcpy(o_str.buf, str.c_str(), str.size());
std::copy(str.begin(), str.end(), o_str.buf);
o_str.buf[str.length()] = '\0';
o_str.size = str.length() + 1;
}
//------------------------------------------------------------------------------
bool conv::int8_2_octet_string(const uint8_t& value, OCTET_STRING_t& o_str) {
o_str.buf = (uint8_t*) calloc(1, sizeof(uint8_t));
if (!o_str.buf) return false;
o_str.size = 1;
o_str.buf[0] = value;
return true;
}
//------------------------------------------------------------------------------
bool conv::octet_string_2_int8(const OCTET_STRING_t& o_str, uint8_t& value) {
if (o_str.size != 1) return false;
value = o_str.buf[0];
return true;
}
......@@ -67,12 +67,18 @@ class conv {
static void octet_string_2_bstring(
const OCTET_STRING_t& octet_str, bstring& b_str);
static void bstring_2_octet_string(bstring& b_str, OCTET_STRING_t& octet_str);
static void sd_string_to_int(const std::string& sd_str, uint32_t& sd);
static bool sd_string_to_int(const std::string& sd_str, uint32_t& sd);
static bool string_to_int(
const std::string& str, uint32_t& value, const uint8_t& base);
static bool string_to_int8(const std::string& str, uint8_t& value);
static bool string_to_int32(const std::string& str, uint32_t& value);
static void bstring_2_string(const bstring& b_str, std::string& str);
static void string_2_bstring(const std::string& str, bstring& b_str);
static void octet_string_2_string(
const OCTET_STRING_t& octet_str, std::string& str);
static void string_2_octet_string(
const std::string& str, OCTET_STRING_t& o_str);
static bool int8_2_octet_string(const uint8_t& value, OCTET_STRING_t& o_str);
static bool octet_string_2_int8(const OCTET_STRING_t& o_str, uint8_t& value);
};
#endif /* FILE_CONVERSIONS_HPP_SEEN */
......@@ -21,54 +21,38 @@
#include "AMFName.hpp"
extern "C" {
#include "OCTET_STRING.h"
}
#include <iostream>
using namespace std;
#include "conversions.hpp"
namespace ngap {
//------------------------------------------------------------------------------
AmfName::AmfName() {
amfname = nullptr;
}
AmfName::AmfName() {}
//------------------------------------------------------------------------------
AmfName::~AmfName() {
free(amfname);
amfname = nullptr;
}
AmfName::~AmfName() {}
//------------------------------------------------------------------------------
void AmfName::setValue(const std::string m_amfName) {
if (amfname) {
free(amfname);
amfname = nullptr;
}
amfname = (char*) calloc(1, m_amfName.size() + 1);
memcpy(amfname, m_amfName.c_str(), m_amfName.size());
amfname[m_amfName.size()] = '\0';
bool AmfName::setValue(const std::string& amf_name) {
if (amf_name.size() > AMF_NAME_SIZE_MAX) return false;
amf_name_ = amf_name;
return true;
}
//------------------------------------------------------------------------------
void AmfName::getValue(std::string& m_amfName) {
if (amfname) m_amfName = amfname;
void AmfName::getValue(std::string& amf_name) const {
amf_name = amf_name_;
}
//------------------------------------------------------------------------------
bool AmfName::encode2AmfName(Ngap_AMFName_t* amfNameIe) {
if (amfname)
if (OCTET_STRING_fromBuf(amfNameIe, amfname, strlen(amfname)) < 0)
return false;
bool AmfName::encode(Ngap_AMFName_t* amf_name_ie) {
conv::string_2_octet_string(amf_name_, *amf_name_ie);
return true;
}
//------------------------------------------------------------------------------
bool AmfName::decodefromAmfName(Ngap_AMFName_t* pdu) {
if (!pdu->buf) return false;
amfname = (char*) pdu->buf;
bool AmfName::decode(const Ngap_AMFName_t* amf_name_ie) {
if (!amf_name_ie->buf) return false;
conv::octet_string_2_string(*amf_name_ie, amf_name_);
return true;
}
......
......@@ -28,6 +28,7 @@ extern "C" {
#include "Ngap_AMFName.h"
}
constexpr uint8_t AMF_NAME_SIZE_MAX = 150;
namespace ngap {
class AmfName {
......@@ -35,13 +36,13 @@ class AmfName {
AmfName();
virtual ~AmfName();
bool encode2AmfName(Ngap_AMFName_t*);
bool decodefromAmfName(Ngap_AMFName_t*);
void setValue(const std::string m_amfName);
void getValue(std::string&);
bool encode(Ngap_AMFName_t*);
bool decode(const Ngap_AMFName_t*);
bool setValue(const std::string& amf_name);
void getValue(std::string& amf_name) const;
private:
char* amfname;
std::string amf_name_;
};
} // namespace ngap
......
......@@ -97,7 +97,7 @@ bool CoreNetworkAssistanceInfo::encode2CoreNetworkAssistanceInfo(
Ngap_PagingDRX_t* pagingdrx =
(Ngap_PagingDRX_t*) calloc(1, sizeof(Ngap_PagingDRX_t));
if (!pagingdrx) return false;
if (!pagingDRX->encode2DefaultPagingDRX(*pagingdrx)) return false;
if (!pagingDRX->encode(*pagingdrx)) return false;
coreNetworkAssistanceInformation->uESpecificDRX = pagingdrx;
}
......@@ -138,8 +138,7 @@ bool CoreNetworkAssistanceInfo::decodefromCoreNetworkAssistanceInfo(
if (coreNetworkAssistanceInformation->uESpecificDRX) {
if (pagingDRX == nullptr) pagingDRX = new DefaultPagingDRX();
if (!pagingDRX->decodefromDefaultPagingDRX(
*(coreNetworkAssistanceInformation->uESpecificDRX)))
if (!pagingDRX->decode(*(coreNetworkAssistanceInformation->uESpecificDRX)))
return false;
}
......
......@@ -28,32 +28,32 @@ namespace ngap {
//------------------------------------------------------------------------------
DefaultPagingDRX::DefaultPagingDRX() {
pagingDrx = 0;
paging_drx_ = 0;
}
//------------------------------------------------------------------------------
DefaultPagingDRX::~DefaultPagingDRX() {}
//------------------------------------------------------------------------------
void DefaultPagingDRX::setValue(e_Ngap_PagingDRX m_pagingDrx) {
pagingDrx = m_pagingDrx;
void DefaultPagingDRX::setValue(const e_Ngap_PagingDRX& paging_drx) {
paging_drx_ = paging_drx;
}
//------------------------------------------------------------------------------
bool DefaultPagingDRX::encode2DefaultPagingDRX(Ngap_PagingDRX_t& pagingdrx) {
pagingdrx = pagingDrx;
return true;
int DefaultPagingDRX::getValue() const {
return paging_drx_;
}
//------------------------------------------------------------------------------
bool DefaultPagingDRX::decodefromDefaultPagingDRX(Ngap_PagingDRX_t& pagingdrx) {
pagingDrx = pagingdrx;
bool DefaultPagingDRX::encode(Ngap_PagingDRX_t& paging_drx) {
paging_drx = paging_drx_;
return true;
}
//------------------------------------------------------------------------------
int DefaultPagingDRX::getValue() {
return pagingDrx;
bool DefaultPagingDRX::decode(const Ngap_PagingDRX_t& paging_drx) {
paging_drx_ = paging_drx;
return true;
}
} // namespace ngap
......@@ -33,13 +33,13 @@ class DefaultPagingDRX {
DefaultPagingDRX();
virtual ~DefaultPagingDRX();
void setValue(e_Ngap_PagingDRX m_pagingDrx);
int getValue();
bool encode2DefaultPagingDRX(Ngap_PagingDRX_t&);
bool decodefromDefaultPagingDRX(Ngap_PagingDRX_t&);
void setValue(const e_Ngap_PagingDRX& paging_drx);
int getValue() const;
bool encode(Ngap_PagingDRX_t&);
bool decode(const Ngap_PagingDRX_t&);
private:
int pagingDrx;
int paging_drx_;
};
} // namespace ngap
......
......@@ -36,45 +36,42 @@ PLMNSupportItem::PLMNSupportItem() {}
PLMNSupportItem::~PLMNSupportItem() {}
//------------------------------------------------------------------------------
void PLMNSupportItem::setPlmnSliceSupportList(
const PlmnId& m_plmn, const std::vector<S_NSSAI>& m_snssais) {
plmn = m_plmn;
snssais = m_snssais;
void PLMNSupportItem::set(
const PlmnId& plmn_id, const std::vector<S_NSSAI>& snssais) {
plmn_id_ = plmn_id;
slice_support_list_ = snssais;
}
//------------------------------------------------------------------------------
bool PLMNSupportItem::encode2PLMNSupportItem(
Ngap_PLMNSupportItem_t* plmnsupportItem) {
if (!plmn.encode(plmnsupportItem->pLMNIdentity)) return false;
for (std::vector<S_NSSAI>::iterator it = std::begin(snssais);
it < std::end(snssais); ++it) {
void PLMNSupportItem::get(PlmnId& plmn_id, std::vector<S_NSSAI>& snssais) {
plmn_id = plmn_id_;
snssais = slice_support_list_;
}
//------------------------------------------------------------------------------
bool PLMNSupportItem::encode(Ngap_PLMNSupportItem_t* plmn_support_item) {
if (!plmn_id_.encode(plmn_support_item->pLMNIdentity)) return false;
for (std::vector<S_NSSAI>::iterator it = std::begin(slice_support_list_);
it < std::end(slice_support_list_); ++it) {
Ngap_SliceSupportItem_t* slice =
(Ngap_SliceSupportItem_t*) calloc(1, sizeof(Ngap_SliceSupportItem_t));
if (!it->encode2S_NSSAI(&slice->s_NSSAI)) return false;
ASN_SEQUENCE_ADD(&plmnsupportItem->sliceSupportList.list, slice);
if (!it->encode(&slice->s_NSSAI)) return false;
ASN_SEQUENCE_ADD(&plmn_support_item->sliceSupportList.list, slice);
}
return true;
}
//------------------------------------------------------------------------------
bool PLMNSupportItem::decodefromPLMNSupportItem(
Ngap_PLMNSupportItem_t* plmnsupportItem) {
if (!plmn.decode(plmnsupportItem->pLMNIdentity)) return false;
bool PLMNSupportItem::decode(Ngap_PLMNSupportItem_t* plmn_support_item) {
if (!plmn_id_.decode(plmn_support_item->pLMNIdentity)) return false;
for (int i = 0; i < plmnsupportItem->sliceSupportList.list.count; i++) {
for (int i = 0; i < plmn_support_item->sliceSupportList.list.count; i++) {
S_NSSAI snssai = {};
if (!snssai.decodefromS_NSSAI(
&plmnsupportItem->sliceSupportList.list.array[i]->s_NSSAI))
if (!snssai.decode(
&plmn_support_item->sliceSupportList.list.array[i]->s_NSSAI))
return false;
snssais.push_back(snssai);
slice_support_list_.push_back(snssai);
}
return true;
}
//------------------------------------------------------------------------------
void PLMNSupportItem::getPlmnSliceSupportList(
PlmnId& m_plmn, std::vector<S_NSSAI>& m_snssais) {
m_plmn = plmn;
m_snssais = snssais;
}
} // namespace ngap
......@@ -37,16 +37,15 @@ class PLMNSupportItem {
PLMNSupportItem();
virtual ~PLMNSupportItem();
void setPlmnSliceSupportList(
const PlmnId& m_plmn, const std::vector<S_NSSAI>& m_snssais);
void getPlmnSliceSupportList(PlmnId& m_plmn, std::vector<S_NSSAI>& m_snssais);
void set(const PlmnId& plmn_id, const std::vector<S_NSSAI>& snssais);
void get(PlmnId& plmn_id, std::vector<S_NSSAI>& snssais);
bool encode2PLMNSupportItem(Ngap_PLMNSupportItem_t*);
bool decodefromPLMNSupportItem(Ngap_PLMNSupportItem_t*);
bool encode(Ngap_PLMNSupportItem_t*);
bool decode(Ngap_PLMNSupportItem_t*);
private:
PlmnId plmn; // Mandatory
std::vector<S_NSSAI> snssais; // Mandatory
PlmnId plmn_id_; // Mandatory
std::vector<S_NSSAI> slice_support_list_; // Mandatory
};
} // namespace ngap
......
......@@ -32,47 +32,44 @@ PLMNSupportList::PLMNSupportList() {}
PLMNSupportList::~PLMNSupportList() {}
//------------------------------------------------------------------------------
bool PLMNSupportList::encode2PLMNSupportList(
Ngap_PLMNSupportList_t* plmnsupportList) {
for (std::vector<PLMNSupportItem>::iterator it = std::begin(plmnSupportItems);
it != std::end(plmnSupportItems); ++it) {
bool PLMNSupportList::encode(Ngap_PLMNSupportList_t& plmn_support_list) {
for (std::vector<PLMNSupportItem>::iterator it = std::begin(list_);
it != std::end(list_); ++it) {
Ngap_PLMNSupportItem_t* supportItem =
(Ngap_PLMNSupportItem_t*) calloc(1, sizeof(Ngap_PLMNSupportItem_t));
if (!supportItem) return false;
if (!it->encode2PLMNSupportItem(supportItem)) return false;
if (ASN_SEQUENCE_ADD(&plmnsupportList->list, supportItem) != 0)
if (!it->encode(supportItem)) return false;
if (ASN_SEQUENCE_ADD(&plmn_support_list.list, supportItem) != 0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool PLMNSupportList::decodefromPLMNSupportList(
Ngap_PLMNSupportList_t* plmnsupportList) {
for (int i = 0; i < plmnsupportList->list.count; i++) {
bool PLMNSupportList::decode(Ngap_PLMNSupportList_t& plmn_support_list) {
list_.clear();
for (int i = 0; i < plmn_support_list.list.count; i++) {
PLMNSupportItem item = {};
if (!item.decodefromPLMNSupportItem(plmnsupportList->list.array[i]))
return false;
plmnSupportItems.push_back(item);
if (!item.decode(plmn_support_list.list.array[i])) return false;
list_.push_back(item);
}
return true;
}
//------------------------------------------------------------------------------
void PLMNSupportList::addPLMNSupportItems(
const std::vector<PLMNSupportItem>& items) {
plmnSupportItems = items;
void PLMNSupportList::set(const std::vector<PLMNSupportItem>& items) {
list_ = items;
}
//------------------------------------------------------------------------------
void PLMNSupportList::getPLMNSupportItems(std::vector<PLMNSupportItem>& items) {
items = plmnSupportItems;
void PLMNSupportList::get(std::vector<PLMNSupportItem>& items) {
items = list_;
}
//------------------------------------------------------------------------------
void PLMNSupportList::addPLMNSupportItem(const PLMNSupportItem& item) {
plmnSupportItems.push_back(item);
void PLMNSupportList::addItem(const PLMNSupportItem& item) {
list_.push_back(item);
}
} // namespace ngap
......@@ -36,16 +36,16 @@ class PLMNSupportList {
PLMNSupportList();
virtual ~PLMNSupportList();
bool encode2PLMNSupportList(Ngap_PLMNSupportList_t*);
bool decodefromPLMNSupportList(Ngap_PLMNSupportList_t*);
bool encode(Ngap_PLMNSupportList_t&);
bool decode(Ngap_PLMNSupportList_t&);
void addPLMNSupportItems(const std::vector<PLMNSupportItem>& items);
void getPLMNSupportItems(std::vector<PLMNSupportItem>& items);
void set(const std::vector<PLMNSupportItem>& items);
void get(std::vector<PLMNSupportItem>& items);
void addPLMNSupportItem(const PLMNSupportItem& item);
void addItem(const PLMNSupportItem& item);
private:
std::vector<PLMNSupportItem> plmnSupportItems;
std::vector<PLMNSupportItem> list_;
};
} // namespace ngap
......
......@@ -34,8 +34,10 @@ RanNodeName::RanNodeName() {
RanNodeName::~RanNodeName() {}
//------------------------------------------------------------------------------
void RanNodeName::setValue(const std::string& value) {
bool RanNodeName::setValue(const std::string& value) {
if (value.size() > RAN_NODE_NAME_SIZE_MAX) return false;
ran_node_name_ = value;
return true;
}
//------------------------------------------------------------------------------
......
......@@ -28,6 +28,7 @@ extern "C" {
#include <string>
constexpr uint8_t RAN_NODE_NAME_SIZE_MAX = 150;
namespace ngap {
class RanNodeName {
......@@ -35,7 +36,7 @@ class RanNodeName {
RanNodeName();
virtual ~RanNodeName();
void setValue(const std::string& value);
bool setValue(const std::string& value);
void getValue(std::string& value) const;
bool encode(Ngap_RANNodeName_t&);
......
......@@ -21,43 +21,37 @@
#include "RelativeAMFCapacity.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
RelativeAMFCapacity::RelativeAMFCapacity() {
amfcapacity = 0;
amf_capacity_ = 0;
}
//------------------------------------------------------------------------------
RelativeAMFCapacity::~RelativeAMFCapacity() {}
//------------------------------------------------------------------------------
void RelativeAMFCapacity::setValue(long m_amfcapacity) {
amfcapacity = m_amfcapacity;
if (m_amfcapacity > 255)
cout << "[Warning] RelativeAMFCapacity > 255 !" << endl;
void RelativeAMFCapacity::setValue(uint8_t amf_capacity) {
amf_capacity_ = amf_capacity;
}
//------------------------------------------------------------------------------
long RelativeAMFCapacity::getValue() {
return amfcapacity;
uint8_t RelativeAMFCapacity::getValue() const {
return amf_capacity_;
}
//------------------------------------------------------------------------------
bool RelativeAMFCapacity::encode2RelativeAMFCapacity(
Ngap_RelativeAMFCapacity_t* amfCapacityIe) {
*amfCapacityIe = amfcapacity;
bool RelativeAMFCapacity::encode(
Ngap_RelativeAMFCapacity_t& amf_capacity_ie) const {
amf_capacity_ie = amf_capacity_;
return true;
}
//------------------------------------------------------------------------------
bool RelativeAMFCapacity::decodefromRelativeAMFCapacity(
Ngap_RelativeAMFCapacity_t* pdu) {
amfcapacity = *pdu;
bool RelativeAMFCapacity::decode(
const Ngap_RelativeAMFCapacity_t& amf_capacity_ie) {
amf_capacity_ = (uint8_t) amf_capacity_ie;
return true;
}
......
......@@ -33,13 +33,13 @@ class RelativeAMFCapacity {
RelativeAMFCapacity();
virtual ~RelativeAMFCapacity();
bool encode2RelativeAMFCapacity(Ngap_RelativeAMFCapacity_t*);
bool decodefromRelativeAMFCapacity(Ngap_RelativeAMFCapacity_t*);
void setValue(long m_amfcapacity);
long getValue();
bool encode(Ngap_RelativeAMFCapacity_t&) const;
bool decode(const Ngap_RelativeAMFCapacity_t&);
void setValue(uint8_t amf_capacity);
uint8_t getValue() const;
private:
long amfcapacity;
uint8_t amf_capacity_;
};
} // namespace ngap
......
......@@ -22,143 +22,131 @@
#include "S-NSSAI.hpp"
#include "amf.hpp"
#include "String2Value.hpp"
using namespace std;
#include "conversions.hpp"
namespace ngap {
//------------------------------------------------------------------------------
S_NSSAI::S_NSSAI() {
sdIsSet = false;
sst = 0;
sd = SD_NO_VALUE;
// sdIsSet = false;
sst_ = 0;
// sd = SD_NO_VALUE;
sd_ = std::nullopt;
}
//------------------------------------------------------------------------------
S_NSSAI::~S_NSSAI() {}
//------------------------------------------------------------------------------
bool S_NSSAI::sSTEncode2OctetString(Ngap_SST_t& m_sst) {
m_sst.size = 1;
uint8_t* buffer = (uint8_t*) calloc(1, sizeof(uint8_t));
if (!buffer) return false;
*buffer = sst;
m_sst.buf = buffer;
return true;
}
//------------------------------------------------------------------------------
bool S_NSSAI::sSTdecodefromOctetString(Ngap_SST_t m_sst) {
if (!m_sst.buf) return false;
sst = *m_sst.buf;
return true;
}
//------------------------------------------------------------------------------
bool S_NSSAI::sDEncode2OctetString(Ngap_SD_t* m_sd) {
m_sd->size = 3;
uint8_t* buffer = (uint8_t*) calloc(1, sizeof(uint8_t) + sizeof(uint16_t));
if (!buffer) return false;
buffer[0] = (sd & 0x00ff0000) >> 16;
buffer[1] = (sd & 0x0000ff00) >> 8;
buffer[2] = (sd & 0x000000ff) >> 0;
m_sd->buf = buffer;
bool S_NSSAI::EncodeSD(Ngap_SD_t* m_sd) {
if (!sd_.has_value()) {
return false;
}
m_sd->size = 3;
m_sd->buf = (uint8_t*) calloc(3, sizeof(uint8_t));
if (!m_sd->buf) return false;
m_sd->buf[0] = (sd_.value() & 0x00ff0000) >> 16;
m_sd->buf[1] = (sd_.value() & 0x0000ff00) >> 8;
m_sd->buf[2] = (sd_.value() & 0x000000ff) >> 0;
return true;
}
//------------------------------------------------------------------------------
bool S_NSSAI::sDdecodefromOctetString(Ngap_SD_t* m_sd) {
bool S_NSSAI::DecodeSD(Ngap_SD_t* m_sd) {
if (!m_sd->buf) return false;
uint32_t value = SD_NO_VALUE;
if (m_sd->size == 3) {
sd = ((m_sd->buf[0] << 16) + (m_sd->buf[1] << 8) + m_sd->buf[2]);
sd_ = ((m_sd->buf[0] << 16) + (m_sd->buf[1] << 8) + m_sd->buf[2]);
sd_ = std::optional<uint32_t>(value);
return true;
} else if (m_sd->size == 4) {
sd = ((m_sd->buf[1] << 16) + (m_sd->buf[2] << 8) + m_sd->buf[3]);
sd_ = ((m_sd->buf[1] << 16) + (m_sd->buf[2] << 8) + m_sd->buf[3]);
sd_ = std::optional<uint32_t>(value);
return true;
}
return false;
}
//------------------------------------------------------------------------------
void S_NSSAI::setSst(const std::string charSst) {
sst = fromString<int>(charSst);
void S_NSSAI::setSst(const std::string& sst) {
conv::string_to_int8(sst, sst_);
}
//------------------------------------------------------------------------------
void S_NSSAI::setSst(const uint8_t s) {
sst = s;
void S_NSSAI::setSst(const uint8_t& sst) {
sst_ = sst;
}
//------------------------------------------------------------------------------
void S_NSSAI::getSst(std::string& charSst) const {
charSst = to_string((int) sst);
void S_NSSAI::getSst(std::string& sst) const {
sst = std::to_string(sst_);
}
//------------------------------------------------------------------------------
std::string S_NSSAI::getSst() const {
return to_string((int) sst);
return std::to_string(sst_);
}
//------------------------------------------------------------------------------
void S_NSSAI::setSd(const std::string charSd) {
sdIsSet = true;
sd = fromString<int>(charSd);
void S_NSSAI::setSd(const std::string& sd_str) {
uint32_t sd = SD_NO_VALUE;
if (conv::sd_string_to_int(sd_str, sd)) {
sd_ = std::optional<uint32_t>(sd);
}
}
//------------------------------------------------------------------------------
void S_NSSAI::setSd(const uint32_t s) {
sdIsSet = true;
sd = s;
void S_NSSAI::setSd(const uint32_t& sd) {
sd_ = std::optional<uint32_t>(sd);
}
//------------------------------------------------------------------------------
bool S_NSSAI::getSd(std::string& s_nssaiSd) const {
if (sdIsSet) {
s_nssaiSd = to_string(sd);
} else {
s_nssaiSd = to_string(SD_NO_VALUE);
bool S_NSSAI::getSd(std::string& sd) const {
if (sd_.has_value()) {
sd = std::to_string(sd_.value());
return true;
}
return sdIsSet;
sd = std::to_string(SD_NO_VALUE);
return false;
}
//------------------------------------------------------------------------------
bool S_NSSAI::getSd(uint32_t& s_nssaiSd) const {
if (sdIsSet) {
s_nssaiSd = sd;
} else {
s_nssaiSd = SD_NO_VALUE;
bool S_NSSAI::getSd(uint32_t& sd) const {
if (sd_.has_value()) {
sd = sd_.value();
return true;
}
return sdIsSet;
sd = SD_NO_VALUE;
return false;
}
//------------------------------------------------------------------------------
std::string S_NSSAI::getSd() const {
if (sdIsSet) {
return to_string(sd);
} else
return to_string(SD_NO_VALUE);
if (sd_.has_value()) {
return std::to_string(sd_.value());
}
return std::to_string(SD_NO_VALUE);
}
//------------------------------------------------------------------------------
bool S_NSSAI::encode2S_NSSAI(Ngap_S_NSSAI_t* s_NSSAI) {
if (!sSTEncode2OctetString(s_NSSAI->sST)) return false;
if (sdIsSet && (sd != SD_NO_VALUE)) {
Ngap_SD_t* sd_tmp = (Ngap_SD_t*) calloc(1, sizeof(Ngap_SD_t));
if (!sd_tmp) return false;
if (!sDEncode2OctetString(sd_tmp)) {
free(sd_tmp);
bool S_NSSAI::encode(Ngap_S_NSSAI_t* s_NSSAI) {
conv::int8_2_octet_string(sst_, s_NSSAI->sST);
if (sd_.has_value()) {
s_NSSAI->sD = (Ngap_SD_t*) calloc(1, sizeof(Ngap_SD_t));
if (!s_NSSAI->sD) return false;
if (!EncodeSD(s_NSSAI->sD)) {
return false;
}
s_NSSAI->sD = sd_tmp;
}
return true;
}
//------------------------------------------------------------------------------
bool S_NSSAI::decodefromS_NSSAI(Ngap_S_NSSAI_t* s_NSSAI) {
if (!sSTdecodefromOctetString(s_NSSAI->sST)) return false;
sd = SD_NO_VALUE;
bool S_NSSAI::decode(Ngap_S_NSSAI_t* s_NSSAI) {
if (!conv::octet_string_2_int8(s_NSSAI->sST, sst_)) return false;
if (s_NSSAI->sD) {
sdIsSet = true;
if (!sDdecodefromOctetString(s_NSSAI->sD)) return false;
if (!DecodeSD(s_NSSAI->sD)) return false;
}
return true;
}
......
......@@ -22,7 +22,7 @@
#ifndef _S_NSSAI_H_
#define _S_NSSAI_H_
#include <string>
#include <optional>
extern "C" {
#include "Ngap_S-NSSAI.h"
......@@ -36,26 +36,25 @@ class S_NSSAI {
public:
S_NSSAI();
virtual ~S_NSSAI();
bool sSTEncode2OctetString(Ngap_SST_t&);
bool sSTdecodefromOctetString(Ngap_SST_t);
bool sDEncode2OctetString(Ngap_SD_t*);
bool sDdecodefromOctetString(Ngap_SD_t*);
void setSst(const std::string charSst);
void setSst(const uint8_t s);
void getSst(std::string& charSst) const;
bool EncodeSD(Ngap_SD_t*);
bool DecodeSD(Ngap_SD_t*);
void setSst(const std::string& sst);
void setSst(const uint8_t& sst);
void getSst(std::string& sst) const;
std::string getSst() const;
void setSd(const std::string charSd);
void setSd(const uint32_t s);
bool getSd(std::string& s_nssaiSd) const;
void setSd(const std::string& sd_str);
void setSd(const uint32_t& sd);
bool getSd(std::string& sd) const;
std::string getSd() const;
bool getSd(uint32_t& s_nssaiSd) const;
bool encode2S_NSSAI(Ngap_S_NSSAI_t*);
bool decodefromS_NSSAI(Ngap_S_NSSAI_t*);
bool encode(Ngap_S_NSSAI_t*);
bool decode(Ngap_S_NSSAI_t*);
private:
uint8_t sst; // mandatory OCTET_STRING(SIZE(1))
uint32_t sd; // OCTET_STRING(SIZE(3))
bool sdIsSet;
uint8_t sst_; // mandatory OCTET_STRING(SIZE(1))
// uint32_t sd; // OCTET_STRING(SIZE(3))
std::optional<uint32_t> sd_;
// bool sdIsSet;
};
} // namespace ngap
......
......@@ -25,8 +25,7 @@ namespace ngap {
//------------------------------------------------------------------------------
ServedGUAMIItem::ServedGUAMIItem() {
backupAMFName = nullptr;
backupAMFNameIsSet = false;
backupAMFName = std::nullopt;
}
//------------------------------------------------------------------------------
......@@ -38,21 +37,26 @@ void ServedGUAMIItem::setGUAMI(const GUAMI& m_guami) {
}
//------------------------------------------------------------------------------
void ServedGUAMIItem::setBackupAMFName(AmfName* m_backupAMFName) {
backupAMFNameIsSet = true;
backupAMFName = m_backupAMFName;
void ServedGUAMIItem::setBackupAMFName(const AmfName& amf_name) {
backupAMFName = std::optional<AmfName>(amf_name);
}
//------------------------------------------------------------------------------
bool ServedGUAMIItem::getBackupAMFName(AmfName& amf_name) const {
if (!backupAMFName.has_value()) return false;
amf_name = backupAMFName.value();
return true;
}
//------------------------------------------------------------------------------
bool ServedGUAMIItem::encode2ServedGUAMIItem(
Ngap_ServedGUAMIItem* servedGUAMIItem) {
if (!guamiGroup.encode2GUAMI(&(servedGUAMIItem->gUAMI))) return false;
if (backupAMFNameIsSet) {
Ngap_AMFName_t* backupamfname =
if (backupAMFName.has_value()) {
servedGUAMIItem->backupAMFName =
(Ngap_AMFName_t*) calloc(1, sizeof(Ngap_AMFName_t));
if (!backupamfname) return false;
if (!backupAMFName->encode2AmfName(backupamfname)) return false;
servedGUAMIItem->backupAMFName = backupamfname;
if (!servedGUAMIItem->backupAMFName) return false;
if (!backupAMFName.value().encode(servedGUAMIItem->backupAMFName))
return false;
}
return true;
}
......@@ -61,9 +65,9 @@ bool ServedGUAMIItem::encode2ServedGUAMIItem(
bool ServedGUAMIItem::decodefromServedGUAMIItem(Ngap_ServedGUAMIItem* pdu) {
if (!guamiGroup.decodefromGUAMI(&pdu->gUAMI)) return false;
if (pdu->backupAMFName) {
backupAMFNameIsSet = true;
backupAMFName = new AmfName();
if (!backupAMFName->decodefromAmfName(pdu->backupAMFName)) return false;
AmfName amf_name = {};
if (!amf_name.decode(pdu->backupAMFName)) return false;
backupAMFName = std::optional<AmfName>(amf_name);
}
return true;
}
......@@ -73,9 +77,4 @@ void ServedGUAMIItem::getGUAMI(GUAMI& m_guami) {
m_guami = guamiGroup;
}
//------------------------------------------------------------------------------
bool ServedGUAMIItem::getBackupAMFName(AmfName*& m_backupAMFName) {
m_backupAMFName = backupAMFName;
return backupAMFNameIsSet;
}
} // namespace ngap
......@@ -25,6 +25,8 @@
#include "AMFName.hpp"
#include "GUAMI.hpp"
#include <optional>
extern "C" {
#include "Ngap_ServedGUAMIItem.h"
}
......@@ -39,16 +41,16 @@ class ServedGUAMIItem {
void setGUAMI(const GUAMI& m_guami);
void getGUAMI(GUAMI& m_guami);
void setBackupAMFName(AmfName*);
bool getBackupAMFName(AmfName*&);
void setBackupAMFName(const AmfName&);
bool getBackupAMFName(AmfName&) const;
bool encode2ServedGUAMIItem(Ngap_ServedGUAMIItem*);
bool decodefromServedGUAMIItem(Ngap_ServedGUAMIItem*);
private:
GUAMI guamiGroup; // Mandatory
AmfName* backupAMFName; // Optional
bool backupAMFNameIsSet;
GUAMI guamiGroup; // Mandatory
std::optional<AmfName> backupAMFName; // Optional
// bool backupAMFNameIsSet;
// TODO: GUAMI Type (Optional)
};
......
......@@ -30,44 +30,42 @@ ServedGUAMIList::ServedGUAMIList() {}
ServedGUAMIList::~ServedGUAMIList() {}
//------------------------------------------------------------------------------
bool ServedGUAMIList::encode2ServedGUAMIList(
Ngap_ServedGUAMIList_t* servedGUAMIList) {
void ServedGUAMIList::set(const std::vector<ServedGUAMIItem>& list) {
itemList = list;
}
//------------------------------------------------------------------------------
void ServedGUAMIList::get(std::vector<ServedGUAMIItem>& list) const {
list = itemList;
}
//------------------------------------------------------------------------------
void ServedGUAMIList::addItem(const ServedGUAMIItem& item) {
itemList.push_back(item);
}
//------------------------------------------------------------------------------
bool ServedGUAMIList::encode(Ngap_ServedGUAMIList_t& servedGUAMIList) {
for (std::vector<ServedGUAMIItem>::iterator it = std::begin(itemList);
it != std::end(itemList); ++it) {
Ngap_ServedGUAMIItem* guamiItem =
(Ngap_ServedGUAMIItem*) calloc(1, sizeof(Ngap_ServedGUAMIItem));
if (!guamiItem) return false;
if (!it->encode2ServedGUAMIItem(guamiItem)) return false;
if (ASN_SEQUENCE_ADD(&servedGUAMIList->list, guamiItem) != 0) return false;
if (ASN_SEQUENCE_ADD(&servedGUAMIList.list, guamiItem) != 0) return false;
}
return true;
}
//------------------------------------------------------------------------------
bool ServedGUAMIList::decodefromServedGUAMIList(Ngap_ServedGUAMIList_t* pdu) {
// itemList.clear();
for (int i = 0; i < pdu->list.count; i++) {
bool ServedGUAMIList::decode(const Ngap_ServedGUAMIList_t& pdu) {
itemList.clear();
for (int i = 0; i < pdu.list.count; i++) {
ServedGUAMIItem item = {};
if (item.decodefromServedGUAMIItem(pdu->list.array[i])) return false;
if (item.decodefromServedGUAMIItem(pdu.list.array[i])) return false;
itemList.push_back(item);
}
return true;
}
//------------------------------------------------------------------------------
void ServedGUAMIList::addServedGUAMIItems(
const std::vector<ServedGUAMIItem>& list) {
itemList = list;
}
//------------------------------------------------------------------------------
void ServedGUAMIList::getServedGUAMIItems(
std::vector<ServedGUAMIItem>& list) const {
list = itemList;
}
void ServedGUAMIList::addServedGUAMIItem(const ServedGUAMIItem& item) {
itemList.push_back(item);
}
} // namespace ngap
......@@ -19,8 +19,8 @@
* contact@openairinterface.org
*/
#ifndef _SERVEDGUAMILIST_H_
#define _SERVEDGUAMILIST_H_
#ifndef _SERVED_GUAMI_LIST_H_
#define _SERVED_GUAMI_LIST_H_
#include "ServedGUAMIItem.hpp"
#include <vector>
......@@ -36,13 +36,13 @@ class ServedGUAMIList {
ServedGUAMIList();
virtual ~ServedGUAMIList();
bool encode2ServedGUAMIList(Ngap_ServedGUAMIList_t*);
bool decodefromServedGUAMIList(Ngap_ServedGUAMIList_t*);
bool encode(Ngap_ServedGUAMIList_t&);
bool decode(const Ngap_ServedGUAMIList_t&);
void addServedGUAMIItems(const std::vector<ServedGUAMIItem>& list);
void getServedGUAMIItems(std::vector<ServedGUAMIItem>& list) const;
void set(const std::vector<ServedGUAMIItem>& list);
void get(std::vector<ServedGUAMIItem>& list) const;
void addServedGUAMIItem(const ServedGUAMIItem& item);
void addItem(const ServedGUAMIItem& item);
private:
std::vector<ServedGUAMIItem> itemList;
......
......@@ -30,23 +30,22 @@ SupportedTAList::SupportedTAList() {}
SupportedTAList::~SupportedTAList() {}
//------------------------------------------------------------------------------
bool SupportedTAList::encode2SupportedTAList(
Ngap_SupportedTAList_t* supportedTAList) {
bool SupportedTAList::encode(Ngap_SupportedTAList_t& supportedTAList) {
for (std::vector<SupportedTaItem>::iterator it = std::begin(supportedTAItems);
it < std::end(supportedTAItems); ++it) {
Ngap_SupportedTAItem_t* ta =
(Ngap_SupportedTAItem_t*) calloc(1, sizeof(Ngap_SupportedTAItem_t));
if (!it->encode2SupportedTaItem(ta)) return false;
if (ASN_SEQUENCE_ADD(&supportedTAList->list, ta) != 0) return false;
if (ASN_SEQUENCE_ADD(&supportedTAList.list, ta) != 0) return false;
}
return true;
}
//------------------------------------------------------------------------------
bool SupportedTAList::decodefromSupportedTAList(Ngap_SupportedTAList_t* pdu) {
for (int i = 0; i < pdu->list.count; i++) {
bool SupportedTAList::decode(const Ngap_SupportedTAList_t& pdu) {
for (int i = 0; i < pdu.list.count; i++) {
SupportedTaItem item = {};
if (!item.decodefromSupportedTaItem(pdu->list.array[i])) return false;
if (!item.decodefromSupportedTaItem(pdu.list.array[i])) return false;
supportedTAItems.push_back(item);
}
......
......@@ -36,8 +36,8 @@ class SupportedTAList {
SupportedTAList();
virtual ~SupportedTAList();
bool encode2SupportedTAList(Ngap_SupportedTAList_t* ngSetupRequest);
bool decodefromSupportedTAList(Ngap_SupportedTAList_t* pdu);
bool encode(Ngap_SupportedTAList_t& ngSetupRequest);
bool decode(const Ngap_SupportedTAList_t& pdu);
void setSupportedTaItems(const std::vector<SupportedTaItem>& items);
void getSupportedTaItems(std::vector<SupportedTaItem>& items);
......
......@@ -108,7 +108,7 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) {
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkNASTransport_IEs__value_PR_AMFName;
int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName);
int ret = oldAmfName->encode(&ie->value.choice.AMFName);
if (!ret) {
Logger::ngap().error("Encode oldAmfName IE error");
free_wrapper((void**) &ie);
......@@ -251,7 +251,7 @@ bool DownLinkNasTransportMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
downLinkNasTransportIEs->protocolIEs.list.array[i]->value.present ==
Ngap_DownlinkNASTransport_IEs__value_PR_AMFName) {
oldAmfName = new AmfName();
if (!oldAmfName->decodefromAmfName(
if (!oldAmfName->decode(
&downLinkNasTransportIEs->protocolIEs.list.array[i]
->value.choice.AMFName)) {
Logger::ngap().error("Decode NGAP OldAMFName IE error");
......
......@@ -113,7 +113,7 @@ void InitialContextSetupRequestMsg::setOldAmfName(const std::string& name) {
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_InitialContextSetupRequestIEs__value_PR_AMFName;
int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName);
int ret = oldAmfName->encode(&ie->value.choice.AMFName);
if (!ret) {
Logger::ngap().error("Encode oldAmfName IE error!");
free_wrapper((void**) &ie);
......@@ -487,7 +487,7 @@ bool InitialContextSetupRequestMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
->value.present ==
Ngap_InitialContextSetupRequestIEs__value_PR_AMFName) {
oldAmfName = new AmfName();
if (!oldAmfName->decodefromAmfName(
if (!oldAmfName->decode(
&initialContextSetupRequestIEs->protocolIEs.list.array[i]
->value.choice.AMFName)) {
Logger::ngap().error("Decoded NGAP OldAMFName IE error");
......
......@@ -31,16 +31,14 @@ namespace ngap {
//------------------------------------------------------------------------------
NGSetupRequestMsg::NGSetupRequestMsg() : NgapMessage() {
ngSetupRequestIEs = nullptr;
ranNodeName = nullptr;
ranNodeName = std::nullopt;
NgapMessage::setMessageType(NgapMessageType::NG_SETUP_REQUEST);
initialize();
}
//------------------------------------------------------------------------------
NGSetupRequestMsg::~NGSetupRequestMsg() {
if (ranNodeName) delete ranNodeName;
}
NGSetupRequestMsg::~NGSetupRequestMsg() {}
//------------------------------------------------------------------------------
void NGSetupRequestMsg::initialize() {
......@@ -83,8 +81,12 @@ void NGSetupRequestMsg::setGlobalRanNodeID(
//------------------------------------------------------------------------------
void NGSetupRequestMsg::setRanNodeName(const std::string& value) {
if (!ranNodeName) ranNodeName = new RanNodeName();
ranNodeName->setValue(value);
RanNodeName tmp = {};
if (!tmp.setValue(value)) {
return;
}
ranNodeName = std::optional<RanNodeName>(tmp);
Ngap_NGSetupRequestIEs_t* ie =
(Ngap_NGSetupRequestIEs_t*) calloc(1, sizeof(Ngap_NGSetupRequestIEs_t));
......@@ -92,7 +94,7 @@ void NGSetupRequestMsg::setRanNodeName(const std::string& value) {
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_NGSetupRequestIEs__value_PR_RANNodeName;
if (!ranNodeName->encode(ie->value.choice.RANNodeName)) {
if (!ranNodeName.value().encode(ie->value.choice.RANNodeName)) {
Logger::ngap().error("Encode NGAP RANNodeName IE error");
free_wrapper((void**) &ie);
return;
......@@ -149,8 +151,7 @@ void NGSetupRequestMsg::setSupportedTAList(
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_NGSetupRequestIEs__value_PR_SupportedTAList;
if (!supportedTAListIE.encode2SupportedTAList(
&ie->value.choice.SupportedTAList)) {
if (!supportedTAListIE.encode(ie->value.choice.SupportedTAList)) {
Logger::ngap().error("Encode SupportedTAList IE error");
free_wrapper((void**) &ie);
return;
......@@ -171,7 +172,7 @@ void NGSetupRequestMsg::setDefaultPagingDRX(const e_Ngap_PagingDRX& value) {
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_NGSetupRequestIEs__value_PR_PagingDRX;
if (!defaultPagingDRXIE.encode2DefaultPagingDRX(ie->value.choice.PagingDRX)) {
if (!defaultPagingDRXIE.encode(ie->value.choice.PagingDRX)) {
Logger::ngap().error("Encode DefaultPagingDRX IE error");
free_wrapper((void**) &ie);
return;
......@@ -219,8 +220,8 @@ bool NGSetupRequestMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_ignore &&
ngSetupRequestIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupRequestIEs__value_PR_RANNodeName) {
ranNodeName = new RanNodeName();
if (!ranNodeName->decode(
ranNodeName = std::make_optional<RanNodeName>();
if (!ranNodeName.value().decode(
ngSetupRequestIEs->protocolIEs.list.array[i]
->value.choice.RANNodeName)) {
Logger::ngap().error("Decoded NGAP RanNodeName IE error");
......@@ -236,9 +237,9 @@ bool NGSetupRequestMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_reject &&
ngSetupRequestIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupRequestIEs__value_PR_SupportedTAList) {
if (!supportedTAList.decodefromSupportedTAList(
&ngSetupRequestIEs->protocolIEs.list.array[i]
->value.choice.SupportedTAList)) {
if (!supportedTAList.decode(
ngSetupRequestIEs->protocolIEs.list.array[i]
->value.choice.SupportedTAList)) {
Logger::ngap().error("Decoded NGAP SupportedTAList IE error");
return false;
}
......@@ -252,7 +253,7 @@ bool NGSetupRequestMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_ignore &&
ngSetupRequestIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupRequestIEs__value_PR_PagingDRX) {
if (!defaultPagingDrx.decodefromDefaultPagingDRX(
if (!defaultPagingDrx.decode(
ngSetupRequestIEs->protocolIEs.list.array[i]
->value.choice.PagingDRX)) {
Logger::ngap().error("Decoded NGAP DefaultPagingDRX IE error");
......@@ -311,8 +312,8 @@ bool NGSetupRequestMsg::getGlobalGnbID(
//------------------------------------------------------------------------------
bool NGSetupRequestMsg::getRanNodeName(std::string& name) {
if (!ranNodeName) return false;
ranNodeName->getValue(name);
if (!ranNodeName.has_value()) return false;
ranNodeName.value().getValue(name);
return true;
}
......
......@@ -30,6 +30,8 @@
#include "SupportedTAList.hpp"
#include "NgapMessage.hpp"
#include <optional>
namespace ngap {
class NGSetupRequestMsg : public NgapMessage {
......@@ -59,10 +61,10 @@ class NGSetupRequestMsg : public NgapMessage {
private:
Ngap_NGSetupRequest_t* ngSetupRequestIEs;
GlobalRanNodeId globalRanNodeId; // Mandatory
RanNodeName* ranNodeName; // Optional
SupportedTAList supportedTAList; // Mandatory
DefaultPagingDRX defaultPagingDrx; // Mandatory
GlobalRanNodeId globalRanNodeId; // Mandatory
std::optional<RanNodeName> ranNodeName; // Optional
SupportedTAList supportedTAList; // Mandatory
DefaultPagingDRX defaultPagingDrx; // Mandatory
// TODO: UE Retention Information (Optional)
};
......
......@@ -48,15 +48,19 @@ void NGSetupResponseMsg::initialize() {
}
//------------------------------------------------------------------------------
void NGSetupResponseMsg::setAMFName(const std::string name) {
amfName.setValue(name);
void NGSetupResponseMsg::setAMFName(const std::string& name) {
if (!amfName.setValue(name)) {
Logger::ngap().warn("Not a valid AMF Name value!");
return;
}
Ngap_NGSetupResponseIEs_t* ie =
(Ngap_NGSetupResponseIEs_t*) calloc(1, sizeof(Ngap_NGSetupResponseIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMFName;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_NGSetupResponseIEs__value_PR_AMFName;
if (!amfName.encode2AmfName(&ie->value.choice.AMFName)) {
if (!amfName.encode(&ie->value.choice.AMFName)) {
Logger::ngap().error("Encode NGAP AMFName IE error");
free_wrapper((void**) &ie);
return;
......@@ -77,11 +81,12 @@ void NGSetupResponseMsg::setGUAMIList(std::vector<struct GuamiItem_s> list) {
servedGUAMIItem.setGUAMI(guami);
if (list[i].backupAMFName.size() > 0) {
AmfName* backupamfname = new AmfName();
backupamfname->setValue(list[i].backupAMFName);
servedGUAMIItem.setBackupAMFName(backupamfname);
AmfName amf_name = {};
if (amf_name.setValue(list[i].backupAMFName)) {
servedGUAMIItem.setBackupAMFName(amf_name);
}
}
servedGUAMIList.addServedGUAMIItem(servedGUAMIItem);
servedGUAMIList.addItem(servedGUAMIItem);
}
Ngap_NGSetupResponseIEs_t* ie =
......@@ -90,8 +95,7 @@ void NGSetupResponseMsg::setGUAMIList(std::vector<struct GuamiItem_s> list) {
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_NGSetupResponseIEs__value_PR_ServedGUAMIList;
if (!servedGUAMIList.encode2ServedGUAMIList(
&ie->value.choice.ServedGUAMIList)) {
if (!servedGUAMIList.encode(ie->value.choice.ServedGUAMIList)) {
Logger::ngap().error("Encode NGAP ServedGUAMIList IE error");
free_wrapper((void**) &ie);
return;
......@@ -111,8 +115,7 @@ void NGSetupResponseMsg::setRelativeAmfCapacity(long capacity) {
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_NGSetupResponseIEs__value_PR_RelativeAMFCapacity;
if (!relativeAmfCapacity.encode2RelativeAMFCapacity(
&ie->value.choice.RelativeAMFCapacity)) {
if (!relativeAmfCapacity.encode(ie->value.choice.RelativeAMFCapacity)) {
Logger::ngap().error("Encode NGAP RelativeAMFCapacity IE error");
free_wrapper((void**) &ie);
return;
......@@ -147,11 +150,11 @@ void NGSetupResponseMsg::setPlmnSupportList(
snssai.setSd(sd);
snssais.push_back(snssai);
}
plmnSupportItem.setPlmnSliceSupportList(plmn, snssais);
plmnSupportItem.set(plmn, snssais);
plmnSupportItems.push_back(plmnSupportItem);
}
plmnSupportList.addPLMNSupportItems(plmnSupportItems);
plmnSupportList.set(plmnSupportItems);
Ngap_NGSetupResponseIEs_t* ie =
(Ngap_NGSetupResponseIEs_t*) calloc(1, sizeof(Ngap_NGSetupResponseIEs_t));
......@@ -159,8 +162,7 @@ void NGSetupResponseMsg::setPlmnSupportList(
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_NGSetupResponseIEs__value_PR_PLMNSupportList;
if (!plmnSupportList.encode2PLMNSupportList(
&ie->value.choice.PLMNSupportList)) {
if (!plmnSupportList.encode(ie->value.choice.PLMNSupportList)) {
Logger::ngap().error("Encode NGAP PLMNSupportList IE error");
free_wrapper((void**) &ie);
return;
......@@ -200,9 +202,8 @@ bool NGSetupResponseMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_reject &&
ngSetupResponsIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupResponseIEs__value_PR_AMFName) {
if (!amfName.decodefromAmfName(
&ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.AMFName)) {
if (!amfName.decode(&ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.AMFName)) {
Logger::ngap().error("Decoded NGAP AMFName error");
return false;
}
......@@ -216,9 +217,9 @@ bool NGSetupResponseMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_reject &&
ngSetupResponsIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupResponseIEs__value_PR_ServedGUAMIList) {
if (!servedGUAMIList.decodefromServedGUAMIList(
&ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.ServedGUAMIList)) {
if (!servedGUAMIList.decode(
ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.ServedGUAMIList)) {
Logger::ngap().error("Decoded NGAP ServedGUAMIList error");
return false;
}
......@@ -232,9 +233,9 @@ bool NGSetupResponseMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_ignore &&
ngSetupResponsIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupResponseIEs__value_PR_RelativeAMFCapacity) {
if (!relativeAmfCapacity.decodefromRelativeAMFCapacity(
&ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.RelativeAMFCapacity)) {
if (!relativeAmfCapacity.decode(
ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.RelativeAMFCapacity)) {
Logger::ngap().error("Decoded NGAP RelativeAMFCapacity error");
return false;
}
......@@ -248,9 +249,9 @@ bool NGSetupResponseMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
Ngap_Criticality_reject &&
ngSetupResponsIEs->protocolIEs.list.array[i]->value.present ==
Ngap_NGSetupResponseIEs__value_PR_PLMNSupportList) {
if (!plmnSupportList.decodefromPLMNSupportList(
&ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.PLMNSupportList)) {
if (!plmnSupportList.decode(
ngSetupResponsIEs->protocolIEs.list.array[i]
->value.choice.PLMNSupportList)) {
Logger::ngap().error("Decoded NGAP PLMNSupportList error");
return false;
}
......@@ -273,7 +274,7 @@ bool NGSetupResponseMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
}
//------------------------------------------------------------------------------
bool NGSetupResponseMsg::getAMFName(std::string& name) {
bool NGSetupResponseMsg::getAMFName(std::string& name) const {
amfName.getValue(name);
return true;
}
......@@ -281,7 +282,7 @@ bool NGSetupResponseMsg::getAMFName(std::string& name) {
//------------------------------------------------------------------------------
bool NGSetupResponseMsg::getGUAMIList(std::vector<struct GuamiItem_s>& list) {
std::vector<ServedGUAMIItem> servedGUAMIItems;
servedGUAMIList.getServedGUAMIItems(servedGUAMIItems);
servedGUAMIList.get(servedGUAMIItems);
for (std::vector<ServedGUAMIItem>::iterator it = std::begin(servedGUAMIItems);
it != std::end(servedGUAMIItems); ++it) {
......@@ -292,11 +293,9 @@ bool NGSetupResponseMsg::getGUAMIList(std::vector<struct GuamiItem_s>& list) {
guamiItem.mcc, guamiItem.mnc, guamiItem.regionID, guamiItem.AmfSetID,
guamiItem.AmfPointer);
AmfName* backupAMFName;
if (it->getBackupAMFName(backupAMFName)) {
backupAMFName->getValue(guamiItem.backupAMFName);
} else {
guamiItem.backupAMFName = "None";
AmfName amf_name = {};
if (it->getBackupAMFName(amf_name)) {
amf_name.getValue(guamiItem.backupAMFName);
}
list.push_back(guamiItem);
......@@ -314,7 +313,7 @@ long NGSetupResponseMsg::getRelativeAmfCapacity() {
bool NGSetupResponseMsg::getPlmnSupportList(
std::vector<PlmnSliceSupport_t>& list) {
std::vector<PLMNSupportItem> plmnsupportItemItems;
plmnSupportList.getPLMNSupportItems(plmnsupportItemItems);
plmnSupportList.get(plmnsupportItemItems);
for (std::vector<PLMNSupportItem>::iterator it =
std::begin(plmnsupportItemItems);
......@@ -323,7 +322,7 @@ bool NGSetupResponseMsg::getPlmnSupportList(
PlmnId plmn = {};
std::vector<S_NSSAI> snssais;
it->getPlmnSliceSupportList(plmn, snssais);
it->get(plmn, snssais);
plmn.getMcc(plmnSliceSupport.mcc);
plmn.getMnc(plmnSliceSupport.mnc);
for (std::vector<S_NSSAI>::iterator it = std::begin(snssais);
......
......@@ -29,7 +29,6 @@
#include "RelativeAMFCapacity.hpp"
#include "ServedGUAMIList.hpp"
#include "NgapMessage.hpp"
//#include "CriticalityDiagnostics.hpp"
extern "C" {
#include "Ngap_NGSetupResponse.h"
......@@ -44,8 +43,8 @@ class NGSetupResponseMsg : public NgapMessage {
void initialize();
void setAMFName(const std::string name);
bool getAMFName(std::string& name);
void setAMFName(const std::string& name);
bool getAMFName(std::string& name) const;
void setGUAMIList(std::vector<struct GuamiItem_s> list);
bool getGUAMIList(std::vector<struct GuamiItem_s>& list);
......
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