diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index c8ee85021..7820311bc 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -375,19 +375,17 @@ public: class pdcp_interface_rrc { public: - virtual void reset(uint16_t rnti) = 0; - virtual void add_user(uint16_t rnti) = 0; - virtual void rem_user(uint16_t rnti) = 0; - virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; - virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0; - virtual void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0; - virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; - virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; - virtual bool - get_bearer_status(uint16_t rnti, uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) = 0; - virtual bool get_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) = 0; - virtual bool set_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) = 0; + virtual void reset(uint16_t rnti) = 0; + virtual void add_user(uint16_t rnti) = 0; + virtual void rem_user(uint16_t rnti) = 0; + virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; + virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0; + virtual void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg) = 0; + virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0; + virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0; + virtual bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) = 0; + virtual bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) = 0; }; // PDCP interface for RLC diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index 3cfd19715..e18f74f84 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -55,9 +55,8 @@ public: void enable_integrity(uint32_t lcid, srslte_direction_t direction); void enable_encryption(uint32_t lcid, srslte_direction_t direction); void enable_security_timed(uint32_t lcid, srslte_direction_t direction, uint32_t sn); - bool get_bearer_status(uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn); - bool get_state(uint32_t lcid, srslte::pdcp_lte_state_t* state); - bool set_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state); + bool get_bearer_state(uint32_t lcid, srslte::pdcp_lte_state_t* state); + bool set_bearer_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state); // RLC interface void write_pdu(uint32_t lcid, unique_byte_buffer_t sdu); diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srslte/upper/pdcp_entity_lte.h index c6251e202..668b90905 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srslte/upper/pdcp_entity_lte.h @@ -58,9 +58,8 @@ public: // GW/RRC interface void write_sdu(unique_byte_buffer_t sdu, bool blocking); - void get_bearer_status(uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn); - void get_state(pdcp_lte_state_t* state); - void set_state(const pdcp_lte_state_t& state); + void get_bearer_state(pdcp_lte_state_t* state); + void set_bearer_state(const pdcp_lte_state_t& state); // RLC interface void write_pdu(unique_byte_buffer_t pdu); diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 22a85e334..ed41e6ba5 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -219,30 +219,21 @@ void pdcp::enable_security_timed(uint32_t lcid, srslte_direction_t direction, ui } } -bool pdcp::get_bearer_status(uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) +bool pdcp::get_bearer_state(uint32_t lcid, srslte::pdcp_lte_state_t* state) { if (not valid_lcid(lcid)) { return false; } - pdcp_array[lcid]->get_bearer_status(dlsn, dlhfn, ulsn, ulhfn); + pdcp_array[lcid]->get_bearer_state(state); return true; } -bool pdcp::get_state(uint32_t lcid, srslte::pdcp_lte_state_t* state) +bool pdcp::set_bearer_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state) { if (not valid_lcid(lcid)) { return false; } - pdcp_array[lcid]->get_state(state); - return true; -} - -bool pdcp::set_state(uint32_t lcid, const srslte::pdcp_lte_state_t& state) -{ - if (not valid_lcid(lcid)) { - return false; - } - pdcp_array[lcid]->set_state(state); + pdcp_array[lcid]->set_bearer_state(state); return true; } diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 5b9088d63..b44358d98 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -335,17 +335,6 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu) gw->write_pdu(lcid, std::move(pdu)); } -/**************************************************************************** - * Security functions - ***************************************************************************/ -void pdcp_entity_lte::get_bearer_status(uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) -{ - *dlsn = (uint16_t)st.next_pdcp_tx_sn; - *dlhfn = (uint16_t)st.tx_hfn; - *ulsn = (uint16_t)st.next_pdcp_rx_sn; - *ulhfn = (uint16_t)st.rx_hfn; -} - /**************************************************************************** * Config checking helper ***************************************************************************/ @@ -373,12 +362,12 @@ bool pdcp_entity_lte::check_valid_config() /**************************************************************************** * Internal state getters/setters ***************************************************************************/ -void pdcp_entity_lte::get_state(pdcp_lte_state_t* state) +void pdcp_entity_lte::get_bearer_state(pdcp_lte_state_t* state) { *state = st; } -void pdcp_entity_lte::set_state(const pdcp_lte_state_t& state) +void pdcp_entity_lte::set_bearer_state(const pdcp_lte_state_t& state) { st = state; } diff --git a/lib/test/upper/pdcp_lte_test.h b/lib/test/upper/pdcp_lte_test.h index 3c5455f89..350bca7b6 100644 --- a/lib/test/upper/pdcp_lte_test.h +++ b/lib/test/upper/pdcp_lte_test.h @@ -77,7 +77,7 @@ public: pdcp.enable_encryption(srslte::DIRECTION_TXRX); } - void set_pdcp_initial_state(const srslte::pdcp_lte_state_t& init_state) { pdcp.set_state(init_state); } + void set_pdcp_initial_state(const srslte::pdcp_lte_state_t& init_state) { pdcp.set_bearer_state(init_state); } rlc_dummy rlc; rrc_dummy rrc; diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index f9e43e0fb..074864ca8 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -52,10 +52,8 @@ public: void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t cfg_sec) override; void enable_integrity(uint16_t rnti, uint32_t lcid) override; void enable_encryption(uint16_t rnti, uint32_t lcid) override; - bool get_bearer_status(uint16_t rnti, uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) - override; - bool get_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state); - bool set_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state); + bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) override; + bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) override; private: class user_interface_rlc : public srsue::rlc_interface_pdcp diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 641e0bac5..74d5d6ef0 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -816,10 +816,15 @@ bool rrc::ue::rrc_mobility::start_enb_status_transfer() s1ap_interface_rrc::bearer_status_info b = {}; uint8_t lcid = erab_pair.second.id - 2u; b.erab_id = erab_pair.second.id; - if (not rrc_enb->pdcp->get_bearer_status(rrc_ue->rnti, lcid, &b.pdcp_dl_sn, &b.dl_hfn, &b.pdcp_ul_sn, &b.ul_hfn)) { + srslte::pdcp_lte_state_t pdcp_state = {}; + if (not rrc_enb->pdcp->get_bearer_state(rrc_ue->rnti, lcid, &pdcp_state)) { Error("PDCP bearer lcid=%d for rnti=0x%x was not found\n", lcid, rrc_ue->rnti); return false; } + b.dl_hfn = pdcp_state.tx_hfn; + b.pdcp_dl_sn = pdcp_state.next_pdcp_tx_sn; + b.ul_hfn = pdcp_state.rx_hfn; + b.pdcp_ul_sn = pdcp_state.next_pdcp_rx_sn; s1ap_bearers.push_back(b); } diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 4c8c59dec..495006a89 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -368,7 +368,7 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg) for (const auto& erab_pair : parent->users[old_rnti]->bearer_list.get_erabs()) { uint16_t lcid = erab_pair.second.id - 2; old_reest_pdcp_state[lcid] = {}; - parent->pdcp->get_state(old_rnti, lcid, &old_reest_pdcp_state[lcid]); + parent->pdcp->get_bearer_state(old_rnti, lcid, &old_reest_pdcp_state[lcid]); parent->rrc_log->debug("Getting PDCP state for E-RAB with LCID %d\n", lcid); parent->rrc_log->debug("Got PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, " @@ -576,7 +576,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) old_reest_pdcp_state[lcid].rx_hfn, old_reest_pdcp_state[lcid].next_pdcp_rx_sn, old_reest_pdcp_state[lcid].last_submitted_pdcp_rx_sn); - parent->pdcp->set_state(rnti, lcid, old_reest_pdcp_state[lcid]); + parent->pdcp->set_bearer_state(rnti, lcid, old_reest_pdcp_state[lcid]); } } } diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index e7013ecad..3356c85ce 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -117,33 +117,20 @@ void pdcp::enable_encryption(uint16_t rnti, uint32_t lcid) users[rnti].pdcp->enable_encryption(lcid, srslte::DIRECTION_TXRX); } -bool pdcp::get_bearer_status(uint16_t rnti, - uint32_t lcid, - uint16_t* dlsn, - uint16_t* dlhfn, - uint16_t* ulsn, - uint16_t* ulhfn) +bool pdcp::get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) { if (users.count(rnti) == 0) { return false; } - return users[rnti].pdcp->get_bearer_status(lcid, dlsn, dlhfn, ulsn, ulhfn); + return users[rnti].pdcp->get_bearer_state(lcid, state); } -bool pdcp::get_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) +bool pdcp::set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) { if (users.count(rnti) == 0) { return false; } - return users[rnti].pdcp->get_state(lcid, state); -} - -bool pdcp::set_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) -{ - if (users.count(rnti) == 0) { - return false; - } - return users[rnti].pdcp->set_state(lcid, state); + return users[rnti].pdcp->set_bearer_state(lcid, state); } void pdcp::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index f6e00bf11..e03ae47c1 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -72,13 +72,8 @@ public: void config_security(uint16_t rnti, uint32_t lcid, srslte::as_security_config_t sec_cfg_) override {} void enable_integrity(uint16_t rnti, uint32_t lcid) override {} void enable_encryption(uint16_t rnti, uint32_t lcid) override {} - bool get_bearer_status(uint16_t rnti, uint32_t lcid, uint16_t* dlsn, uint16_t* dlhfn, uint16_t* ulsn, uint16_t* ulhfn) - override - { - return true; - } - bool get_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) { return true; } - bool set_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) { return true; } + bool get_bearer_state(uint16_t rnti, uint32_t lcid, srslte::pdcp_lte_state_t* state) override { return true; } + bool set_bearer_state(uint16_t rnti, uint32_t lcid, const srslte::pdcp_lte_state_t& state) override { return true; } }; class s1ap_dummy : public s1ap_interface_rrc diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 804a013ac..6baba95f3 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -1140,9 +1140,12 @@ ttcn3_helpers::pdcp_count_map_t ttcn3_syssim::get_pdcp_count() if (pdcp.is_lcid_enabled(i)) { ttcn3_helpers::pdcp_count_t bearer; uint16_t tmp; // not handling HFN - pdcp.get_bearer_status(i, &bearer.dl_value, &tmp, &bearer.ul_value, &tmp); + srslte::pdcp_lte_state_t pdcp_state; + pdcp.get_bearer_state(i, &pdcp_state); bearer.rb_is_srb = i <= 2; bearer.rb_id = i; + bearer.dl_value = pdcp_state.next_pdcp_tx_sn; + bearer.ul_value = pdcp_state.next_pdcp_rx_sn; log->debug("PDCP count lcid=%d, dl=%d, ul=%d\n", bearer.rb_id, bearer.dl_value, bearer.ul_value); bearers.push_back(bearer); }