removed most of clang-tidy warnings, introduced logmap in asn1, fixed info object naming in s1ap and ngap for successful and unsuccessful outcomes

master
Francisco Paisana 5 years ago
parent dffa2af461
commit ac52208409

@ -22,7 +22,7 @@
#ifndef SRSASN_COMMON_UTILS_H #ifndef SRSASN_COMMON_UTILS_H
#define SRSASN_COMMON_UTILS_H #define SRSASN_COMMON_UTILS_H
#include "srslte/common/log.h" #include "srslte/common/logmap.h"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cmath> #include <cmath>
@ -46,20 +46,6 @@ constexpr Integer ceil_frac(Integer n, Integer d)
return (n + (d - 1)) / d; return (n + (d - 1)) / d;
} }
/************************
logging
************************/
using srsasn_logger_level_t = srslte::LOG_LEVEL_ENUM;
using srslte::LOG_LEVEL_DEBUG;
using srslte::LOG_LEVEL_ERROR;
using srslte::LOG_LEVEL_INFO;
using srslte::LOG_LEVEL_WARNING;
void vlog_print(srslte::log* log_ptr, srsasn_logger_level_t log_level, const char* format, va_list args);
void srsasn_log_register_handler(srslte::log* ctx);
void srsasn_log_print(srsasn_logger_level_t log_level, const char* format, ...);
/************************ /************************
error handling error handling
************************/ ************************/
@ -251,7 +237,7 @@ public:
void push_back(const T& elem) void push_back(const T& elem)
{ {
if (current_size >= MAX_N) { if (current_size >= MAX_N) {
srsasn_log_print(srslte::LOG_LEVEL_ERROR, "Maximum size %d achieved for bounded_array.\n", MAX_N); srslte::logmap::get("ASN1")->error("Maximum size %d achieved for bounded_array.\n", MAX_N);
} }
data_[current_size++] = elem; data_[current_size++] = elem;
} }
@ -614,8 +600,8 @@ public:
fixed_octstring<N, aligned>& from_string(const std::string& hexstr) fixed_octstring<N, aligned>& from_string(const std::string& hexstr)
{ {
if (hexstr.size() != 2 * N) { if (hexstr.size() != 2 * N) {
srsasn_log_print( srslte::logmap::get("ASN1")->error(
srslte::LOG_LEVEL_ERROR, "The provided hex string size is not valid (%d!=2*%d).\n", hexstr.size(), N); "The provided hex string size is not valid (%zd!=2*%zd).\n", hexstr.size(), (size_t)N);
} else { } else {
string_to_octstring(&octets_[0], hexstr); string_to_octstring(&octets_[0], hexstr);
} }
@ -784,11 +770,8 @@ public:
this_type& from_string(const std::string& s) this_type& from_string(const std::string& s)
{ {
if (s.size() < lb or s.size() > ub) { if (s.size() < lb or s.size() > ub) {
srsasn_log_print(srslte::LOG_LEVEL_ERROR, srslte::logmap::get("ASN1")->error(
"The provided string size=%zd is not withing the bounds [%d, %d]\n", "The provided string size=%zd is not withing the bounds [%d, %d]\n", s.size(), lb, ub);
s.size(),
lb,
ub);
} else { } else {
resize(s.size()); resize(s.size());
for (uint32_t i = 0; i < s.size(); ++i) { for (uint32_t i = 0; i < s.size(); ++i) {
@ -1116,6 +1099,8 @@ struct choice_buffer_base_t {
using buffer_t = typename std::aligned_storage<data_size, data_align>::type; using buffer_t = typename std::aligned_storage<data_size, data_align>::type;
buffer_t buffer; buffer_t buffer;
choice_buffer_base_t() : buffer() {}
template <typename T> template <typename T>
T& get() T& get()
{ {
@ -1275,17 +1260,17 @@ int test_pack_unpack_consistency(const Msg& msg)
// unpack and last pack done for the same number of bits // unpack and last pack done for the same number of bits
if (bref3.distance() != bref2.distance()) { if (bref3.distance() != bref2.distance()) {
srsasn_log_print(LOG_LEVEL_ERROR, "[%s][%d] .\n", __FILE__, __LINE__); srslte::logmap::get("ASN1")->error("[%s][%d] .\n", __FILE__, __LINE__);
return -1; return -1;
} }
// ensure packed messages are the same // ensure packed messages are the same
if (bref3.distance() != bref.distance()) { if (bref3.distance() != bref.distance()) {
srsasn_log_print(LOG_LEVEL_ERROR, "[%s][%d] .\n", __FILE__, __LINE__); srslte::logmap::get("ASN1")->error("[%s][%d] .\n", __FILE__, __LINE__);
return -1; return -1;
} }
if (memcmp(buf, buf2, bref.distance_bytes()) != 0) { if (memcmp(buf, buf2, bref.distance_bytes()) != 0) {
srsasn_log_print(LOG_LEVEL_ERROR, "[%s][%d] .\n", __FILE__, __LINE__); srslte::logmap::get("ASN1")->error("[%s][%d] .\n", __FILE__, __LINE__);
return -1; return -1;
} }
return SRSASN_SUCCESS; return SRSASN_SUCCESS;

File diff suppressed because it is too large Load Diff

@ -39,12 +39,6 @@ namespace rrc {
* Functions for external logging * Functions for external logging
******************************************************************************/ ******************************************************************************/
extern srslte::log* rrc_log_ptr;
void rrc_log_register_handler(srslte::log* ctx);
void rrc_log_print(srslte::LOG_LEVEL_ENUM log_level, const char* format, ...);
void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id); void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id);
void assert_choice_type(uint32_t val, uint32_t choice_id); void assert_choice_type(uint32_t val, uint32_t choice_id);
@ -56,19 +50,7 @@ void assert_choice_type(const std::string& access_type,
const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type); const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type);
template <class ItemType> template <class ItemType>
ItemType convert_enum_idx(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type) ItemType map_enum_number(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type);
{
if (enum_val >= nof_types) {
if (enum_val == nof_types) {
rrc_log_print(LOG_LEVEL_ERROR, "The enum of type %s was not initialized.\n", enum_type);
} else {
rrc_log_print(
LOG_LEVEL_ERROR, "The provided enum value=%d of type %s cannot be converted.\n", enum_val, enum_type);
}
return 0;
}
return array[enum_val];
}
/******************************************************************************* /*******************************************************************************
* Constant Definitions * Constant Definitions

@ -39,12 +39,6 @@ namespace rrc_nr {
* Functions for external logging * Functions for external logging
******************************************************************************/ ******************************************************************************/
extern srslte::log* rrc_nr_log_ptr;
void rrc_nr_log_register_handler(srslte::log* ctx);
void rrc_nr_log_print(srslte::LOG_LEVEL_ENUM log_level, const char* format, ...);
void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id); void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id);
void assert_choice_type(uint32_t val, uint32_t choice_id); void assert_choice_type(uint32_t val, uint32_t choice_id);
@ -56,19 +50,7 @@ void assert_choice_type(const std::string& access_type,
const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type); const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type);
template <class ItemType> template <class ItemType>
ItemType convert_enum_idx(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type) ItemType map_enum_number(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type);
{
if (enum_val >= nof_types) {
if (enum_val == nof_types) {
rrc_nr_log_print(LOG_LEVEL_ERROR, "The enum of type %s was not initialized.\n", enum_type);
} else {
rrc_nr_log_print(
LOG_LEVEL_ERROR, "The provided enum value=%d of type %s cannot be converted.\n", enum_val, enum_type);
}
return 0;
}
return array[enum_val];
}
/******************************************************************************* /*******************************************************************************
* Constant Definitions * Constant Definitions

@ -39,12 +39,6 @@ namespace s1ap {
* Functions for external logging * Functions for external logging
******************************************************************************/ ******************************************************************************/
extern srslte::log* s1ap_log_ptr;
void s1ap_log_register_handler(srslte::log* ctx);
void s1ap_log_print(srslte::LOG_LEVEL_ENUM log_level, const char* format, ...);
void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id); void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id);
void assert_choice_type(uint32_t val, uint32_t choice_id); void assert_choice_type(uint32_t val, uint32_t choice_id);
@ -56,19 +50,7 @@ void assert_choice_type(const std::string& access_type,
const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type); const char* convert_enum_idx(const char* array[], uint32_t nof_types, uint32_t enum_val, const char* enum_type);
template <class ItemType> template <class ItemType>
ItemType convert_enum_idx(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type) ItemType map_enum_number(ItemType* array, uint32_t nof_types, uint32_t enum_val, const char* enum_type);
{
if (enum_val >= nof_types) {
if (enum_val == nof_types) {
s1ap_log_print(LOG_LEVEL_ERROR, "The enum of type %s was not initialized.\n", enum_type);
} else {
s1ap_log_print(
LOG_LEVEL_ERROR, "The provided enum value=%d of type %s cannot be converted.\n", enum_val, enum_type);
}
return 0;
}
return array[enum_val];
}
/******************************************************************************* /*******************************************************************************
* Constant Definitions * Constant Definitions
@ -15505,8 +15487,8 @@ struct write_replace_warning_resp_s {
void to_json(json_writer& j) const; void to_json(json_writer& j) const;
}; };
// S1AP-ELEMENTARY-PROCEDURES-CLASS-1 ::= OBJECT SET OF S1AP-ELEMENTARY-PROCEDURE // S1AP-ELEMENTARY-PROCEDURES ::= OBJECT SET OF S1AP-ELEMENTARY-PROCEDURE
struct s1ap_elem_procs_class_minus1_o { struct s1ap_elem_procs_o {
// InitiatingMessage ::= OPEN TYPE // InitiatingMessage ::= OPEN TYPE
struct init_msg_c { struct init_msg_c {
struct types_opts { struct types_opts {
@ -15527,263 +15509,6 @@ struct s1ap_elem_procs_class_minus1_o {
enb_cfg_upd, enb_cfg_upd,
mme_cfg_upd, mme_cfg_upd,
write_replace_warning_request, write_replace_warning_request,
nulltype
} value;
typedef uint8_t number_type;
std::string to_string() const;
uint8_t to_number() const;
};
typedef enumerated<types_opts> types;
// choice methods
init_msg_c() = default;
init_msg_c(const init_msg_c& other);
init_msg_c& operator=(const init_msg_c& other);
~init_msg_c() { destroy_(); }
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
// getters
ho_required_s& ho_required();
ho_request_s& ho_request();
path_switch_request_s& path_switch_request();
erab_setup_request_s& erab_setup_request();
erab_modify_request_s& erab_modify_request();
erab_release_cmd_s& erab_release_cmd();
init_context_setup_request_s& init_context_setup_request();
ho_cancel_s& ho_cancel();
kill_request_s& kill_request();
reset_s& reset();
s1_setup_request_s& s1_setup_request();
ue_context_mod_request_s& ue_context_mod_request();
ue_context_release_cmd_s& ue_context_release_cmd();
enb_cfg_upd_s& enb_cfg_upd();
mme_cfg_upd_s& mme_cfg_upd();
write_replace_warning_request_s& write_replace_warning_request();
const ho_required_s& ho_required() const;
const ho_request_s& ho_request() const;
const path_switch_request_s& path_switch_request() const;
const erab_setup_request_s& erab_setup_request() const;
const erab_modify_request_s& erab_modify_request() const;
const erab_release_cmd_s& erab_release_cmd() const;
const init_context_setup_request_s& init_context_setup_request() const;
const ho_cancel_s& ho_cancel() const;
const kill_request_s& kill_request() const;
const reset_s& reset() const;
const s1_setup_request_s& s1_setup_request() const;
const ue_context_mod_request_s& ue_context_mod_request() const;
const ue_context_release_cmd_s& ue_context_release_cmd() const;
const enb_cfg_upd_s& enb_cfg_upd() const;
const mme_cfg_upd_s& mme_cfg_upd() const;
const write_replace_warning_request_s& write_replace_warning_request() const;
private:
types type_;
choice_buffer_t<enb_cfg_upd_s,
erab_modify_request_s,
erab_release_cmd_s,
erab_setup_request_s,
ho_cancel_s,
ho_request_s,
ho_required_s,
init_context_setup_request_s,
kill_request_s,
mme_cfg_upd_s,
path_switch_request_s,
reset_s,
s1_setup_request_s,
ue_context_mod_request_s,
ue_context_release_cmd_s,
write_replace_warning_request_s>
c;
void destroy_();
};
// SuccessfulOutcome ::= OPEN TYPE
struct successful_outcome_c {
struct types_opts {
enum options {
ho_required,
ho_request,
path_switch_request,
erab_setup_request,
erab_modify_request,
erab_release_cmd,
init_context_setup_request,
ho_cancel,
kill_request,
reset,
s1_setup_request,
ue_context_mod_request,
ue_context_release_cmd,
enb_cfg_upd,
mme_cfg_upd,
write_replace_warning_request,
nulltype
} value;
typedef uint8_t number_type;
std::string to_string() const;
uint8_t to_number() const;
};
typedef enumerated<types_opts> types;
// choice methods
successful_outcome_c() = default;
successful_outcome_c(const successful_outcome_c& other);
successful_outcome_c& operator=(const successful_outcome_c& other);
~successful_outcome_c() { destroy_(); }
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
// getters
ho_cmd_s& ho_required();
ho_request_ack_s& ho_request();
path_switch_request_ack_s& path_switch_request();
erab_setup_resp_s& erab_setup_request();
erab_modify_resp_s& erab_modify_request();
erab_release_resp_s& erab_release_cmd();
init_context_setup_resp_s& init_context_setup_request();
ho_cancel_ack_s& ho_cancel();
kill_resp_s& kill_request();
reset_ack_s& reset();
s1_setup_resp_s& s1_setup_request();
ue_context_mod_resp_s& ue_context_mod_request();
ue_context_release_complete_s& ue_context_release_cmd();
enb_cfg_upd_ack_s& enb_cfg_upd();
mme_cfg_upd_ack_s& mme_cfg_upd();
write_replace_warning_resp_s& write_replace_warning_request();
const ho_cmd_s& ho_required() const;
const ho_request_ack_s& ho_request() const;
const path_switch_request_ack_s& path_switch_request() const;
const erab_setup_resp_s& erab_setup_request() const;
const erab_modify_resp_s& erab_modify_request() const;
const erab_release_resp_s& erab_release_cmd() const;
const init_context_setup_resp_s& init_context_setup_request() const;
const ho_cancel_ack_s& ho_cancel() const;
const kill_resp_s& kill_request() const;
const reset_ack_s& reset() const;
const s1_setup_resp_s& s1_setup_request() const;
const ue_context_mod_resp_s& ue_context_mod_request() const;
const ue_context_release_complete_s& ue_context_release_cmd() const;
const enb_cfg_upd_ack_s& enb_cfg_upd() const;
const mme_cfg_upd_ack_s& mme_cfg_upd() const;
const write_replace_warning_resp_s& write_replace_warning_request() const;
private:
types type_;
choice_buffer_t<enb_cfg_upd_ack_s,
erab_modify_resp_s,
erab_release_resp_s,
erab_setup_resp_s,
ho_cancel_ack_s,
ho_cmd_s,
ho_request_ack_s,
init_context_setup_resp_s,
kill_resp_s,
mme_cfg_upd_ack_s,
path_switch_request_ack_s,
reset_ack_s,
s1_setup_resp_s,
ue_context_mod_resp_s,
ue_context_release_complete_s,
write_replace_warning_resp_s>
c;
void destroy_();
};
// UnsuccessfulOutcome ::= OPEN TYPE
struct unsuccessful_outcome_c {
struct types_opts {
enum options {
ho_required,
ho_request,
path_switch_request,
erab_setup_request,
erab_modify_request,
erab_release_cmd,
init_context_setup_request,
ho_cancel,
kill_request,
reset,
s1_setup_request,
ue_context_mod_request,
ue_context_release_cmd,
enb_cfg_upd,
mme_cfg_upd,
write_replace_warning_request,
nulltype
} value;
typedef uint8_t number_type;
std::string to_string() const;
uint8_t to_number() const;
};
typedef enumerated<types_opts> types;
// choice methods
unsuccessful_outcome_c() = default;
unsuccessful_outcome_c(const unsuccessful_outcome_c& other);
unsuccessful_outcome_c& operator=(const unsuccessful_outcome_c& other);
~unsuccessful_outcome_c() { destroy_(); }
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
// getters
ho_prep_fail_s& ho_required();
ho_fail_s& ho_request();
path_switch_request_fail_s& path_switch_request();
init_context_setup_fail_s& init_context_setup_request();
s1_setup_fail_s& s1_setup_request();
ue_context_mod_fail_s& ue_context_mod_request();
enb_cfg_upd_fail_s& enb_cfg_upd();
mme_cfg_upd_fail_s& mme_cfg_upd();
const ho_prep_fail_s& ho_required() const;
const ho_fail_s& ho_request() const;
const path_switch_request_fail_s& path_switch_request() const;
const init_context_setup_fail_s& init_context_setup_request() const;
const s1_setup_fail_s& s1_setup_request() const;
const ue_context_mod_fail_s& ue_context_mod_request() const;
const enb_cfg_upd_fail_s& enb_cfg_upd() const;
const mme_cfg_upd_fail_s& mme_cfg_upd() const;
private:
types type_;
choice_buffer_t<enb_cfg_upd_fail_s,
ho_fail_s,
ho_prep_fail_s,
init_context_setup_fail_s,
mme_cfg_upd_fail_s,
path_switch_request_fail_s,
s1_setup_fail_s,
ue_context_mod_fail_s>
c;
void destroy_();
};
// members lookup methods
static uint16_t idx_to_proc_code(uint32_t idx);
static bool is_proc_code_valid(const uint16_t& proc_code);
static init_msg_c get_init_msg(const uint16_t& proc_code);
static successful_outcome_c get_successful_outcome(const uint16_t& proc_code);
static unsuccessful_outcome_c get_unsuccessful_outcome(const uint16_t& proc_code);
static crit_e get_crit(const uint16_t& proc_code);
};
// S1AP-ELEMENTARY-PROCEDURES-CLASS-2 ::= OBJECT SET OF S1AP-ELEMENTARY-PROCEDURE
struct s1ap_elem_procs_class_minus2_o {
// InitiatingMessage ::= OPEN TYPE
struct init_msg_c {
struct types_opts {
enum options {
ho_notify, ho_notify,
erab_release_ind, erab_release_ind,
paging, paging,
@ -15830,6 +15555,22 @@ struct s1ap_elem_procs_class_minus2_o {
SRSASN_CODE unpack(cbit_ref& bref); SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const; void to_json(json_writer& j) const;
// getters // getters
ho_required_s& ho_required();
ho_request_s& ho_request();
path_switch_request_s& path_switch_request();
erab_setup_request_s& erab_setup_request();
erab_modify_request_s& erab_modify_request();
erab_release_cmd_s& erab_release_cmd();
init_context_setup_request_s& init_context_setup_request();
ho_cancel_s& ho_cancel();
kill_request_s& kill_request();
reset_s& reset();
s1_setup_request_s& s1_setup_request();
ue_context_mod_request_s& ue_context_mod_request();
ue_context_release_cmd_s& ue_context_release_cmd();
enb_cfg_upd_s& enb_cfg_upd();
mme_cfg_upd_s& mme_cfg_upd();
write_replace_warning_request_s& write_replace_warning_request();
ho_notify_s& ho_notify(); ho_notify_s& ho_notify();
erab_release_ind_s& erab_release_ind(); erab_release_ind_s& erab_release_ind();
paging_s& paging(); paging_s& paging();
@ -15858,6 +15599,22 @@ struct s1ap_elem_procs_class_minus2_o {
enb_cfg_transfer_s& enb_cfg_transfer(); enb_cfg_transfer_s& enb_cfg_transfer();
mme_cfg_transfer_s& mme_cfg_transfer(); mme_cfg_transfer_s& mme_cfg_transfer();
private_msg_s& private_msg(); private_msg_s& private_msg();
const ho_required_s& ho_required() const;
const ho_request_s& ho_request() const;
const path_switch_request_s& path_switch_request() const;
const erab_setup_request_s& erab_setup_request() const;
const erab_modify_request_s& erab_modify_request() const;
const erab_release_cmd_s& erab_release_cmd() const;
const init_context_setup_request_s& init_context_setup_request() const;
const ho_cancel_s& ho_cancel() const;
const kill_request_s& kill_request() const;
const reset_s& reset() const;
const s1_setup_request_s& s1_setup_request() const;
const ue_context_mod_request_s& ue_context_mod_request() const;
const ue_context_release_cmd_s& ue_context_release_cmd() const;
const enb_cfg_upd_s& enb_cfg_upd() const;
const mme_cfg_upd_s& mme_cfg_upd() const;
const write_replace_warning_request_s& write_replace_warning_request() const;
const ho_notify_s& ho_notify() const; const ho_notify_s& ho_notify() const;
const erab_release_ind_s& erab_release_ind() const; const erab_release_ind_s& erab_release_ind() const;
const paging_s& paging() const; const paging_s& paging() const;
@ -15894,334 +15651,33 @@ struct s1ap_elem_procs_class_minus2_o {
dl_nas_transport_s, dl_nas_transport_s,
dl_s1cdma2000tunnelling_s, dl_s1cdma2000tunnelling_s,
enb_cfg_transfer_s, enb_cfg_transfer_s,
enb_cfg_upd_s,
enb_direct_info_transfer_s, enb_direct_info_transfer_s,
enb_status_transfer_s, enb_status_transfer_s,
erab_modify_request_s,
erab_release_cmd_s,
erab_release_ind_s, erab_release_ind_s,
erab_setup_request_s,
error_ind_s, error_ind_s,
ho_cancel_s,
ho_notify_s, ho_notify_s,
ho_request_s,
ho_required_s,
init_context_setup_request_s,
init_ue_msg_s, init_ue_msg_s,
kill_request_s,
location_report_ctrl_s, location_report_ctrl_s,
location_report_fail_ind_s, location_report_fail_ind_s,
location_report_s, location_report_s,
mme_cfg_transfer_s, mme_cfg_transfer_s,
mme_cfg_upd_s,
mme_direct_info_transfer_s, mme_direct_info_transfer_s,
mme_status_transfer_s, mme_status_transfer_s,
nas_non_delivery_ind_s, nas_non_delivery_ind_s,
overload_start_s, overload_start_s,
overload_stop_s, overload_stop_s,
paging_s, paging_s,
private_msg_s, path_switch_request_s,
trace_fail_ind_s,
trace_start_s,
ue_cap_info_ind_s,
ue_context_release_request_s,
ul_nas_transport_s,
ul_s1cdma2000tunnelling_s>
c;
void destroy_();
};
// SuccessfulOutcome ::= OPEN TYPE
struct successful_outcome_c {
struct types_opts {
enum options {
ho_notify,
erab_release_ind,
paging,
dl_nas_transport,
init_ue_msg,
ul_nas_transport,
error_ind,
nas_non_delivery_ind,
ue_context_release_request,
dl_s1cdma2000tunnelling,
ul_s1cdma2000tunnelling,
ue_cap_info_ind,
enb_status_transfer,
mme_status_transfer,
deactiv_trace,
trace_start,
trace_fail_ind,
cell_traffic_trace,
location_report_ctrl,
location_report_fail_ind,
location_report,
overload_start,
overload_stop,
enb_direct_info_transfer,
mme_direct_info_transfer,
enb_cfg_transfer,
mme_cfg_transfer,
private_msg,
nulltype
} value;
std::string to_string() const;
};
typedef enumerated<types_opts> types;
// choice methods
successful_outcome_c() = default;
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
private:
types type_;
};
// UnsuccessfulOutcome ::= OPEN TYPE
struct unsuccessful_outcome_c {
struct types_opts {
enum options {
ho_notify,
erab_release_ind,
paging,
dl_nas_transport,
init_ue_msg,
ul_nas_transport,
error_ind,
nas_non_delivery_ind,
ue_context_release_request,
dl_s1cdma2000tunnelling,
ul_s1cdma2000tunnelling,
ue_cap_info_ind,
enb_status_transfer,
mme_status_transfer,
deactiv_trace,
trace_start,
trace_fail_ind,
cell_traffic_trace,
location_report_ctrl,
location_report_fail_ind,
location_report,
overload_start,
overload_stop,
enb_direct_info_transfer,
mme_direct_info_transfer,
enb_cfg_transfer,
mme_cfg_transfer,
private_msg,
nulltype
} value;
std::string to_string() const;
};
typedef enumerated<types_opts> types;
// choice methods
unsuccessful_outcome_c() = default;
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
private:
types type_;
};
// members lookup methods
static uint16_t idx_to_proc_code(uint32_t idx);
static bool is_proc_code_valid(const uint16_t& proc_code);
static init_msg_c get_init_msg(const uint16_t& proc_code);
static successful_outcome_c get_successful_outcome(const uint16_t& proc_code);
static unsuccessful_outcome_c get_unsuccessful_outcome(const uint16_t& proc_code);
static crit_e get_crit(const uint16_t& proc_code);
};
// S1AP-ELEMENTARY-PROCEDURES ::= OBJECT SET OF S1AP-ELEMENTARY-PROCEDURE
struct s1ap_elem_procs_o {
// InitiatingMessage ::= OPEN TYPE
struct init_msg_c {
struct types_opts {
enum options {
ho_required,
ho_request,
path_switch_request,
erab_setup_request,
erab_modify_request,
erab_release_cmd,
init_context_setup_request,
ho_cancel,
kill_request,
reset,
s1_setup_request,
ue_context_mod_request,
ue_context_release_cmd,
enb_cfg_upd,
mme_cfg_upd,
write_replace_warning_request,
ho_notify,
erab_release_ind,
paging,
dl_nas_transport,
init_ue_msg,
ul_nas_transport,
error_ind,
nas_non_delivery_ind,
ue_context_release_request,
dl_s1cdma2000tunnelling,
ul_s1cdma2000tunnelling,
ue_cap_info_ind,
enb_status_transfer,
mme_status_transfer,
deactiv_trace,
trace_start,
trace_fail_ind,
cell_traffic_trace,
location_report_ctrl,
location_report_fail_ind,
location_report,
overload_start,
overload_stop,
enb_direct_info_transfer,
mme_direct_info_transfer,
enb_cfg_transfer,
mme_cfg_transfer,
private_msg,
nulltype
} value;
std::string to_string() const;
};
typedef enumerated<types_opts> types;
// choice methods
init_msg_c() = default;
init_msg_c(const init_msg_c& other);
init_msg_c& operator=(const init_msg_c& other);
~init_msg_c() { destroy_(); }
void set(types::options e = types::nulltype);
types type() const { return type_; }
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
// getters
ho_required_s& ho_required();
ho_request_s& ho_request();
path_switch_request_s& path_switch_request();
erab_setup_request_s& erab_setup_request();
erab_modify_request_s& erab_modify_request();
erab_release_cmd_s& erab_release_cmd();
init_context_setup_request_s& init_context_setup_request();
ho_cancel_s& ho_cancel();
kill_request_s& kill_request();
reset_s& reset();
s1_setup_request_s& s1_setup_request();
ue_context_mod_request_s& ue_context_mod_request();
ue_context_release_cmd_s& ue_context_release_cmd();
enb_cfg_upd_s& enb_cfg_upd();
mme_cfg_upd_s& mme_cfg_upd();
write_replace_warning_request_s& write_replace_warning_request();
ho_notify_s& ho_notify();
erab_release_ind_s& erab_release_ind();
paging_s& paging();
dl_nas_transport_s& dl_nas_transport();
init_ue_msg_s& init_ue_msg();
ul_nas_transport_s& ul_nas_transport();
error_ind_s& error_ind();
nas_non_delivery_ind_s& nas_non_delivery_ind();
ue_context_release_request_s& ue_context_release_request();
dl_s1cdma2000tunnelling_s& dl_s1cdma2000tunnelling();
ul_s1cdma2000tunnelling_s& ul_s1cdma2000tunnelling();
ue_cap_info_ind_s& ue_cap_info_ind();
enb_status_transfer_s& enb_status_transfer();
mme_status_transfer_s& mme_status_transfer();
deactiv_trace_s& deactiv_trace();
trace_start_s& trace_start();
trace_fail_ind_s& trace_fail_ind();
cell_traffic_trace_s& cell_traffic_trace();
location_report_ctrl_s& location_report_ctrl();
location_report_fail_ind_s& location_report_fail_ind();
location_report_s& location_report();
overload_start_s& overload_start();
overload_stop_s& overload_stop();
enb_direct_info_transfer_s& enb_direct_info_transfer();
mme_direct_info_transfer_s& mme_direct_info_transfer();
enb_cfg_transfer_s& enb_cfg_transfer();
mme_cfg_transfer_s& mme_cfg_transfer();
private_msg_s& private_msg();
const ho_required_s& ho_required() const;
const ho_request_s& ho_request() const;
const path_switch_request_s& path_switch_request() const;
const erab_setup_request_s& erab_setup_request() const;
const erab_modify_request_s& erab_modify_request() const;
const erab_release_cmd_s& erab_release_cmd() const;
const init_context_setup_request_s& init_context_setup_request() const;
const ho_cancel_s& ho_cancel() const;
const kill_request_s& kill_request() const;
const reset_s& reset() const;
const s1_setup_request_s& s1_setup_request() const;
const ue_context_mod_request_s& ue_context_mod_request() const;
const ue_context_release_cmd_s& ue_context_release_cmd() const;
const enb_cfg_upd_s& enb_cfg_upd() const;
const mme_cfg_upd_s& mme_cfg_upd() const;
const write_replace_warning_request_s& write_replace_warning_request() const;
const ho_notify_s& ho_notify() const;
const erab_release_ind_s& erab_release_ind() const;
const paging_s& paging() const;
const dl_nas_transport_s& dl_nas_transport() const;
const init_ue_msg_s& init_ue_msg() const;
const ul_nas_transport_s& ul_nas_transport() const;
const error_ind_s& error_ind() const;
const nas_non_delivery_ind_s& nas_non_delivery_ind() const;
const ue_context_release_request_s& ue_context_release_request() const;
const dl_s1cdma2000tunnelling_s& dl_s1cdma2000tunnelling() const;
const ul_s1cdma2000tunnelling_s& ul_s1cdma2000tunnelling() const;
const ue_cap_info_ind_s& ue_cap_info_ind() const;
const enb_status_transfer_s& enb_status_transfer() const;
const mme_status_transfer_s& mme_status_transfer() const;
const deactiv_trace_s& deactiv_trace() const;
const trace_start_s& trace_start() const;
const trace_fail_ind_s& trace_fail_ind() const;
const cell_traffic_trace_s& cell_traffic_trace() const;
const location_report_ctrl_s& location_report_ctrl() const;
const location_report_fail_ind_s& location_report_fail_ind() const;
const location_report_s& location_report() const;
const overload_start_s& overload_start() const;
const overload_stop_s& overload_stop() const;
const enb_direct_info_transfer_s& enb_direct_info_transfer() const;
const mme_direct_info_transfer_s& mme_direct_info_transfer() const;
const enb_cfg_transfer_s& enb_cfg_transfer() const;
const mme_cfg_transfer_s& mme_cfg_transfer() const;
const private_msg_s& private_msg() const;
private:
types type_;
choice_buffer_t<cell_traffic_trace_s,
deactiv_trace_s,
dl_nas_transport_s,
dl_s1cdma2000tunnelling_s,
enb_cfg_transfer_s,
enb_cfg_upd_s,
enb_direct_info_transfer_s,
enb_status_transfer_s,
erab_modify_request_s,
erab_release_cmd_s,
erab_release_ind_s,
erab_setup_request_s,
error_ind_s,
ho_cancel_s,
ho_notify_s,
ho_request_s,
ho_required_s,
init_context_setup_request_s,
init_ue_msg_s,
kill_request_s,
location_report_ctrl_s,
location_report_fail_ind_s,
location_report_s,
mme_cfg_transfer_s,
mme_cfg_upd_s,
mme_direct_info_transfer_s,
mme_status_transfer_s,
nas_non_delivery_ind_s,
overload_start_s,
overload_stop_s,
paging_s,
path_switch_request_s,
private_msg_s, private_msg_s,
reset_s, reset_s,
s1_setup_request_s, s1_setup_request_s,
@ -16242,50 +15698,22 @@ struct s1ap_elem_procs_o {
struct successful_outcome_c { struct successful_outcome_c {
struct types_opts { struct types_opts {
enum options { enum options {
ho_required, ho_cmd,
ho_request, ho_request_ack,
path_switch_request, path_switch_request_ack,
erab_setup_request, erab_setup_resp,
erab_modify_request, erab_modify_resp,
erab_release_cmd, erab_release_resp,
init_context_setup_request, init_context_setup_resp,
ho_cancel, ho_cancel_ack,
kill_request, kill_resp,
reset, reset_ack,
s1_setup_request, s1_setup_resp,
ue_context_mod_request, ue_context_mod_resp,
ue_context_release_cmd, ue_context_release_complete,
enb_cfg_upd, enb_cfg_upd_ack,
mme_cfg_upd, mme_cfg_upd_ack,
write_replace_warning_request, write_replace_warning_resp,
ho_notify,
erab_release_ind,
paging,
dl_nas_transport,
init_ue_msg,
ul_nas_transport,
error_ind,
nas_non_delivery_ind,
ue_context_release_request,
dl_s1cdma2000tunnelling,
ul_s1cdma2000tunnelling,
ue_cap_info_ind,
enb_status_transfer,
mme_status_transfer,
deactiv_trace,
trace_start,
trace_fail_ind,
cell_traffic_trace,
location_report_ctrl,
location_report_fail_ind,
location_report,
overload_start,
overload_stop,
enb_direct_info_transfer,
mme_direct_info_transfer,
enb_cfg_transfer,
mme_cfg_transfer,
private_msg,
nulltype nulltype
} value; } value;
typedef uint8_t number_type; typedef uint8_t number_type;
@ -16306,38 +15734,38 @@ struct s1ap_elem_procs_o {
SRSASN_CODE unpack(cbit_ref& bref); SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const; void to_json(json_writer& j) const;
// getters // getters
ho_cmd_s& ho_required(); ho_cmd_s& ho_cmd();
ho_request_ack_s& ho_request(); ho_request_ack_s& ho_request_ack();
path_switch_request_ack_s& path_switch_request(); path_switch_request_ack_s& path_switch_request_ack();
erab_setup_resp_s& erab_setup_request(); erab_setup_resp_s& erab_setup_resp();
erab_modify_resp_s& erab_modify_request(); erab_modify_resp_s& erab_modify_resp();
erab_release_resp_s& erab_release_cmd(); erab_release_resp_s& erab_release_resp();
init_context_setup_resp_s& init_context_setup_request(); init_context_setup_resp_s& init_context_setup_resp();
ho_cancel_ack_s& ho_cancel(); ho_cancel_ack_s& ho_cancel_ack();
kill_resp_s& kill_request(); kill_resp_s& kill_resp();
reset_ack_s& reset(); reset_ack_s& reset_ack();
s1_setup_resp_s& s1_setup_request(); s1_setup_resp_s& s1_setup_resp();
ue_context_mod_resp_s& ue_context_mod_request(); ue_context_mod_resp_s& ue_context_mod_resp();
ue_context_release_complete_s& ue_context_release_cmd(); ue_context_release_complete_s& ue_context_release_complete();
enb_cfg_upd_ack_s& enb_cfg_upd(); enb_cfg_upd_ack_s& enb_cfg_upd_ack();
mme_cfg_upd_ack_s& mme_cfg_upd(); mme_cfg_upd_ack_s& mme_cfg_upd_ack();
write_replace_warning_resp_s& write_replace_warning_request(); write_replace_warning_resp_s& write_replace_warning_resp();
const ho_cmd_s& ho_required() const; const ho_cmd_s& ho_cmd() const;
const ho_request_ack_s& ho_request() const; const ho_request_ack_s& ho_request_ack() const;
const path_switch_request_ack_s& path_switch_request() const; const path_switch_request_ack_s& path_switch_request_ack() const;
const erab_setup_resp_s& erab_setup_request() const; const erab_setup_resp_s& erab_setup_resp() const;
const erab_modify_resp_s& erab_modify_request() const; const erab_modify_resp_s& erab_modify_resp() const;
const erab_release_resp_s& erab_release_cmd() const; const erab_release_resp_s& erab_release_resp() const;
const init_context_setup_resp_s& init_context_setup_request() const; const init_context_setup_resp_s& init_context_setup_resp() const;
const ho_cancel_ack_s& ho_cancel() const; const ho_cancel_ack_s& ho_cancel_ack() const;
const kill_resp_s& kill_request() const; const kill_resp_s& kill_resp() const;
const reset_ack_s& reset() const; const reset_ack_s& reset_ack() const;
const s1_setup_resp_s& s1_setup_request() const; const s1_setup_resp_s& s1_setup_resp() const;
const ue_context_mod_resp_s& ue_context_mod_request() const; const ue_context_mod_resp_s& ue_context_mod_resp() const;
const ue_context_release_complete_s& ue_context_release_cmd() const; const ue_context_release_complete_s& ue_context_release_complete() const;
const enb_cfg_upd_ack_s& enb_cfg_upd() const; const enb_cfg_upd_ack_s& enb_cfg_upd_ack() const;
const mme_cfg_upd_ack_s& mme_cfg_upd() const; const mme_cfg_upd_ack_s& mme_cfg_upd_ack() const;
const write_replace_warning_resp_s& write_replace_warning_request() const; const write_replace_warning_resp_s& write_replace_warning_resp() const;
private: private:
types type_; types type_;
@ -16365,50 +15793,14 @@ struct s1ap_elem_procs_o {
struct unsuccessful_outcome_c { struct unsuccessful_outcome_c {
struct types_opts { struct types_opts {
enum options { enum options {
ho_required, ho_prep_fail,
ho_request, ho_fail,
path_switch_request, path_switch_request_fail,
erab_setup_request, init_context_setup_fail,
erab_modify_request, s1_setup_fail,
erab_release_cmd, ue_context_mod_fail,
init_context_setup_request, enb_cfg_upd_fail,
ho_cancel, mme_cfg_upd_fail,
kill_request,
reset,
s1_setup_request,
ue_context_mod_request,
ue_context_release_cmd,
enb_cfg_upd,
mme_cfg_upd,
write_replace_warning_request,
ho_notify,
erab_release_ind,
paging,
dl_nas_transport,
init_ue_msg,
ul_nas_transport,
error_ind,
nas_non_delivery_ind,
ue_context_release_request,
dl_s1cdma2000tunnelling,
ul_s1cdma2000tunnelling,
ue_cap_info_ind,
enb_status_transfer,
mme_status_transfer,
deactiv_trace,
trace_start,
trace_fail_ind,
cell_traffic_trace,
location_report_ctrl,
location_report_fail_ind,
location_report,
overload_start,
overload_stop,
enb_direct_info_transfer,
mme_direct_info_transfer,
enb_cfg_transfer,
mme_cfg_transfer,
private_msg,
nulltype nulltype
} value; } value;
typedef uint8_t number_type; typedef uint8_t number_type;
@ -16429,22 +15821,22 @@ struct s1ap_elem_procs_o {
SRSASN_CODE unpack(cbit_ref& bref); SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const; void to_json(json_writer& j) const;
// getters // getters
ho_prep_fail_s& ho_required(); ho_prep_fail_s& ho_prep_fail();
ho_fail_s& ho_request(); ho_fail_s& ho_fail();
path_switch_request_fail_s& path_switch_request(); path_switch_request_fail_s& path_switch_request_fail();
init_context_setup_fail_s& init_context_setup_request(); init_context_setup_fail_s& init_context_setup_fail();
s1_setup_fail_s& s1_setup_request(); s1_setup_fail_s& s1_setup_fail();
ue_context_mod_fail_s& ue_context_mod_request(); ue_context_mod_fail_s& ue_context_mod_fail();
enb_cfg_upd_fail_s& enb_cfg_upd(); enb_cfg_upd_fail_s& enb_cfg_upd_fail();
mme_cfg_upd_fail_s& mme_cfg_upd(); mme_cfg_upd_fail_s& mme_cfg_upd_fail();
const ho_prep_fail_s& ho_required() const; const ho_prep_fail_s& ho_prep_fail() const;
const ho_fail_s& ho_request() const; const ho_fail_s& ho_fail() const;
const path_switch_request_fail_s& path_switch_request() const; const path_switch_request_fail_s& path_switch_request_fail() const;
const init_context_setup_fail_s& init_context_setup_request() const; const init_context_setup_fail_s& init_context_setup_fail() const;
const s1_setup_fail_s& s1_setup_request() const; const s1_setup_fail_s& s1_setup_fail() const;
const ue_context_mod_fail_s& ue_context_mod_request() const; const ue_context_mod_fail_s& ue_context_mod_fail() const;
const enb_cfg_upd_fail_s& enb_cfg_upd() const; const enb_cfg_upd_fail_s& enb_cfg_upd_fail() const;
const mme_cfg_upd_fail_s& mme_cfg_upd() const; const mme_cfg_upd_fail_s& mme_cfg_upd_fail() const;
private: private:
types type_; types type_;

@ -37,23 +37,23 @@ add_library(rrc_asn1 STATIC
) )
# Compile RRC ASN1 optimized for size # Compile RRC ASN1 optimized for size
target_compile_options(rrc_asn1 PRIVATE "-Os") target_compile_options(rrc_asn1 PRIVATE "-Os")
target_link_libraries(rrc_asn1 asn1_utils) target_link_libraries(rrc_asn1 asn1_utils srslte_common)
add_library(s1ap_asn1 STATIC add_library(s1ap_asn1 STATIC
s1ap_asn1.cc) s1ap_asn1.cc)
target_compile_options(s1ap_asn1 PRIVATE "-Os") target_compile_options(s1ap_asn1 PRIVATE "-Os")
target_link_libraries(s1ap_asn1 asn1_utils) target_link_libraries(s1ap_asn1 asn1_utils srslte_common)
if (ENABLE_5GNR) if (ENABLE_5GNR)
# RRC NR ASN1 # RRC NR ASN1
add_library(rrc_nr_asn1 STATIC rrc_nr_asn1.cc) add_library(rrc_nr_asn1 STATIC rrc_nr_asn1.cc)
target_compile_options(rrc_nr_asn1 PRIVATE "-Os") target_compile_options(rrc_nr_asn1 PRIVATE "-Os")
target_link_libraries(rrc_nr_asn1 asn1_utils) target_link_libraries(rrc_nr_asn1 asn1_utils srslte_common)
# NGAP ASN1 # NGAP ASN1
add_library(ngap_nr_asn1 STATIC ngap_nr_asn1.cc) add_library(ngap_nr_asn1 STATIC ngap_nr_asn1.cc)
target_compile_options(ngap_nr_asn1 PRIVATE "-Os") target_compile_options(ngap_nr_asn1 PRIVATE "-Os")
target_link_libraries(ngap_nr_asn1 asn1_utils) target_link_libraries(ngap_nr_asn1 asn1_utils srslte_common)
endif(ENABLE_5GNR) endif(ENABLE_5GNR)

@ -23,62 +23,9 @@
#include <cmath> #include <cmath>
#include <stdio.h> #include <stdio.h>
namespace asn1 { using srslte::logmap;
/************************
logging
************************/
// Global ASN1 Log
static srslte::log* asn1_log_ptr = nullptr;
// Demux of log level to respective log method
void srs_log_call(srslte::LOG_LEVEL_ENUM log_level, srslte::log* log_ptr, const char* str)
{
switch (log_level) {
case LOG_LEVEL_ERROR:
log_ptr->error("%s", str);
break;
case LOG_LEVEL_WARNING:
log_ptr->warning("%s", str);
break;
case LOG_LEVEL_INFO:
log_ptr->info("%s", str);
break;
case LOG_LEVEL_DEBUG:
log_ptr->debug("%s", str);
default:
break;
}
}
void vlog_print(srslte::log* log_ptr, srsasn_logger_level_t log_level, const char* format, va_list args) namespace asn1 {
{
if (log_ptr != nullptr) {
char* args_msg = nullptr;
if (vasprintf(&args_msg, format, args) > 0) {
srs_log_call(log_level, log_ptr, args_msg);
}
if (args_msg) {
free(args_msg);
}
} else {
vprintf(format, args);
}
}
void srsasn_log_register_handler(srslte::log* ctx)
{
asn1_log_ptr = ctx;
}
void srsasn_log_print(srslte::LOG_LEVEL_ENUM log_level, const char* format, ...)
{
va_list args;
va_start(args, format);
vlog_print(asn1_log_ptr, log_level, format, args);
va_end(args);
}
/************************ /************************
error handling error handling
@ -88,13 +35,13 @@ void log_error_code(SRSASN_CODE code, const char* filename, int line)
{ {
switch (code) { switch (code) {
case SRSASN_ERROR_ENCODE_FAIL: case SRSASN_ERROR_ENCODE_FAIL:
srsasn_log_print(LOG_LEVEL_ERROR, "[%s][%d] Encoding failure.\n", filename, line); logmap::get("ASN1")->error("[%s][%d] Encoding failure.\n", filename, line);
break; break;
case SRSASN_ERROR_DECODE_FAIL: case SRSASN_ERROR_DECODE_FAIL:
srsasn_log_print(LOG_LEVEL_ERROR, "[%s][%d] Decoding failure.\n", filename, line); logmap::get("ASN1")->error("[%s][%d] Decoding failure.\n", filename, line);
break; break;
default: default:
srsasn_log_print(LOG_LEVEL_WARNING, "[%s][%d] SRSASN_CODE=%d not recognized.\n", filename, line, (int)code); logmap::get("ASN1")->warning("[%s][%d] SRSASN_CODE=%d not recognized.\n", filename, line, (int)code);
} }
} }
@ -131,13 +78,13 @@ int bit_ref_impl<Ptr>::distance_bytes() const
SRSASN_CODE bit_ref::pack(uint32_t val, uint32_t n_bits) SRSASN_CODE bit_ref::pack(uint32_t val, uint32_t n_bits)
{ {
if (n_bits >= 32) { if (n_bits >= 32) {
srsasn_log_print(LOG_LEVEL_ERROR, "This method only supports packing up to 32 bits\n"); logmap::get("ASN1")->error("This method only supports packing up to 32 bits\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
uint32_t mask; uint32_t mask;
while (n_bits > 0) { while (n_bits > 0) {
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
mask = ((1u << n_bits) - 1u); mask = ((1u << n_bits) - 1u);
@ -163,13 +110,13 @@ template <typename T, typename Ptr>
SRSASN_CODE unpack_bits(T& val, Ptr& ptr, uint8_t& offset, const uint8_t* max_ptr, uint32_t n_bits) SRSASN_CODE unpack_bits(T& val, Ptr& ptr, uint8_t& offset, const uint8_t* max_ptr, uint32_t n_bits)
{ {
if (n_bits > sizeof(T) * 8) { if (n_bits > sizeof(T) * 8) {
srsasn_log_print(LOG_LEVEL_ERROR, "This method only supports unpacking up to %d bits\n", (int)sizeof(T) * 8); logmap::get("ASN1")->error("This method only supports unpacking up to %d bits\n", (int)sizeof(T) * 8);
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
val = 0; val = 0;
while (n_bits > 0) { while (n_bits > 0) {
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
if ((uint32_t)(8 - offset) > n_bits) { if ((uint32_t)(8 - offset) > n_bits) {
@ -231,7 +178,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::unpack_bytes(uint8_t* buf, uint32_t n_bytes)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
} }
if (ptr + n_bytes >= max_ptr) { if (ptr + n_bytes >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
if (offset == 0) { if (offset == 0) {
@ -252,7 +199,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::align_bytes()
if (offset == 0) if (offset == 0)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
offset = 0; offset = 0;
@ -268,7 +215,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::advance_bits(uint32_t n_bits)
uint32_t bytes_offset = floorf((offset + n_bits) / 8.0f); uint32_t bytes_offset = floorf((offset + n_bits) / 8.0f);
if (ptr + bytes_required >= max_ptr) { if (ptr + bytes_required >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
ptr += bytes_offset; ptr += bytes_offset;
@ -294,7 +241,7 @@ SRSASN_CODE bit_ref::pack_bytes(const uint8_t* buf, uint32_t n_bytes)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
} }
if (ptr + n_bytes >= max_ptr) { if (ptr + n_bytes >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
if (offset == 0) { if (offset == 0) {
@ -314,7 +261,7 @@ SRSASN_CODE bit_ref::align_bytes_zero()
if (offset == 0) if (offset == 0)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
srsasn_log_print(LOG_LEVEL_ERROR, "Buffer size limit was achieved\n"); logmap::get("ASN1")->error("Buffer size limit was achieved\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
uint8_t mask = (uint8_t)(256u - (1u << (8u - offset))); uint8_t mask = (uint8_t)(256u - (1u << (8u - offset)));
@ -332,7 +279,7 @@ SRSASN_CODE pack_unsupported_ext_flag(bit_ref& bref, bool ext)
{ {
HANDLE_CODE(bref.pack(ext, 1)); HANDLE_CODE(bref.pack(ext, 1));
if (ext) { if (ext) {
srsasn_log_print(LOG_LEVEL_ERROR, "asn1 error: ASN extensions not currently supported\n"); logmap::get("ASN1")->error("asn1 error: ASN extensions not currently supported\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
@ -342,7 +289,7 @@ SRSASN_CODE unpack_unsupported_ext_flag(bool& ext, bit_ref& bref)
{ {
SRSASN_CODE ret = bref.unpack(ext, 1); SRSASN_CODE ret = bref.unpack(ext, 1);
if (ext) { if (ext) {
srsasn_log_print(LOG_LEVEL_ERROR, "asn1 error: ASN extensions not currently supported\n"); logmap::get("ASN1")->error("asn1 error: ASN extensions not currently supported\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
return ret; return ret;
@ -375,10 +322,8 @@ SRSASN_CODE pack_enum(bit_ref& bref, uint32_t enum_val, uint32_t nbits, uint32_t
SRSASN_CODE pack_enum(bit_ref& bref, uint32_t e, uint32_t nof_types, uint32_t nof_exts, bool has_ext) SRSASN_CODE pack_enum(bit_ref& bref, uint32_t e, uint32_t nof_types, uint32_t nof_exts, bool has_ext)
{ {
if (e >= nof_types) { if (e >= nof_types) {
srsasn_log_print(LOG_LEVEL_ERROR, logmap::get("ASN1")->error(
"The provided enum is not within the range of possible values (%u>=%u)\n", "The provided enum is not within the range of possible values (%u>=%u)\n", (unsigned)e, (unsigned)nof_types);
(unsigned)e,
(unsigned)nof_types);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
SRSASN_CODE ret; SRSASN_CODE ret;
@ -413,8 +358,7 @@ ValOrError unpack_enum(uint32_t nof_types, uint32_t nof_exts, bool has_ext, cbit
ret.code = bref.unpack(ret.val, nof_bits); ret.code = bref.unpack(ret.val, nof_bits);
} }
if (ret.val >= nof_types) { if (ret.val >= nof_types) {
srsasn_log_print(LOG_LEVEL_ERROR, logmap::get("ASN1")->error("The provided enum is not within the range of possible values (%u>=%u)\n",
"The provided enum is not within the range of possible values (%u>=%u)\n",
(unsigned)ret.val, (unsigned)ret.val,
(unsigned)nof_types); (unsigned)nof_types);
ret.code = SRSASN_ERROR_DECODE_FAIL; ret.code = SRSASN_ERROR_DECODE_FAIL;
@ -440,8 +384,8 @@ template <class IntType>
SRSASN_CODE pack_constrained_whole_number(bit_ref& bref, IntType n, IntType lb, IntType ub, bool aligned) SRSASN_CODE pack_constrained_whole_number(bit_ref& bref, IntType n, IntType lb, IntType ub, bool aligned)
{ {
if (ub < lb or n < lb or n > ub) { if (ub < lb or n < lb or n > ub) {
srsasn_log_print( logmap::get("ASN1")->error(
LOG_LEVEL_ERROR, "The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub); "The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
uint64_t ra = (uint64_t)(ub - lb) + 1; // NOTE: Can overflow if IntType is kept uint64_t ra = (uint64_t)(ub - lb) + 1; // NOTE: Can overflow if IntType is kept
@ -509,7 +453,7 @@ template <class IntType>
SRSASN_CODE unpack_constrained_whole_number(IntType& n, cbit_ref& bref, IntType lb, IntType ub, bool aligned) SRSASN_CODE unpack_constrained_whole_number(IntType& n, cbit_ref& bref, IntType lb, IntType ub, bool aligned)
{ {
if (ub < lb) { if (ub < lb) {
srsasn_log_print(LOG_LEVEL_ERROR, "The condition lb <= ub (%ld <= %ld) was not met\n", (long)lb, (long)ub); logmap::get("ASN1")->error("The condition lb <= ub (%ld <= %ld) was not met\n", (long)lb, (long)ub);
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
uint64_t ra = (uint64_t)(ub - lb) + 1; // NOTE: Can overflow if IntType is kept. uint64_t ra = (uint64_t)(ub - lb) + 1; // NOTE: Can overflow if IntType is kept.
@ -523,11 +467,8 @@ SRSASN_CODE unpack_constrained_whole_number(IntType& n, cbit_ref& bref, IntType
HANDLE_CODE(bref.unpack(n, n_bits)); HANDLE_CODE(bref.unpack(n, n_bits));
n += lb; n += lb;
if (n > ub) { if (n > ub) {
srsasn_log_print(LOG_LEVEL_ERROR, logmap::get("ASN1")->error(
"The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", "The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub);
(long)lb,
(long)n,
(long)ub);
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
} else { } else {
@ -584,7 +525,7 @@ SRSASN_CODE pack_norm_small_non_neg_whole_number(bit_ref& bref, UintType n)
HANDLE_CODE(bref.pack(n, 7)); // [1 bit: 0 | 6 bit: n] HANDLE_CODE(bref.pack(n, 7)); // [1 bit: 0 | 6 bit: n]
} else { } else {
HANDLE_CODE(bref.pack(1, 1)); HANDLE_CODE(bref.pack(1, 1));
srsasn_log_print(LOG_LEVEL_ERROR, "Long small integers not supported\n"); logmap::get("ASN1")->error("Long small integers not supported\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
@ -598,7 +539,7 @@ SRSASN_CODE unpack_norm_small_non_neg_whole_number(UintType& n, cbit_ref& bref)
if (not ext) { if (not ext) {
ret = bref.unpack(n, 6); ret = bref.unpack(n, 6);
} else { } else {
srsasn_log_print(LOG_LEVEL_ERROR, "Long small integers not supported\n"); logmap::get("ASN1")->error("Long small integers not supported\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
return ret; return ret;
@ -717,7 +658,7 @@ SRSASN_CODE pack_length(bit_ref& bref, uint32_t val, bool aligned)
HANDLE_CODE(bref.pack(0b10, 2)); HANDLE_CODE(bref.pack(0b10, 2));
HANDLE_CODE(bref.pack(val, 14)); HANDLE_CODE(bref.pack(val, 14));
} else { } else {
srsasn_log_print(LOG_LEVEL_ERROR, "Not handling sizes longer than 16383 octets\n"); logmap::get("ASN1")->error("Not handling sizes longer than 16383 octets\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
} else { } else {
@ -756,7 +697,7 @@ SRSASN_CODE unpack_length(uint32_t& val, cbit_ref& bref, bool aligned)
if (not ext) { if (not ext) {
ret = bref.unpack(val, 14); ret = bref.unpack(val, 14);
} else { } else {
srsasn_log_print(LOG_LEVEL_ERROR, "Not handling octet strings longer than 16383 octets\n"); logmap::get("ASN1")->error("Not handling octet strings longer than 16383 octets\n");
val = 0; val = 0;
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
@ -796,7 +737,8 @@ SRSASN_CODE pack_integer(bit_ref& bref, IntType n, IntType lb, IntType ub, bool
if (has_ext) { if (has_ext) {
HANDLE_CODE(bref.pack(not within_bounds, 1)); HANDLE_CODE(bref.pack(not within_bounds, 1));
} else if (not within_bounds) { } else if (not within_bounds) {
srsasn_log_print(LOG_LEVEL_ERROR, "The condition lb <= n <= ub (%d <= %d <= %d) was not met\n", lb, n, ub); logmap::get("ASN1")->error(
"The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
bool lower_bounded = lb != std::numeric_limits<IntType>::min() or lb == 0; bool lower_bounded = lb != std::numeric_limits<IntType>::min() or lb == 0;
@ -946,7 +888,7 @@ template struct integer_packer<uint64_t>;
uint64_t octstring_to_number(const uint8_t* ptr, uint32_t nbytes) uint64_t octstring_to_number(const uint8_t* ptr, uint32_t nbytes)
{ {
if (nbytes > 8) { if (nbytes > 8) {
srsasn_log_print(LOG_LEVEL_ERROR, "octstring of size=%d does not fit in an uint64_t\n", nbytes); logmap::get("ASN1")->error("octstring of size=%d does not fit in an uint64_t\n", nbytes);
return 0; return 0;
} }
uint64_t val = 0; uint64_t val = 0;
@ -959,7 +901,7 @@ uint64_t octstring_to_number(const uint8_t* ptr, uint32_t nbytes)
void number_to_octstring(uint8_t* ptr, uint64_t number, uint32_t nbytes) void number_to_octstring(uint8_t* ptr, uint64_t number, uint32_t nbytes)
{ {
if (nbytes > 8) { if (nbytes > 8) {
srsasn_log_print(LOG_LEVEL_ERROR, "octstring of size=%d does not fit in an uint64_t\n", nbytes); logmap::get("ASN1")->error("octstring of size=%d does not fit in an uint64_t\n", nbytes);
return; return;
} }
for (uint32_t i = 0; i < nbytes; ++i) { for (uint32_t i = 0; i < nbytes; ++i) {
@ -988,12 +930,12 @@ std::string octstring_to_string(const uint8_t* ptr, uint32_t N)
void string_to_octstring(uint8_t* ptr, const std::string& str) void string_to_octstring(uint8_t* ptr, const std::string& str)
{ {
if (str.size() % 2 != 0) { if (str.size() % 2 != 0) {
srsasn_log_print(LOG_LEVEL_WARNING, "The provided hex string size=%zd is not a multiple of 2\n.", str.size()); logmap::get("ASN1")->warning("The provided hex string size=%zd is not a multiple of 2\n.", str.size());
} }
char cstr[] = "\0\0\0"; char cstr[] = "\0\0\0";
for (uint32_t i = 0; i < str.size(); i += 2) { for (uint32_t i = 0; i < str.size(); i += 2) {
memcpy(&cstr[0], &str[i], 2); memcpy(&cstr[0], &str[i], 2);
ptr[i / 2] = strtoul(cstr, NULL, 16); ptr[i / 2] = strtoul(cstr, nullptr, 16);
} }
} }
@ -1057,12 +999,12 @@ SRSASN_CODE pack_length_prefix(bit_ref& bref,
bool is_aligned = false) bool is_aligned = false)
{ {
if (has_ext and ub == std::numeric_limits<uint32_t>::max()) { if (has_ext and ub == std::numeric_limits<uint32_t>::max()) {
srsasn_log_print(LOG_LEVEL_ERROR, "has extension marker but it is an unbounded prefix size\n"); logmap::get("ASN1")->error("has extension marker but it is an unbounded prefix size\n");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
bool within_bounds = len >= lb and len <= ub; bool within_bounds = len >= lb and len <= ub;
if (not within_bounds and not has_ext) { if (not within_bounds and not has_ext) {
srsasn_log_print(LOG_LEVEL_ERROR, "bitstring length=%d is not within bounds [%d, %d]\n", len, lb, ub); logmap::get("ASN1")->error("bitstring length=%d is not within bounds [%d, %d]\n", len, lb, ub);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
@ -1093,7 +1035,7 @@ SRSASN_CODE pack_length_prefix(bit_ref& bref,
SRSASN_CODE pack_bitfield(bit_ref& bref, const uint8_t* buf, uint32_t nbits, uint32_t lb, uint32_t ub, bool is_aligned) SRSASN_CODE pack_bitfield(bit_ref& bref, const uint8_t* buf, uint32_t nbits, uint32_t lb, uint32_t ub, bool is_aligned)
{ {
if (nbits == 0) { if (nbits == 0) {
srsasn_log_print(LOG_LEVEL_ERROR, "Invalid bitstring size=%d\n", nbits); logmap::get("ASN1")->error("Invalid bitstring size=%d\n", nbits);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
if (is_aligned and (lb != ub or ub > 16)) { if (is_aligned and (lb != ub or ub > 16)) {
@ -1156,7 +1098,7 @@ SRSASN_CODE unpack_length_prefix(uint32_t& len, cbit_ref& bref, uint32_t lb, uin
SRSASN_CODE unpack_bitfield(uint8_t* buf, cbit_ref& bref, uint32_t n, uint32_t lb, uint32_t ub, bool is_aligned) SRSASN_CODE unpack_bitfield(uint8_t* buf, cbit_ref& bref, uint32_t n, uint32_t lb, uint32_t ub, bool is_aligned)
{ {
if (n > ASN_64K) { if (n > ASN_64K) {
srsasn_log_print(LOG_LEVEL_ERROR, "bitstrings longer than 64K not supported\n"); logmap::get("ASN1")->error("bitstrings longer than 64K not supported\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
if (n == 0) { if (n == 0) {
@ -1179,7 +1121,7 @@ SRSASN_CODE unpack_bitfield(uint8_t* buf, cbit_ref& bref, uint32_t n, uint32_t l
void from_number(uint8_t* ptr, uint64_t number, uint32_t nbits) void from_number(uint8_t* ptr, uint64_t number, uint32_t nbits)
{ {
if (nbits > 64) { if (nbits > 64) {
srsasn_log_print(LOG_LEVEL_ERROR, "bitstring of size=%d does not fit in an uint64_t\n", nbits); logmap::get("ASN1")->error("bitstring of size=%d does not fit in an uint64_t\n", nbits);
return; return;
} }
uint32_t nof_bytes = (uint32_t)ceilf(nbits / 8.0f); uint32_t nof_bytes = (uint32_t)ceilf(nbits / 8.0f);
@ -1204,7 +1146,7 @@ std::string to_string(const uint8_t* ptr, uint32_t nbits)
uint64_t to_number(const uint8_t* ptr, uint32_t nbits) uint64_t to_number(const uint8_t* ptr, uint32_t nbits)
{ {
if (nbits > 64) { if (nbits > 64) {
srsasn_log_print(LOG_LEVEL_ERROR, "bitstring of size=%d does not fit in an uint64_t\n", nbits); logmap::get("ASN1")->error("bitstring of size=%d does not fit in an uint64_t\n", nbits);
return 0; return 0;
} }
uint64_t val = 0; uint64_t val = 0;
@ -1222,11 +1164,11 @@ uint64_t to_number(const uint8_t* ptr, uint32_t nbits)
*********************/ *********************/
void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id) void log_invalid_access_choice_id(uint32_t val, uint32_t choice_id)
{ {
srsasn_log_print(LOG_LEVEL_ERROR, "The access choide id is invalid (%zd!=%zd)\n", (size_t)val, (size_t)choice_id); logmap::get("ASN1")->error("The access choide id is invalid (%zd!=%zd)\n", (size_t)val, (size_t)choice_id);
} }
void log_invalid_choice_id(uint32_t val, const char* choice_type) void log_invalid_choice_id(uint32_t val, const char* choice_type)
{ {
srsasn_log_print(LOG_LEVEL_ERROR, "Invalid choice id=%zd for choice type %s\n", (size_t)val, choice_type); logmap::get("ASN1")->error("Invalid choice id=%zd for choice type %s\n", (size_t)val, choice_type);
} }
/********************* /*********************
@ -1263,8 +1205,8 @@ pack(bit_ref& bref, const std::string& s, size_t lb, size_t ub, size_t alb, size
if (not within_limits) { if (not within_limits) {
// TODO: print error // TODO: print error
// NOTE: This should be valid for exts // NOTE: This should be valid for exts
srsasn_log_print( logmap::get("ASN1")->error(
LOG_LEVEL_ERROR, "The PrintableString size=%zd is not within the limits [%zd, %zd]\n", s.size(), alb, aub); "The PrintableString size=%zd is not within the limits [%zd, %zd]\n", s.size(), alb, aub);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
size_t b = asn_string_utils::get_nof_bits_per_char(lb, ub, aligned); size_t b = asn_string_utils::get_nof_bits_per_char(lb, ub, aligned);
@ -1301,7 +1243,7 @@ SRSASN_CODE unpack(std::string& s, cbit_ref& bref, size_t lb, size_t ub, size_t
bool is_ext; bool is_ext;
HANDLE_CODE(bref.unpack(is_ext, 1)); HANDLE_CODE(bref.unpack(is_ext, 1));
if (is_ext) { if (is_ext) {
srsasn_log_print(LOG_LEVEL_ERROR, "Extension of PrintableString not supported\n"); logmap::get("ASN1")->error("Extension of PrintableString not supported\n");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
} }
@ -1424,8 +1366,7 @@ varlength_field_pack_guard::~varlength_field_pack_guard()
// check how many bytes were written in total // check how many bytes were written in total
uint32_t nof_bytes = bref_tracker->distance(bref0) / (uint32_t)8; uint32_t nof_bytes = bref_tracker->distance(bref0) / (uint32_t)8;
if (nof_bytes > sizeof(buffer)) { if (nof_bytes > sizeof(buffer)) {
srsasn_log_print(LOG_LEVEL_ERROR, logmap::get("ASN1")->error("The packed variable sized field is too long for the reserved buffer (%zd > %zd)\n",
"The packed variable sized field is too long for the reserved buffer (%zd > %zd)\n",
(size_t)nof_bytes, (size_t)nof_bytes,
sizeof(buffer)); sizeof(buffer));
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -152,8 +152,7 @@ srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_t
if (asn1_type.srb_id <= 2) { if (asn1_type.srb_id <= 2) {
return rlc_config_t::srb_config(asn1_type.srb_id); return rlc_config_t::srb_config(asn1_type.srb_id);
} else { } else {
asn1::rrc::rrc_log_print( srslte::logmap::get("ASN1::RRC")->error("SRB %d does not support default initialization type\n", asn1_type.srb_id);
asn1::LOG_LEVEL_ERROR, "SRB %d does not support default initialization type\n", asn1_type.srb_id);
return rlc_config_t(); return rlc_config_t();
} }
} }
@ -352,7 +351,7 @@ srsenb::sched_interface::ant_info_ded_t make_ant_info_ded(const asn1::rrc::ant_i
ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm6().to_number(); ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm6().to_number();
break; break;
default: default:
asn1::rrc::rrc_log_print(LOG_LEVEL_ERROR, "Failed to convert antenna codebook type to number\n"); srslte::logmap::get("ASN1::RRC")->error("Failed to convert antenna codebook type to number\n");
} }
} }
ant_ded.ue_tx_ant_sel = srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::release; ant_ded.ue_tx_ant_sel = srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::release;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -133,8 +133,8 @@ int test_ngsetup_response()
TESTASSERT(pdu.successful_outcome().proc_code == 21); TESTASSERT(pdu.successful_outcome().proc_code == 21);
TESTASSERT(pdu.successful_outcome().crit.value == crit_opts::reject); TESTASSERT(pdu.successful_outcome().crit.value == crit_opts::reject);
TESTASSERT(pdu.successful_outcome().value.type().value == TESTASSERT(pdu.successful_outcome().value.type().value ==
ngap_elem_procs_o::successful_outcome_c::types_opts::ng_setup_request); // FIXME: Change name ngap_elem_procs_o::successful_outcome_c::types_opts::ng_setup_resp); // FIXME: Change name
ng_setup_resp_s& resp = pdu.successful_outcome().value.ng_setup_request(); ng_setup_resp_s& resp = pdu.successful_outcome().value.ng_setup_resp();
// field 0 // field 0
TESTASSERT(resp.protocol_ies.amf_name.id == 1); TESTASSERT(resp.protocol_ies.amf_name.id == 1);
TESTASSERT(resp.protocol_ies.amf_name.crit.value == crit_opts::reject); TESTASSERT(resp.protocol_ies.amf_name.crit.value == crit_opts::reject);
@ -288,7 +288,7 @@ int test_ue_context_release_complete()
TESTASSERT(pdu.successful_outcome().proc_code == 41); TESTASSERT(pdu.successful_outcome().proc_code == 41);
TESTASSERT(pdu.successful_outcome().crit.value == crit_opts::reject); TESTASSERT(pdu.successful_outcome().crit.value == crit_opts::reject);
TESTASSERT(pdu.successful_outcome().value.type().value == TESTASSERT(pdu.successful_outcome().value.type().value ==
ngap_elem_procs_o::successful_outcome_c::types_opts::ue_context_release_cmd); ngap_elem_procs_o::successful_outcome_c::types_opts::ue_context_release_complete);
TESTASSERT(ceil(bref.distance(ngap_msg) / 8.0) == sizeof(ngap_msg)); TESTASSERT(ceil(bref.distance(ngap_msg) / 8.0) == sizeof(ngap_msg));
TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS); TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS);
@ -345,9 +345,7 @@ int test_session_res_setup_request()
int main() int main()
{ {
srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
srsasn_log_register_handler(srslte::logmap::get("ASN1").get());
ngap_nr_log_register_handler(srslte::logmap::get("NGAP").get());
TESTASSERT(test_amf_upd() == 0); TESTASSERT(test_amf_upd() == 0);
TESTASSERT(test_ngsetup_request() == 0); TESTASSERT(test_ngsetup_request() == 0);

@ -36,15 +36,12 @@ int test_generic()
// test logger handler // test logger handler
{ {
srslte::nullsink_log null_log("NULL"); srslte::scoped_log<srslte::nullsink_log> null_log("ASN1::RRC");
null_log.set_level(LOG_LEVEL_INFO); null_log->set_level(srslte::LOG_LEVEL_INFO);
rrc_log_register_handler(&null_log); srslte::logmap::get("ASN1::RRC")->info("This is a console test to see if the RRC logger is working fine\n");
std::string test_str = "This is a console test to see if the RRC logger is working fine\n"; TESTASSERT(null_log->last_log_msg == "This is a console test to see if the RRC logger is working fine\n");
rrc_log_print(LOG_LEVEL_INFO, test_str.c_str()); TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_INFO);
TESTASSERT(null_log.last_log_msg == test_str);
TESTASSERT(null_log.last_log_level == LOG_LEVEL_INFO);
// go back to original logger // go back to original logger
rrc_log_register_handler(srslte::logmap::get("RRC ").get());
} }
// Test deep copy of choice types // Test deep copy of choice types
@ -599,9 +596,7 @@ int test_rrc_conn_reconf_r15_2()
int main() int main()
{ {
srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
srsasn_log_register_handler(srslte::logmap::get("ASN1").get());
rrc_log_register_handler(srslte::logmap::get("RRC ").get());
TESTASSERT(test_generic() == 0); TESTASSERT(test_generic() == 0);
TESTASSERT(test_json_printer() == 0); TESTASSERT(test_json_printer() == 0);

@ -0,0 +1,152 @@
/*
Copyright 2013-2019 Software Radio Systems Limited
This file is part of srsLTE
srsLTE is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
srsLTE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
A copy of the GNU Affero General Public License can be found in
the LICENSE file in the top-level directory of this distribution
and at http://www.gnu.org/licenses/.
*/
#include "srslte/asn1/s1ap_asn1.h"
#include "srslte/common/test_common.h"
using namespace asn1;
using namespace asn1::s1ap;
/* TESTS */
int test_s1setup_request()
{
uint8_t ngap_msg[] = {0x00, 0x11, 0x00, 0x2d, 0x00, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x08, 0x00, 0x09,
0xf1, 0x07, 0x00, 0x00, 0x19, 0xb0, 0x00, 0x3c, 0x40, 0x0a, 0x03, 0x80, 0x65,
0x6e, 0x62, 0x30, 0x30, 0x31, 0x39, 0x62, 0x00, 0x40, 0x00, 0x07, 0x00, 0x00,
0x01, 0xc0, 0x09, 0xf1, 0x07, 0x00, 0x89, 0x40, 0x01, 0x40};
cbit_ref bref(&ngap_msg[0], sizeof(ngap_msg));
// 0011002D000004003B00080009F107000019B0003C400A0380656E62303031396200400007000001C009F1070089400140
s1ap_pdu_c pdu;
TESTASSERT(pdu.unpack(bref) == SRSASN_SUCCESS);
TESTASSERT(pdu.type().value == s1ap_pdu_c::types_opts::init_msg);
TESTASSERT(pdu.init_msg().proc_code == 17);
TESTASSERT(pdu.init_msg().crit.value == crit_opts::reject);
s1ap_elem_procs_o::init_msg_c& init_choice = pdu.init_msg().value;
TESTASSERT(init_choice.type().value == s1ap_elem_procs_o::init_msg_c::types_opts::s1_setup_request);
s1_setup_request_s& s1req = init_choice.s1_setup_request();
TESTASSERT(not s1req.ext);
TESTASSERT(s1req.protocol_ies.global_enb_id.id == ASN1_S1AP_ID_GLOBAL_ENB_ID);
TESTASSERT(s1req.protocol_ies.global_enb_id.crit.value == crit_opts::reject);
TESTASSERT(s1req.protocol_ies.global_enb_id.value.enb_id.type().value == enb_id_c::types_opts::macro_enb_id);
TESTASSERT(s1req.protocol_ies.global_enb_id.value.enb_id.macro_enb_id().to_number() == 0x0019B);
//
// // json_writer js;
// // pdu.to_json(js);
// // printf("PDU json: %s\n", js.to_string().c_str());
TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS);
return 0;
}
int test_init_ctxt_setup_req()
{
uint8_t s1ap_msg[] = {
0x00, 0x09, 0x00, 0x80, 0xc6, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x64, 0x00, 0x08, 0x00, 0x02, 0x00,
0x01, 0x00, 0x42, 0x00, 0x0a, 0x18, 0x3b, 0x9a, 0xca, 0x00, 0x60, 0x3b, 0x9a, 0xca, 0x00, 0x00, 0x18, 0x00, 0x78,
0x00, 0x00, 0x34, 0x00, 0x73, 0x45, 0x00, 0x09, 0x3c, 0x0f, 0x80, 0x0a, 0x00, 0x21, 0xf0, 0xb7, 0x36, 0x1c, 0x56,
0x64, 0x27, 0x3e, 0x5b, 0x04, 0xb7, 0x02, 0x07, 0x42, 0x02, 0x3e, 0x06, 0x00, 0x09, 0xf1, 0x07, 0x00, 0x07, 0x00,
0x37, 0x52, 0x66, 0xc1, 0x01, 0x09, 0x1b, 0x07, 0x74, 0x65, 0x73, 0x74, 0x31, 0x32, 0x33, 0x06, 0x6d, 0x6e, 0x63,
0x30, 0x37, 0x30, 0x06, 0x6d, 0x63, 0x63, 0x39, 0x30, 0x31, 0x04, 0x67, 0x70, 0x72, 0x73, 0x05, 0x01, 0xc0, 0xa8,
0x03, 0x02, 0x27, 0x0e, 0x80, 0x80, 0x21, 0x0a, 0x03, 0x00, 0x00, 0x0a, 0x81, 0x06, 0x08, 0x08, 0x08, 0x08, 0x50,
0x0b, 0xf6, 0x09, 0xf1, 0x07, 0x80, 0x01, 0x01, 0xf6, 0x7e, 0x72, 0x69, 0x13, 0x09, 0xf1, 0x07, 0x00, 0x01, 0x23,
0x05, 0xf4, 0xf6, 0x7e, 0x72, 0x69, 0x00, 0x6b, 0x00, 0x05, 0x18, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x49, 0x00, 0x20,
0x45, 0x25, 0xe4, 0x9a, 0x77, 0xc8, 0xd5, 0xcf, 0x26, 0x33, 0x63, 0xeb, 0x5b, 0xb9, 0xc3, 0x43, 0x9b, 0x9e, 0xb3,
0x86, 0x1f, 0xa8, 0xa7, 0xcf, 0x43, 0x54, 0x07, 0xae, 0x42, 0x2b, 0x63, 0xb9};
// 00090080c60000060000000200640008000200010042000a183b9aca00603b9aca000018007800003400734500093c0f800a0021f0b7361c5664273e5b04b7020742023e060009f107000700375266c101091b0774657374313233066d6e63303730066d636339303104677072730501c0a80302270e8080210a0300000a810608080808500bf609f107800101f67e72691309f10700012305f4f67e7269006b000518000c0000004900204525e49a77c8d5cf263363eb5bb9c3439b9eb3861fa8a7cf435407ae422b63b9
cbit_ref bref(&s1ap_msg[0], sizeof(s1ap_msg));
s1ap_pdu_c pdu;
TESTASSERT(pdu.unpack(bref) == SRSASN_SUCCESS);
TESTASSERT(pdu.type().value == s1ap_pdu_c::types_opts::init_msg);
TESTASSERT(pdu.init_msg().proc_code == 9);
TESTASSERT(pdu.init_msg().crit.value == crit_opts::reject);
s1ap_elem_procs_o::init_msg_c& init_choice = pdu.init_msg().value;
auto& ctxt_setup = init_choice.init_context_setup_request().protocol_ies;
TESTASSERT(ctxt_setup.ue_security_cap.id == 107);
TESTASSERT(ctxt_setup.ue_security_cap.value.encryption_algorithms.to_string() == "1100000000000000");
TESTASSERT(ctxt_setup.ue_security_cap.value.integrity_protection_algorithms.to_string() == "1100000000000000");
TESTASSERT(test_pack_unpack_consistency(pdu) == SRSASN_SUCCESS);
return SRSLTE_SUCCESS;
}
template <typename T, typename U>
bool is_same_type(U& u)
{
return std::is_same<T, U>::value;
}
int test_proc_id_consistency()
{
s1ap_pdu_c pdu;
/* Check IDs */
TESTASSERT(ASN1_S1AP_ID_HO_PREP == 0);
TESTASSERT(ASN1_S1AP_ID_HO_RES_ALLOC == 1);
TESTASSERT(ASN1_S1AP_ID_ERAB_SETUP == 5);
TESTASSERT(ASN1_S1AP_ID_INIT_CONTEXT_SETUP == 9);
/* Unsuccessful case */
unsuccessful_outcome_s& unsuc = pdu.set_unsuccessful_outcome();
// HandoverPreparation
TESTASSERT(unsuc.load_info_obj(ASN1_S1AP_ID_HO_PREP));
TESTASSERT(unsuc.proc_code == ASN1_S1AP_ID_HO_PREP);
TESTASSERT(unsuc.crit.value == crit_opts::reject);
TESTASSERT(unsuc.value.type().value == s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ho_prep_fail);
TESTASSERT(is_same_type<ho_prep_fail_s>(unsuc.value.ho_prep_fail()));
// HandoverResourceAllocation
TESTASSERT(unsuc.load_info_obj(ASN1_S1AP_ID_HO_RES_ALLOC));
TESTASSERT(unsuc.proc_code == ASN1_S1AP_ID_HO_RES_ALLOC);
TESTASSERT(unsuc.crit.value == crit_opts::reject);
TESTASSERT(unsuc.value.type().value == s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ho_fail);
TESTASSERT(is_same_type<ho_fail_s>(unsuc.value.ho_fail()));
// e-RABSetup (No Unsuccessful Outcome)
{
srslte::scoped_log<srslte::nullsink_log> sink("ASN1::S1AP");
TESTASSERT(not unsuc.load_info_obj(ASN1_S1AP_ID_ERAB_SETUP));
TESTASSERT(sink->error_counter == 1);
}
// initialContextSetup
TESTASSERT(unsuc.load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP));
TESTASSERT(unsuc.proc_code == ASN1_S1AP_ID_INIT_CONTEXT_SETUP);
TESTASSERT(unsuc.crit.value == crit_opts::reject);
TESTASSERT(is_same_type<init_context_setup_fail_s>(unsuc.value.init_context_setup_fail()));
return SRSLTE_SUCCESS;
}
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
TESTASSERT(srslte::logmap::get("ASN1")->get_level() == srslte::LOG_LEVEL_DEBUG);
TESTASSERT(test_s1setup_request() == 0);
TESTASSERT(test_init_ctxt_setup_req() == 0);
TESTASSERT(test_proc_id_consistency() == 0);
printf("Success\n");
return 0;
}

@ -61,7 +61,7 @@ int test_initial_ctxt_setup_response()
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP); tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP);
// Fill in the MME and eNB IDs // Fill in the MME and eNB IDs
auto& container = tx_pdu.successful_outcome().value.init_context_setup_request().protocol_ies; auto& container = tx_pdu.successful_outcome().value.init_context_setup_resp().protocol_ies;
container.mme_ue_s1ap_id.value = 1; container.mme_ue_s1ap_id.value = 1;
container.enb_ue_s1ap_id.value = 1; container.enb_ue_s1ap_id.value = 1;
@ -133,7 +133,7 @@ int test_eci_pack()
int main() int main()
{ {
srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
srslte::logmap::set_default_hex_limit(1024); srslte::logmap::set_default_hex_limit(1024);
TESTASSERT(unpack_test_served_gummeis_with_multiple_plmns() == SRSLTE_SUCCESS); TESTASSERT(unpack_test_served_gummeis_with_multiple_plmns() == SRSLTE_SUCCESS);

@ -153,7 +153,6 @@ private:
srslte::log_filter s1ap_log; srslte::log_filter s1ap_log;
srslte::log_filter gtpu_log; srslte::log_filter gtpu_log;
srslte::log_filter stack_log; srslte::log_filter stack_log;
srslte::log_filter asn1_log, rrc_asn1_log;
// RAT-specific interfaces // RAT-specific interfaces
phy_interface_stack_lte* phy = nullptr; phy_interface_stack_lte* phy = nullptr;

@ -78,8 +78,6 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
gtpu_log.init("GTPU", logger); gtpu_log.init("GTPU", logger);
s1ap_log.init("S1AP", logger); s1ap_log.init("S1AP", logger);
stack_log.init("STACK", logger); stack_log.init("STACK", logger);
asn1_log.init("ASN1", logger);
rrc_asn1_log.init("ASN1::RRC", logger);
// Init logs // Init logs
mac_log.set_level(args.log.mac_level); mac_log.set_level(args.log.mac_level);
@ -89,8 +87,6 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
gtpu_log.set_level(args.log.gtpu_level); gtpu_log.set_level(args.log.gtpu_level);
s1ap_log.set_level(args.log.s1ap_level); s1ap_log.set_level(args.log.s1ap_level);
stack_log.set_level(LOG_LEVEL_INFO); stack_log.set_level(LOG_LEVEL_INFO);
asn1_log.set_level(LOG_LEVEL_INFO);
rrc_asn1_log.set_level(args.log.rrc_level);
mac_log.set_hex_limit(args.log.mac_hex_limit); mac_log.set_hex_limit(args.log.mac_hex_limit);
rlc_log.set_hex_limit(args.log.rlc_hex_limit); rlc_log.set_hex_limit(args.log.rlc_hex_limit);
@ -99,10 +95,6 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
gtpu_log.set_hex_limit(args.log.gtpu_hex_limit); gtpu_log.set_hex_limit(args.log.gtpu_hex_limit);
s1ap_log.set_hex_limit(args.log.s1ap_hex_limit); s1ap_log.set_hex_limit(args.log.s1ap_hex_limit);
stack_log.set_hex_limit(128); stack_log.set_hex_limit(128);
asn1_log.set_hex_limit(128);
asn1::srsasn_log_register_handler(&asn1_log);
rrc_asn1_log.set_hex_limit(args.log.rrc_hex_limit);
asn1::rrc::rrc_log_register_handler(&rrc_log);
// Set up pcap and trace // Set up pcap and trace
if (args.pcap.enable) { if (args.pcap.enable) {

@ -571,10 +571,10 @@ bool s1ap::handle_initiatingmessage(const init_msg_s& msg)
bool s1ap::handle_successfuloutcome(const successful_outcome_s& msg) bool s1ap::handle_successfuloutcome(const successful_outcome_s& msg)
{ {
switch (msg.value.type().value) { switch (msg.value.type().value) {
case s1ap_elem_procs_o::successful_outcome_c::types_opts::s1_setup_request: case s1ap_elem_procs_o::successful_outcome_c::types_opts::s1_setup_resp:
return handle_s1setupresponse(msg.value.s1_setup_request()); return handle_s1setupresponse(msg.value.s1_setup_resp());
case s1ap_elem_procs_o::successful_outcome_c::types_opts::ho_required: case s1ap_elem_procs_o::successful_outcome_c::types_opts::ho_cmd:
return handle_s1hocommand(msg.value.ho_required()); return handle_s1hocommand(msg.value.ho_cmd());
default: default:
s1ap_log->error("Unhandled successful outcome message: %s\n", msg.value.type().to_string().c_str()); s1ap_log->error("Unhandled successful outcome message: %s\n", msg.value.type().to_string().c_str());
} }
@ -584,10 +584,10 @@ bool s1ap::handle_successfuloutcome(const successful_outcome_s& msg)
bool s1ap::handle_unsuccessfuloutcome(const unsuccessful_outcome_s& msg) bool s1ap::handle_unsuccessfuloutcome(const unsuccessful_outcome_s& msg)
{ {
switch (msg.value.type().value) { switch (msg.value.type().value) {
case s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::s1_setup_request: case s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::s1_setup_fail:
return handle_s1setupfailure(msg.value.s1_setup_request()); return handle_s1setupfailure(msg.value.s1_setup_fail());
case s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ho_required: case s1ap_elem_procs_o::unsuccessful_outcome_c::types_opts::ho_prep_fail:
return handle_hopreparationfailure(msg.value.ho_required()); return handle_hopreparationfailure(msg.value.ho_prep_fail());
default: default:
s1ap_log->error("Unhandled unsuccessful outcome message: %s\n", msg.value.type().to_string().c_str()); s1ap_log->error("Unhandled unsuccessful outcome message: %s\n", msg.value.type().to_string().c_str());
} }
@ -906,7 +906,7 @@ bool s1ap::ue::send_uectxtreleasecomplete()
s1ap_pdu_c tx_pdu; s1ap_pdu_c tx_pdu;
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_RELEASE); tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_RELEASE);
auto& container = tx_pdu.successful_outcome().value.ue_context_release_cmd().protocol_ies; auto& container = tx_pdu.successful_outcome().value.ue_context_release_complete().protocol_ies;
container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id;
container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id;
@ -923,10 +923,10 @@ bool s1ap::ue::send_initial_ctxt_setup_response(const asn1::s1ap::init_context_s
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP); tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP);
// Copy in the provided response message // Copy in the provided response message
tx_pdu.successful_outcome().value.init_context_setup_request() = res_; tx_pdu.successful_outcome().value.init_context_setup_resp() = res_;
// Fill in the MME and eNB IDs // Fill in the MME and eNB IDs
auto& container = tx_pdu.successful_outcome().value.init_context_setup_request().protocol_ies; auto& container = tx_pdu.successful_outcome().value.init_context_setup_resp().protocol_ies;
container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id;
container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id;
@ -952,7 +952,7 @@ bool s1ap::ue::send_erab_setup_response(const erab_setup_resp_s& res_)
asn1::s1ap::s1ap_pdu_c tx_pdu; asn1::s1ap::s1ap_pdu_c tx_pdu;
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_ERAB_SETUP); tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_ERAB_SETUP);
erab_setup_resp_s& res = tx_pdu.successful_outcome().value.erab_setup_request(); erab_setup_resp_s& res = tx_pdu.successful_outcome().value.erab_setup_resp();
res = res_; res = res_;
@ -984,7 +984,7 @@ bool s1ap::ue::send_initial_ctxt_setup_failure()
s1ap_pdu_c tx_pdu; s1ap_pdu_c tx_pdu;
tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP); tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_INIT_CONTEXT_SETUP);
auto& container = tx_pdu.unsuccessful_outcome().value.init_context_setup_request().protocol_ies; auto& container = tx_pdu.unsuccessful_outcome().value.init_context_setup_fail().protocol_ies;
container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id;
container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id;
@ -1001,7 +1001,7 @@ bool s1ap::ue::send_uectxtmodifyresp()
s1ap_pdu_c tx_pdu; s1ap_pdu_c tx_pdu;
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD); tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD);
auto& container = tx_pdu.successful_outcome().value.ue_context_mod_request().protocol_ies; auto& container = tx_pdu.successful_outcome().value.ue_context_mod_resp().protocol_ies;
container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id;
container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id;
@ -1017,7 +1017,7 @@ bool s1ap::ue::send_uectxtmodifyfailure(const cause_c& cause)
s1ap_pdu_c tx_pdu; s1ap_pdu_c tx_pdu;
tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD); tx_pdu.set_unsuccessful_outcome().load_info_obj(ASN1_S1AP_ID_UE_CONTEXT_MOD);
auto& container = tx_pdu.unsuccessful_outcome().value.ue_context_mod_request().protocol_ies; auto& container = tx_pdu.unsuccessful_outcome().value.ue_context_mod_fail().protocol_ies;
container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id; container.enb_ue_s1ap_id.value = ctxt.enb_ue_s1ap_id;
container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id; container.mme_ue_s1ap_id.value = ctxt.mme_ue_s1ap_id;

