diff --git a/lib/include/srslte/upper/pdcp_entity.h b/lib/include/srslte/upper/pdcp_entity.h index 186da3767..0894b6578 100644 --- a/lib/include/srslte/upper/pdcp_entity.h +++ b/lib/include/srslte/upper/pdcp_entity.h @@ -61,7 +61,6 @@ static const char pdcp_d_c_text[PDCP_D_C_N_ITEMS][20] = {"Control PDU", * Common interface for all PDCP entities ***************************************************************************/ class pdcp_entity - :public thread { public: pdcp_entity(); @@ -71,7 +70,6 @@ public: srslte::log *log_, uint32_t lcid_, srslte_pdcp_config_t cfg_); - void stop(); void reset(); void reestablish(); @@ -97,10 +95,6 @@ private: srsue::rrc_interface_pdcp *rrc; srsue::gw_interface_pdcp *gw; - static const int PDCP_THREAD_PRIO = 7; - srslte::msg_queue rx_pdu_queue; - bool running; - bool active; uint32_t lcid; srslte_pdcp_config_t cfg; @@ -134,8 +128,6 @@ private: uint32_t ct_len, uint8_t *msg); - void run_thread(); - uint8_t get_bearer_id(uint8_t lcid); }; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index e7c02c179..320f02450 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -52,11 +52,6 @@ void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_ void pdcp::stop() { - for(uint32_t i=0;idebug("Init %s\n", rrc->get_rb_name(lcid).c_str()); } -void pdcp_entity::stop() -{ - if(running) { - running = false; - thread_cancel(); - wait_thread_finish(); - } -} - // Reestablishment procedure: 36.323 5.2 void pdcp_entity::reestablish() { // For SRBs @@ -165,7 +154,53 @@ void pdcp_entity::enable_encryption() // RLC interface void pdcp_entity::write_pdu(byte_buffer_t *pdu) { - rx_pdu_queue.write(pdu); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU, do_integrity = %s, do_encryption = %s", + rrc->get_rb_name(lcid).c_str(), (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); + + // Handle DRB messages + if (cfg.is_data) { + uint32_t sn; + if (do_encryption) { + cipher_decrypt(&(pdu->msg[sn_len_bytes]), + rx_count, + pdu->N_bytes - sn_len_bytes, + &(pdu->msg[sn_len_bytes])); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str()); + } + if(12 == cfg.sn_len) + { + pdcp_unpack_data_pdu_long_sn(pdu, &sn); + } else { + pdcp_unpack_data_pdu_short_sn(pdu, &sn); + } + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn); + gw->write_pdu(lcid, pdu); + } else { + // Handle SRB messages + if (cfg.is_control) { + uint32_t sn; + if (do_encryption) { + cipher_decrypt(&(pdu->msg[sn_len_bytes]), + rx_count, + pdu->N_bytes - sn_len_bytes, + &(pdu->msg[sn_len_bytes])); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str()); + } + + if (do_integrity) { + integrity_verify(pdu->msg, + rx_count, + pdu->N_bytes - 4, + &(pdu->msg[pdu->N_bytes - 4])); + } + + pdcp_unpack_control_pdu(pdu, &sn); + log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn); + } + // pass to RRC + rrc->write_pdu(lcid, pdu); + } + rx_count++; } void pdcp_entity::integrity_generate( uint8_t *msg, @@ -332,63 +367,6 @@ void pdcp_entity::cipher_decrypt(uint8_t *ct, } -void pdcp_entity::run_thread() -{ - byte_buffer_t *pdu; - running = true; - - while(running) { - rx_pdu_queue.read(&pdu); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU, do_integrity = %s, do_encryption = %s", - rrc->get_rb_name(lcid).c_str(), (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); - - // Handle DRB messages - if (cfg.is_data) { - uint32_t sn; - if (do_encryption) { - cipher_decrypt(&(pdu->msg[sn_len_bytes]), - rx_count, - pdu->N_bytes - sn_len_bytes, - &(pdu->msg[sn_len_bytes])); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str()); - } - if(12 == cfg.sn_len) - { - pdcp_unpack_data_pdu_long_sn(pdu, &sn); - } else { - pdcp_unpack_data_pdu_short_sn(pdu, &sn); - } - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn); - gw->write_pdu(lcid, pdu); - } else { - // Handle SRB messages - if (cfg.is_control) { - uint32_t sn; - if (do_encryption) { - cipher_decrypt(&(pdu->msg[sn_len_bytes]), - rx_count, - pdu->N_bytes - sn_len_bytes, - &(pdu->msg[sn_len_bytes])); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU (decrypted)", rrc->get_rb_name(lcid).c_str()); - } - - if (do_integrity) { - integrity_verify(pdu->msg, - rx_count, - pdu->N_bytes - 4, - &(pdu->msg[pdu->N_bytes - 4])); - } - - pdcp_unpack_control_pdu(pdu, &sn); - log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU SN: %d", rrc->get_rb_name(lcid).c_str(), sn); - } - // pass to RRC - rrc->write_pdu(lcid, pdu); - } - rx_count++; - } -} - uint8_t pdcp_entity::get_bearer_id(uint8_t lcid) { #define RB_ID_SRB2 2