diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 4fb9b6331..8c8fd5e85 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -735,7 +735,7 @@ uint32_t rrc::generate_sibs() return SRSRAN_ERROR; } asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); - if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { + if (msg[msg_index].pack(bref) != asn1::SRSASN_SUCCESS) { logger.error("Failed to pack SIB message %d", msg_index); return SRSRAN_ERROR; } @@ -889,7 +889,10 @@ int rrc::pack_mcch() const int rlc_header_len = 1; asn1::bit_ref bref(&mcch_payload_buffer[rlc_header_len], sizeof(mcch_payload_buffer) - rlc_header_len); - mcch.pack(bref); + if (mcch.pack(bref) != asn1::SRSASN_SUCCESS) { + logger.error("Failed to pack MCCH message"); + } + current_mcch_length = bref.distance_bytes(&mcch_payload_buffer[1]); current_mcch_length = current_mcch_length + rlc_header_len; return current_mcch_length; diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 2f66c6ae5..e8b107603 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -215,7 +215,10 @@ int32_t rrc_nr::generate_sibs() return SRSRAN_ERROR; } asn1::bit_ref bref(mib_buf->msg, mib_buf->get_tailroom()); - mib_msg.pack(bref); + if (mib_msg.pack(bref) != asn1::SRSASN_SUCCESS) { + logger.error("Couldn't pack mib msg"); + return SRSRAN_ERROR; + } mib_buf->N_bytes = bref.distance_bytes(); logger.debug(mib_buf->msg, mib_buf->N_bytes, "MIB payload (%d B)", mib_buf->N_bytes); mib_buffer = std::move(mib_buf); @@ -253,7 +256,10 @@ int32_t rrc_nr::generate_sibs() return SRSRAN_ERROR; } asn1::bit_ref bref(sib->msg, sib->get_tailroom()); - msg[msg_index].pack(bref); + if (msg[msg_index].pack(bref) != asn1::SRSASN_SUCCESS) { + logger.error("Failed to pack SIB message %d", msg_index); + return SRSRAN_ERROR; + } sib->N_bytes = bref.distance_bytes(); sib_buffer.push_back(std::move(sib)); diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 78255d958..12192230e 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -911,7 +911,10 @@ bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg) dest.resize(bref2.distance_bytes()); memcpy(dest.data(), pdu->msg, bref2.distance_bytes()); bref2 = asn1::bit_ref{pdu->msg, pdu->get_tailroom()}; - ue_rat_caps.pack(bref2); + if (ue_rat_caps.pack(bref2) != asn1::SRSASN_SUCCESS) { + parent->logger.error("Couldn't pack ue rat caps"); + return false; + } pdu->N_bytes = bref2.distance_bytes(); parent->s1ap->send_ue_cap_info_indication(rnti, std::move(pdu)); } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index a828911d7..7b78d27df 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -1806,7 +1806,10 @@ bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnt return false; } asn1::bit_ref bref(buf->msg, buf->get_tailroom()); - tx_pdu.pack(bref); + if (tx_pdu.pack(bref) != asn1::SRSASN_SUCCESS) { + logger.error("Failed to pack TX PDU %s", procedure_name); + return false; + } buf->N_bytes = bref.distance_bytes(); // Save message to PCAP