Capture false encoded messages before sending

master
David Rupprecht 4 years ago committed by David Rupprecht
parent 8c194b887b
commit 3284143b39

@ -735,7 +735,7 @@ uint32_t rrc::generate_sibs()
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); 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); logger.error("Failed to pack SIB message %d", msg_index);
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -889,7 +889,10 @@ int rrc::pack_mcch()
const int rlc_header_len = 1; const int rlc_header_len = 1;
asn1::bit_ref bref(&mcch_payload_buffer[rlc_header_len], sizeof(mcch_payload_buffer) - rlc_header_len); 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 = bref.distance_bytes(&mcch_payload_buffer[1]);
current_mcch_length = current_mcch_length + rlc_header_len; current_mcch_length = current_mcch_length + rlc_header_len;
return current_mcch_length; return current_mcch_length;

@ -215,7 +215,10 @@ int32_t rrc_nr::generate_sibs()
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
asn1::bit_ref bref(mib_buf->msg, mib_buf->get_tailroom()); 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(); mib_buf->N_bytes = bref.distance_bytes();
logger.debug(mib_buf->msg, mib_buf->N_bytes, "MIB payload (%d B)", mib_buf->N_bytes); logger.debug(mib_buf->msg, mib_buf->N_bytes, "MIB payload (%d B)", mib_buf->N_bytes);
mib_buffer = std::move(mib_buf); mib_buffer = std::move(mib_buf);
@ -253,7 +256,10 @@ int32_t rrc_nr::generate_sibs()
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
asn1::bit_ref bref(sib->msg, sib->get_tailroom()); 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->N_bytes = bref.distance_bytes();
sib_buffer.push_back(std::move(sib)); sib_buffer.push_back(std::move(sib));

@ -911,7 +911,10 @@ bool rrc::ue::handle_ue_cap_info(ue_cap_info_s* msg)
dest.resize(bref2.distance_bytes()); dest.resize(bref2.distance_bytes());
memcpy(dest.data(), pdu->msg, bref2.distance_bytes()); memcpy(dest.data(), pdu->msg, bref2.distance_bytes());
bref2 = asn1::bit_ref{pdu->msg, pdu->get_tailroom()}; 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(); pdu->N_bytes = bref2.distance_bytes();
parent->s1ap->send_ue_cap_info_indication(rnti, std::move(pdu)); parent->s1ap->send_ue_cap_info_indication(rnti, std::move(pdu));
} }

@ -1806,7 +1806,10 @@ bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnt
return false; return false;
} }
asn1::bit_ref bref(buf->msg, buf->get_tailroom()); 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(); buf->N_bytes = bref.distance_bytes();
// Save message to PCAP // Save message to PCAP

Loading…
Cancel
Save