added default enum inits

master
Francisco Paisana 6 years ago committed by Andre Puschmann
parent 5f7b6ba79e
commit dc0b903130

@ -29,10 +29,6 @@ and at http://www.gnu.org/licenses/.
#include <stdint.h>
#include <string>
// TODOS/FIXME:
// - ext flag as an template arg?
// - custom allocators?
namespace asn1 {
#define ASN_16K 16383
@ -314,14 +310,14 @@ bool number_string_to_enum(EnumType& e, const std::string& val)
return false;
}
template <class EnumType, uint32_t N, uint32_t M, bool E>
template <class EnumType, bool E = false, uint32_t M = 0>
class enumerated : public EnumType
{
public:
static const uint32_t nof_types = N, nof_exts = M;
static const uint32_t nof_types = EnumType::nulltype, nof_exts = M;
static const bool has_ext = E;
enumerated() {}
enumerated() { EnumType::value = EnumType::nulltype; }
enumerated(typename EnumType::options o) { EnumType::value = o; }
SRSASN_CODE pack(bit_ref& bref) const { return pack_enum(bref, EnumType::value); }
SRSASN_CODE unpack(bit_ref& bref) { return unpack_enum(EnumType::value, bref); }
@ -347,8 +343,8 @@ struct UnalignedIntegerPacker {
UnalignedIntegerPacker(IntType, IntType);
IntType lb;
IntType ub;
SRSASN_CODE pack(bit_ref& bref, IntType n);
SRSASN_CODE unpack(IntType& n, bit_ref& bref);
SRSASN_CODE pack(bit_ref& bref, IntType n) const;
SRSASN_CODE unpack(IntType& n, bit_ref& bref) const;
};
template <class IntType>
@ -763,7 +759,7 @@ template <class InnerPacker>
struct SeqOfPacker {
SeqOfPacker(uint32_t lb_, uint32_t ub_, InnerPacker packer_) : lb(lb_), ub(ub_), packer(packer_) {}
template <typename T>
SRSASN_CODE pack(bit_ref& bref, const T& topack)
SRSASN_CODE pack(bit_ref& bref, const T& topack) const
{
return pack_dyn_seq_of(bref, topack, lb, ub, packer);
}
@ -791,15 +787,15 @@ union alignment_t {
uint32_t* ptr;
};
#define MAX2(a, b) ((a) > (b)) ? (a) : (b)
#define MAX4(a, b, c, d) MAX2((MAX2(a, b)), MAX2(c, d))
#define MAX8(a, b, c, d, e, f, g, h) MAX2((MAX4(a, b, c, d)), (MAX4(e, f, g, h)))
#define MAX12(a, b, c, d, e, f, g, h, i, j, k, l) MAX2((MAX8(a, b, c, d, e, f, g, h)), (MAX4(i, j, k, l)))
#define MAX16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
MAX2((MAX8(a, b, c, d, e, f, g, h)), (MAX8(i, j, k, l, m, n, o, p)))
#define MAX32(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, \
o1, p1) \
MAX2((MAX16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)), \
(MAX16(a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1)))
template <class It>
constexpr size_t max_size(It b, It e)
{
return (b != e) ? MAX2(max_size((b + 1), e), *b) : 0;
}
constexpr size_t max_sizeof(const std::initializer_list<size_t>& l)
{
return max_size(l.begin(), l.end());
}
template <size_t SIZE>
class choice_buffer_t

File diff suppressed because it is too large Load Diff

