added logref class to forbid logmap pointer invalidation. Created a test for the logref, and introduced it in the scheduler, rrc and nas

master
Francisco Paisana 5 years ago
parent e621853566
commit e859d622c7

@ -113,7 +113,7 @@ public:
} }
LOG_LEVEL_ENUM get_level() { return level; } LOG_LEVEL_ENUM get_level() { return level; }
std::string get_service_name() { return service_name; } const std::string& get_service_name() const { return service_name; }
void set_hex_limit(int limit) { hex_limit = limit; } void set_hex_limit(int limit) { hex_limit = limit; }
int get_hex_limit() { return hex_limit; } int get_hex_limit() { return hex_limit; }

@ -34,74 +34,116 @@ namespace srslte {
class log_filter; class log_filter;
class log_ref
{
using ptr_type = std::unique_ptr<log>*;
public:
log_ref() = default;
explicit log_ref(ptr_type p) : ptr_(p) {}
// works like a log*
log* operator->() { return ptr_->get(); }
log* operator->() const { return ptr_->get(); }
// in case we want to obtain log*
log* operator*() { return ptr_->get(); }
log* get() { return ptr_->get(); }
// identity defined by ref address
bool operator==(const log_ref& l) { return ptr_ == l.ptr_; }
// to do checks like if(log_ref)
operator bool() { return ptr_ != nullptr; }
private:
ptr_type ptr_ = nullptr;
};
class logmap : public singleton_t<logmap> class logmap : public singleton_t<logmap>
{ {
static const size_t servicename_minimum_length = 4;
using it_t = std::unordered_map<std::string, std::unique_ptr<log> >::iterator;
public: public:
// Access to log map by servicename. If servicename does not exist, create a new log_filter with default cfg // Access to log map by servicename. If servicename does not exist, create a new log_filter with default cfg
// Access to the map is protected by a mutex // Access to the map is protected by a mutex
static log* get(const std::string& servicename) static log_ref get(std::string servicename)
{
logmap* pool = get_instance();
if (servicename.size() < servicename_minimum_length) {
// pad right of string with spaces
servicename.insert(servicename.end(), servicename_minimum_length - servicename.length(), ' ');
}
return pool->get_impl(std::move(servicename));
}
// register manually created log
static void register_log(std::unique_ptr<log> log_ptr)
{
logmap* pool = get_instance();
std::lock_guard<std::mutex> lock(pool->mutex);
if (log_ptr != nullptr) {
pool->log_map[log_ptr->get_service_name()] = std::move(log_ptr);
}
}
static std::unique_ptr<srslte::log> deregister_log(const std::string& servicename)
{ {
logmap* pool = get_instance(); logmap* pool = get_instance();
std::unique_ptr<srslte::log> ret;
std::lock_guard<std::mutex> lock(pool->mutex); std::lock_guard<std::mutex> lock(pool->mutex);
auto it = pool->log_map.find(servicename); auto it = pool->log_map.find(servicename);
if (it == pool->log_map.end()) { if (it != pool->log_map.end()) {
// create a new logger with default cfg ret = std::move(it->second);
std::unique_ptr<log_filter> filter(new log_filter{servicename, pool->default_logger}); pool->log_map.erase(it);
filter->set_level(pool->default_log_level);
filter->set_hex_limit(pool->default_hex_limit);
auto ret = pool->log_map.insert(std::make_pair(servicename, std::move(filter)));
std::unique_ptr<log>& inserted = ret.first->second;
return inserted.get();
} }
return it->second.get(); return ret;
} }
// set default logger // set default logger
void set_default_logger(logger* logger_) static void set_default_logger(logger* logger_)
{ {
std::lock_guard<std::mutex> lock(mutex); logmap* pool = get_instance();
default_logger = logger_; std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_logger = logger_;
} }
// set default log level // set default log level
void set_default_log_level(LOG_LEVEL_ENUM l) static void set_default_log_level(LOG_LEVEL_ENUM l)
{ {
std::lock_guard<std::mutex> lock(mutex); logmap* pool = get_instance();
default_log_level = l; std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_log_level = l;
} }
// set default hex limit // set default hex limit
void set_default_hex_limit(int hex_limit) static void set_default_hex_limit(int hex_limit)
{ {
std::lock_guard<std::mutex> lock(mutex); logmap* pool = get_instance();
default_hex_limit = hex_limit; std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_hex_limit = hex_limit;
} }
// register manually created log protected:
void register_log(std::unique_ptr<log> log_ptr) logmap() : default_logger(&logger_stdout_val) {}
{
std::lock_guard<std::mutex> lock(mutex);
if (log_ptr != nullptr) {
log_map[log_ptr->get_service_name()] = std::move(log_ptr);
}
}
std::unique_ptr<srslte::log> deregister_log(const std::string& servicename) private:
log_ref get_impl(std::string servicename)
{ {
std::unique_ptr<srslte::log> ret;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
auto it = log_map.find(servicename); auto it = log_map.find(servicename);
if (it != log_map.end()) { if (it == log_map.end()) {
ret = std::move(it->second); // create a new logger with default cfg
log_map.erase(it); std::unique_ptr<log_filter> filter(new log_filter{std::move(servicename), default_logger});
filter->set_level(default_log_level);
filter->set_hex_limit(default_hex_limit);
auto ret = log_map.insert(std::make_pair(filter->get_service_name(), std::move(filter)));
return log_ref{&ret.first->second};
} }
return ret; return log_ref{&it->second};
} }
protected:
logmap() : default_logger(&logger_stdout_val) {}
private:
// consts // consts
logger_stdout logger_stdout_val; logger_stdout logger_stdout_val;

@ -345,9 +345,9 @@ int test_session_res_setup_request()
int main() int main()
{ {
srslte::logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srsasn_log_register_handler(srslte::logmap::get("ASN1")); srsasn_log_register_handler(srslte::logmap::get("ASN1").get());
ngap_nr_log_register_handler(srslte::logmap::get("NGAP")); 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);

@ -44,7 +44,7 @@ int test_generic()
TESTASSERT(null_log.last_log_msg == test_str); TESTASSERT(null_log.last_log_msg == test_str);
TESTASSERT(null_log.last_log_level == LOG_LEVEL_INFO); 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 ")); rrc_log_register_handler(srslte::logmap::get("RRC ").get());
} }
// Test deep copy of choice types // Test deep copy of choice types
@ -599,9 +599,9 @@ int test_rrc_conn_reconf_r15_2()
int main() int main()
{ {
srslte::logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srsasn_log_register_handler(srslte::logmap::get("ASN1")); srsasn_log_register_handler(srslte::logmap::get("ASN1").get());
rrc_log_register_handler(srslte::logmap::get("RRC ")); 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);

@ -133,8 +133,8 @@ int test_eci_pack()
int main() int main()
{ {
srslte::logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srslte::logmap::get_instance()->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);
TESTASSERT(test_initial_ctxt_setup_response() == SRSLTE_SUCCESS); TESTASSERT(test_initial_ctxt_setup_response() == SRSLTE_SUCCESS);

@ -142,17 +142,27 @@ int basic_hex_test()
int test_log_singleton() int test_log_singleton()
{ {
srslte::logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srslte::log* log_ptr = srslte::logmap::get("LAYER1");
TESTASSERT(log_ptr->get_service_name() == "LAYER1"); // TEST: Check if default setters are working
TESTASSERT(log_ptr->get_level() == LOG_LEVEL_DEBUG); srslte::log_ref log1 = srslte::logmap::get("LAYER1");
// register logger manually TESTASSERT(log1->get_service_name() == "LAYER1");
TESTASSERT(log1->get_level() == LOG_LEVEL_DEBUG);
// TEST: register logger manually. Verify log_ref stays valid after overwrite
std::unique_ptr<srslte::log_filter> log_ptr2(new srslte::log_filter("LAYER2")); std::unique_ptr<srslte::log_filter> log_ptr2(new srslte::log_filter("LAYER2"));
log_ptr2->set_level(LOG_LEVEL_WARNING); log_ptr2->set_level(LOG_LEVEL_WARNING);
TESTASSERT(srslte::logmap::get("LAYER2")->get_level() == LOG_LEVEL_DEBUG); srslte::log_ref old_ref = srslte::logmap::get("LAYER2");
srslte::logmap::get_instance()->register_log(std::move(log_ptr2)); TESTASSERT(old_ref->get_level() == LOG_LEVEL_DEBUG);
TESTASSERT(srslte::logmap::get("LAYER2")->get_level() == LOG_LEVEL_WARNING); srslte::logmap::register_log(std::move(log_ptr2));
srslte::log_ref new_ref = srslte::logmap::get("LAYER2");
TESTASSERT(new_ref->get_level() == LOG_LEVEL_WARNING);
TESTASSERT(old_ref == new_ref);
// TEST: padding working correctly
TESTASSERT(srslte::logmap::get("MAC").get() == srslte::logmap::get("MAC ").get());
log1->info("logmap test finished successfully\n");
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -175,6 +185,7 @@ int full_test()
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
TESTASSERT(basic_hex_test() == SRSLTE_SUCCESS); TESTASSERT(basic_hex_test() == SRSLTE_SUCCESS);

@ -21,7 +21,6 @@
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h" #include "srslte/common/interfaces_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include "srslte/common/mac_pcap.h" #include "srslte/common/mac_pcap.h"
#include "srslte/common/pdu.h" #include "srslte/common/pdu.h"
@ -547,10 +546,10 @@ int mac_sch_pdu_pack_test7()
// Test Packing of SCell Activation CE command // Test Packing of SCell Activation CE command
int mac_sch_pdu_pack_test8() int mac_sch_pdu_pack_test8()
{ {
srslte::log* log_h = logmap::get("MAC"); srslte::log_ref log_h = logmap::get("MAC");
const uint32_t pdu_size = 2; const uint32_t pdu_size = 2;
srslte::sch_pdu pdu(10, log_h); srslte::sch_pdu pdu(10, log_h.get());
std::bitset<8> cc_mask(uniform_dist_u8(rand_gen)); std::bitset<8> cc_mask(uniform_dist_u8(rand_gen));
// subheader: R|F2|E|LCID = 0|0|0|11011 // subheader: R|F2|E|LCID = 0|0|0|11011
@ -571,7 +570,7 @@ int mac_sch_pdu_pack_test8()
TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_mask)); TESTASSERT(pdu.get()->set_scell_activation_cmd(cc_mask));
// write PDU // write PDU
pdu.write_packet(log_h); pdu.write_packet(log_h.get());
// compare with tv // compare with tv
TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0); TESTASSERT(memcmp(buffer.msg, tv, buffer.N_bytes) == 0);
@ -752,8 +751,8 @@ int main(int argc, char** argv)
pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap()); pcap_handle = std::unique_ptr<srslte::mac_pcap>(new srslte::mac_pcap());
pcap_handle->open("mac_pdu_test.pcap"); pcap_handle->open("mac_pdu_test.pcap");
#endif #endif
logmap::get_instance()->set_default_hex_limit(32); logmap::set_default_hex_limit(100000);
logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); logmap::set_default_log_level(LOG_LEVEL_DEBUG);
if (mac_rar_pdu_unpack_test1()) { if (mac_rar_pdu_unpack_test1()) {
fprintf(stderr, "mac_rar_pdu_unpack_test1 failed.\n"); fprintf(stderr, "mac_rar_pdu_unpack_test1 failed.\n");

@ -31,7 +31,7 @@ int test_nullsink_log()
// without contaminating the console/log file, and to check what error message was stored // without contaminating the console/log file, and to check what error message was stored
scoped_log<nullsink_log> null_log("TEST"); scoped_log<nullsink_log> null_log("TEST");
TESTASSERT(srslte::logmap::get("TEST") == null_log.get()); TESTASSERT(srslte::logmap::get("TEST").get() == null_log.get());
TESTASSERT(null_log->error_counter == 0); TESTASSERT(null_log->error_counter == 0);
TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_NONE); TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_NONE);
TESTASSERT(null_log->last_log_msg.empty()); TESTASSERT(null_log->last_log_msg.empty());
@ -50,7 +50,7 @@ int test_log_scoping()
// This behavior is useful for the cases we have one generic logger for all tests, but in a specific test // This behavior is useful for the cases we have one generic logger for all tests, but in a specific test
// we want to use a different one // we want to use a different one
scoped_log<nullsink_log> log1("TEST"); scoped_log<nullsink_log> log1("TEST");
TESTASSERT(srslte::logmap::get("TEST") == log1.get()); TESTASSERT(srslte::logmap::get("TEST").get() == log1.get());
log1->error("message1"); log1->error("message1");
log1->error("message2"); log1->error("message2");
@ -60,7 +60,7 @@ int test_log_scoping()
{ {
// the global test log should be overwriten here, and used by TESTASSERT macro // the global test log should be overwriten here, and used by TESTASSERT macro
scoped_log<nullsink_log> log2("TEST"); scoped_log<nullsink_log> log2("TEST");
TESTASSERT(srslte::logmap::get("TEST") == log2.get()); TESTASSERT(srslte::logmap::get("TEST").get() == log2.get());
TESTASSERT(log2->error_counter == 0); TESTASSERT(log2->error_counter == 0);
log2->error("error message in logger2\n"); log2->error("error message in logger2\n");
TESTASSERT(log2->last_log_msg == "error message in logger2\n"); TESTASSERT(log2->last_log_msg == "error message in logger2\n");
@ -68,7 +68,7 @@ int test_log_scoping()
} }
// the last logger should be recovered // the last logger should be recovered
TESTASSERT(srslte::logmap::get("TEST") == log1.get()); TESTASSERT(srslte::logmap::get("TEST").get() == log1.get());
TESTASSERT(log1->error_counter == 2); TESTASSERT(log1->error_counter == 2);
return 0; return 0;
} }

@ -183,7 +183,7 @@ public:
class carrier_sched; class carrier_sched;
protected: protected:
srslte::log* log_h = nullptr; srslte::log_ref log_h;
rrc_interface_mac* rrc = nullptr; rrc_interface_mac* rrc = nullptr;
sched_args_t sched_cfg = {}; sched_args_t sched_cfg = {};
std::vector<sched_cell_params_t> sched_cell_params; std::vector<sched_cell_params_t> sched_cell_params;

@ -52,7 +52,7 @@ private:
// args // args
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
rrc_interface_mac* rrc = nullptr; rrc_interface_mac* rrc = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr; std::map<uint16_t, sched_ue>* ue_db = nullptr;
std::unique_ptr<metric_dl> dl_metric; std::unique_ptr<metric_dl> dl_metric;
@ -114,7 +114,7 @@ public:
using dl_sched_rar_t = sched_interface::dl_sched_rar_t; using dl_sched_rar_t = sched_interface::dl_sched_rar_t;
using dl_sched_rar_grant_t = sched_interface::dl_sched_rar_grant_t; using dl_sched_rar_grant_t = sched_interface::dl_sched_rar_grant_t;
explicit ra_sched(const sched_cell_params_t& cfg_, srslte::log* log_, std::map<uint16_t, sched_ue>& ue_db_); explicit ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_);
void dl_sched(sf_sched* tti_sched); void dl_sched(sf_sched* tti_sched);
void ul_sched(sf_sched* tti_sched); void ul_sched(sf_sched* tti_sched);
int dl_rach_info(dl_sched_rar_info_t rar_info); int dl_rach_info(dl_sched_rar_info_t rar_info);
@ -123,7 +123,7 @@ public:
private: private:
// args // args
srslte::log* log_h = nullptr; srslte::log_ref log_h;
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
std::map<uint16_t, sched_ue>* ue_db = nullptr; std::map<uint16_t, sched_ue>* ue_db = nullptr;

