From b9366292215b130b1ff4ca910e00adeeae0dcf91 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Wed, 3 Jul 2019 19:55:26 +0100 Subject: [PATCH] removed rrc asn1 header from bcd_helpers, from rlc_interface, and rlc tests --- lib/include/srslte/asn1/rrc_asn1_utils.h | 23 ++- lib/include/srslte/common/bcd_helpers.h | 38 +--- lib/include/srslte/upper/rlc_interface.h | 45 ----- lib/src/asn1/rrc_asn1_utils.cc | 98 ++++++++-- lib/src/upper/rlc.cc | 21 +-- lib/test/asn1/srslte_asn1_rrc_mcch_test.cc | 10 +- lib/test/asn1/srslte_asn1_rrc_meas_test.cc | 5 +- lib/test/upper/rlc_am_test.cc | 202 ++++----------------- lib/test/upper/rlc_um_test.cc | 72 +++++--- srsenb/src/enb_cfg_parser.cc | 4 +- srsenb/src/stack/rrc/rrc.cc | 18 +- srsenb/test/upper/plmn_test.cc | 5 +- srsue/hdr/stack/rrc/rrc.h | 3 +- srsue/src/stack/rrc/rrc.cc | 13 +- srsue/src/stack/upper/nas.cc | 4 - 15 files changed, 235 insertions(+), 326 deletions(-) diff --git a/lib/include/srslte/asn1/rrc_asn1_utils.h b/lib/include/srslte/asn1/rrc_asn1_utils.h index 16fb1c6b4..55b4775d2 100644 --- a/lib/include/srslte/asn1/rrc_asn1_utils.h +++ b/lib/include/srslte/asn1/rrc_asn1_utils.h @@ -30,30 +30,37 @@ namespace rrc { struct plmn_id_s; struct s_tmsi_s; +struct rlc_cfg_c; } // namespace rrc } // namespace asn1 namespace srslte { +bool plmn_is_valid(const asn1::rrc::plmn_id_s& asn1_type); + struct plmn_id_t { uint8_t mcc[3]; uint8_t mnc[3]; uint8_t nof_mnc_digits; - plmn_id_t() : mcc(), mnc(), nof_mnc_digits(0) {} - int from_asn1(const asn1::rrc::plmn_id_s* asn1_type); - void to_asn1(asn1::rrc::plmn_id_s* asn1_type) const; - void from_number(uint16_t mcc_num, uint16_t mnc_num); + plmn_id_t() : mcc(), mnc(), nof_mnc_digits(2) {} + explicit plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type); + void reset(); + int from_asn1(const asn1::rrc::plmn_id_s& asn1_type); + int to_asn1(asn1::rrc::plmn_id_s* asn1_type) const; + int from_number(uint16_t mcc_num, uint16_t mnc_num); int from_string(const std::string& plmn_str); std::string to_string() const; }; struct s_tmsi_t { - uint8_t mmec; - uint32_t m_tmsi; + uint8_t mmec = 0; + uint32_t m_tmsi = 0; - void from_asn1(const asn1::rrc::s_tmsi_s* asn1_type); + s_tmsi_t() = default; + explicit s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type); + void from_asn1(const asn1::rrc::s_tmsi_s& asn1_type); void to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const; }; @@ -70,6 +77,8 @@ enum class establishment_cause_t { }; std::string to_string(const establishment_cause_t& cause); +class srslte_rlc_config_t; +void convert_from_asn1(srslte_rlc_config_t* out, const asn1::rrc::rlc_cfg_c& asn1_type); } #endif // SRSLTE_RRC_ASN1_UTILS_H diff --git a/lib/include/srslte/common/bcd_helpers.h b/lib/include/srslte/common/bcd_helpers.h index b4bf50b6d..04dc6392f 100644 --- a/lib/include/srslte/common/bcd_helpers.h +++ b/lib/include/srslte/common/bcd_helpers.h @@ -26,8 +26,6 @@ #include #include -#include "srslte/asn1/rrc_asn1.h" - namespace srslte { /****************************************************************************** @@ -89,7 +87,7 @@ inline bool mcc_to_bytes(uint16_t mcc, uint8_t* bytes) return true; } -inline std::string mcc_bytes_to_string(asn1::rrc::mcc_l mcc_bytes) +inline std::string mcc_bytes_to_string(uint8_t* mcc_bytes) { std::string mcc_str; uint16_t mcc; @@ -200,45 +198,21 @@ bool mnc_to_bytes(uint16_t mnc, Vec& vec) return ret; } -inline std::string mnc_bytes_to_string(asn1::rrc::mnc_l mnc_bytes) +inline std::string mnc_bytes_to_string(uint8_t* mnc_bytes, uint32_t nof_bytes) { std::string mnc_str; uint16_t mnc; - bytes_to_mnc(&mnc_bytes[0], &mnc, mnc_bytes.size()); + bytes_to_mnc(&mnc_bytes[0], &mnc, nof_bytes); if (!mnc_to_string(mnc, &mnc_str)) { mnc_str = "000"; } return mnc_str; } -inline std::string plmn_id_to_string(asn1::rrc::plmn_id_s plmn_id) -{ - std::string mcc_str, mnc_str; - uint16_t mnc, mcc; - bytes_to_mnc(&plmn_id.mnc[0], &mnc, plmn_id.mnc.size()); - bytes_to_mcc(&plmn_id.mcc[0], &mcc); - mnc_to_string(mnc, &mnc_str); - mcc_to_string(mcc, &mcc_str); - return mcc_str + mnc_str; -} - -inline bool string_to_plmn_id(asn1::rrc::plmn_id_s& plmn, std::string mccmnc_str) +template +std::string mnc_bytes_to_string(Vec mnc_bytes) { - if (mccmnc_str.size() < 5 or mccmnc_str.size() > 6) { - return false; - } - uint16_t mnc, mcc; - if (not string_to_mcc(std::string(mccmnc_str.begin(), mccmnc_str.begin() + 3), &mcc)) { - return false; - } - if (not string_to_mnc(std::string(mccmnc_str.begin() + 3, mccmnc_str.end()), &mnc)) { - return false; - } - plmn.mcc_present = true; - if (not mcc_to_bytes(mcc, &plmn.mcc[0])) { - return false; - } - return mnc_to_bytes(mnc, plmn.mnc); + return mnc_bytes_to_string(&mnc_bytes[0], mnc_bytes.size()); } /****************************************************************************** diff --git a/lib/include/srslte/upper/rlc_interface.h b/lib/include/srslte/upper/rlc_interface.h index 077c864d1..d8f084cf1 100644 --- a/lib/include/srslte/upper/rlc_interface.h +++ b/lib/include/srslte/upper/rlc_interface.h @@ -22,9 +22,6 @@ #ifndef SRSLTE_RLC_INTERFACE_H #define SRSLTE_RLC_INTERFACE_H -// for custom constructors -#include "srslte/asn1/rrc_asn1.h" - #define RLC_TX_QUEUE_LEN (128) namespace srslte { @@ -91,48 +88,6 @@ public: // Default ctor srslte_rlc_config_t() : rlc_mode(RLC_MODE_TM), am(), um(), tx_queue_length(RLC_TX_QUEUE_LEN){}; - // Constructor based on rrc_asn1's RLC config - srslte_rlc_config_t(asn1::rrc::rlc_cfg_c* cnfg) : rlc_mode(RLC_MODE_AM), am(), um() - { - // update RLC mode to internal mode struct - rlc_mode = (cnfg->type() == asn1::rrc::rlc_cfg_c::types::am) ? RLC_MODE_AM : RLC_MODE_UM; - - switch(rlc_mode) - { - case RLC_MODE_AM: - am.t_poll_retx = cnfg->am().ul_am_rlc.t_poll_retx.to_number(); - am.poll_pdu = cnfg->am().ul_am_rlc.poll_pdu.to_number(); - am.poll_byte = cnfg->am().ul_am_rlc.poll_byte.to_number() * 1000; // KB - am.max_retx_thresh = cnfg->am().ul_am_rlc.max_retx_thres.to_number(); - am.t_reordering = cnfg->am().dl_am_rlc.t_reordering.to_number(); - am.t_status_prohibit = cnfg->am().dl_am_rlc.t_status_prohibit.to_number(); - break; - case RLC_MODE_UM: - um.t_reordering = cnfg->um_bi_dir().dl_um_rlc.t_reordering.to_number(); - um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_bi_dir().dl_um_rlc.sn_field_len.value; - um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512; - um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 32 : 1024; - um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_bi_dir().ul_um_rlc.sn_field_len.value; - um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024; - break; - // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_ul: - // um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_ul().ul_um_rlc.sn_field_len.value; - // um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024; - // break; - // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_dl: - // um.t_reordering = cnfg->um_uni_dir_dl().dl_um_rlc.t_reordering.to_number(); - // um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_dl().dl_um_rlc.sn_field_len.value; - // um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512; - // um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 32 : 1024; - // break; - default: - // Handle default case - break; - } - - tx_queue_length = RLC_TX_QUEUE_LEN; - } - // Factory for MCH static srslte_rlc_config_t mch_config() { diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index ed94d38f9..f81c78776 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -23,49 +23,77 @@ #include "srslte/asn1/rrc_asn1.h" #include "srslte/common/bcd_helpers.h" #include "srslte/config.h" +#include "srslte/upper/rlc_interface.h" #include namespace srslte { -int plmn_id_t::from_asn1(const asn1::rrc::plmn_id_s* asn1_type) +bool plmn_is_valid(const asn1::rrc::plmn_id_s& asn1_type) { - if (not asn1_type->mcc_present) { + return asn1_type.mcc_present and (asn1_type.mnc.size() == 3 or asn1_type.mnc.size() == 2); +} + +plmn_id_t::plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type) +{ + from_asn1(asn1_type); +} + +void plmn_id_t::reset() +{ + nof_mnc_digits = 2; + std::fill(&mnc[0], &mnc[3], 3); + std::fill(&mcc[0], &mcc[3], 3); +} + +int plmn_id_t::from_asn1(const asn1::rrc::plmn_id_s& asn1_type) +{ + if (not plmn_is_valid(asn1_type)) { + reset(); return SRSLTE_ERROR; } - std::copy(&asn1_type->mcc[0], &asn1_type->mcc[3], &mcc[0]); - nof_mnc_digits = asn1_type->mnc.size(); - std::copy(&asn1_type->mnc[0], &asn1_type->mnc[nof_mnc_digits], &mnc[0]); + std::copy(&asn1_type.mcc[0], &asn1_type.mcc[3], &mcc[0]); + nof_mnc_digits = asn1_type.mnc.size(); + std::copy(&asn1_type.mnc[0], &asn1_type.mnc[nof_mnc_digits], &mnc[0]); return SRSLTE_SUCCESS; } -void plmn_id_t::to_asn1(asn1::rrc::plmn_id_s* asn1_type) const +int plmn_id_t::to_asn1(asn1::rrc::plmn_id_s* asn1_type) const { asn1_type->mcc_present = true; std::copy(&mcc[0], &mcc[3], &asn1_type->mcc[0]); asn1_type->mnc.resize(nof_mnc_digits); std::copy(&mnc[0], &mnc[nof_mnc_digits], &asn1_type->mnc[0]); + return SRSLTE_SUCCESS; } -void plmn_id_t::from_number(uint16_t mcc_num, uint16_t mnc_num) +int plmn_id_t::from_number(uint16_t mcc_num, uint16_t mnc_num) { srslte::mcc_to_bytes(mcc_num, &mcc[0]); - srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits); + if (not srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits)) { + reset(); + return SRSLTE_ERROR; + } + return SRSLTE_SUCCESS; } int plmn_id_t::from_string(const std::string& plmn_str) { if (plmn_str.size() < 5 or plmn_str.size() > 6) { + reset(); return SRSLTE_ERROR; } uint16_t mnc_num, mcc_num; if (not string_to_mcc(std::string(plmn_str.begin(), plmn_str.begin() + 3), &mcc_num)) { + reset(); return SRSLTE_ERROR; } if (not string_to_mnc(std::string(plmn_str.begin() + 3, plmn_str.end()), &mnc_num)) { + reset(); return SRSLTE_ERROR; } if (not mcc_to_bytes(mcc_num, &mcc[0])) { + reset(); return SRSLTE_ERROR; } return mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits) ? SRSLTE_SUCCESS : SRSLTE_ERROR; @@ -82,10 +110,15 @@ std::string plmn_id_t::to_string() const return mcc_str + mnc_str; } -void s_tmsi_t::from_asn1(const asn1::rrc::s_tmsi_s* asn1_type) +s_tmsi_t::s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type) +{ + from_asn1(asn1_type); +} + +void s_tmsi_t::from_asn1(const asn1::rrc::s_tmsi_s& asn1_type) { - mmec = asn1_type->mmec.to_number(); - m_tmsi = asn1_type->m_tmsi.to_number(); + mmec = asn1_type.mmec.to_number(); + m_tmsi = asn1_type.m_tmsi.to_number(); } void s_tmsi_t::to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const @@ -102,4 +135,47 @@ std::string to_string(const establishment_cause_t& cause) return asn1_cause.to_string(); } +void convert_from_asn1(srslte_rlc_config_t* out, const asn1::rrc::rlc_cfg_c& asn1_type) +{ + out->am = srslte_rlc_am_config_t(); + out->um = srslte_rlc_um_config_t(); + + // update RLC mode to internal mode struct + out->rlc_mode = (asn1_type.type() == asn1::rrc::rlc_cfg_c::types::am) ? RLC_MODE_AM : RLC_MODE_UM; + + switch (out->rlc_mode) { + case RLC_MODE_AM: + out->am.t_poll_retx = asn1_type.am().ul_am_rlc.t_poll_retx.to_number(); + out->am.poll_pdu = asn1_type.am().ul_am_rlc.poll_pdu.to_number(); + out->am.poll_byte = asn1_type.am().ul_am_rlc.poll_byte.to_number() * 1000; // KB + out->am.max_retx_thresh = asn1_type.am().ul_am_rlc.max_retx_thres.to_number(); + out->am.t_reordering = asn1_type.am().dl_am_rlc.t_reordering.to_number(); + out->am.t_status_prohibit = asn1_type.am().dl_am_rlc.t_status_prohibit.to_number(); + break; + case RLC_MODE_UM: + out->um.t_reordering = asn1_type.um_bi_dir().dl_um_rlc.t_reordering.to_number(); + out->um.rx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().dl_um_rlc.sn_field_len.value; + out->um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == out->um.rx_sn_field_length) ? 16 : 512; + out->um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == out->um.rx_sn_field_length) ? 32 : 1024; + out->um.tx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().ul_um_rlc.sn_field_len.value; + out->um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == out->um.tx_sn_field_length) ? 32 : 1024; + break; + // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_ul: + // um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_ul().ul_um_rlc.sn_field_len.value; + // um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024; + // break; + // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_dl: + // um.t_reordering = cnfg->um_uni_dir_dl().dl_um_rlc.t_reordering.to_number(); + // um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_dl().dl_um_rlc.sn_field_len.value; + // um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512; + // um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 32 : 1024; + // break; + default: + // Handle default case + break; + } + + out->tx_queue_length = RLC_TX_QUEUE_LEN; +} + } // namespace \ No newline at end of file diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 789daf1e6..5625679cf 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -24,8 +24,6 @@ #include "srslte/upper/rlc_um.h" #include "srslte/upper/rlc_am.h" -using namespace asn1::rrc; - namespace srslte { rlc::rlc(log* log_) : rlc_log(log_) @@ -390,16 +388,15 @@ void rlc::add_bearer(uint32_t lcid) add_bearer(lcid, srslte_rlc_config_t()); } else { // SRB1 and SRB2 are AM - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - rlc_cfg_c::am_s_* amcfg = &cnfg.am(); - amcfg->ul_am_rlc.t_poll_retx = t_poll_retx_e::ms45; - amcfg->ul_am_rlc.poll_pdu = poll_pdu_e::p_infinity; - amcfg->ul_am_rlc.poll_byte = poll_byte_e::kbinfinity; - amcfg->ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - amcfg->dl_am_rlc.t_reordering = t_reordering_e::ms35; - amcfg->dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms0; - add_bearer(lcid, srslte_rlc_config_t(&cnfg)); + srslte_rlc_config_t rlc_cfg; + rlc_cfg.rlc_mode = RLC_MODE_AM; + rlc_cfg.am.t_poll_retx = 45; + rlc_cfg.am.poll_pdu = -1; + rlc_cfg.am.poll_byte = -1; + rlc_cfg.am.max_retx_thresh = 4; + rlc_cfg.am.t_reordering = 35; + rlc_cfg.am.t_status_prohibit = 0; + add_bearer(lcid, rlc_cfg); } } diff --git a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc index 5428fb95d..175e2e216 100644 --- a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc @@ -20,6 +20,7 @@ */ #include "srslte/asn1/rrc_asn1.h" +#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/log_filter.h" #include @@ -84,9 +85,9 @@ int basic_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - std::string mccmnc_str = srslte::plmn_id_to_string( + srslte::plmn_id_t plmn( area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); - TESTASSERT(mccmnc_str == "987654"); + TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == "000001"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].session_id_r9.to_string() == "01"); @@ -107,9 +108,8 @@ int basic_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - mccmnc_str = srslte::plmn_id_to_string( - area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); - TESTASSERT(mccmnc_str == "987654"); + plmn.from_asn1(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); + TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[1].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == "000002"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[1].mbms_session_info_list_r9[0].session_id_r9.to_string() == "02"); diff --git a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc index f6d283bdc..aea41f4c0 100644 --- a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc @@ -20,6 +20,7 @@ */ #include "srslte/asn1/rrc_asn1.h" +#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/log_filter.h" #include @@ -75,8 +76,8 @@ int basic_test() TESTASSERT(meas_list[0].cgi_info_present); TESTASSERT(meas_list[0].cgi_info.plmn_id_list_present); TESTASSERT(meas_list[0].cgi_info.cell_global_id.plmn_id.mcc_present); - std::string mccmnc_str = srslte::plmn_id_to_string(meas_list[0].cgi_info.cell_global_id.plmn_id); - TESTASSERT(mccmnc_str == "89878"); + srslte::plmn_id_t plmn(meas_list[0].cgi_info.cell_global_id.plmn_id); + TESTASSERT(plmn.to_string() == "89878"); TESTASSERT(meas_list[0].cgi_info.cell_global_id.cell_id.to_number() == 0x1084104); TESTASSERT(meas_list[0].cgi_info.tac.to_number() == 0x1042); TESTASSERT(meas_list[0].cgi_info.plmn_id_list.size() == 1); diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 2d3a98152..cb6eceeb6 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -129,6 +129,19 @@ private: bool running; }; +srslte_rlc_config_t default_rlc_cnfg() +{ + srslte_rlc_config_t rlc_cnfg; + rlc_cnfg.rlc_mode = RLC_MODE_AM; + rlc_cnfg.am.t_reordering = 5; + rlc_cnfg.am.t_status_prohibit = 5; + rlc_cnfg.am.max_retx_thresh = 4; + rlc_cnfg.am.poll_byte = 25; + rlc_cnfg.am.poll_pdu = 4; + rlc_cnfg.am.t_poll_retx = 5; + return rlc_cnfg; +} + void basic_test_tx(rlc_am* rlc, byte_buffer_t pdu_bufs[NBUFS]) { @@ -169,20 +182,11 @@ bool basic_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -237,20 +241,11 @@ bool concat_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -312,20 +307,11 @@ bool segment_test(bool in_seq_rx) rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -415,20 +401,11 @@ bool retx_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -517,20 +494,11 @@ bool resegment_test_1() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -632,20 +600,11 @@ bool resegment_test_2() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -743,20 +702,11 @@ bool resegment_test_3() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -849,20 +799,11 @@ bool resegment_test_4() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -957,20 +898,11 @@ bool resegment_test_5() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -1066,20 +998,11 @@ bool resegment_test_6() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -1211,20 +1134,11 @@ bool resegment_test_7() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -1393,20 +1307,11 @@ bool resegment_test_8() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); rlc_am rlc2(&log2, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } - if (not rlc2.configure(&cnfg)) { + if (not rlc2.configure(default_rlc_cnfg())) { return -1; } @@ -1546,16 +1451,7 @@ bool reset_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } @@ -1600,16 +1496,7 @@ bool resume_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } @@ -1653,16 +1540,7 @@ bool stop_test() rlc_am rlc1(&log1, 1, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::am); - cnfg.am().dl_am_rlc.t_reordering = t_reordering_e::ms5; - cnfg.am().dl_am_rlc.t_status_prohibit = t_status_prohibit_e::ms5; - cnfg.am().ul_am_rlc.max_retx_thres = ul_am_rlc_s::max_retx_thres_e_::t4; - cnfg.am().ul_am_rlc.poll_byte = poll_byte_e::kb25; - cnfg.am().ul_am_rlc.poll_pdu = poll_pdu_e::p4; - cnfg.am().ul_am_rlc.t_poll_retx = t_poll_retx_e::ms5; - - if (not rlc1.configure(&cnfg)) { + if (not rlc1.configure(default_rlc_cnfg())) { return -1; } diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index 5463d62ad..7eca32096 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -109,14 +109,17 @@ int basic_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::um_bi_dir); - cnfg.um_bi_dir().dl_um_rlc.t_reordering = t_reordering_e::ms5; - cnfg.um_bi_dir().dl_um_rlc.sn_field_len = sn_field_len_e::size10; - cnfg.um_bi_dir().ul_um_rlc.sn_field_len = sn_field_len_e::size10; - - TESTASSERT(rlc1.configure(&cnfg) == true); - TESTASSERT(rlc2.configure(&cnfg) == true); + srslte_rlc_config_t cnfg; + cnfg.rlc_mode = RLC_MODE_UM; + cnfg.um.t_reordering = 5; + cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.rx_window_size = 512; + cnfg.um.rx_mod = 1024; + cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.tx_mod = 1024; + + TESTASSERT(rlc1.configure(cnfg) == true); + TESTASSERT(rlc2.configure(cnfg) == true); tester.set_expected_sdu_len(1); @@ -176,14 +179,17 @@ int loss_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::um_bi_dir); - cnfg.um_bi_dir().dl_um_rlc.t_reordering = t_reordering_e::ms5; - cnfg.um_bi_dir().dl_um_rlc.sn_field_len = sn_field_len_e::size10; - cnfg.um_bi_dir().ul_um_rlc.sn_field_len = sn_field_len_e::size10; + srslte_rlc_config_t cnfg; + cnfg.rlc_mode = RLC_MODE_UM; + cnfg.um.t_reordering = 5; + cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.rx_window_size = 512; + cnfg.um.rx_mod = 1024; + cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.tx_mod = 1024; - rlc1.configure(&cnfg); - rlc2.configure(&cnfg); + rlc1.configure(cnfg); + rlc2.configure(cnfg); tester.set_expected_sdu_len(1); @@ -313,14 +319,17 @@ int reassmble_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::um_bi_dir); - cnfg.um_bi_dir().dl_um_rlc.t_reordering = t_reordering_e::ms5; - cnfg.um_bi_dir().dl_um_rlc.sn_field_len = sn_field_len_e::size5; - cnfg.um_bi_dir().ul_um_rlc.sn_field_len = sn_field_len_e::size5; + srslte_rlc_config_t cnfg; + cnfg.rlc_mode = RLC_MODE_UM; + cnfg.um.t_reordering = 5; + cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.rx_window_size = 16; + cnfg.um.rx_mod = 32; + cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.tx_mod = 32; - rlc1.configure(&cnfg); - rlc2.configure(&cnfg); + rlc1.configure(cnfg); + rlc2.configure(cnfg); // Push SDUs into RLC1 const int n_sdus = 25; @@ -426,14 +435,17 @@ int reassmble_test2() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - rlc_cfg_c cnfg; - cnfg.set(rlc_cfg_c::types::um_bi_dir); - cnfg.um_bi_dir().dl_um_rlc.t_reordering = t_reordering_e::ms5; - cnfg.um_bi_dir().dl_um_rlc.sn_field_len = sn_field_len_e::size5; - cnfg.um_bi_dir().ul_um_rlc.sn_field_len = sn_field_len_e::size5; - - rlc1.configure(&cnfg); - rlc2.configure(&cnfg); + srslte_rlc_config_t cnfg; + cnfg.rlc_mode = RLC_MODE_UM; + cnfg.um.t_reordering = 5; + cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.rx_window_size = 16; + cnfg.um.rx_mod = 32; + cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.tx_mod = 32; + + rlc1.configure(cnfg); + rlc2.configure(cnfg); // Push SDUs into RLC1 const int n_sdus = 25; diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 120abec55..22581146f 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -635,10 +635,12 @@ int enb::parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_ return -1; } cell_access->plmn_id_list.resize(1); - if (not srslte::string_to_plmn_id(cell_access->plmn_id_list[0].plmn_id, mcc_str + mnc_str)) { + srslte::plmn_id_t plmn; + if (plmn.from_string(mcc_str + mnc_str) == SRSLTE_ERROR) { ERROR("Could not convert %s to a plmn_id\n", (mcc_str + mnc_str).c_str()); return -1; } + plmn.to_asn1(&cell_access->plmn_id_list[0].plmn_id); cell_access->plmn_id_list[0].cell_reserved_for_oper = plmn_id_info_s::cell_reserved_for_oper_e_::not_reserved; sib1->cell_sel_info.q_rx_lev_min_offset = 0; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index a69e1cc1b..0792d3db8 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -22,6 +22,7 @@ #include "srsenb/hdr/stack/rrc/rrc.h" #include "srslte/asn1/asn1_utils.h" #include "srslte/asn1/liblte_mme.h" +#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/int_helpers.h" #include "srslte/interfaces/sched_interface.h" @@ -761,8 +762,9 @@ void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13) 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_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"); + srslte::plmn_id_t plmn_obj; + plmn_obj.from_string("00003"); + plmn_obj.to_asn1(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); uint8_t byte[] = {0x0, 0x0, 0x0}; memcpy(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.service_id_r9[0], &byte[0], 3); @@ -770,8 +772,8 @@ 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_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"); + pmch_item->mbms_session_info_list_r9[1].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(); byte[2] = 1; memcpy(&pmch_item->mbms_session_info_list_r9[1].tmgi_r9.service_id_r9[0], &byte[0], 3); // FIXME: Check if service is set to 1 @@ -1749,7 +1751,9 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) parent->pdcp->enable_encryption(rnti, 2); // Configure DRB1 in RLC - parent->rlc->add_bearer(rnti, 3, &conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].rlc_cfg); + srslte::srslte_rlc_config_t rlc_cfg; + srslte::convert_from_asn1(&rlc_cfg, conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].rlc_cfg); + parent->rlc->add_bearer(rnti, 3, rlc_cfg); // Configure DRB1 in PDCP pdcp_cnfg.is_control = false; @@ -1816,7 +1820,9 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE parent->mac->bearer_ue_cfg(rnti, lcid, &bearer_cfg); // Configure DRB in RLC - parent->rlc->add_bearer(rnti, lcid, &drb_item.rlc_cfg); + srslte::srslte_rlc_config_t rlc_cfg; + srslte::convert_from_asn1(&rlc_cfg, drb_item.rlc_cfg); + parent->rlc->add_bearer(rnti, lcid, rlc_cfg); // Configure DRB in PDCP srslte::srslte_pdcp_config_t pdcp_config; diff --git a/srsenb/test/upper/plmn_test.cc b/srsenb/test/upper/plmn_test.cc index cefcecd32..2d30e4a33 100644 --- a/srsenb/test/upper/plmn_test.cc +++ b/srsenb/test/upper/plmn_test.cc @@ -21,6 +21,7 @@ #include "srsenb/hdr/stack/upper/common_enb.h" #include "srslte/asn1/rrc_asn1.h" +#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include @@ -62,8 +63,8 @@ int rrc_plmn_test() TESTASSERT(plmn_in.mnc == plmn_out.mnc); // Test plmn --> string - std::string mccmnc_str = srslte::plmn_id_to_string(plmn_in); - TESTASSERT(mccmnc_str == "12345"); + srslte::plmn_id_t srsplmn_out(plmn_out); + TESTASSERT(srsplmn_out.to_string() == "12345"); asn1::bit_ref bref_in(&byte_buf[0], sizeof(byte_buf)); asn1::bit_ref bref_in0(&byte_buf[0], sizeof(byte_buf)); diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index fc38a822a..9be2a3c23 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -104,8 +104,7 @@ class cell_t srslte::plmn_id_t get_plmn(uint32_t idx) { if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) { - srslte::plmn_id_t ret; - ret.from_asn1(&sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); + srslte::plmn_id_t ret(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); return ret; } else { return {}; diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index c841c54e6..59ed9de7f 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1156,7 +1156,7 @@ std::string rrc::print_mbms() ss << ", Session ID: " << sess->session_id_r9.to_string(); } if (sess->tmgi_r9.plmn_id_r9.type() == tmgi_r9_s::plmn_id_r9_c_::types::explicit_value_r9) { - ss << ", MCC: " << mcc_bytes_to_string(sess->tmgi_r9.plmn_id_r9.explicit_value_r9().mcc); + ss << ", MCC: " << mcc_bytes_to_string(&sess->tmgi_r9.plmn_id_r9.explicit_value_r9().mcc[0]); ss << ", MNC: " << mnc_bytes_to_string(sess->tmgi_r9.plmn_id_r9.explicit_value_r9().mnc); } else { ss << ", PLMN index: " << sess->tmgi_r9.plmn_id_r9.plmn_idx_r9(); @@ -2087,8 +2087,7 @@ void rrc::process_pcch(unique_byte_buffer_t pdu) } for (uint32_t i = 0; i < paging->paging_record_list.size(); i++) { - s_tmsi_t s_tmsi_paged; - s_tmsi_paged.from_asn1(&paging->paging_record_list[i].ue_id.s_tmsi()); + s_tmsi_t s_tmsi_paged(paging->paging_record_list[i].ue_id.s_tmsi()); rrc_log->info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "\n", i + 1, paging->paging_record_list.size(), @@ -3098,7 +3097,9 @@ void rrc::add_srb(srb_to_add_mod_s* srb_cnfg) if (srb_cnfg->rlc_cfg.type() == srb_to_add_mod_s::rlc_cfg_c_::types::default_value) { rlc->add_bearer(srb_cnfg->srb_id); }else{ - rlc->add_bearer(srb_cnfg->srb_id, srslte_rlc_config_t(&srb_cnfg->rlc_cfg.explicit_value())); + srslte_rlc_config_t rlc_cfg; + srslte::convert_from_asn1(&rlc_cfg, srb_cnfg->rlc_cfg.explicit_value()); + rlc->add_bearer(srb_cnfg->srb_id, rlc_cfg); } } @@ -3175,7 +3176,9 @@ void rrc::add_drb(drb_to_add_mod_s* drb_cnfg) pdcp->enable_encryption(lcid); // Setup RLC - rlc->add_bearer(lcid, srslte_rlc_config_t(&drb_cnfg->rlc_cfg)); + srslte_rlc_config_t rlc_cfg; + srslte::convert_from_asn1(&rlc_cfg, drb_cnfg->rlc_cfg); + rlc->add_bearer(lcid, rlc_cfg); // Setup MAC uint8_t log_chan_group = 0; diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 36c0b4ee6..cc5527ec4 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -20,7 +20,6 @@ */ #include "srsue/hdr/stack/upper/nas.h" -#include "srslte/asn1/rrc_asn1.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/security.h" #include @@ -31,17 +30,14 @@ #include #include "srslte/asn1/liblte_mme.h" -#include "srslte/asn1/rrc_asn1.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/security.h" #include "srsue/hdr/stack/upper/nas.h" using namespace srslte; -using namespace asn1::rrc; namespace srsue { - /********************************************************************* * NAS ********************************************************************/