From e27ba38f2b61d7bbf68d6ecefa5d167089b14cf6 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 13 May 2021 13:01:56 +0100 Subject: [PATCH] fix conversions of drb id to erab id in srsenb --- srsenb/hdr/common/common_enb.h | 4 ++++ srsenb/src/stack/rrc/rrc_bearer_cfg.cc | 20 +++++++++++--------- srsenb/src/stack/rrc/rrc_mobility.cc | 10 +++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/srsenb/hdr/common/common_enb.h b/srsenb/hdr/common/common_enb.h index e38cec0134..431719dda9 100644 --- a/srsenb/hdr/common/common_enb.h +++ b/srsenb/hdr/common/common_enb.h @@ -51,6 +51,10 @@ constexpr uint32_t drb_to_lcid(lte_drb drb_id) { return srb_to_lcid(lte_srb::srb2) + static_cast(drb_id); } +constexpr lte_drb lte_lcid_to_drb(uint32_t lcid) +{ + return srsran::is_lte_drb(lcid) ? static_cast(lcid - srb_to_lcid(lte_srb::srb2)) : lte_drb::invalid; +} // Cat 3 UE - Max number of DL-SCH transport block bits received within a TTI // 3GPP 36.306 Table 4.1.1 diff --git a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc index 3b81e2f494..d728244809 100644 --- a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc @@ -336,9 +336,8 @@ int bearer_cfg_handler::release_erab(uint8_t erab_id) return SRSRAN_ERROR; } - uint8_t drb_id = erab_id - 4; - - srsran::rem_rrc_obj_id(current_drbs, drb_id); + lte_drb drb_id = lte_lcid_to_drb(it->second.lcid); + srsran::rem_rrc_obj_id(current_drbs, (uint8_t)drb_id); rem_gtpu_bearer(erab_id); @@ -438,16 +437,19 @@ void bearer_cfg_handler::fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_ // Add E-RAB info message for the E-RABs if (msg->rr_cfg_ded.drb_to_add_mod_list_present) { for (const drb_to_add_mod_s& drb : msg->rr_cfg_ded.drb_to_add_mod_list) { - uint8_t erab_id = drb.drb_id + 4; - auto it = erab_info_list.find(erab_id); - if (it != erab_info_list.end()) { - const std::vector& erab_info = it->second; + uint32_t lcid = drb_to_lcid((lte_drb)drb.drb_id); + auto erab_it = std::find_if( + erabs.begin(), erabs.end(), [lcid](const std::pair& e) { return e.second.lcid == lcid; }); + uint32_t erab_id = erab_it->second.id; + auto info_it = erab_info_list.find(erab_id); + if (info_it != erab_info_list.end()) { + const std::vector& erab_info = info_it->second; logger->info(&erab_info[0], erab_info.size(), "connection_reconf erab_info -> nas_info rnti 0x%x", rnti); msg->ded_info_nas_list[idx].resize(erab_info.size()); memcpy(msg->ded_info_nas_list[idx].data(), &erab_info[0], erab_info.size()); - erab_info_list.erase(it); + erab_info_list.erase(info_it); } else { - logger->debug("Not adding NAS message to connection reconfiguration. E-RAB id %d", erab_id); + logger->info("Not adding NAS message to connection reconfiguration. E-RAB id %d", erab_id); } idx++; } diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 89cbf1dab6..c6ed18b717 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -997,12 +997,12 @@ void rrc::ue::rrc_mobility::handle_status_transfer(s1_target_ho_st& s, const sta logger.warning("The E-RAB Id=%d is not recognized", erab_item.erab_id); continue; } - const auto& drbs = rrc_ue->bearer_list.get_established_drbs(); - uint8_t drbid = erab_item.erab_id - 4; - auto drb_it = - std::find_if(drbs.begin(), drbs.end(), [drbid](const drb_to_add_mod_s& drb) { return drb.drb_id == drbid; }); + const auto& drbs = rrc_ue->bearer_list.get_established_drbs(); + lte_drb drbid = lte_lcid_to_drb(erab_it->second.lcid); + auto drb_it = std::find_if( + drbs.begin(), drbs.end(), [drbid](const drb_to_add_mod_s& drb) { return (lte_drb)drb.drb_id == drbid; }); if (drb_it == drbs.end()) { - logger.warning("The DRB id=%d does not exist", erab_item.erab_id - 4); + logger.warning("The DRB id=%d does not exist", (int)drbid); } srsran::pdcp_lte_state_t drb_state{};