mac_pdu_nr: add error handling to init_tx() method

check provided byte_buffer and return error if it's not valid
master
Andre Puschmann 3 years ago
parent 4ef1ac2649
commit 9bf74843f6

@ -128,7 +128,7 @@ public:
const mac_sch_subpdu_nr& get_subpdu(const uint32_t& index); const mac_sch_subpdu_nr& get_subpdu(const uint32_t& index);
bool is_ulsch(); bool is_ulsch();
void init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool is_ulsch_ = false); int init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool is_ulsch_ = false);
void init_rx(bool ulsch_ = false); void init_rx(bool ulsch_ = false);
// Add SDU or CEs to PDU // Add SDU or CEs to PDU

@ -334,13 +334,18 @@ bool mac_sch_pdu_nr::is_ulsch()
return ulsch; return ulsch;
} }
void mac_sch_pdu_nr::init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool ulsch_) int mac_sch_pdu_nr::init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool ulsch_)
{ {
if (buffer_ == nullptr || buffer_->msg == nullptr) {
logger.error("Invalid buffer");
return SRSRAN_ERROR;
}
buffer = buffer_; buffer = buffer_;
subpdus.clear(); subpdus.clear();
pdu_len = pdu_len_; pdu_len = pdu_len_;
remaining_len = pdu_len_; remaining_len = pdu_len_;
ulsch = ulsch_; ulsch = ulsch_;
return SRSRAN_SUCCESS;
} }
void mac_sch_pdu_nr::init_rx(bool ulsch_) void mac_sch_pdu_nr::init_rx(bool ulsch_)

@ -111,7 +111,10 @@ int ue_nr::generate_pdu(srsran::byte_buffer_t* pdu, uint32_t grant_size)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
mac_pdu_dl.init_tx(pdu, grant_size); if (mac_pdu_dl.init_tx(pdu, grant_size) != SRSRAN_SUCCESS) {
logger.error("Couldn't initialize MAC PDU buffer");
return SRSRAN_ERROR;
}
// read RLC PDU // read RLC PDU
ue_rlc_buffer->clear(); ue_rlc_buffer->clear();

Loading…
Cancel
Save