diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index 6fde8fc6f..03398c9f6 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -90,7 +90,7 @@ public: uint32_t COUNT(uint32_t hfn, uint32_t sn); protected: - srslte::log* log = nullptr; + srslte::log* log = nullptr; srslte::timer_handler* timers = nullptr; bool active = false; @@ -119,7 +119,6 @@ protected: bool integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac); void cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* ct); void cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg); - }; inline uint32_t pdcp_entity_base::HFN(uint32_t count) diff --git a/lib/include/srslte/upper/pdcp_entity_nr.h b/lib/include/srslte/upper/pdcp_entity_nr.h index c024fc0b6..7df9387f8 100644 --- a/lib/include/srslte/upper/pdcp_entity_nr.h +++ b/lib/include/srslte/upper/pdcp_entity_nr.h @@ -46,8 +46,7 @@ public: srslte::timer_handler* timers_, srslte::log* log_); ~pdcp_entity_nr(); - void init( uint32_t lcid_, - pdcp_config_t cfg_); + void init(uint32_t lcid_, pdcp_config_t cfg_); void reset(); void reestablish(); diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 3cddf5282..16c38b0f7 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -33,7 +33,7 @@ pdcp::~pdcp() // destroy all remaining entities pthread_rwlock_wrlock(&rwlock); for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) { - delete(it->second); + delete (it->second); } pdcp_array.clear(); @@ -48,16 +48,15 @@ pdcp::~pdcp() void pdcp::init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_) { - rlc = rlc_; - rrc = rrc_; - gw = gw_; + rlc = rlc_; + rrc = rrc_; + gw = gw_; } -void pdcp::stop() -{ -} +void pdcp::stop() {} -void pdcp::reestablish() { +void pdcp::reestablish() +{ pthread_rwlock_rdlock(&rwlock); for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) { it->second->reestablish(); @@ -78,9 +77,9 @@ void pdcp::reset() { // destroy all bearers pthread_rwlock_wrlock(&rwlock); - for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); /* post increment in erase */ ) { + for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); /* post increment in erase */) { it->second->reset(); - delete(it->second); + delete (it->second); pdcp_array.erase(it++); } pthread_rwlock_unlock(&rwlock); @@ -114,7 +113,7 @@ void pdcp::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking) void pdcp::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu) { pthread_rwlock_rdlock(&rwlock); - if (valid_mch_lcid(lcid)){ + if (valid_mch_lcid(lcid)) { pdcp_array_mrb.at(lcid)->write_sdu(std::move(sdu), true); } pthread_rwlock_unlock(&rwlock); @@ -149,7 +148,7 @@ void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg) pdcp_log->error("Error inserting PDCP entity in to array\n."); goto unlock_and_exit; } - pdcp_array_mrb.at(lcid)->init( lcid, cfg); + pdcp_array_mrb.at(lcid)->init(lcid, cfg); pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", rrc->get_rb_name(lcid).c_str(), lcid, @@ -167,7 +166,7 @@ void pdcp::del_bearer(uint32_t lcid) pthread_rwlock_wrlock(&rwlock); if (valid_lcid(lcid)) { pdcp_map_t::iterator it = pdcp_array.find(lcid); - delete(it->second); + delete (it->second); pdcp_array.erase(it); pdcp_log->warning("Deleted PDCP bearer %s\n", rrc->get_rb_name(lcid).c_str()); } else { @@ -203,10 +202,10 @@ exit: pthread_rwlock_unlock(&rwlock); } -void pdcp::config_security(uint32_t lcid, - uint8_t *k_rrc_enc, - uint8_t *k_rrc_int, - uint8_t *k_up_enc, +void pdcp::config_security(uint32_t lcid, + uint8_t* k_rrc_enc, + uint8_t* k_rrc_int, + uint8_t* k_up_enc, CIPHERING_ALGORITHM_ID_ENUM cipher_algo, INTEGRITY_ALGORITHM_ID_ENUM integ_algo) { @@ -217,8 +216,11 @@ void pdcp::config_security(uint32_t lcid, pthread_rwlock_unlock(&rwlock); } -void pdcp::config_security_all(uint8_t* k_rrc_enc, uint8_t* k_rrc_int, uint8_t* k_up_enc, - CIPHERING_ALGORITHM_ID_ENUM cipher_algo, INTEGRITY_ALGORITHM_ID_ENUM integ_algo) +void pdcp::config_security_all(uint8_t* k_rrc_enc, + uint8_t* k_rrc_int, + uint8_t* k_up_enc, + CIPHERING_ALGORITHM_ID_ENUM cipher_algo, + INTEGRITY_ALGORITHM_ID_ENUM integ_algo) { pthread_rwlock_rdlock(&rwlock); for (pdcp_map_t::iterator it = pdcp_array.begin(); it != pdcp_array.end(); ++it) { diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 54731c579..18ecb3e5a 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -27,7 +27,7 @@ namespace srslte { pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, - srslte::timer_handler* timers_, + srslte::timer_handler* timers_, srslte::log* log_) : pdcp_entity_base(timers_, log_), rlc(rlc_), diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index fa3792126..d0d1d1009 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -34,10 +34,10 @@ class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_ { public: pdcp(srslte::timer_handler* timers, srslte::log* pdcp_log_); - virtual ~pdcp() {}; + virtual ~pdcp(){}; void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_); - void stop(); - + void stop(); + // pdcp_interface_rlc void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu); void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {} diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index 79ae020cd..850f8542c 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -33,9 +33,9 @@ pdcp::pdcp(srslte::timer_handler* timers_, srslte::log* log_) : void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_) { - rlc = rlc_; - rrc = rrc_; - gtpu = gtpu_; + rlc = rlc_; + rrc = rrc_; + gtpu = gtpu_; pthread_rwlock_init(&rwlock, NULL); } @@ -43,7 +43,7 @@ void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interfa void pdcp::stop() { pthread_rwlock_wrlock(&rwlock); - for(std::map::iterator iter=users.begin(); iter!=users.end(); ++iter) { + for (std::map::iterator iter = users.begin(); iter != users.end(); ++iter) { clear_user(&iter->second); } users.clear(); @@ -60,17 +60,17 @@ void pdcp::add_user(uint16_t rnti) users[rnti].rlc_itf.rnti = rnti; users[rnti].gtpu_itf.rnti = rnti; users[rnti].rrc_itf.rnti = rnti; - + users[rnti].rrc_itf.rrc = rrc; users[rnti].rlc_itf.rlc = rlc; users[rnti].gtpu_itf.gtpu = gtpu; - users[rnti].pdcp = obj; + users[rnti].pdcp = obj; } pthread_rwlock_unlock(&rwlock); } // Private unlocked deallocation of user -void pdcp::clear_user(user_interface *ue) +void pdcp::clear_user(user_interface* ue) { ue->pdcp->stop(); delete ue->pdcp; @@ -91,7 +91,7 @@ void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { - if(rnti != SRSLTE_MRNTI){ + if (rnti != SRSLTE_MRNTI) { users[rnti].pdcp->add_bearer(lcid, cfg); } else { users[rnti].pdcp->add_bearer_mrb(lcid, cfg); @@ -109,7 +109,11 @@ void pdcp::reset(uint16_t rnti) pthread_rwlock_unlock(&rwlock); } -void pdcp::config_security(uint16_t rnti, uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, +void pdcp::config_security(uint16_t rnti, + uint32_t lcid, + uint8_t* k_rrc_enc_, + uint8_t* k_rrc_int_, + uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) { @@ -147,9 +151,9 @@ void pdcp::write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { - if(rnti != SRSLTE_MRNTI){ + if (rnti != SRSLTE_MRNTI) { users[rnti].pdcp->write_sdu(lcid, std::move(sdu)); - }else { + } else { users[rnti].pdcp->write_sdu_mch(lcid, std::move(sdu)); } } @@ -166,7 +170,8 @@ void pdcp::user_interface_rlc::write_sdu(uint32_t lcid, srslte::unique_byte_buff rlc->write_sdu(rnti, lcid, std::move(sdu)); } -bool pdcp::user_interface_rlc::rb_is_um(uint32_t lcid) { +bool pdcp::user_interface_rlc::rb_is_um(uint32_t lcid) +{ return rlc->rb_is_um(rnti, lcid); } @@ -195,4 +200,4 @@ std::string pdcp::user_interface_rrc::get_rb_name(uint32_t lcid) return std::string(rb_id_text[lcid]); } -} +} // namespace srsenb