@ -18,7 +18,7 @@
# and at http://www.gnu.org/licenses/.
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-but-set-variable -Wno-unused-variable -Wno-return-type -Wno-sign-compare -Wno-reorder -Wno-parantheses")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-but-set-variable -Wno-unused-variable -Wno-return-type -Wno-sign-compare -Wno-reorder -Wno-parantheses -fno-exceptions")
add_library(srslte_asn1 STATIC
liblte_common.cc
liblte_mme.cc

@ -375,12 +375,12 @@ UnalignedIntegerPacker<IntType>::UnalignedIntegerPacker(IntType lb_, IntType ub_
{
}
template <class IntType>
SRSASN_CODE UnalignedIntegerPacker<IntType>::pack(bit_ref& bref, IntType n)
SRSASN_CODE UnalignedIntegerPacker<IntType>::pack(bit_ref& bref, IntType n) const
{
return pack_unalign_integer(bref, n, lb, ub);
}
template <class IntType>
SRSASN_CODE UnalignedIntegerPacker<IntType>::unpack(IntType& n, bit_ref& bref)
SRSASN_CODE UnalignedIntegerPacker<IntType>::unpack(IntType& n, bit_ref& bref) const
{
return unpack_unalign_integer(n, bref, lb, ub);
}

@ -24550,49 +24550,21 @@ SRSASN_CODE csi_rs_cfg_emimo_v1530_c::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void csi_rs_cfg_emimo_v1530_c::setup_c_::set(types::options e)
{
type_ = e;
}
void csi_rs_cfg_emimo_v1530_c::setup_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::non_precoded_v1530:
j.write_fieldname("nonPrecoded-v1530");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "csi_rs_cfg_emimo_v1530_c::setup_c_");
}
j.write_fieldname("nonPrecoded-v1530");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE csi_rs_cfg_emimo_v1530_c::setup_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::non_precoded_v1530:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "csi_rs_cfg_emimo_v1530_c::setup_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE csi_rs_cfg_emimo_v1530_c::setup_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::non_precoded_v1530:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "csi_rs_cfg_emimo_v1530_c::setup_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -74747,54 +74719,37 @@ void cell_change_order_s::to_json(json_writer& j) const
j.end_obj();
}
void cell_change_order_s::target_rat_type_c_::set(types::options e)
{
type_ = e;
}
void cell_change_order_s::target_rat_type_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::geran:
j.write_fieldname("geran");
j.start_obj();
j.write_fieldname("physCellId");
c.pci.to_json(j);
j.write_fieldname("carrierFreq");
c.carrier_freq.to_json(j);
if (c.network_ctrl_order_present) {
j.write_str("networkControlOrder", c.network_ctrl_order.to_string());
}
if (c.sys_info_present) {
j.write_fieldname("systemInformation");
c.sys_info.to_json(j);
}
j.end_obj();
break;
default:
log_invalid_choice_id(type_, "cell_change_order_s::target_rat_type_c_");
j.write_fieldname("geran");
j.start_obj();
j.write_fieldname("physCellId");
c.pci.to_json(j);
j.write_fieldname("carrierFreq");
c.carrier_freq.to_json(j);
if (c.network_ctrl_order_present) {
j.write_str("networkControlOrder", c.network_ctrl_order.to_string());
}
if (c.sys_info_present) {
j.write_fieldname("systemInformation");
c.sys_info.to_json(j);
}
j.end_obj();
j.end_obj();
}
SRSASN_CODE cell_change_order_s::target_rat_type_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::geran:
HANDLE_CODE(bref.pack(c.network_ctrl_order_present, 1));
HANDLE_CODE(bref.pack(c.sys_info_present, 1));
HANDLE_CODE(c.pci.pack(bref));
HANDLE_CODE(c.carrier_freq.pack(bref));
if (c.network_ctrl_order_present) {
HANDLE_CODE(c.network_ctrl_order.pack(bref));
}
if (c.sys_info_present) {
HANDLE_CODE(c.sys_info.pack(bref));
}
break;
default:
log_invalid_choice_id(type_, "cell_change_order_s::target_rat_type_c_");
return SRSASN_ERROR_ENCODE_FAIL;
pack_enum(bref, type());
HANDLE_CODE(bref.pack(c.network_ctrl_order_present, 1));
HANDLE_CODE(bref.pack(c.sys_info_present, 1));
HANDLE_CODE(c.pci.pack(bref));
HANDLE_CODE(c.carrier_freq.pack(bref));
if (c.network_ctrl_order_present) {
HANDLE_CODE(c.network_ctrl_order.pack(bref));
}
if (c.sys_info_present) {
HANDLE_CODE(c.sys_info.pack(bref));
}
return SRSASN_SUCCESS;
}
@ -74802,23 +74757,19 @@ SRSASN_CODE cell_change_order_s::target_rat_type_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::geran:
HANDLE_CODE(bref.unpack(c.network_ctrl_order_present, 1));
HANDLE_CODE(bref.unpack(c.sys_info_present, 1));
HANDLE_CODE(c.pci.unpack(bref));
HANDLE_CODE(c.carrier_freq.unpack(bref));
if (c.network_ctrl_order_present) {
HANDLE_CODE(c.network_ctrl_order.unpack(bref));
}
if (c.sys_info_present) {
HANDLE_CODE(c.sys_info.unpack(bref));
}
break;
default:
log_invalid_choice_id(type_, "cell_change_order_s::target_rat_type_c_");
return SRSASN_ERROR_DECODE_FAIL;
if (e != type()) {
log_invalid_choice_id(e, "cell_change_order_s::target_rat_type_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(bref.unpack(c.network_ctrl_order_present, 1));
HANDLE_CODE(bref.unpack(c.sys_info_present, 1));
HANDLE_CODE(c.pci.unpack(bref));
HANDLE_CODE(c.carrier_freq.unpack(bref));
if (c.network_ctrl_order_present) {
HANDLE_CODE(c.network_ctrl_order.unpack(bref));
}
if (c.sys_info_present) {
HANDLE_CODE(c.sys_info.unpack(bref));
}
return SRSASN_SUCCESS;
}
@ -83525,49 +83476,21 @@ SRSASN_CODE mcch_msg_type_c::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void mcch_msg_type_c::c1_c_::set(types::options e)
{
type_ = e;
}
void mcch_msg_type_c::c1_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::mbsfn_area_cfg_r9:
j.write_fieldname("mbsfnAreaConfiguration-r9");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::c1_c_");
}
j.write_fieldname("mbsfnAreaConfiguration-r9");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE mcch_msg_type_c::c1_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::mbsfn_area_cfg_r9:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::c1_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE mcch_msg_type_c::c1_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::mbsfn_area_cfg_r9:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::c1_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -83680,49 +83603,21 @@ SRSASN_CODE mcch_msg_type_c::later_c_::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void mcch_msg_type_c::later_c_::c2_c_::set(types::options e)
{
type_ = e;
}
void mcch_msg_type_c::later_c_::c2_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::mbms_count_request_r10:
j.write_fieldname("mbmsCountingRequest-r10");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::later_c_::c2_c_");
}
j.write_fieldname("mbmsCountingRequest-r10");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE mcch_msg_type_c::later_c_::c2_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::mbms_count_request_r10:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::later_c_::c2_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE mcch_msg_type_c::later_c_::c2_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::mbms_count_request_r10:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "mcch_msg_type_c::later_c_::c2_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -84360,49 +84255,21 @@ SRSASN_CODE pcch_msg_type_c::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void pcch_msg_type_c::c1_c_::set(types::options e)
{
type_ = e;
}
void pcch_msg_type_c::c1_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::paging:
j.write_fieldname("paging");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "pcch_msg_type_c::c1_c_");
}
j.write_fieldname("paging");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE pcch_msg_type_c::c1_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::paging:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "pcch_msg_type_c::c1_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE pcch_msg_type_c::c1_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::paging:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "pcch_msg_type_c::c1_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -85776,49 +85643,21 @@ SRSASN_CODE sc_mcch_msg_type_r13_c::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void sc_mcch_msg_type_r13_c::c1_c_::set(types::options e)
{
type_ = e;
}
void sc_mcch_msg_type_r13_c::c1_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::scptm_cfg_r13:
j.write_fieldname("scptmConfiguration-r13");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "sc_mcch_msg_type_r13_c::c1_c_");
}
j.write_fieldname("scptmConfiguration-r13");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE sc_mcch_msg_type_r13_c::c1_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::scptm_cfg_r13:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "sc_mcch_msg_type_r13_c::c1_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE sc_mcch_msg_type_r13_c::c1_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::scptm_cfg_r13:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "sc_mcch_msg_type_r13_c::c1_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -87444,49 +87283,21 @@ SRSASN_CODE ul_ccch_msg_type_c::msg_class_ext_c_::unpack(bit_ref& bref)
return SRSASN_SUCCESS;
}
void ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_::set(types::options e)
{
type_ = e;
}
void ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::rrc_conn_resume_request_r13:
j.write_fieldname("rrcConnectionResumeRequest-r13");
c.to_json(j);
break;
default:
log_invalid_choice_id(type_, "ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_");
}
j.write_fieldname("rrcConnectionResumeRequest-r13");
c.to_json(j);
j.end_obj();
}
SRSASN_CODE ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::rrc_conn_resume_request_r13:
HANDLE_CODE(c.pack(bref));
break;
default:
log_invalid_choice_id(type_, "ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
HANDLE_CODE(c.pack(bref));
return SRSASN_SUCCESS;
}
SRSASN_CODE ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::rrc_conn_resume_request_r13:
HANDLE_CODE(c.unpack(bref));
break;
default:
log_invalid_choice_id(type_, "ul_ccch_msg_type_c::msg_class_ext_c_::c2_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(c.unpack(bref));
return SRSASN_SUCCESS;
}
@ -90045,52 +89856,31 @@ void meas_result_idle_r15_s::to_json(json_writer& j) const
j.end_obj();
}
void meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_::set(types::options e)
{
type_ = e;
}
void meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_::to_json(json_writer& j) const
{
j.start_obj();
switch (type_) {
case types::meas_result_idle_list_eutra_r15:
j.start_array("measResultIdleListEUTRA-r15");
for (uint32_t i1 = 0; i1 < c.size(); ++i1) {
c[i1].to_json(j);
}
j.end_array();
break;
default:
log_invalid_choice_id(type_, "meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_");
j.start_array("measResultIdleListEUTRA-r15");
for (uint32_t i1 = 0; i1 < c.size(); ++i1) {
c[i1].to_json(j);
}
j.end_array();
j.end_obj();
}
SRSASN_CODE meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_::pack(bit_ref& bref) const
{
pack_enum(bref, type_);
switch (type_) {
case types::meas_result_idle_list_eutra_r15:
HANDLE_CODE(pack_dyn_seq_of(bref, c, 1, 8));
break;
default:
log_invalid_choice_id(type_, "meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_");
return SRSASN_ERROR_ENCODE_FAIL;
}
pack_enum(bref, type());
HANDLE_CODE(pack_dyn_seq_of(bref, c, 1, 8));
return SRSASN_SUCCESS;
}
SRSASN_CODE meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_::unpack(bit_ref& bref)
{
types e;
unpack_enum(e, bref);
set(e);
switch (type_) {
case types::meas_result_idle_list_eutra_r15:
HANDLE_CODE(unpack_dyn_seq_of(c, bref, 1, 8));
break;
default:
log_invalid_choice_id(type_, "meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_");
return SRSASN_ERROR_DECODE_FAIL;
if (e != type()) {
log_invalid_choice_id(e, "meas_result_idle_r15_s::meas_result_neigh_cells_r15_c_");
return SRSASN_ERROR_DECODE_FAIL;
}
HANDLE_CODE(unpack_dyn_seq_of(c, bref, 1, 8));
return SRSASN_SUCCESS;
}

File diff suppressed because it is too large Load Diff

@ -432,7 +432,6 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t *payload_len)
asn1::rrc::pcch_msg_s pcch_msg;
pcch_msg.msg.set(pcch_msg_type_c::types::c1);
pcch_msg.msg.c1().set(pcch_msg_type_c::c1_c_::types::paging);
paging_s* paging_rec = &pcch_msg.msg.c1().paging();
// Default paging cycle, should get DRX from user
@ -755,7 +754,6 @@ 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.c1().set(mcch_msg_type_c::c1_c_::types::mbsfn_area_cfg_r9);
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);

Loading…
Cancel
Save