@ -94,7 +94,7 @@ private:
// consts // consts
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
// tti vars // tti vars
const tti_params_t* tti_params = nullptr; const tti_params_t* tti_params = nullptr;
@ -132,7 +132,7 @@ private:
// consts // consts
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
uint32_t nof_rbgs = 0; uint32_t nof_rbgs = 0;
uint32_t si_n_rbg = 0, rar_n_rbg = 0; uint32_t si_n_rbg = 0, rar_n_rbg = 0;
@ -286,7 +286,7 @@ private:
// consts // consts
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
// internal state // internal state
tti_params_t tti_params{10241}; tti_params_t tti_params{10241};

@ -90,7 +90,7 @@ protected:
int last_mcs[SRSLTE_MAX_TB]; int last_mcs[SRSLTE_MAX_TB];
int last_tbs[SRSLTE_MAX_TB]; int last_tbs[SRSLTE_MAX_TB];
srslte::log* log_h = nullptr; srslte::log_ref log_h;
}; };
typedef srslte::bounded_bitset<25, true> rbgmask_t; typedef srslte::bounded_bitset<25, true> rbgmask_t;

@ -39,7 +39,7 @@ private:
dl_harq_proc* allocate_user(sched_ue* user); dl_harq_proc* allocate_user(sched_ue* user);
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
dl_sf_sched_itf* tti_alloc = nullptr; dl_sf_sched_itf* tti_alloc = nullptr;
}; };
@ -55,7 +55,7 @@ private:
ul_harq_proc* allocate_user_retx_prbs(sched_ue* user); ul_harq_proc* allocate_user_retx_prbs(sched_ue* user);
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslte::log* log_h = nullptr; srslte::log_ref log_h;
ul_sf_sched_itf* tti_alloc = nullptr; ul_sf_sched_itf* tti_alloc = nullptr;
uint32_t current_tti = 0; uint32_t current_tti = 0;
}; };

