diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 6bd8954b2..3aa3bbfba 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -152,12 +152,13 @@ protected: void cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg); // Common packing functions - bool is_control_pdu(const unique_byte_buffer_t& pdu); - uint32_t read_data_header(const unique_byte_buffer_t& pdu); - void discard_data_header(const unique_byte_buffer_t& pdu); - void write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count); - void extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac); - void append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac); + bool is_control_pdu(const unique_byte_buffer_t& pdu); + pdcp_pdu_type_t get_control_pdu_type(const unique_byte_buffer_t& pdu); + uint32_t read_data_header(const unique_byte_buffer_t& pdu); + void discard_data_header(const unique_byte_buffer_t& pdu); + void write_data_header(const srslte::unique_byte_buffer_t& sdu, uint32_t count); + void extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac); + void append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac); }; inline uint32_t pdcp_entity_base::HFN(uint32_t count) diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index 22a3db98f..c8520dceb 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -219,6 +219,11 @@ bool pdcp_entity_base::is_control_pdu(const unique_byte_buffer_t& pdu) return ((*(payload) >> 7) & 0x01) == PDCP_DC_FIELD_CONTROL_PDU; } +pdcp_pdu_type_t pdcp_entity_base::get_control_pdu_type(const unique_byte_buffer_t& pdu) +{ + return pdcp_pdu_type_t((pdu->msg[0] >> 4U) & 0x03U); +} + uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu) { // Check PDU is long enough to extract header diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 95f09d111..8b209ce52 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -229,7 +229,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu) // Handle control PDU void pdcp_entity_lte::handle_control_pdu(unique_byte_buffer_t pdu) { - switch ((pdu->msg[0] >> 4) & 0x03) { + switch (get_control_pdu_type(pdu)) { case PDCP_PDU_TYPE_STATUS_REPORT: handle_status_report_pdu(std::move(pdu)); break; @@ -393,7 +393,7 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) // Section 5.3.1 transmit operation bool pdcp_entity_lte::send_status_report() { - // Check wether RCL AM is being used. + // Check wether RLC AM is being used. if (rlc->rb_is_um(lcid)) { logger.error("Trying to send PDCP Status Report and RLC is not AM"); return false; @@ -407,10 +407,14 @@ bool pdcp_entity_lte::send_status_report() fms = undelivered_sdus_queue.begin()->first; } - logger.debug("PDCP Status report: FMS=%d", fms); + logger.debug("Status report: FMS=%d", fms); // Allocate Status Report PDU unique_byte_buffer_t pdu = make_byte_buffer(); + if (pdu == nullptr) { + logger.error("Error allocating buffer for status report"); + return false; + } // Set control bit and type of PDU pdu->msg[0] = ((uint8_t)PDCP_DC_FIELD_CONTROL_PDU << 7) | ((uint8_t)PDCP_PDU_TYPE_STATUS_REPORT << 4); diff --git a/lib/test/upper/pdcp_lte_test_status_report.cc b/lib/test/upper/pdcp_lte_test_status_report.cc index f22c7ade4..7b7ba87eb 100644 --- a/lib/test/upper/pdcp_lte_test_status_report.cc +++ b/lib/test/upper/pdcp_lte_test_status_report.cc @@ -171,7 +171,7 @@ int test_rx_status_report(const srslte::pdcp_lte_state_t& init_state, srslog::ba int run_all_tests() { // Setup log - srslog::basic_logger& logger = srslog::fetch_basic_logger("PDCP LTE Test Status Report", false); + srslog::basic_logger& logger = srslog::fetch_basic_logger("PDCP", false); logger.set_level(srslog::basic_levels::debug); logger.set_hex_dump_max_size(128);