Commit 48cc6605 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code refactoring for DownlinkNasTransport

parent 69030eef
......@@ -42,8 +42,17 @@ void MobilityRestrictionList::getPLMN(PlmnId& sPLMN) {
//------------------------------------------------------------------------------
bool MobilityRestrictionList::encode(
Ngap_MobilityRestrictionList_t* mobilityrestrictionlist) {
if (!servingPLMN.encode(mobilityrestrictionlist->servingPLMN)) {
Ngap_MobilityRestrictionList_t* mobility_restriction_list) {
if (!servingPLMN.encode(mobility_restriction_list->servingPLMN)) {
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool MobilityRestrictionList::decode(
Ngap_MobilityRestrictionList_t* mobility_restriction_list) {
if (!servingPLMN.decode(mobility_restriction_list->servingPLMN)) {
return false;
}
return true;
......
......@@ -36,7 +36,7 @@ class MobilityRestrictionList {
void getPLMN(PlmnId& sPlmn);
bool encode(Ngap_MobilityRestrictionList_t* mobilityrestrictionlist);
// TODO: Decode
bool decode(Ngap_MobilityRestrictionList_t* mobilityrestrictionlist);
private:
PlmnId servingPLMN; // Mandatory
......
......@@ -204,6 +204,20 @@ bool DownLinkNasTransportMsg::getMobilityRestrictionList(
return true;
}
//------------------------------------------------------------------------------
void DownLinkNasTransportMsg::setUEAggregateMaxBitRate(
const UEAggregateMaxBitRate& bit_rate) {
uEAggregateMaxBitRate = std::make_optional<UEAggregateMaxBitRate>(bit_rate);
};
//------------------------------------------------------------------------------
bool DownLinkNasTransportMsg::getUEAggregateMaxBitRate(
UEAggregateMaxBitRate& bit_rate) {
if (!uEAggregateMaxBitRate.has_value()) return false;
bit_rate = uEAggregateMaxBitRate.value();
return true;
}
//------------------------------------------------------------------------------
void DownLinkNasTransportMsg::setIndex2Rat_FrequencySelectionPriority(
const uint32_t& value) {
......@@ -236,6 +250,20 @@ bool DownLinkNasTransportMsg::getIndex2Rat_FrequencySelectionPriority(
return true;
}
//------------------------------------------------------------------------------
void DownLinkNasTransportMsg::setAllowedNssai(
const AllowedNSSAI& allowed_nssai) {
allowedNssai = std::make_optional<AllowedNSSAI>(allowed_nssai);
}
//------------------------------------------------------------------------------
bool DownLinkNasTransportMsg::getAllowedNssai(
AllowedNSSAI& allowed_nssai) const {
if (!allowedNssai.has_value()) return false;
allowed_nssai = allowedNssai.value();
return true;
}
//------------------------------------------------------------------------------
bool DownLinkNasTransportMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
ngapPdu = ngapMsgPdu;
......@@ -341,6 +369,26 @@ bool DownLinkNasTransportMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_MobilityRestrictionList: {
if (downLinkNasTransportIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
downLinkNasTransportIEs->protocolIEs.list.array[i]->value.present ==
Ngap_DownlinkNASTransport_IEs__value_PR_MobilityRestrictionList) {
MobilityRestrictionList tmp = {};
if (!tmp.decode(&downLinkNasTransportIEs->protocolIEs.list.array[i]
->value.choice.MobilityRestrictionList)) {
Logger::ngap().error(
"Decode NGAP MobilityRestrictionList IE error");
return false;
}
mobilityRestrictionList = std::optional<MobilityRestrictionList>(tmp);
} else {
Logger::ngap().error("Decode NGAP MobilityRestrictionList IE error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_IndexToRFSP: {
if (downLinkNasTransportIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
......@@ -359,6 +407,44 @@ bool DownLinkNasTransportMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
}
} break;
case Ngap_ProtocolIE_ID_id_UEAggregateMaximumBitRate: {
if (downLinkNasTransportIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
downLinkNasTransportIEs->protocolIEs.list.array[i]->value.present ==
Ngap_DownlinkNASTransport_IEs__value_PR_UEAggregateMaximumBitRate) {
UEAggregateMaxBitRate tmp = {};
if (!tmp.decode(downLinkNasTransportIEs->protocolIEs.list.array[i]
->value.choice.UEAggregateMaximumBitRate)) {
Logger::ngap().error(
"Decode NGAP UEAggregateMaximumBitRate IE error");
return false;
}
uEAggregateMaxBitRate = std::optional<UEAggregateMaxBitRate>(tmp);
} else {
Logger::ngap().error(
"Decode NGAP UEAggregateMaximumBitRate IE error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_AllowedNSSAI: {
if (downLinkNasTransportIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_reject &&
downLinkNasTransportIEs->protocolIEs.list.array[i]->value.present ==
Ngap_DownlinkNASTransport_IEs__value_PR_AllowedNSSAI) {
AllowedNSSAI tmp = {};
if (!tmp.decode(&downLinkNasTransportIEs->protocolIEs.list.array[i]
->value.choice.AllowedNSSAI)) {
Logger::ngap().error("Decode NGAP AllowedNSSAI IE error");
return false;
}
allowedNssai = std::optional<AllowedNSSAI>(tmp);
} else {
Logger::ngap().error("Decode NGAP AllowedNSSAI IE error");
return false;
}
} break;
default: {
Logger::ngap().error("Decode NGAP message PDU error");
return false;
......
......@@ -22,6 +22,7 @@
#ifndef _DOWNLINK_NAS_TRANSPORT_H_
#define _DOWNLINK_NAS_TRANSPORT_H_
#include "AllowedNssai.hpp"
#include "AMFName.hpp"
#include "IndexToRFSP.hpp"
#include "NAS-PDU.hpp"
......@@ -57,9 +58,15 @@ class DownLinkNasTransportMsg : public NgapUEMessage {
void setMobilityRestrictionList(const MobilityRestrictionList&);
bool getMobilityRestrictionList(MobilityRestrictionList&) const;
void setUEAggregateMaxBitRate(const UEAggregateMaxBitRate& bit_rate);
bool getUEAggregateMaxBitRate(UEAggregateMaxBitRate& bit_rate);
void setIndex2Rat_FrequencySelectionPriority(const uint32_t& value); // 1~256
bool getIndex2Rat_FrequencySelectionPriority(uint32_t&) const;
void setAllowedNssai(const AllowedNSSAI& allowed_nssai);
bool getAllowedNssai(AllowedNSSAI& allowed_nssai) const;
private:
Ngap_DownlinkNASTransport_t* downLinkNasTransportIEs;
......@@ -71,7 +78,7 @@ class DownLinkNasTransportMsg : public NgapUEMessage {
std::optional<MobilityRestrictionList> mobilityRestrictionList; // Optional
std::optional<IndexToRFSP> indexToRFSP; // Optional
std::optional<UEAggregateMaxBitRate> uEAggregateMaxBitRate; // Optional
// TODO: Allowed NSSAI (Optional)
std::optional<AllowedNSSAI> allowedNssai; // Optional
};
} // namespace ngap
......
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