Commit 1a4e2296 authored by aligungr's avatar aligungr

NTS memory leak fix

parent 2d700bc4
...@@ -112,8 +112,8 @@ void GnbRrcTask::triggerSysInfoBroadcast() ...@@ -112,8 +112,8 @@ void GnbRrcTask::triggerSysInfoBroadcast()
auto *mib = ConstructMibMessage(m_isBarred, m_intraFreqReselectAllowed); auto *mib = ConstructMibMessage(m_isBarred, m_intraFreqReselectAllowed);
auto *sib1 = ConstructSib1Message(m_cellReserved, m_config->tac, m_config->nci, m_config->plmn, m_aiBarringSet); auto *sib1 = ConstructSib1Message(m_cellReserved, m_config->tac, m_config->nci, m_config->plmn, m_aiBarringSet);
sendRrcMessage(mib); sendRrcMessage(*mib);
sendRrcMessage(sib1); sendRrcMessage(*sib1);
asn::Free(asn_DEF_ASN_RRC_BCCH_BCH_Message, mib); asn::Free(asn_DEF_ASN_RRC_BCCH_BCH_Message, mib);
asn::Free(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, sib1); asn::Free(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, sib1);
......
...@@ -65,7 +65,7 @@ void GnbRrcTask::handleUplinkRrc(int ueId, rrc::RrcChannel channel, const OctetS ...@@ -65,7 +65,7 @@ void GnbRrcTask::handleUplinkRrc(int ueId, rrc::RrcChannel channel, const OctetS
} }
} }
void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg) void GnbRrcTask::sendRrcMessage(const ASN_RRC_BCCH_BCH_Message &msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_BCCH_BCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_BCCH_BCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -81,7 +81,7 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg) ...@@ -81,7 +81,7 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg)
m_base->rlsTask->push(std::move(w)); m_base->rlsTask->push(std::move(w));
} }
void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg) void GnbRrcTask::sendRrcMessage(const ASN_RRC_BCCH_DL_SCH_Message &msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -97,7 +97,7 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg) ...@@ -97,7 +97,7 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg)
m_base->rlsTask->push(std::move(w)); m_base->rlsTask->push(std::move(w));
} }
void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg) void GnbRrcTask::sendRrcMessage(int ueId, const ASN_RRC_DL_CCCH_Message &msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_DL_CCCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_DL_CCCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -113,7 +113,7 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg) ...@@ -113,7 +113,7 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg)
m_base->rlsTask->push(std::move(w)); m_base->rlsTask->push(std::move(w));
} }
void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg) void GnbRrcTask::sendRrcMessage(int ueId, const ASN_RRC_DL_DCCH_Message &msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_DL_DCCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_DL_DCCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -129,7 +129,7 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg) ...@@ -129,7 +129,7 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg)
m_base->rlsTask->push(std::move(w)); m_base->rlsTask->push(std::move(w));
} }
void GnbRrcTask::sendRrcMessage(ASN_RRC_PCCH_Message *msg) void GnbRrcTask::sendRrcMessage(const ASN_RRC_PCCH_Message &msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_PCCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_PCCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
......
...@@ -87,7 +87,9 @@ void GnbRrcTask::receiveRrcSetupRequest(int ueId, const ASN_RRC_RRCSetupRequest ...@@ -87,7 +87,9 @@ void GnbRrcTask::receiveRrcSetupRequest(int ueId, const ASN_RRC_RRCSetupRequest
rrc::encode::EncodeS(asn_DEF_ASN_RRC_CellGroupConfig, &masterCellGroup)); rrc::encode::EncodeS(asn_DEF_ASN_RRC_CellGroupConfig, &masterCellGroup));
m_logger->info("RRC Setup for UE[%d]", ueId); m_logger->info("RRC Setup for UE[%d]", ueId);
sendRrcMessage(ueId, pdu);
sendRrcMessage(ueId, *pdu);
asn::Free(asn_DEF_ASN_RRC_DL_CCCH_Message, pdu);
} }
void GnbRrcTask::receiveRrcSetupComplete(int ueId, const ASN_RRC_RRCSetupComplete &msg) void GnbRrcTask::receiveRrcSetupComplete(int ueId, const ASN_RRC_RRCSetupComplete &msg)
......
...@@ -54,7 +54,8 @@ void GnbRrcTask::handleDownlinkNasDelivery(int ueId, const OctetString &nasPdu) ...@@ -54,7 +54,8 @@ void GnbRrcTask::handleDownlinkNasDelivery(int ueId, const OctetString &nasPdu)
c1.choice.dlInformationTransfer->dedicatedNAS_Message = asn::New<ASN_RRC_DedicatedNAS_Message_t>(); c1.choice.dlInformationTransfer->dedicatedNAS_Message = asn::New<ASN_RRC_DedicatedNAS_Message_t>();
asn::SetOctetString(*c1.choice.dlInformationTransfer->dedicatedNAS_Message, nasPdu); asn::SetOctetString(*c1.choice.dlInformationTransfer->dedicatedNAS_Message, nasPdu);
sendRrcMessage(ueId, pdu); sendRrcMessage(ueId, *pdu);
asn::Free(asn_DEF_ASN_RRC_DL_DCCH_Message, pdu);
} }
void GnbRrcTask::deliverUplinkNas(int ueId, OctetString &&nasPdu) void GnbRrcTask::deliverUplinkNas(int ueId, OctetString &&nasPdu)
...@@ -86,7 +87,8 @@ void GnbRrcTask::releaseConnection(int ueId) ...@@ -86,7 +87,8 @@ void GnbRrcTask::releaseConnection(int ueId)
rrcRelease->criticalExtensions.present = ASN_RRC_RRCRelease__criticalExtensions_PR_rrcRelease; rrcRelease->criticalExtensions.present = ASN_RRC_RRCRelease__criticalExtensions_PR_rrcRelease;
rrcRelease->criticalExtensions.choice.rrcRelease = asn::New<ASN_RRC_RRCRelease_IEs>(); rrcRelease->criticalExtensions.choice.rrcRelease = asn::New<ASN_RRC_RRCRelease_IEs>();
sendRrcMessage(ueId, pdu); sendRrcMessage(ueId, *pdu);
asn::Free(asn_DEF_ASN_RRC_DL_DCCH_Message, pdu);
// Delete UE RRC context // Delete UE RRC context
m_ueCtx.erase(ueId); m_ueCtx.erase(ueId);
...@@ -128,7 +130,8 @@ void GnbRrcTask::handlePaging(const asn::Unique<ASN_NGAP_FiveG_S_TMSI> &tmsi, ...@@ -128,7 +130,8 @@ void GnbRrcTask::handlePaging(const asn::Unique<ASN_NGAP_FiveG_S_TMSI> &tmsi,
paging->pagingRecordList = asn::NewFor(paging->pagingRecordList); paging->pagingRecordList = asn::NewFor(paging->pagingRecordList);
asn::SequenceAdd(*paging->pagingRecordList, record); asn::SequenceAdd(*paging->pagingRecordList, record);
sendRrcMessage(pdu); sendRrcMessage(*pdu);
asn::Free(asn_DEF_ASN_RRC_PCCH_Message, pdu);
} }
} // namespace nr::gnb } // namespace nr::gnb
\ No newline at end of file
...@@ -80,11 +80,11 @@ class GnbRrcTask : public NtsTask ...@@ -80,11 +80,11 @@ class GnbRrcTask : public NtsTask
void receiveUplinkInformationTransfer(int ueId, const ASN_RRC_ULInformationTransfer &msg); void receiveUplinkInformationTransfer(int ueId, const ASN_RRC_ULInformationTransfer &msg);
/* RRC channel send message */ /* RRC channel send message */
void sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg); void sendRrcMessage(const ASN_RRC_BCCH_BCH_Message &msg);
void sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg); void sendRrcMessage(const ASN_RRC_BCCH_DL_SCH_Message &msg);
void sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg); void sendRrcMessage(int ueId, const ASN_RRC_DL_CCCH_Message &msg);
void sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg); void sendRrcMessage(int ueId, const ASN_RRC_DL_DCCH_Message &msg);
void sendRrcMessage(ASN_RRC_PCCH_Message *msg); void sendRrcMessage(const ASN_RRC_PCCH_Message &msg);
/* RRC channel receive message */ /* RRC channel receive message */
void receiveRrcMessage(int ueId, ASN_RRC_BCCH_BCH_Message *msg); void receiveRrcMessage(int ueId, ASN_RRC_BCCH_BCH_Message *msg);
......
...@@ -24,9 +24,9 @@ namespace rrc::encode ...@@ -24,9 +24,9 @@ namespace rrc::encode
{ {
template <typename T> template <typename T>
inline bool Encode(const asn_TYPE_descriptor_t &desc, T *pdu, ssize_t &encoded, uint8_t *&buffer) inline bool Encode(const asn_TYPE_descriptor_t &desc, const T &pdu, ssize_t &encoded, uint8_t *&buffer)
{ {
auto res = asn_encode_to_new_buffer(nullptr, ATS_UNALIGNED_CANONICAL_PER, &desc, pdu); auto res = asn_encode_to_new_buffer(nullptr, ATS_UNALIGNED_CANONICAL_PER, &desc, &pdu);
if (res.buffer == nullptr || res.result.encoded < 0) if (res.buffer == nullptr || res.result.encoded < 0)
return false; return false;
...@@ -38,7 +38,7 @@ inline bool Encode(const asn_TYPE_descriptor_t &desc, T *pdu, ssize_t &encoded, ...@@ -38,7 +38,7 @@ inline bool Encode(const asn_TYPE_descriptor_t &desc, T *pdu, ssize_t &encoded,
} }
template <typename T> template <typename T>
inline OctetString EncodeS(const asn_TYPE_descriptor_t &desc, T *pdu) inline OctetString EncodeS(const asn_TYPE_descriptor_t &desc, const T &pdu)
{ {
uint8_t *buffer; uint8_t *buffer;
ssize_t encoded; ssize_t encoded;
......
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