asn1: move setup_release_c from rrc_nr_asn1 to asn1_utils and improved interface

master
Francisco Paisana 3 years ago
parent e2b8a80f87
commit 61e225d762

@ -1458,6 +1458,86 @@ struct setup_release_opts {
}; };
using setup_release_e = enumerated<setup_release_opts>; using setup_release_e = enumerated<setup_release_opts>;
// SetupRelease{ElementTypeParam} ::= CHOICE
template <class T>
struct setup_release_c {
using types_opts = setup_release_opts;
using types = setup_release_e;
// choice methods
setup_release_c() = default;
void set(typename types::options e = types::nulltype) { type_ = e; }
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const
{
type_.pack(bref);
switch (type_) {
case types::release:
break;
case types::setup:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
return SRSASN_ERROR_ENCODE_FAIL;
}
return SRSASN_SUCCESS;
}
SRSASN_CODE unpack(cbit_ref& bref)
{
types e;
e.unpack(bref);
set(e);
switch (type_) {
case types::release:
break;
case types::setup:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
return SRSASN_ERROR_DECODE_FAIL;
}
return SRSASN_SUCCESS;
}
void to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::release:
break;
case types::setup:
asn1::to_json(j, setup());
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
}
j.end_obj();
}
// getters
bool is_setup() const { return type_.value == setup_release_opts::setup; }
T& setup()
{
assert_choice_type(types::setup, type_, "SetupRelease");
return c;
}
const T& setup() const
{
assert_choice_type(types::setup, type_, "SetupRelease");
return c;
}
void set_release() { set(types::release); }
T& set_setup()
{
set(types::setup);
return c;
}
private:
types type_;
T c;
};
// Criticality ::= ENUMERATED // Criticality ::= ENUMERATED
struct crit_opts { struct crit_opts {
enum options { reject, ignore, notify, nulltype } value; enum options { reject, ignore, notify, nulltype } value;

@ -2238,101 +2238,6 @@ struct sib_type_info_s {
void to_json(json_writer& j) const; void to_json(json_writer& j) const;
}; };
// SetupRelease{ElementTypeParam} ::= CHOICE
template <class elem_type_paramT_>
struct setup_release_c {
struct types_opts {
enum options { release, setup, nulltype } value;
const char* to_string() const
{
static const char* options[] = {"release", "setup"};
return convert_enum_idx(options, 2, value, "setup_release_c::types");
}
};
typedef enumerated<types_opts> types;
// choice methods
setup_release_c() = default;
types type() const { return type_; }
// getters
elem_type_paramT_& setup()
{
assert_choice_type(types::setup, type_, "SetupRelease");
return c;
}
const elem_type_paramT_& setup() const
{
assert_choice_type(types::setup, type_, "SetupRelease");
return c;
}
void set_release() { set(types::release); }
void set(typename types::options e) { type_ = e; }
void to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::release:
j.write_null("release");
break;
case types::setup:
j.write_fieldname("setup");
asn1::to_json(j, setup());
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
}
j.end_obj();
}
SRSASN_CODE pack(bit_ref& bref) const
{
type_.pack(bref);
switch (type_) {
case types::release:
break;
case types::setup:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
return SRSASN_ERROR_ENCODE_FAIL;
}
return SRSASN_SUCCESS;
}
SRSASN_CODE unpack(cbit_ref& bref)
{
types e;
e.unpack(bref);
set(e);
switch (type_) {
case types::release:
break;
case types::setup:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "setup_release_c");
return SRSASN_ERROR_DECODE_FAIL;
}
return SRSASN_SUCCESS;
}
elem_type_paramT_& set_setup()
{
set(types::setup);
return c;
}
private:
types type_;
elem_type_paramT_ c;
};
// UAC-BarringPerCat ::= SEQUENCE // UAC-BarringPerCat ::= SEQUENCE
struct uac_barr_per_cat_s { struct uac_barr_per_cat_s {
uint8_t access_category = 1; uint8_t access_category = 1;

@ -1530,9 +1530,7 @@ bool make_phy_mib(const asn1::rrc_nr::mib_s& mib_cfg, srsran_mib_nr_t* mib)
bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl) bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_sch_hl_cfg_nr_t* sch_hl)
{ {
if (serv_cell.csi_meas_cfg_present and if (serv_cell.csi_meas_cfg_present and serv_cell.csi_meas_cfg.is_setup()) {
serv_cell.csi_meas_cfg.type().value ==
setup_release_c< ::asn1::rrc_nr::csi_meas_cfg_s>::types_opts::options::setup) {
auto& setup = serv_cell.csi_meas_cfg.setup(); auto& setup = serv_cell.csi_meas_cfg.setup();
// Configure NZP-CSI // Configure NZP-CSI
@ -1552,8 +1550,7 @@ bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_
} }
} }
if (serv_cell.init_dl_bwp.pdsch_cfg_present and if (serv_cell.init_dl_bwp.pdsch_cfg_present and serv_cell.init_dl_bwp.pdsch_cfg.is_setup()) {
serv_cell.init_dl_bwp.pdsch_cfg.type() == setup_release_c<pdsch_cfg_s>::types_opts::setup) {
const auto& setup = serv_cell.init_dl_bwp.pdsch_cfg.setup(); const auto& setup = serv_cell.init_dl_bwp.pdsch_cfg.setup();
if (setup.p_zp_csi_rs_res_set_present) { if (setup.p_zp_csi_rs_res_set_present) {
auto& setup_set = setup.p_zp_csi_rs_res_set.setup(); auto& setup_set = setup.p_zp_csi_rs_res_set.setup();
@ -1573,9 +1570,7 @@ bool make_pdsch_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_
bool make_csi_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl) bool make_csi_cfg_from_serv_cell(const asn1::rrc_nr::serving_cell_cfg_s& serv_cell, srsran_csi_hl_cfg_t* csi_hl)
{ {
if (serv_cell.csi_meas_cfg_present and if (serv_cell.csi_meas_cfg_present and serv_cell.csi_meas_cfg.is_setup()) {
serv_cell.csi_meas_cfg.type().value ==
setup_release_c< ::asn1::rrc_nr::csi_meas_cfg_s>::types_opts::options::setup) {
auto& setup = serv_cell.csi_meas_cfg.setup(); auto& setup = serv_cell.csi_meas_cfg.setup();
// Configure CSI-Report // Configure CSI-Report

@ -362,9 +362,8 @@ int test_cell_group_config_tdd()
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present == cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present ==
true); true);
TESTASSERT( TESTASSERT(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.type() == .is_setup());
asn1::rrc_nr::setup_release_c<rach_cfg_common_s>::types_opts::setup);
asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common = asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common =
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup(); cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup();
@ -980,9 +979,8 @@ int test_cell_group_config_fdd()
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present == cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present ==
true); true);
TESTASSERT( TESTASSERT(cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.type() == .is_setup());
asn1::rrc_nr::setup_release_c<rach_cfg_common_s>::types_opts::setup);
asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common = asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common =
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup(); cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup();

@ -974,7 +974,7 @@ bool rrc_nr::apply_mac_cell_group(const mac_cell_group_cfg_s& mac_cell_group_cfg
} }
if (mac_cell_group_cfg.phr_cfg_present) { if (mac_cell_group_cfg.phr_cfg_present) {
if (mac_cell_group_cfg.phr_cfg.type() == setup_release_c<asn1::rrc_nr::phr_cfg_s>::types_opts::setup) { if (mac_cell_group_cfg.phr_cfg.is_setup()) {
phr_cfg_nr_t phr_cfg_nr; phr_cfg_nr_t phr_cfg_nr;
if (make_mac_phr_cfg_t(mac_cell_group_cfg.phr_cfg.setup(), &phr_cfg_nr) != true) { if (make_mac_phr_cfg_t(mac_cell_group_cfg.phr_cfg.setup(), &phr_cfg_nr) != true) {
logger.warning("Unable to build PHR config"); logger.warning("Unable to build PHR config");
@ -1196,8 +1196,7 @@ bool rrc_nr::apply_dl_common_cfg(const asn1::rrc_nr::dl_cfg_common_s& dl_cfg_com
} }
if (dl_cfg_common.init_dl_bwp_present) { if (dl_cfg_common.init_dl_bwp_present) {
if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common_present) { if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common_present) {
if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common.type() == if (dl_cfg_common.init_dl_bwp.pdsch_cfg_common.is_setup()) {
asn1::rrc_nr::setup_release_c<asn1::rrc_nr::pdsch_cfg_common_s>::types_opts::setup) {
const pdcch_cfg_common_s& pdcch_cfg_common = dl_cfg_common.init_dl_bwp.pdcch_cfg_common.setup(); const pdcch_cfg_common_s& pdcch_cfg_common = dl_cfg_common.init_dl_bwp.pdcch_cfg_common.setup();
// Load CORESET Zero // Load CORESET Zero

Loading…
Cancel
Save