@ -145,8 +145,6 @@ private:
srslte::log_filter rrc_log; srslte::log_filter rrc_log;
srslte::log_filter usim_log; srslte::log_filter usim_log;
srslte::log_filter pool_log; srslte::log_filter pool_log;
srslte::log_filter asn1_log;
srslte::log_filter rrc_asn1_log;
// stack components // stack components
srsue::mac mac; srsue::mac mac;

@ -88,8 +88,6 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
pdcp_log.init("PDCP", logger); pdcp_log.init("PDCP", logger);
rrc_log.init("RRC ", logger); rrc_log.init("RRC ", logger);
usim_log.init("USIM", logger); usim_log.init("USIM", logger);
asn1_log.init("ASN1", logger);
rrc_asn1_log.init("ASN1::RRC", logger);
pool_log.init("POOL", logger); pool_log.init("POOL", logger);
pool_log.set_level(srslte::LOG_LEVEL_ERROR); pool_log.set_level(srslte::LOG_LEVEL_ERROR);
@ -100,18 +98,12 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
pdcp_log.set_level(args.log.pdcp_level); pdcp_log.set_level(args.log.pdcp_level);
rrc_log.set_level(args.log.rrc_level); rrc_log.set_level(args.log.rrc_level);
usim_log.set_level(args.log.usim_level); usim_log.set_level(args.log.usim_level);
asn1_log.set_level(LOG_LEVEL_INFO);
rrc_asn1_log.set_level(args.log.rrc_level);
mac_log.set_hex_limit(args.log.mac_hex_limit); mac_log.set_hex_limit(args.log.mac_hex_limit);
rlc_log.set_hex_limit(args.log.rlc_hex_limit); rlc_log.set_hex_limit(args.log.rlc_hex_limit);
pdcp_log.set_hex_limit(args.log.pdcp_hex_limit); pdcp_log.set_hex_limit(args.log.pdcp_hex_limit);
rrc_log.set_hex_limit(args.log.rrc_hex_limit); rrc_log.set_hex_limit(args.log.rrc_hex_limit);
usim_log.set_hex_limit(args.log.usim_hex_limit); usim_log.set_hex_limit(args.log.usim_hex_limit);
asn1_log.set_hex_limit(128);
rrc_asn1_log.set_hex_limit(args.log.rrc_hex_limit);
asn1::srsasn_log_register_handler(&asn1_log);
asn1::rrc::rrc_log_register_handler(&rrc_log);
// Set NAS log // Set NAS log
srslte::log_ref log_ptr = logmap::get("NAS"); srslte::log_ref log_ptr = logmap::get("NAS");

Loading…
Cancel
Save