From 6435c6d894fd6b67df055df4c7db3d4bb2464ce7 Mon Sep 17 00:00:00 2001 From: Natale Patriciello Date: Thu, 25 Oct 2018 16:36:24 +0200 Subject: [PATCH] lte: Do not assume that the helper is setting all the vectors In lte-enb-rrc, in a lot of places there is the assumption that vectors such as m_cphySapProvider, m_cmacSapProvider, m_ffrRrcSapProvider, are filled by the helper. That assumption does not hold with external modules: therefore, for a better coexistence, check the size of these vector before doing any operation. If there are elements in it, then execute; otherwise, just ignore. --- src/lte/model/lte-enb-rrc.cc | 68 ++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index 2211f9ef6..a1037a2a2 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -1108,7 +1108,7 @@ UeManager::RecvMeasurementReport (LteRrcSap::MeasurementReport msg) m_rrc->m_anrSapProvider->ReportUeMeas (msg.measResults); } - if ((m_rrc->m_ffrRrcSapProvider.at (0) != 0) + if ((m_rrc->m_ffrRrcSapProvider.size () > 0) && (m_rrc->m_ffrMeasIds.find (measId) != m_rrc->m_ffrMeasIds.end ())) { // this measurement was requested by the FFR function @@ -1545,9 +1545,6 @@ LteEnbRrc::LteEnbRrc () m_s1SapUser = new MemberEpcEnbS1SapUser (this); m_cphySapUser.push_back (new MemberLteEnbCphySapUser (this)); m_ccmRrcSapUser = new MemberLteCcmRrcSapUser (this); - m_cphySapProvider.push_back (0); - m_cmacSapProvider.push_back (0); - m_ffrRrcSapProvider.push_back (0); } void @@ -1563,9 +1560,6 @@ LteEnbRrc::ConfigureCarriers (std::map m_cphySapUser.push_back (new MemberLteEnbCphySapUser (this)); m_cmacSapUser.push_back (new EnbRrcMemberLteEnbCmacSapUser (this, i)); m_ffrRrcSapUser.push_back (new MemberLteFfrRrcSapUser (this)); - m_cphySapProvider.push_back (0); - m_cmacSapProvider.push_back (0); - m_ffrRrcSapProvider.push_back (0); } m_carriersConfigured = true; Object::DoInitialize (); @@ -1790,7 +1784,15 @@ void LteEnbRrc::SetLteEnbCmacSapProvider (LteEnbCmacSapProvider * s, uint8_t pos) { NS_LOG_FUNCTION (this << s); - m_cmacSapProvider.at (pos) = s; + if (m_cmacSapProvider.size () > pos) + { + m_cmacSapProvider.at (pos) = s; + } + else + { + m_cmacSapProvider.push_back (s); + NS_ABORT_IF (m_cmacSapProvider.size () - 1 != pos); + } } LteEnbCmacSapUser* @@ -1853,14 +1855,33 @@ void LteEnbRrc::SetLteFfrRrcSapProvider (LteFfrRrcSapProvider * s) { NS_LOG_FUNCTION (this << s); - m_ffrRrcSapProvider.at (0) = s; + if (m_ffrRrcSapProvider.size () > 0) + { + m_ffrRrcSapProvider.at (0) = s; + } + else + { + m_ffrRrcSapProvider.push_back (s); + } + } void LteEnbRrc::SetLteFfrRrcSapProvider (LteFfrRrcSapProvider * s, uint8_t index) { NS_LOG_FUNCTION (this << s); - m_ffrRrcSapProvider.at (index) = s; + if (m_ffrRrcSapProvider.size () > index) + { + m_ffrRrcSapProvider.at (index) = s; + } + else + { + m_ffrRrcSapProvider.push_back (s); + NS_ABORT_MSG_IF (m_ffrRrcSapProvider.size () - 1 != index, + "You meant to store the pointer at position " << + static_cast (index) << + " but it went to " << m_ffrRrcSapProvider.size () - 1); + } } LteFfrRrcSapUser* @@ -1916,7 +1937,14 @@ void LteEnbRrc::SetLteEnbCphySapProvider (LteEnbCphySapProvider * s) { NS_LOG_FUNCTION (this << s); - m_cphySapProvider.at(0) = s; + if (m_cphySapProvider.size () > 0) + { + m_cphySapProvider.at (0) = s; + } + else + { + m_cphySapProvider.push_back (s); + } } LteEnbCphySapUser* @@ -1930,7 +1958,15 @@ void LteEnbRrc::SetLteEnbCphySapProvider (LteEnbCphySapProvider * s, uint8_t pos) { NS_LOG_FUNCTION (this << s); - m_cphySapProvider.at(pos) = s; + if (m_cphySapProvider.size () > pos) + { + m_cphySapProvider.at(pos) = s; + } + else + { + m_cphySapProvider.push_back (s); + NS_ABORT_IF (m_cphySapProvider.size () - 1 != pos); + } } LteEnbCphySapUser* @@ -2065,8 +2101,11 @@ LteEnbRrc::ConfigureCell (std::map> cc m_cphySapProvider.at (it.first)->SetEarfcn (it.second->GetUlEarfcn (), it.second->GetDlEarfcn ()); m_cphySapProvider.at (it.first)->SetCellId (it.second->GetCellId ()); m_cmacSapProvider.at (it.first)->ConfigureMac (it.second->GetUlBandwidth (), it.second->GetDlBandwidth ()); - m_ffrRrcSapProvider.at (it.first)->SetCellId (it.second->GetCellId ()); - m_ffrRrcSapProvider.at (it.first)->SetBandwidth (it.second->GetUlBandwidth (), it.second->GetDlBandwidth ()); + if (m_ffrRrcSapProvider.size () > it.first) + { + m_ffrRrcSapProvider.at (it.first)->SetCellId (it.second->GetCellId ()); + m_ffrRrcSapProvider.at (it.first)->SetBandwidth (it.second->GetUlBandwidth (), it.second->GetDlBandwidth ()); + } } m_dlEarfcn = dlEarfcn; @@ -2481,6 +2520,7 @@ LteEnbRrc::DoRecvLoadInformation (EpcX2SapUser::LoadInformationParams params) NS_LOG_LOGIC ("Number of cellInformationItems = " << params.cellInformationList.size ()); + NS_ABORT_IF (m_ffrRrcSapProvider.size () == 0); m_ffrRrcSapProvider.at (0)->RecvLoadInformation (params); }