small updates for testing handover and configuring the rrc

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent f2af447b1a
commit f43985b6cd

@ -103,13 +103,13 @@ auto call_enter(FSM* f, State* s) -> decltype(s->enter(f))
{
s->enter(f);
}
void call_enter(...) {}
inline void call_enter(...) {}
template <typename FSM, typename State>
auto call_exit(FSM* f, State* s) -> decltype(s->exit(f))
{
s->exit(f);
}
void call_exit(...) {}
inline void call_exit(...) {}
//! Find State in FSM recursively (e.g. find State in FSM,FSM::parentFSM,FSM::parentFSM::parentFSM,...)
template <typename State, typename FSM>
@ -604,6 +604,11 @@ private:
int launch_counter = 0;
};
// Generic events
struct success_ev {};
struct failure_ev {};
} // namespace srslte
#endif // SRSLTE_FSM_H

@ -369,6 +369,7 @@ public:
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;

@ -36,13 +36,18 @@ 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 regenerate_keys_handover(uint32_t new_pci, uint32_t new_dl_earfcn);
asn1::rrc::security_algorithm_cfg_s get_security_algorithm_cfg();
const srslte::as_security_config_t& get_as_sec_cfg() const { return sec_cfg; }
bool is_as_sec_cfg_valid() const { return k_enb_present; }
private:
void generate_as_keys();
srslte::log_ref log_h{"RRC"};
const rrc_cfg_t* cfg;
bool k_enb_present = false;
asn1::s1ap::ue_security_cap_s security_capabilities;
uint8_t k_enb[32] = {}; // Provided by MME
srslte::as_security_config_t sec_cfg = {};
@ -69,6 +74,7 @@ public:
const asn1::unbounded_octstring<true>* nas_pdu);
void release_erab(uint8_t erab_id);
void release_erabs();
void reest_bearers();
bool fill_rr_cfg_ded(asn1::rrc::rr_cfg_ded_s& msg);
void rr_ded_cfg_complete();
@ -80,6 +86,7 @@ public:
void fill_pending_nas_info(asn1::rrc::rrc_conn_recfg_r8_ies_s* msg);
const std::map<uint8_t, erab_t>& get_erabs() const { return erabs; }
const asn1::rrc::drb_to_add_mod_list_l& established_drbs() const { return last_drbs; }
private:
srslte::log_ref log_h{"RRC"};

@ -48,6 +48,7 @@ public:
void rem_user(uint16_t rnti) override;
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override;
void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override;
void del_bearer(uint16_t rnti, uint32_t lcid) override;
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;