@ -89,7 +89,7 @@ struct sched_ue_carrier {
private: private:
// config // config
srslte::log* log_h = nullptr; srslte::log_ref log_h;
const sched_interface::ue_cfg_t* cfg = nullptr; const sched_interface::ue_cfg_t* cfg = nullptr;
const sched_cell_params_t* cell_params = nullptr; const sched_cell_params_t* cell_params = nullptr;
uint16_t rnti; uint16_t rnti;
@ -261,7 +261,7 @@ private:
/* Args */ /* Args */
sched_interface::ue_cfg_t cfg = {}; sched_interface::ue_cfg_t cfg = {};
srslte_cell_t cell = {}; srslte_cell_t cell = {};
srslte::log* log_h = nullptr; srslte::log_ref log_h;
const std::vector<sched_cell_params_t>* cell_params_list = nullptr; const std::vector<sched_cell_params_t>* cell_params_list = nullptr;
const sched_cell_params_t* main_cc_params = nullptr; const sched_cell_params_t* main_cc_params = nullptr;

@ -23,6 +23,7 @@
#define SRSENB_RRC_MOBILITY_H #define SRSENB_RRC_MOBILITY_H
#include "rrc.h" #include "rrc.h"
#include "srslte/common/logmap.h"
#include <map> #include <map>
namespace srsenb { namespace srsenb {
@ -34,12 +35,12 @@ namespace srsenb {
class var_meas_cfg_t class var_meas_cfg_t
{ {
public: public:
explicit var_meas_cfg_t(srslte::log* log_) : rrc_log(log_) {}
using meas_cell_t = asn1::rrc::cells_to_add_mod_s; using meas_cell_t = asn1::rrc::cells_to_add_mod_s;
using meas_id_t = asn1::rrc::meas_id_to_add_mod_s; using meas_id_t = asn1::rrc::meas_id_to_add_mod_s;
using meas_obj_t = asn1::rrc::meas_obj_to_add_mod_s; using meas_obj_t = asn1::rrc::meas_obj_to_add_mod_s;
using report_cfg_t = asn1::rrc::report_cfg_to_add_mod_s; using report_cfg_t = asn1::rrc::report_cfg_to_add_mod_s;
var_meas_cfg_t() : rrc_log(srslte::logmap::get("RRC")) {}
std::tuple<bool, meas_obj_t*, meas_cell_t*> add_cell_cfg(const meas_cell_cfg_t& cellcfg); std::tuple<bool, meas_obj_t*, meas_cell_t*> add_cell_cfg(const meas_cell_cfg_t& cellcfg);
report_cfg_t* add_report_cfg(const asn1::rrc::report_cfg_eutra_s& reportcfg); report_cfg_t* add_report_cfg(const asn1::rrc::report_cfg_eutra_s& reportcfg);
meas_id_t* add_measid_cfg(uint8_t measobjid, uint8_t repid); meas_id_t* add_measid_cfg(uint8_t measobjid, uint8_t repid);
@ -64,13 +65,13 @@ public:
private: private:
asn1::rrc::var_meas_cfg_s var_meas; asn1::rrc::var_meas_cfg_s var_meas;
srslte::log* rrc_log = nullptr; srslte::log_ref rrc_log;
}; };
class rrc::mobility_cfg class rrc::mobility_cfg
{ {
public: public:
explicit mobility_cfg(const rrc_cfg_t* cfg_, srslte::log* log_); explicit mobility_cfg(const rrc_cfg_t* cfg_);
std::shared_ptr<const var_meas_cfg_t> current_meas_cfg; ///< const to enable ptr comparison as identity comparison std::shared_ptr<const var_meas_cfg_t> current_meas_cfg; ///< const to enable ptr comparison as identity comparison

@ -27,7 +27,7 @@
#include "common_enb.h" #include "common_enb.h"
#include "srslte/common/buffer_pool.h" #include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/log.h" #include "srslte/common/logmap.h"
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
@ -98,7 +98,7 @@ private:
// args // args
rrc_interface_s1ap* rrc = nullptr; rrc_interface_s1ap* rrc = nullptr;
s1ap_args_t args; s1ap_args_t args;
srslte::log* s1ap_log = nullptr; srslte::log_ref s1ap_log;
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
srsenb::stack_interface_s1ap_lte* stack = nullptr; srsenb::stack_interface_s1ap_lte* stack = nullptr;
@ -199,7 +199,7 @@ private:
// args // args
s1ap* s1ap_ptr; s1ap* s1ap_ptr;
srslte::log* s1ap_log; srslte::log_ref s1ap_log;
// state // state
bool release_requested = false; bool release_requested = false;

@ -70,7 +70,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
rrc_cfg = rrc_cfg_; rrc_cfg = rrc_cfg_;
// setup logging for each layer // setup logging for each layer
srslte::logmap::get_instance()->set_default_logger(logger); srslte::logmap::set_default_logger(logger);
mac_log.init("MAC ", logger, true); mac_log.init("MAC ", logger, true);
rlc_log.init("RLC ", logger); rlc_log.init("RLC ", logger);
pdcp_log.init("PDCP", logger); pdcp_log.init("PDCP", logger);

@ -139,7 +139,7 @@ sched::~sched()
void sched::init(rrc_interface_mac* rrc_) void sched::init(rrc_interface_mac* rrc_)
{ {
log_h = srslte::logmap::get("MAC "); log_h = srslte::logmap::get("MAC");
rrc = rrc_; rrc = rrc_;
// Initialize first carrier scheduler // Initialize first carrier scheduler

@ -136,9 +136,9 @@ void bc_sched::reset()
* RAR scheduling * RAR scheduling
*******************************************************/ *******************************************************/
ra_sched::ra_sched(const sched_cell_params_t& cfg_, srslte::log* log_, std::map<uint16_t, sched_ue>& ue_db_) : ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map<uint16_t, sched_ue>& ue_db_) :
cc_cfg(&cfg_), cc_cfg(&cfg_),
log_h(log_), log_h(srslte::logmap::get("MAC")),
ue_db(&ue_db_) ue_db(&ue_db_)
{ {
} }
@ -311,7 +311,7 @@ void sched::carrier_sched::carrier_cfg(const sched_cell_params_t& cell_params_)
// init Broadcast/RA schedulers // init Broadcast/RA schedulers
bc_sched_ptr.reset(new bc_sched{*cc_cfg, rrc}); bc_sched_ptr.reset(new bc_sched{*cc_cfg, rrc});
ra_sched_ptr.reset(new ra_sched{*cc_cfg, log_h, *ue_db}); ra_sched_ptr.reset(new ra_sched{*cc_cfg, *ue_db});
// Setup data scheduling algorithms // Setup data scheduling algorithms
dl_metric.reset(new srsenb::dl_metric_rr{}); dl_metric.reset(new srsenb::dl_metric_rr{});

@ -76,7 +76,7 @@ void rrc::init(rrc_cfg_t* cfg_,
nof_si_messages = generate_sibs(); nof_si_messages = generate_sibs();
config_mac(); config_mac();
enb_mobility_cfg.reset(new mobility_cfg(&cfg, log_rrc)); enb_mobility_cfg.reset(new mobility_cfg(&cfg));
pthread_mutex_init(&user_mutex, nullptr); pthread_mutex_init(&user_mutex, nullptr);
pthread_mutex_init(&paging_mutex, nullptr); pthread_mutex_init(&paging_mutex, nullptr);

@ -610,9 +610,9 @@ void var_meas_cfg_t::compute_diff_quant_cfg(const var_meas_cfg_t& target_cfg, as
* mobility_cfg class * mobility_cfg class
************************************************************************************************/ ************************************************************************************************/
rrc::mobility_cfg::mobility_cfg(const rrc_cfg_t* cfg_, srslte::log* log_) : cfg(cfg_) rrc::mobility_cfg::mobility_cfg(const rrc_cfg_t* cfg_) : cfg(cfg_)
{ {
var_meas_cfg_t var_meas{log_}; var_meas_cfg_t var_meas{};
if (cfg->meas_cfg_present) { if (cfg->meas_cfg_present) {
// inserts all neighbor cells // inserts all neighbor cells
@ -650,9 +650,9 @@ rrc::ue::rrc_mobility::rrc_mobility(rrc::ue* outer_ue) :
cfg(outer_ue->parent->enb_mobility_cfg.get()), cfg(outer_ue->parent->enb_mobility_cfg.get()),
pool(outer_ue->pool), pool(outer_ue->pool),
rrc_log(outer_ue->parent->rrc_log), rrc_log(outer_ue->parent->rrc_log),
source_ho_proc(this) source_ho_proc(this),
ue_var_meas(std::make_shared<var_meas_cfg_t>())
{ {
ue_var_meas = std::make_shared<var_meas_cfg_t>(outer_ue->parent->rrc_log);
} }
//! Method to add Mobility Info to a RRC Connection Reconfiguration Message //! Method to add Mobility Info to a RRC Connection Reconfiguration Message
@ -803,7 +803,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci,
/*** fill AS-Config ***/ /*** fill AS-Config ***/
hoprep_r8.as_cfg_present = true; hoprep_r8.as_cfg_present = true;
// NOTE: set source_meas_cnfg equal to the UE's current var_meas_cfg // NOTE: set source_meas_cnfg equal to the UE's current var_meas_cfg
var_meas_cfg_t empty_meascfg{rrc_log}, target_var_meas = *ue_var_meas; var_meas_cfg_t empty_meascfg{}, target_var_meas = *ue_var_meas;
// // however, reset the MeasObjToAdd Cells, so that the UE does not measure again the target eNB // // however, reset the MeasObjToAdd Cells, so that the UE does not measure again the target eNB
// meas_obj_to_add_mod_s* obj = rrc_details::binary_find(target_var_meas.meas_objs(), measobj_id); // meas_obj_to_add_mod_s* obj = rrc_details::binary_find(target_var_meas.meas_objs(), measobj_id);
// obj->meas_obj.meas_obj_eutra().cells_to_add_mod_list.resize(0); // obj->meas_obj.meas_obj_eutra().cells_to_add_mod_list.resize(0);

@ -432,12 +432,12 @@ bool s1ap::connect_mme()
// Init SCTP socket and bind it // Init SCTP socket and bind it
if (not srslte::net_utils::sctp_init_client( if (not srslte::net_utils::sctp_init_client(
&s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str(), s1ap_log)) { &s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str(), s1ap_log.get())) {
return false; return false;
} }
// Connect to the MME address // Connect to the MME address
if (not s1ap_socket.connect_to(args.mme_addr.c_str(), MME_PORT, &mme_addr, s1ap_log)) { if (not s1ap_socket.connect_to(args.mme_addr.c_str(), MME_PORT, &mme_addr, s1ap_log.get())) {
return false; return false;
} }

@ -1041,7 +1041,7 @@ sched_sim_args rand_sim_params(const srsenb::sched_interface::cell_cfg_t& cell_c
int main() int main()
{ {
srslte::logmap::get_instance()->set_default_log_level(srslte::LOG_LEVEL_INFO); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
printf("[TESTER] This is the chosen seed: %u\n", seed); printf("[TESTER] This is the chosen seed: %u\n", seed);
/* initialize random seed: */ /* initialize random seed: */
uint32_t N_runs = 1, nof_ttis = 10240 + 10; uint32_t N_runs = 1, nof_ttis = 10240 + 10;

@ -108,7 +108,7 @@ int test_erab_setup(bool qci_exists)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslte::logmap::get_instance()->set_default_log_level(srslte::LOG_LEVEL_INFO); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
if (argc < 3) { if (argc < 3) {
argparse::usage(argv[0]); argparse::usage(argv[0]);

@ -76,7 +76,7 @@ int test_correct_insertion()
// TEST 1: cell/rep insertion in empty varMeasCfg // TEST 1: cell/rep insertion in empty varMeasCfg
{ {
var_meas_cfg_t var_cfg(srslte::logmap::get("RRC ")); var_meas_cfg_t var_cfg;
auto ret = var_cfg.add_cell_cfg(cell1); auto ret = var_cfg.add_cell_cfg(cell1);
TESTASSERT(std::get<0>(ret) and std::get<1>(ret) != nullptr); TESTASSERT(std::get<0>(ret) and std::get<1>(ret) != nullptr);
const auto& objs = var_cfg.meas_objs(); const auto& objs = var_cfg.meas_objs();
@ -94,7 +94,7 @@ int test_correct_insertion()
} }
{ {
var_meas_cfg_t var_cfg(srslte::logmap::get("RRC ")); var_meas_cfg_t var_cfg;
const auto& objs = var_cfg.meas_objs(); const auto& objs = var_cfg.meas_objs();
// TEST 2: insertion of out-of-order cell ids in same earfcn // TEST 2: insertion of out-of-order cell ids in same earfcn
@ -133,7 +133,7 @@ int test_correct_insertion()
int test_correct_meascfg_calculation() int test_correct_meascfg_calculation()
{ {
var_meas_cfg_t src_var(srslte::logmap::get("RRC ")), target_var(srslte::logmap::get("RRC ")); var_meas_cfg_t src_var, target_var;
meas_cell_cfg_t cell1{}, cell2{}; meas_cell_cfg_t cell1{}, cell2{};
cell1.earfcn = 3400; cell1.earfcn = 3400;
@ -213,7 +213,7 @@ int test_correct_meascfg_calculation()
// TEST: Removal of cell/rep from target propagates to the resulting meas_cfg_s // TEST: Removal of cell/rep from target propagates to the resulting meas_cfg_s
src_var = target_var; src_var = target_var;
target_var = var_meas_cfg_t{srslte::logmap::get("RRC ")}; target_var = var_meas_cfg_t{};
target_var.add_cell_cfg(cell2); target_var.add_cell_cfg(cell2);
target_var.add_report_cfg(rep1); target_var.add_report_cfg(rep1);
target_var.add_report_cfg(rep3); target_var.add_report_cfg(rep3);
@ -363,7 +363,7 @@ int test_mobility_class(mobility_test_params test_params)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslte::logmap::get_instance()->set_default_log_level(srslte::LOG_LEVEL_INFO); srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
if (argc < 3) { if (argc < 3) {
argparse::usage(argv[0]); argparse::usage(argv[0]);

@ -25,7 +25,7 @@
#include "srslte/asn1/liblte_mme.h" #include "srslte/asn1/liblte_mme.h"
#include "srslte/common/buffer_pool.h" #include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/log.h" #include "srslte/common/logmap.h"
#include "srslte/common/nas_pcap.h" #include "srslte/common/nas_pcap.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/common/stack_procedure.h" #include "srslte/common/stack_procedure.h"
@ -75,7 +75,7 @@ public:
private: private:
srslte::byte_buffer_pool* pool = nullptr; srslte::byte_buffer_pool* pool = nullptr;
srslte::log* nas_log = nullptr; srslte::log_ref nas_log;
rrc_interface_nas* rrc = nullptr; rrc_interface_nas* rrc = nullptr;
usim_interface_nas* usim = nullptr; usim_interface_nas* usim = nullptr;
gw_interface_nas* gw = nullptr; gw_interface_nas* gw = nullptr;

@ -573,7 +573,7 @@ int main(int argc, char* argv[])
logger_file.init(args.log.filename, args.log.file_max_size); logger_file.init(args.log.filename, args.log.file_max_size);
logger = &logger_file; logger = &logger_file;
} }
srslte::logmap::get_instance()->set_default_logger(logger); srslte::logmap::set_default_logger(logger);
// Create UE instance // Create UE instance
srsue::ue ue; srsue::ue ue;

@ -114,7 +114,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
asn1::rrc::rrc_log_register_handler(&rrc_log); asn1::rrc::rrc_log_register_handler(&rrc_log);
// Set NAS log // Set NAS log
srslte::log* log_ptr = logmap::get("NAS "); srslte::log_ref log_ptr = logmap::get("NAS");
log_ptr->set_level(args.log.nas_level); log_ptr->set_level(args.log.nas_level);
log_ptr->set_hex_limit(args.log.nas_hex_limit); log_ptr->set_hex_limit(args.log.nas_hex_limit);

@ -118,7 +118,7 @@ int main(int argc, char** argv)
// Instantiate file logger // Instantiate file logger
srslte::logger_file logger_file; srslte::logger_file logger_file;
srslte::logmap::get_instance()->set_default_logger(&logger_file); srslte::logmap::set_default_logger(&logger_file);
// Create UE object // Create UE object
unique_ptr<ttcn3_ue> ue = std::unique_ptr<ttcn3_ue>(new ttcn3_ue()); unique_ptr<ttcn3_ue> ue = std::unique_ptr<ttcn3_ue>(new ttcn3_ue());

@ -478,8 +478,8 @@ int dedicated_eps_bearer_test()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srslte::logmap::get_instance()->set_default_log_level(LOG_LEVEL_DEBUG); srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
srslte::logmap::get_instance()->set_default_hex_limit(100000); srslte::logmap::set_default_hex_limit(100000);
if (security_command_test()) { if (security_command_test()) {
printf("Security command test failed.\n"); printf("Security command test failed.\n");

Loading…
Cancel
Save