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