From b04cb0deb9b4d9d2a18e670a0249063cfced1ddb Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 7 May 2019 15:15:31 +0100 Subject: [PATCH] using the new choice set api in UE and eNB RRC --- srsenb/src/enb_cfg_parser.cc | 35 ++++------ srsenb/src/upper/rrc.cc | 125 +++++++++++------------------------ srsue/src/upper/rrc.cc | 94 ++++++++------------------ 3 files changed, 82 insertions(+), 172 deletions(-) diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index d7da60456..120abec55 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -608,18 +608,11 @@ int mbsfn_area_info_list_parser::parse(Setting& root) int enb::parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_common) { // FIXME: Leave 0 blank for now - rrc_cfg->sibs[1].set(asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib2); - rrc_cfg->sibs[2].set(asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib3); - rrc_cfg->sibs[3].set(asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib4); - rrc_cfg->sibs[8].set(asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib9); - rrc_cfg->sibs[12].set( - asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib13_v920); // TODO: Confirm it matches with old - // LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_13 - sib_type2_s* sib2 = &rrc_cfg->sibs[1].sib2(); - sib_type3_s* sib3 = &rrc_cfg->sibs[2].sib3(); - sib_type4_s* sib4 = &rrc_cfg->sibs[3].sib4(); - sib_type9_s* sib9 = &rrc_cfg->sibs[8].sib9(); - sib_type13_r9_s* sib13 = &rrc_cfg->sibs[12].sib13_v920(); + sib_type2_s* sib2 = &rrc_cfg->sibs[1].set_sib2(); + sib_type3_s* sib3 = &rrc_cfg->sibs[2].set_sib3(); + sib_type4_s* sib4 = &rrc_cfg->sibs[3].set_sib4(); + sib_type9_s* sib9 = &rrc_cfg->sibs[8].set_sib9(); + sib_type13_r9_s* sib13 = &rrc_cfg->sibs[12].set_sib13_v920(); sib_type1_s* sib1 = &rrc_cfg->sib1; if (parse_sib1(args->enb_files.sib_config, sib1)) { @@ -743,7 +736,7 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg) rrc_cfg->antenna_info.tx_mode = (ant_info_ded_s::tx_mode_e_::options)(args->enb.transmission_mode - 1); - rrc_cfg->antenna_info.ue_tx_ant_sel.set(ant_info_ded_s::ue_tx_ant_sel_c_::types::setup); + rrc_cfg->antenna_info.ue_tx_ant_sel.set_setup(); switch (rrc_cfg->antenna_info.tx_mode) { case ant_info_ded_s::tx_mode_e_::tm1: case ant_info_ded_s::tx_mode_e_::tm2: @@ -754,16 +747,14 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg) rrc_cfg->antenna_info.ue_tx_ant_sel.setup().value = ant_info_ded_s::ue_tx_ant_sel_c_::setup_e_::open_loop; rrc_cfg->antenna_info.codebook_subset_restrict_present = true; - rrc_cfg->antenna_info.codebook_subset_restrict.set( - ant_info_ded_s::codebook_subset_restrict_c_::types::n2_tx_ant_tm3); + rrc_cfg->antenna_info.codebook_subset_restrict.set_n2_tx_ant_tm3(); rrc_cfg->antenna_info.codebook_subset_restrict.n2_tx_ant_tm3().from_number(0b11); break; case ant_info_ded_s::tx_mode_e_::tm4: rrc_cfg->antenna_info.ue_tx_ant_sel.setup().value = ant_info_ded_s::ue_tx_ant_sel_c_::setup_e_::closed_loop; rrc_cfg->antenna_info.codebook_subset_restrict_present = true; - rrc_cfg->antenna_info.codebook_subset_restrict.set( - ant_info_ded_s::codebook_subset_restrict_c_::types::n2_tx_ant_tm4); + rrc_cfg->antenna_info.codebook_subset_restrict.set_n2_tx_ant_tm4(); rrc_cfg->antenna_info.codebook_subset_restrict.n2_tx_ant_tm4().from_number(0b111111); break; default: @@ -849,7 +840,7 @@ int phr_cnfg_parser::parse(libconfig::Setting& root) phr_cfg->set(mac_main_cfg_s::phr_cfg_c_::types::release); return 0; } - phr_cfg->set(mac_main_cfg_s::phr_cfg_c_::types::setup); + phr_cfg->set_setup(); mac_main_cfg_s::phr_cfg_c_::setup_s_& s = phr_cfg->setup(); if (not parse_enum_by_str(s.dl_pathloss_change, "dl_pathloss_change", root["phr_cnfg"])) { @@ -908,13 +899,13 @@ int field_qci::parse(libconfig::Setting& root) // Parse RLC section rlc_cfg_c* rlc_cfg = &cfg[qci].rlc_cfg; if (q["rlc_config"].exists("ul_am")) { - rlc_cfg->set(rlc_cfg_c::types::am); + rlc_cfg->set_am(); } else if (q["rlc_config"].exists("ul_um") && q["rlc_config"].exists("dl_um")) { - rlc_cfg->set(rlc_cfg_c::types::um_bi_dir); + rlc_cfg->set_um_bi_dir(); } else if (q["rlc_config"].exists("ul_um") && !q["rlc_config"].exists("dl_um")) { - rlc_cfg->set(rlc_cfg_c::types::um_uni_dir_ul); + rlc_cfg->set_um_uni_dir_ul(); } else if (!q["rlc_config"].exists("ul_um") && q["rlc_config"].exists("dl_um")) { - rlc_cfg->set(rlc_cfg_c::types::um_uni_dir_dl); + rlc_cfg->set_um_uni_dir_dl(); } else { fprintf(stderr, "Invalid combination of UL/DL UM/AM for qci=%d\n", qci); return -1; diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index 95f692bfb..2f62e6c3f 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -248,19 +248,17 @@ void rrc::write_pdu(uint16_t rnti, uint32_t lcid, byte_buffer_t* pdu) void rrc::write_dl_info(uint16_t rnti, byte_buffer_t* sdu) { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); + dl_dcch_msg.msg.set_c1(); dl_dcch_msg_type_c::c1_c_* msg_c1 = &dl_dcch_msg.msg.c1(); pthread_mutex_lock(&user_mutex); if (users.count(rnti) == 1) { - msg_c1->set(dl_dcch_msg_type_c::c1_c_::types::dl_info_transfer); + dl_info_transfer_r8_ies_s* dl_info_r8 = + &msg_c1->set_dl_info_transfer().crit_exts.set_c1().set_dl_info_transfer_r8(); // msg_c1->dl_info_transfer().rrc_transaction_id = ; - msg_c1->dl_info_transfer().crit_exts.set(dl_info_transfer_s::crit_exts_c_::types::c1); - msg_c1->dl_info_transfer().crit_exts.c1().set(dl_info_transfer_s::crit_exts_c_::c1_c_::types::dl_info_transfer_r8); - dl_info_transfer_r8_ies_s* dl_info_r8 = &msg_c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8(); dl_info_r8->non_crit_ext_present = false; - dl_info_r8->ded_info_type.set(dl_info_transfer_r8_ies_s::ded_info_type_c_::types::ded_info_nas); + dl_info_r8->ded_info_type.set_ded_info_nas(); dl_info_r8->ded_info_type.ded_info_nas().resize(sdu->N_bytes); memcpy(msg_c1->dl_info_transfer().crit_exts.c1().dl_info_transfer_r8().ded_info_type.ded_info_nas().data(), sdu->msg, sdu->N_bytes); @@ -426,7 +424,7 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len) pthread_mutex_lock(&paging_mutex); asn1::rrc::pcch_msg_s pcch_msg; - pcch_msg.msg.set(pcch_msg_type_c::types::c1); + pcch_msg.msg.set_c1(); paging_s* paging_rec = &pcch_msg.msg.c1().paging(); // Default paging cycle, should get DRX from user @@ -456,12 +454,12 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len) paging_rec->paging_record_list_present = true; paging_record_s paging_elem; if (u.choice_type == LIBLTE_S1AP_UEPAGINGID_CHOICE_IMSI) { - paging_elem.ue_id.set(paging_ue_id_c::types::imsi); + paging_elem.ue_id.set_imsi(); paging_elem.ue_id.imsi().resize(u.choice.iMSI.n_octets); memcpy(paging_elem.ue_id.imsi().data(), u.choice.iMSI.buffer, u.choice.iMSI.n_octets); rrc_log->console("Warning IMSI paging not tested\n"); } else { - paging_elem.ue_id.set(paging_ue_id_c::types::s_tmsi); + paging_elem.ue_id.set_s_tmsi(); paging_elem.ue_id.s_tmsi().mmec.from_number(u.choice.s_TMSI.mMEC.buffer[0]); uint32_t m_tmsi = 0; for (int i = 0; i < LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN; i++) { @@ -706,17 +704,13 @@ uint32_t rrc::generate_sibs() asn1::dyn_array msg(nof_messages + 1); // Copy SIB1 to first SI message - msg[0].msg.set(bcch_dl_sch_msg_type_c::types::c1); - msg[0].msg.c1().set(bcch_dl_sch_msg_type_c::c1_c_::types::sib_type1); - msg[0].msg.c1().sib_type1() = cfg.sib1; + msg[0].msg.set_c1().set_sib_type1() = cfg.sib1; // Copy rest of SIBs for (uint32_t sched_info_elem = 0; sched_info_elem < nof_messages - 1; sched_info_elem++) { uint32_t msg_index = sched_info_elem + 1; // first msg is SIB1, therefore start with second - msg[msg_index].msg.set(bcch_dl_sch_msg_type_c::types::c1); - msg[msg_index].msg.c1().set(bcch_dl_sch_msg_type_c::c1_c_::types::sys_info); - msg[msg_index].msg.c1().sys_info().crit_exts.set(sys_info_s::crit_exts_c_::types::sys_info_r8); + msg[msg_index].msg.set_c1().set_sys_info().crit_exts.set_sys_info_r8(); sys_info_r8_ies_s::sib_type_and_info_l_& sib_list = msg[msg_index].msg.c1().sys_info().crit_exts.sys_info_r8().sib_type_and_info; @@ -752,15 +746,14 @@ uint32_t rrc::generate_sibs() void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13) { // Temp assignment of MCCH, this will eventually come from a cfg file - mcch.msg.set(mcch_msg_type_c::types::c1); + mcch.msg.set_c1(); mbsfn_area_cfg_r9_s& area_cfg_r9 = mcch.msg.c1().mbsfn_area_cfg_r9(); area_cfg_r9.common_sf_alloc_period_r9 = mbsfn_area_cfg_r9_s::common_sf_alloc_period_r9_e_::rf64; area_cfg_r9.common_sf_alloc_r9.resize(1); mbsfn_sf_cfg_s* sf_alloc_item = &area_cfg_r9.common_sf_alloc_r9[0]; sf_alloc_item->radioframe_alloc_offset = 0; sf_alloc_item->radioframe_alloc_period = mbsfn_sf_cfg_s::radioframe_alloc_period_e_::n1; - sf_alloc_item->sf_alloc.set(mbsfn_sf_cfg_s::sf_alloc_c_::types::one_frame); - sf_alloc_item->sf_alloc.one_frame().from_number(32 + 31); + sf_alloc_item->sf_alloc.set_one_frame().from_number(32 + 31); area_cfg_r9.pmch_info_list_r9.resize(1); pmch_info_r9_s* pmch_item = &area_cfg_r9.pmch_info_list_r9[0]; @@ -769,7 +762,7 @@ void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13) pmch_item->mbms_session_info_list_r9[0].lc_ch_id_r9 = 1; pmch_item->mbms_session_info_list_r9[0].session_id_r9_present = true; pmch_item->mbms_session_info_list_r9[0].session_id_r9[0] = 0; - pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.set(tmgi_r9_s::plmn_id_r9_c_::types::explicit_value_r9); + pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.set_explicit_value_r9(); pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9().mcc_present = true; srslte::string_to_plmn_id(pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9(), "00003"); uint8_t byte[] = {0x0, 0x0, 0x0}; @@ -779,7 +772,7 @@ void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13) pmch_item->mbms_session_info_list_r9[1].lc_ch_id_r9 = 2; pmch_item->mbms_session_info_list_r9[1].session_id_r9_present = true; pmch_item->mbms_session_info_list_r9[1].session_id_r9[0] = 1; - pmch_item->mbms_session_info_list_r9[1].tmgi_r9.plmn_id_r9.set(tmgi_r9_s::plmn_id_r9_c_::types::explicit_value_r9); + pmch_item->mbms_session_info_list_r9[1].tmgi_r9.plmn_id_r9.set_explicit_value_r9(); srslte::string_to_plmn_id(pmch_item->mbms_session_info_list_r9[1].tmgi_r9.plmn_id_r9.explicit_value_r9(), "00003"); byte[2] = 1; memcpy(&pmch_item->mbms_session_info_list_r9[1].tmgi_r9.service_id_r9[0], &byte[0], @@ -1388,10 +1381,7 @@ void rrc::ue::send_connection_reest_rej() { dl_ccch_msg_s dl_ccch_msg; - dl_ccch_msg.msg.set(dl_ccch_msg_type_c::types::c1); - dl_ccch_msg.msg.c1().set(dl_ccch_msg_type_c::c1_c_::types::rrc_conn_reest_reject); - dl_ccch_msg.msg.c1().rrc_conn_reest_reject().crit_exts.set( - rrc_conn_reest_reject_s::crit_exts_c_::types::rrc_conn_reest_reject_r8); + dl_ccch_msg.msg.set_c1().set_rrc_conn_reest_reject().crit_exts.set_rrc_conn_reest_reject_r8(); send_dl_ccch(&dl_ccch_msg); } @@ -1400,13 +1390,7 @@ void rrc::ue::send_connection_reject() { dl_ccch_msg_s dl_ccch_msg; - dl_ccch_msg.msg.set(dl_ccch_msg_type_c::types::c1); - dl_ccch_msg.msg.c1().set(dl_ccch_msg_type_c::c1_c_::types::rrc_conn_reject); - - dl_ccch_msg.msg.c1().rrc_conn_reject().crit_exts.set(rrc_conn_reject_s::crit_exts_c_::types::c1); - dl_ccch_msg.msg.c1().rrc_conn_reject().crit_exts.c1().set( - rrc_conn_reject_s::crit_exts_c_::c1_c_::types::rrc_conn_reject_r8); - dl_ccch_msg.msg.c1().rrc_conn_reject().crit_exts.c1().rrc_conn_reject_r8().wait_time = 10; + dl_ccch_msg.msg.set_c1().set_rrc_conn_reject().crit_exts.set_c1().set_rrc_conn_reject_r8().wait_time = 10; send_dl_ccch(&dl_ccch_msg); } @@ -1414,23 +1398,18 @@ void rrc::ue::send_connection_reject() void rrc::ue::send_connection_setup(bool is_setup) { dl_ccch_msg_s dl_ccch_msg; - dl_ccch_msg.msg.set(dl_ccch_msg_type_c::types::c1); + dl_ccch_msg.msg.set_c1(); rr_cfg_ded_s* rr_cfg = NULL; if (is_setup) { - dl_ccch_msg.msg.c1().set(dl_ccch_msg_type_c::c1_c_::types::rrc_conn_setup); + dl_ccch_msg.msg.c1().set_rrc_conn_setup(); dl_ccch_msg.msg.c1().rrc_conn_setup().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - dl_ccch_msg.msg.c1().rrc_conn_setup().crit_exts.set(rrc_conn_setup_s::crit_exts_c_::types::c1); - dl_ccch_msg.msg.c1().rrc_conn_setup().crit_exts.c1().set( - rrc_conn_setup_s::crit_exts_c_::c1_c_::types::rrc_conn_setup_r8); - dl_ccch_msg.msg.c1().rrc_conn_setup().crit_exts.c1().rrc_conn_setup_r8(); + dl_ccch_msg.msg.c1().rrc_conn_setup().crit_exts.set_c1().set_rrc_conn_setup_r8(); rr_cfg = &dl_ccch_msg.msg.c1().rrc_conn_setup().crit_exts.c1().rrc_conn_setup_r8().rr_cfg_ded; } else { - dl_ccch_msg.msg.c1().set(dl_ccch_msg_type_c::c1_c_::types::rrc_conn_reest); + dl_ccch_msg.msg.c1().set_rrc_conn_reest(); dl_ccch_msg.msg.c1().rrc_conn_reest().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - dl_ccch_msg.msg.c1().rrc_conn_reest().crit_exts.set(rrc_conn_reest_s::crit_exts_c_::types::c1); - dl_ccch_msg.msg.c1().rrc_conn_reest().crit_exts.c1().set( - rrc_conn_reest_s::crit_exts_c_::c1_c_::types::rrc_conn_reest_r8); + dl_ccch_msg.msg.c1().rrc_conn_reest().crit_exts.set_c1().set_rrc_conn_reest_r8(); rr_cfg = &dl_ccch_msg.msg.c1().rrc_conn_reest().crit_exts.c1().rrc_conn_reest_r8().rr_cfg_ded; } @@ -1445,8 +1424,7 @@ void rrc::ue::send_connection_setup(bool is_setup) // mac-MainConfig rr_cfg->mac_main_cfg_present = true; - rr_cfg->mac_main_cfg.set(rr_cfg_ded_s::mac_main_cfg_c_::types::explicit_value); - mac_main_cfg_s* mac_cfg = &rr_cfg->mac_main_cfg.explicit_value(); + mac_main_cfg_s* mac_cfg = &rr_cfg->mac_main_cfg.set_explicit_value(); mac_cfg->ul_sch_cfg_present = true; mac_cfg->ul_sch_cfg = parent->cfg.mac_cnfg.ul_sch_cfg; mac_cfg->phr_cfg_present = true; @@ -1459,12 +1437,12 @@ void rrc::ue::send_connection_setup(bool is_setup) phy_cfg->pusch_cfg_ded_present = true; phy_cfg->pusch_cfg_ded = parent->cfg.pusch_cfg; phy_cfg->sched_request_cfg_present = true; - phy_cfg->sched_request_cfg.set(sched_request_cfg_c::types::setup); + phy_cfg->sched_request_cfg.set_setup(); phy_cfg->sched_request_cfg.setup().dsr_trans_max = parent->cfg.sr_cfg.dsr_max; // set default antenna config phy_cfg->ant_info_present = true; - phy_cfg->ant_info.set(phys_cfg_ded_s::ant_info_c_::types::explicit_value); + phy_cfg->ant_info.set_explicit_value(); if (parent->cfg.cell.nof_ports == 1) { phy_cfg->ant_info.explicit_value().tx_mode.value = ant_info_ded_s::tx_mode_e_::tm1; } else { @@ -1503,7 +1481,7 @@ void rrc::ue::send_connection_setup(bool is_setup) phy_cfg->cqi_report_cfg.cqi_report_mode_aperiodic = cqi_report_mode_aperiodic_e::rm30; } else { phy_cfg->cqi_report_cfg.cqi_report_periodic_present = true; - phy_cfg->cqi_report_cfg.cqi_report_periodic.set(setup_e::setup); + phy_cfg->cqi_report_cfg.cqi_report_periodic.set_setup(); phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_format_ind_periodic.set( cqi_report_periodic_c::setup_s_::cqi_format_ind_periodic_c_::types::wideband_cqi); phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().simul_ack_nack_and_cqi = false; @@ -1579,12 +1557,9 @@ void rrc::ue::send_connection_reest() void rrc::ue::send_connection_release() { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::rrc_conn_release); + dl_dcch_msg.msg.set_c1().set_rrc_conn_release(); dl_dcch_msg.msg.c1().rrc_conn_release().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.set(rrc_conn_release_s::crit_exts_c_::types::c1); - dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.c1().set( - rrc_conn_release_s::crit_exts_c_::c1_c_::types::rrc_conn_release_r8); + dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.set_c1().set_rrc_conn_release_r8(); dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.c1().rrc_conn_release_r8().release_cause = release_cause_e::other; send_dl_dcch(&dl_dcch_msg); @@ -1630,12 +1605,9 @@ int rrc::ue::get_drbid_config(drb_to_add_mod_s* drb, int drb_id) void rrc::ue::send_connection_reconf_upd(srslte::byte_buffer_t *pdu) { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg); - rrc_conn_recfg_s* rrc_conn_recfg = &dl_dcch_msg.msg.c1().rrc_conn_recfg(); + rrc_conn_recfg_s* rrc_conn_recfg = &dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg(); rrc_conn_recfg->rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - rrc_conn_recfg->crit_exts.set(rrc_conn_recfg_s::crit_exts_c_::types::c1); - rrc_conn_recfg->crit_exts.c1().set(rrc_conn_recfg_s::crit_exts_c_::c1_c_::types::rrc_conn_recfg_r8); + rrc_conn_recfg->crit_exts.set_c1().set_rrc_conn_recfg_r8(); rrc_conn_recfg->crit_exts.c1().rrc_conn_recfg_r8().rr_cfg_ded_present = true; rr_cfg_ded_s* rr_cfg = &rrc_conn_recfg->crit_exts.c1().rrc_conn_recfg_r8().rr_cfg_ded; @@ -1643,14 +1615,13 @@ void rrc::ue::send_connection_reconf_upd(srslte::byte_buffer_t *pdu) rr_cfg->phys_cfg_ded_present = true; phys_cfg_ded_s* phy_cfg = &rr_cfg->phys_cfg_ded; phy_cfg->sched_request_cfg_present = true; - phy_cfg->sched_request_cfg.set(sched_request_cfg_c::types::setup); + phy_cfg->sched_request_cfg.set_setup(); phy_cfg->sched_request_cfg.setup().dsr_trans_max = parent->cfg.sr_cfg.dsr_max; phy_cfg->cqi_report_cfg_present = true; if (cqi_allocated) { phy_cfg->cqi_report_cfg.cqi_report_periodic_present = true; - phy_cfg->cqi_report_cfg.cqi_report_periodic.set(cqi_report_periodic_c::types::setup); - phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_format_ind_periodic.set( + phy_cfg->cqi_report_cfg.cqi_report_periodic.set_setup().cqi_format_ind_periodic.set( cqi_report_periodic_c::setup_s_::cqi_format_ind_periodic_c_::types::wideband_cqi); cqi_get(&phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx, &phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pucch_res_idx); @@ -1685,12 +1656,8 @@ void rrc::ue::send_connection_reconf_upd(srslte::byte_buffer_t *pdu) void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg); + dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg().crit_exts.set_c1().set_rrc_conn_recfg_r8(); dl_dcch_msg.msg.c1().rrc_conn_recfg().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.set(rrc_conn_recfg_s::crit_exts_c_::types::c1); - dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().set( - rrc_conn_recfg_s::crit_exts_c_::c1_c_::types::rrc_conn_recfg_r8); rrc_conn_recfg_r8_ies_s* conn_reconf = &dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); conn_reconf->rr_cfg_ded_present = true; @@ -1714,7 +1681,7 @@ void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) } } else { phy_cfg->cqi_report_cfg.cqi_report_periodic_present = true; - phy_cfg->cqi_report_cfg.cqi_report_periodic.set(cqi_report_periodic_c::types::setup); + phy_cfg->cqi_report_cfg.cqi_report_periodic.set_setup(); cqi_get(&phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx, &phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pucch_res_idx); phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_format_ind_periodic.set( @@ -1723,7 +1690,7 @@ void rrc::ue::send_connection_reconf(srslte::byte_buffer_t *pdu) if (phy_cfg->ant_info_present and ((phy_cfg->ant_info.explicit_value().tx_mode == ant_info_ded_s::tx_mode_e_::tm3) || (phy_cfg->ant_info.explicit_value().tx_mode == ant_info_ded_s::tx_mode_e_::tm4))) { - phy_cfg->cqi_report_cfg.cqi_report_periodic.set(cqi_report_periodic_c::types::setup); + phy_cfg->cqi_report_cfg.cqi_report_periodic.set_setup(); phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx_present = true; phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx = 483; parent->rrc_log->console("\nWarning: Only 1 user is supported in TM3 and TM4\n\n"); @@ -1824,13 +1791,8 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE srslte::byte_buffer_t *pdu = pool_allocate; dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg); + dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg().crit_exts.set_c1().set_rrc_conn_recfg_r8(); dl_dcch_msg.msg.c1().rrc_conn_recfg().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - - dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.set(rrc_conn_recfg_s::crit_exts_c_::types::c1); - dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().set( - rrc_conn_recfg_s::crit_exts_c_::c1_c_::types::rrc_conn_recfg_r8); rrc_conn_recfg_r8_ies_s* conn_reconf = &dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); for(uint32_t i=0; ilen; i++) { @@ -1879,15 +1841,11 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE void rrc::ue::send_security_mode_command() { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::security_mode_cmd); - - security_mode_cmd_s* comm = &dl_dcch_msg.msg.c1().security_mode_cmd(); + security_mode_cmd_s* comm = &dl_dcch_msg.msg.set_c1().set_security_mode_cmd(); comm->rrc_transaction_id = (uint8_t)((transaction_id++) % 4); // TODO: select these based on UE capabilities and preference order - comm->crit_exts.set(security_mode_cmd_s::crit_exts_c_::types::c1); - comm->crit_exts.c1().set(security_mode_cmd_s::crit_exts_c_::c1_c_::types::security_mode_cmd_r8); + comm->crit_exts.set_c1().set_security_mode_cmd_r8(); comm->crit_exts.c1().security_mode_cmd_r8().security_cfg_smc.security_algorithm_cfg.ciphering_algorithm = (ciphering_algorithm_r12_e::options)cipher_algo; comm->crit_exts.c1().security_mode_cmd_r8().security_cfg_smc.security_algorithm_cfg.integrity_prot_algorithm = @@ -1899,14 +1857,11 @@ void rrc::ue::send_security_mode_command() void rrc::ue::send_ue_cap_enquiry() { dl_dcch_msg_s dl_dcch_msg; - dl_dcch_msg.msg.set(dl_dcch_msg_type_c::types::c1); - dl_dcch_msg.msg.c1().set(dl_dcch_msg_type_c::c1_c_::types::ue_cap_enquiry); + dl_dcch_msg.msg.set_c1().set_ue_cap_enquiry().crit_exts.set_c1().set_ue_cap_enquiry_r8(); ue_cap_enquiry_s* enq = &dl_dcch_msg.msg.c1().ue_cap_enquiry(); enq->rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - enq->crit_exts.set(ue_cap_enquiry_s::crit_exts_c_::types::c1); - enq->crit_exts.c1().set(ue_cap_enquiry_s::crit_exts_c_::c1_c_::types::ue_cap_enquiry_r8); enq->crit_exts.c1().ue_cap_enquiry_r8().ue_cap_request.resize(1); enq->crit_exts.c1().ue_cap_enquiry_r8().ue_cap_request[0].value = rat_type_e::eutra; @@ -1968,7 +1923,7 @@ bool rrc::ue::select_security_algorithms() enc_algo_found = false; break; } - if (enc_algo_found == true) { + if (enc_algo_found) { break; } } @@ -2004,12 +1959,12 @@ bool rrc::ue::select_security_algorithms() break; } - if (integ_algo_found == true) { + if (integ_algo_found) { break; } } - if (integ_algo_found == false || enc_algo_found == false) { + if (not integ_algo_found || not enc_algo_found) { // TODO: if no security algorithm found abort radio connection and issue // encryption-and-or-integrity-protection-algorithms-not-supported message parent->rrc_log->error("Did not find a matching integrity or encryption algorithm with the UE\n"); diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 6945fc90e..9173e5dc1 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -1291,17 +1291,14 @@ void rrc::send_con_request(asn1::rrc::establishment_cause_e cause) // Prepare ConnectionRequest packet ul_ccch_msg_s ul_ccch_msg; - ul_ccch_msg.msg.set(asn1::rrc::ul_ccch_msg_type_c::types::c1); - ul_ccch_msg.msg.c1().set(asn1::rrc::ul_ccch_msg_type_c::c1_c_::types::rrc_conn_request); - ul_ccch_msg.msg.c1().rrc_conn_request().crit_exts.set( - asn1::rrc::rrc_conn_request_s::crit_exts_c_::types::rrc_conn_request_r8); - rrc_conn_request_r8_ies_s* rrc_conn_req = &ul_ccch_msg.msg.c1().rrc_conn_request().crit_exts.rrc_conn_request_r8(); + rrc_conn_request_r8_ies_s* rrc_conn_req = + &ul_ccch_msg.msg.set_c1().set_rrc_conn_request().crit_exts.set_rrc_conn_request_r8(); if (ue_identity_configured) { - rrc_conn_req->ue_id.set(asn1::rrc::init_ue_id_c::types::s_tmsi); + rrc_conn_req->ue_id.set_s_tmsi(); rrc_conn_req->ue_id.s_tmsi() = ue_identity; } else { - rrc_conn_req->ue_id.set(asn1::rrc::init_ue_id_c::types::random_value); + rrc_conn_req->ue_id.set_random_value(); // TODO use proper RNG uint64_t random_id = 0; for (uint i = 0; i < 5; i++) { // fill random ID bytewise, 40 bits = 5 bytes @@ -1377,12 +1374,8 @@ void rrc::send_con_restablish_request(asn1::rrc::reest_cause_e cause) // Prepare ConnectionRestalishmentRequest packet asn1::rrc::ul_ccch_msg_s ul_ccch_msg; - ul_ccch_msg.msg.set(asn1::rrc::ul_ccch_msg_type_c::types::c1); - ul_ccch_msg.msg.c1().set(asn1::rrc::ul_ccch_msg_type_c::c1_c_::types::rrc_conn_reest_request); - ul_ccch_msg.msg.c1().rrc_conn_reest_request().crit_exts.set( - asn1::rrc::rrc_conn_reest_request_s::crit_exts_c_::types::rrc_conn_reest_request_r8); rrc_conn_reest_request_r8_ies_s* rrc_conn_reest_req = - &ul_ccch_msg.msg.c1().rrc_conn_reest_request().crit_exts.rrc_conn_reest_request_r8(); + &ul_ccch_msg.msg.set_c1().set_rrc_conn_reest_request().crit_exts.set_rrc_conn_reest_request_r8(); rrc_conn_reest_req->ue_id.c_rnti.from_number(crnti); rrc_conn_reest_req->ue_id.pci = pci; @@ -1434,11 +1427,7 @@ void rrc::send_con_restablish_complete() { // Prepare ConnectionSetupComplete packet asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(asn1::rrc::ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(asn1::rrc::ul_dcch_msg_type_c::c1_c_::types::rrc_conn_reest_complete); - ul_dcch_msg.msg.c1().rrc_conn_reest_complete().crit_exts.set( - asn1::rrc::rrc_conn_reest_complete_s::crit_exts_c_::types::rrc_conn_reest_complete_r8); - + ul_dcch_msg.msg.set_c1().set_rrc_conn_reest_complete().crit_exts.set_rrc_conn_reest_complete_r8(); ul_dcch_msg.msg.c1().rrc_conn_reest_complete().rrc_transaction_id = transaction_id; send_ul_dcch_msg(RB_ID_SRB1, ul_dcch_msg); @@ -1449,14 +1438,8 @@ void rrc::send_con_setup_complete(byte_buffer_t *nas_msg) { // Prepare ConnectionSetupComplete packet asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(asn1::rrc::ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(asn1::rrc::ul_dcch_msg_type_c::c1_c_::types::rrc_conn_setup_complete); - ul_dcch_msg.msg.c1().rrc_conn_setup_complete().crit_exts.set( - asn1::rrc::rrc_conn_setup_complete_s::crit_exts_c_::types::c1); - ul_dcch_msg.msg.c1().rrc_conn_setup_complete().crit_exts.c1().set( - asn1::rrc::rrc_conn_setup_complete_s::crit_exts_c_::c1_c_::types::rrc_conn_setup_complete_r8); rrc_conn_setup_complete_r8_ies_s* rrc_conn_setup_complete = - &ul_dcch_msg.msg.c1().rrc_conn_setup_complete().crit_exts.c1().rrc_conn_setup_complete_r8(); + &ul_dcch_msg.msg.set_c1().set_rrc_conn_setup_complete().crit_exts.set_c1().set_rrc_conn_setup_complete_r8(); ul_dcch_msg.msg.c1().rrc_conn_setup_complete().rrc_transaction_id = transaction_id; @@ -1474,15 +1457,10 @@ void rrc::send_ul_info_transfer(byte_buffer_t* nas_msg) // Prepare UL INFO packet asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(asn1::rrc::ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(asn1::rrc::ul_dcch_msg_type_c::c1_c_::types::ul_info_transfer); - ul_dcch_msg.msg.c1().ul_info_transfer().crit_exts.set(asn1::rrc::ul_info_transfer_s::crit_exts_c_::types::c1); - ul_dcch_msg.msg.c1().ul_info_transfer().crit_exts.c1().set( - asn1::rrc::ul_info_transfer_s::crit_exts_c_::c1_c_::types::ul_info_transfer_r8); ul_info_transfer_r8_ies_s* rrc_ul_info_transfer = - &ul_dcch_msg.msg.c1().ul_info_transfer().crit_exts.c1().ul_info_transfer_r8(); + &ul_dcch_msg.msg.set_c1().set_ul_info_transfer().crit_exts.set_c1().set_ul_info_transfer_r8(); - rrc_ul_info_transfer->ded_info_type.set(asn1::rrc::ul_info_transfer_r8_ies_s::ded_info_type_c_::types::ded_info_nas); + rrc_ul_info_transfer->ded_info_type.set_ded_info_nas(); rrc_ul_info_transfer->ded_info_type.ded_info_nas().resize(nas_msg->N_bytes); memcpy(rrc_ul_info_transfer->ded_info_type.ded_info_nas().data(), nas_msg->msg, nas_msg->N_bytes); // TODO Check! @@ -1496,11 +1474,7 @@ void rrc::send_security_mode_complete() { // Prepare Security Mode Command Complete asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(asn1::rrc::ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(asn1::rrc::ul_dcch_msg_type_c::c1_c_::types::security_mode_complete); - ul_dcch_msg.msg.c1().security_mode_complete().crit_exts.set( - asn1::rrc::security_mode_complete_s::crit_exts_c_::types::security_mode_complete_r8); - + ul_dcch_msg.msg.set_c1().set_security_mode_complete().crit_exts.set_security_mode_complete_r8(); ul_dcch_msg.msg.c1().security_mode_complete().rrc_transaction_id = transaction_id; send_ul_dcch_msg(RB_ID_SRB1, ul_dcch_msg); @@ -1510,11 +1484,7 @@ void rrc::send_rrc_con_reconfig_complete() { rrc_log->debug("Preparing RRC Connection Reconfig Complete\n"); asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(asn1::rrc::ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(asn1::rrc::ul_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg_complete); - ul_dcch_msg.msg.c1().rrc_conn_recfg_complete().crit_exts.set( - asn1::rrc::rrc_conn_recfg_complete_s::crit_exts_c_::types::rrc_conn_recfg_complete_r8); - + ul_dcch_msg.msg.set_c1().set_rrc_conn_recfg_complete().crit_exts.set_rrc_conn_recfg_complete_r8(); ul_dcch_msg.msg.c1().rrc_conn_recfg_complete().rrc_transaction_id = transaction_id; send_ul_dcch_msg(RB_ID_SRB1, ul_dcch_msg); @@ -2323,13 +2293,9 @@ void rrc::send_rrc_ue_cap_info() rrc_log->debug("Preparing UE Capability Info\n"); asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(ul_dcch_msg_type_c::c1_c_::types::ue_cap_info); + ue_cap_info_r8_ies_s* info = &ul_dcch_msg.msg.set_c1().set_ue_cap_info().crit_exts.set_c1().set_ue_cap_info_r8(); ul_dcch_msg.msg.c1().ue_cap_info().rrc_transaction_id = transaction_id; - ul_dcch_msg.msg.c1().ue_cap_info().crit_exts.set(ue_cap_info_s::crit_exts_c_::types::c1); - ul_dcch_msg.msg.c1().ue_cap_info().crit_exts.c1().set(ue_cap_info_s::crit_exts_c_::c1_c_::types::ue_cap_info_r8); - ue_cap_info_r8_ies_s* info = &ul_dcch_msg.msg.c1().ue_cap_info().crit_exts.c1().ue_cap_info_r8(); info->ue_cap_rat_container_list.resize(1); info->ue_cap_rat_container_list[0].rat_type = rat_type_e::eutra; @@ -2670,7 +2636,7 @@ void rrc::set_phy_config_dedicated_default() current_cfg->srs_ul_cfg_ded.set(setup_e::release); current_cfg->ant_info_present = true; - current_cfg->ant_info.set(phys_cfg_ded_s::ant_info_c_::types::explicit_value); + current_cfg->ant_info.set_explicit_value(); current_cfg->ant_info.explicit_value().tx_mode = ant_info_ded_s::tx_mode_e_::tm1; current_cfg->ant_info.explicit_value().codebook_subset_restrict_present = false; current_cfg->ant_info.explicit_value().ue_tx_ant_sel.set(setup_e::release); @@ -3214,10 +3180,7 @@ bool rrc::rrc_meas::find_earfcn_cell(uint32_t earfcn, uint32_t pci, meas_obj_t * void rrc::rrc_meas::generate_report(uint32_t meas_id) { asn1::rrc::ul_dcch_msg_s ul_dcch_msg; - ul_dcch_msg.msg.set(ul_dcch_msg_type_c::types::c1); - ul_dcch_msg.msg.c1().set(ul_dcch_msg_type_c::c1_c_::types::meas_report); - ul_dcch_msg.msg.c1().meas_report().crit_exts.set(meas_report_s::crit_exts_c_::types::c1); - ul_dcch_msg.msg.c1().meas_report().crit_exts.c1().set(meas_report_s::crit_exts_c_::c1_c_::types::meas_report_r8); + ul_dcch_msg.msg.set_c1().set_meas_report().crit_exts.set_c1().set_meas_report_r8(); meas_results_s* report = &ul_dcch_msg.msg.c1().meas_report().crit_exts.c1().meas_report_r8().meas_results; meas_t *m = &active[meas_id]; @@ -3230,22 +3193,23 @@ void rrc::rrc_meas::generate_report(uint32_t meas_id) log_h->info("MEAS: Generate report MeasId=%d, nof_reports_send=%d, Pcell rsrp=%f rsrq=%f\n", report->meas_id, m->nof_reports_sent, pcell_measurement.ms[RSRP], pcell_measurement.ms[RSRQ]); - report->meas_result_neigh_cells.set(meas_results_s::meas_result_neigh_cells_c_::types::meas_result_list_eutra); - meas_result_list_eutra_l& neigh_list = report->meas_result_neigh_cells.meas_result_list_eutra(); + meas_result_list_eutra_l& neigh_list = report->meas_result_neigh_cells.set_meas_result_list_eutra(); // TODO: report up to 8 best cells - for (std::map::iterator cell = m->cell_values.begin(); cell != m->cell_values.end(); ++cell) - { - if (cell->second.triggered and neigh_list.size() <= 8) { + for (const auto& cell : m->cell_values) { + if (cell.second.triggered and neigh_list.size() <= 8) { meas_result_eutra_s rc; - rc.pci = (uint16_t)cell->first; + rc.pci = (uint16_t)cell.first; rc.meas_result.rsrp_result_present = cfg->report_quantity == RSRP || cfg->report_quantity == BOTH; rc.meas_result.rsrq_result_present = cfg->report_quantity == RSRQ || cfg->report_quantity == BOTH; - rc.meas_result.rsrp_result = value_to_range(RSRP, cell->second.ms[RSRP]); - rc.meas_result.rsrq_result = value_to_range(RSRQ, cell->second.ms[RSRQ]); + rc.meas_result.rsrp_result = value_to_range(RSRP, cell.second.ms[RSRP]); + rc.meas_result.rsrq_result = value_to_range(RSRQ, cell.second.ms[RSRQ]); - log_h->info("MEAS: Adding to report neighbour=%d, pci=%d, rsrp=%f, rsrq=%f\n", neigh_list.size(), rc.pci, - cell->second.ms[RSRP], cell->second.ms[RSRQ]); + log_h->info("MEAS: Adding to report neighbour=%d, pci=%d, rsrp=%f, rsrq=%f\n", + neigh_list.size(), + rc.pci, + cell.second.ms[RSRP], + cell.second.ms[RSRQ]); neigh_list.push_back(rc); } @@ -3695,13 +3659,13 @@ bool rrc::rrc_meas::parse_meas_config(meas_cfg_s* cfg) void rrc::rrc_meas::update_phy() { phy->meas_reset(); - for(std::map::iterator iter=objects.begin(); iter!=objects.end(); ++iter) { - meas_obj_t o = iter->second; + for (const auto& obj : objects) { + meas_obj_t o = obj.second; // Instruct PHY to look for neighbour cells on this frequency phy->meas_start(o.earfcn); - for(std::map::iterator iter=o.meas_cells.begin(); iter!=o.meas_cells.end(); ++iter) { + for (const auto& cell : o.meas_cells) { // Instruct PHY to look for cells IDs on this frequency - phy->meas_start(o.earfcn, iter->second.pci); + phy->meas_start(o.earfcn, cell.second.pci); } } }