From f999e256f923878461cc0933a088991199c1dc4c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 17 Jan 2020 12:52:51 +0100 Subject: [PATCH] add error handling for RRC msg packing in eNB --- srsenb/src/stack/rrc/rrc.cc | 9 +++++++-- srsenb/src/stack/rrc/rrc_mobility.cc | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 383a9beaa..d19d4c9af 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -565,7 +565,10 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len) if (paging_rec->paging_record_list.size() > 0) { byte_buf_paging.clear(); asn1::bit_ref bref(byte_buf_paging.msg, byte_buf_paging.get_tailroom()); - pcch_msg.pack(bref); + if (pcch_msg.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { + rrc_log->error("Failed to pack PCCH\n"); + return false; + } byte_buf_paging.N_bytes = (uint32_t)bref.distance_bytes(); uint32_t N_bits = (uint32_t)bref.distance(); @@ -832,7 +835,9 @@ uint32_t rrc::generate_sibs() srslte::unique_byte_buffer_t sib = srslte::allocate_unique_buffer(*pool); asn1::bit_ref bref(sib->msg, sib->get_tailroom()); asn1::bit_ref bref0 = bref; - msg[msg_index].pack(bref); + if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { + rrc_log->error("Failed to pack SIB message %d\n", msg_index); + } sib->N_bytes = static_cast((bref.distance(bref0) - 1) / 8 + 1); sib_buffer.push_back(std::move(sib)); diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index a2a829bad..f58971e76 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -69,7 +69,9 @@ uint16_t compute_mac_i(uint16_t crnti, var_short_mac.c_rnti.from_number(crnti); asn1::bit_ref bref(varShortMAC_packed, sizeof(varShortMAC_packed)); - var_short_mac.pack(bref); // already zeroed, so no need to align + if (var_short_mac.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { // already zeroed, so no need to align + printf("Error packing varShortMAC\n"); + } uint32_t N_bytes = bref.distance_bytes(); printf("Encoded varShortMAC: cellId=0x%x, PCI=%d, rnti=0x%x (%d bytes)\n", cellid, pci, crnti, N_bytes); @@ -793,7 +795,9 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, for (ue_cap_rat_container_s& ratcntr : hoprep_r8.ue_radio_access_cap_info) { ratcntr.rat_type = asn1::rrc::rat_type_e::eutra; asn1::bit_ref bref(&ratcntr.ue_cap_rat_container[0], ratcntr.ue_cap_rat_container.size()); - rrc_ue->eutra_capabilities.pack(bref); + if (rrc_ue->eutra_capabilities.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { + rrc_log->error("Failed to pack UE EUTRA Capability\n"); + } } } /*** fill AS-Config ***/