diff --git a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h index d90ae1891..4414f4003 100644 --- a/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_bearer_cfg.h @@ -36,9 +36,11 @@ public: bool set_security_capabilities(const asn1::s1ap::ue_security_cap_s& caps); void set_security_key(const asn1::fixed_bitstring<256, false, true>& key); + void set_ncc(uint8_t ncc_) { ncc = ncc_; } asn1::rrc::security_algorithm_cfg_s get_security_algorithm_cfg(); const srslte::as_security_config_t& get_as_sec_cfg() const { return sec_cfg; } + uint8_t get_ncc() const { return ncc; } bool is_as_sec_cfg_valid() const { return k_enb_present; } void regenerate_keys_handover(uint32_t new_pci, uint32_t new_dl_earfcn); @@ -52,6 +54,7 @@ private: asn1::s1ap::ue_security_cap_s security_capabilities = {}; uint8_t k_enb[32] = {}; // Provided by MME srslte::as_security_config_t sec_cfg = {}; + uint8_t ncc = 0; }; class bearer_cfg_handler diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index 50642e819..2109f7e16 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -50,7 +50,7 @@ public: rrc_state_t get_state(); void send_connection_setup(); - void send_connection_reest(); + void send_connection_reest(uint8_t ncc); void send_connection_reject(); void send_connection_release(); void send_connection_reest_rej(); diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 8f2f70391..957d6d028 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -1050,6 +1050,7 @@ void rrc::ue::rrc_mobility::handle_ho_req(idle_st& s, const ho_req_rx_ev& ho_req rrc_conn_recfg_r8_ies_s& recfg_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); // Apply new Security Config based on HandoverRequest + // See TS 33.401, Sec. 7.2.8.4.3 recfg_r8.security_cfg_ho_present = true; recfg_r8.security_cfg_ho.handov_type.set(security_cfg_ho_s::handov_type_c_::types_opts::intra_lte); recfg_r8.security_cfg_ho.handov_type.intra_lte().security_algorithm_cfg_present = true; @@ -1143,8 +1144,10 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho } // Regenerate AS Keys + // See TS 33.401, Sec. 7.2.8.4.3 rrc_ue->ue_security_cfg.set_security_capabilities(ho_req_msg.protocol_ies.ue_security_cap.value); rrc_ue->ue_security_cfg.set_security_key(ho_req_msg.protocol_ies.security_context.value.next_hop_param); + rrc_ue->ue_security_cfg.set_ncc(ho_req_msg.protocol_ies.security_context.value.next_hop_chaining_count); rrc_ue->ue_security_cfg.regenerate_keys_handover(target_cell_cfg.pci, target_cell_cfg.dl_earfcn); // Save UE Capabilities diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 929ec250c..ee4b0ca19 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -340,7 +340,7 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg) if (parent->users.count(old_rnti)) { parent->rrc_log->info("ConnectionReestablishmentRequest for rnti=0x%x. Sending Connection Reestablishment\n", old_rnti); - send_connection_reest(); + send_connection_reest(parent->users[old_rnti]->ue_security_cfg.get_ncc()); // Cancel Handover in Target eNB if on-going parent->users[old_rnti]->mobility_handler->trigger(rrc_mobility::ho_cancel_ev{}); @@ -386,7 +386,7 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg) return; } -void rrc::ue::send_connection_reest() +void rrc::ue::send_connection_reest(uint8_t ncc) { // Re-Establish SRB1 bearer_list.add_srb(1); @@ -403,6 +403,9 @@ void rrc::ue::send_connection_reest() fill_rrc_setup_rr_config_dedicated(rr_cfg); phys_cfg_ded_s* phy_cfg = &rr_cfg->phys_cfg_ded; + // Set NCC + reest.next_hop_chaining_count = ncc; + // Apply ConnectionReest Configuration to MAC scheduler mac_ctrl->handle_con_reest(reest);