@ -206,7 +206,6 @@ void cc_worker::rem_rnti(uint16_t rnti)
{
std::lock_guard<std::mutex> lock(mutex);
if (ue_db.count(rnti)) {
delete ue_db[rnti];
ue_db.erase(rnti);

@ -140,7 +140,7 @@ void sched_ue::set_cfg(const sched_interface::ue_cfg_t& cfg_)
// One carrier was added in the place of another
carriers[ue_idx] = sched_ue_carrier{cfg, (*cell_params_list)[cc_cfg.enb_cc_idx], rnti, ue_idx};
if (ue_idx == 0) {
log_h->info("SCHED: PCell has changed for rnti=0x%x.\n", rnti);
log_h->info("SCHED: rnti=0x%x PCell is now %d.\n", rnti, cc_cfg.enb_cc_idx);
}
} else {
// The SCell internal configuration may have changed

@ -167,11 +167,17 @@ bool security_cfg_handler::set_security_capabilities(const asn1::s1ap::ue_securi
void security_cfg_handler::set_security_key(const asn1::fixed_bitstring<256, false, true>& key)
{
k_enb_present = true;
for (uint32_t i = 0; i < key.nof_octets(); ++i) {
k_enb[i] = key.data()[key.nof_octets() - 1 - i];
}
log_h->info_hex(k_enb, 32, "Key eNodeB (k_enb)");
generate_as_keys();
}
void security_cfg_handler::generate_as_keys()
{
log_h->info("Selected security algorithms EEA: EEA%d EIA: EIA%d\n", sec_cfg.cipher_algo, sec_cfg.integ_algo);
// Generate K_rrc_enc and K_rrc_int
@ -187,6 +193,18 @@ void security_cfg_handler::set_security_key(const asn1::fixed_bitstring<256, fal
log_h->info_hex(sec_cfg.k_up_enc.data(), 32, "UP Encryption Key (k_up_enc)");
}
void security_cfg_handler::regenerate_keys_handover(uint32_t new_pci, uint32_t new_dl_earfcn)
{
// Generate K_enb*
uint8_t k_enb_star[32];
srslte::security_generate_k_enb_star(k_enb, new_pci, new_dl_earfcn, k_enb_star);
// K_enb becomes K_enb*
memcpy(k_enb, k_enb_star, 32);
generate_as_keys();
}
/*****************************
* Bearer Handler
****************************/
@ -295,6 +313,13 @@ void bearer_cfg_handler::release_erabs()
}
}
void bearer_cfg_handler::reest_bearers()
{
// Re-add all SRBs/DRBs
srbs_to_add = last_srbs;
drbs_to_add = last_drbs;
}
void bearer_cfg_handler::rr_ded_cfg_complete()
{
// Apply changes in internal bearer_handler DRB/SRBtoAddModLists
@ -347,17 +372,16 @@ void bearer_cfg_handler::apply_pdcp_bearer_updates(pdcp_interface_rrc* pdcp, con
pdcp->add_bearer(rnti, srb.srb_id, srslte::make_srb_pdcp_config_t(srb.srb_id, false));
// For SRB2, enable security/encryption/integrity
if (srb.srb_id > 1) {
if (ue_sec_cfg.is_as_sec_cfg_valid()) {
pdcp->config_security(rnti, srb.srb_id, ue_sec_cfg.get_as_sec_cfg());
pdcp->enable_integrity(rnti, srb.srb_id);
pdcp->enable_encryption(rnti, srb.srb_id);
}
}
if (drbs_to_release.size() > 0) {
log_h->warning("Removing DRBs not currently supported\n");
for (uint8_t drb_id : drbs_to_release) {
pdcp->del_bearer(rnti, drb_id + 2);
}
for (const drb_to_add_mod_s& drb : drbs_to_add) {
// Configure DRB1 in PDCP
if (drb.pdcp_cfg_present) {
@ -368,11 +392,13 @@ void bearer_cfg_handler::apply_pdcp_bearer_updates(pdcp_interface_rrc* pdcp, con
pdcp->add_bearer(rnti, drb.lc_ch_id, pdcp_cnfg_drb);
}
if (ue_sec_cfg.is_as_sec_cfg_valid()) {
pdcp->config_security(rnti, drb.lc_ch_id, ue_sec_cfg.get_as_sec_cfg());
pdcp->enable_integrity(rnti, drb.lc_ch_id);
pdcp->enable_encryption(rnti, drb.lc_ch_id);
}
}
}
void bearer_cfg_handler::apply_rlc_bearer_updates(rlc_interface_rrc* rlc)
{

@ -28,8 +28,7 @@ pdcp::pdcp(srslte::task_handler_interface* task_executor_, const char* logname)
task_executor(task_executor_),
log_h(logname),
pool(srslte::byte_buffer_pool::get_instance())
{
}
{}
void pdcp::init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_)
{
@ -89,6 +88,13 @@ void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cfg)
}
}
void pdcp::del_bearer(uint16_t rnti, uint32_t lcid)
{
if (users.count(rnti)) {
users[rnti].pdcp->del_bearer(lcid);
}
}
void pdcp::reset(uint16_t rnti)
{
if (users.count(rnti)) {

@ -66,6 +66,7 @@ public:
void rem_user(uint16_t rnti) override {}
void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) override {}
void add_bearer(uint16_t rnti, uint32_t lcid, srslte::pdcp_config_t cnfg) override {}
void del_bearer(uint16_t rnti, uint32_t lcid) override {}
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 {}

@ -76,6 +76,7 @@ public:
srslte::unique_byte_buffer_t rrc_container;
} last_ho_required = {};
struct enb_status_transfer_info {
bool status_present;
uint16_t rnti;
std::vector<bearer_status_info> bearer_list;
} last_enb_status = {};
@ -89,6 +90,11 @@ public:
last_ho_required = ho_req_data{rnti, target_eci, target_plmn, std::move(rrc_container)};
return true;
}
bool send_enb_status_transfer_proc(uint16_t rnti, std::vector<bearer_status_info>& bearer_status_list) override
{
last_enb_status = {true, rnti, bearer_status_list};
return true;
}
void ue_erab_setup_complete(uint16_t rnti, const asn1::s1ap::erab_setup_resp_s& res) override
{
if (res.protocol_ies.erab_setup_list_bearer_su_res_present) {
@ -129,6 +135,7 @@ int parse_default_cfg(rrc_cfg_t* rrc_cfg, srsenb::all_args_t& args)
args.enb_files.drb_config = argparse::repository_dir + "/drb.conf.example";
srslte::logmap::get("TEST")->debug("sib file path=%s\n", args.enb_files.sib_config.c_str());
args.enb.enb_id = 0x19B;
args.enb.dl_earfcn = 3400;
args.enb.n_prb = 50;
TESTASSERT(srslte::string_to_mcc("001", &args.stack.s1ap.mcc));

Loading…
Cancel
Save