applied new logmap class to nas

master
Francisco Paisana 5 years ago
parent 3e2de6dd3e
commit ea777d92e8

@ -71,6 +71,13 @@ public:
default_log_level = l; default_log_level = l;
} }
// set default hex limit
void set_default_hex_limit(int hex_limit)
{
std::lock_guard<std::mutex> lock(mutex);
default_hex_limit = hex_limit;
}
// register manually created log // register manually created log
void register_log(std::unique_ptr<log> log_ptr) void register_log(std::unique_ptr<log> log_ptr)
{ {

@ -140,7 +140,6 @@ private:
srslte::log_filter rlc_log; srslte::log_filter rlc_log;
srslte::log_filter pdcp_log; srslte::log_filter pdcp_log;
srslte::log_filter rrc_log; srslte::log_filter rrc_log;
srslte::log_filter nas_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 asn1_log;

@ -40,7 +40,7 @@ namespace srsue {
class nas : public nas_interface_rrc, public nas_interface_ue, public srslte::timer_callback class nas : public nas_interface_rrc, public nas_interface_ue, public srslte::timer_callback
{ {
public: public:
nas(srslte::log* log_, srslte::timer_handler* timers_); nas(srslte::timer_handler* timers_);
void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_); void init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& args_);
void stop(); void stop();
void run_tti(uint32_t tti) final; void run_tti(uint32_t tti) final;

@ -20,6 +20,7 @@
*/ */
#include "srsue/hdr/stack/ue_stack_lte.h" #include "srsue/hdr/stack/ue_stack_lte.h"
#include "srslte/common/logmap.h"
#include "srslte/srslte.h" #include "srslte/srslte.h"
using namespace srslte; using namespace srslte;
@ -37,7 +38,7 @@ ue_stack_lte::ue_stack_lte() :
mac(&mac_log), mac(&mac_log),
rrc(&rrc_log), rrc(&rrc_log),
pdcp(&timers, &pdcp_log), pdcp(&timers, &pdcp_log),
nas(&nas_log, &timers), nas(&timers),
thread("STACK"), thread("STACK"),
pending_tasks(1024), pending_tasks(1024),
background_tasks(2) background_tasks(2)
@ -82,11 +83,11 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
logger = logger_; logger = logger_;
// setup logging for each layer // setup logging for each layer
logmap::get_instance()->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);
rrc_log.init("RRC ", logger); rrc_log.init("RRC ", logger);
nas_log.init("NAS ", logger);
usim_log.init("USIM", logger); usim_log.init("USIM", logger);
asn1_log.init("ASN1", logger); asn1_log.init("ASN1", logger);
rrc_asn1_log.init("ASN1::RRC", logger); rrc_asn1_log.init("ASN1::RRC", logger);
@ -99,7 +100,6 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
rlc_log.set_level(args.log.rlc_level); rlc_log.set_level(args.log.rlc_level);
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);
nas_log.set_level(args.log.nas_level);
usim_log.set_level(args.log.usim_level); usim_log.set_level(args.log.usim_level);
asn1_log.set_level(LOG_LEVEL_INFO); asn1_log.set_level(LOG_LEVEL_INFO);
rrc_asn1_log.set_level(args.log.rrc_level); rrc_asn1_log.set_level(args.log.rrc_level);
@ -108,13 +108,17 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
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);
nas_log.set_hex_limit(args.log.nas_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); asn1_log.set_hex_limit(128);
rrc_asn1_log.set_hex_limit(args.log.rrc_hex_limit); rrc_asn1_log.set_hex_limit(args.log.rrc_hex_limit);
asn1::srsasn_log_register_handler(&asn1_log); asn1::srsasn_log_register_handler(&asn1_log);
asn1::rrc::rrc_log_register_handler(&rrc_log); asn1::rrc::rrc_log_register_handler(&rrc_log);
// Set NAS log
srslte::log* log_ptr = logmap::get("NAS ");
log_ptr->set_level(args.log.nas_level);
log_ptr->set_hex_limit(args.log.nas_hex_limit);
// Set up pcap // Set up pcap
if (args.pcap.enable) { if (args.pcap.enable) {
mac_pcap.open(args.pcap.filename.c_str()); mac_pcap.open(args.pcap.filename.c_str());
@ -196,7 +200,7 @@ bool ue_stack_lte::switch_off()
} }
bool detach_sent = true; bool detach_sent = true;
if (rlc.has_data(RB_ID_SRB1)) { if (rlc.has_data(RB_ID_SRB1)) {
nas_log.warning("Detach couldn't be sent after %ds.\n", timeout); logmap::get("NAS ")->warning("Detach couldn't be sent after %ds.\n", timeout);
detach_sent = false; detach_sent = false;
} }

@ -31,6 +31,7 @@
#include "srslte/asn1/liblte_mme.h" #include "srslte/asn1/liblte_mme.h"
#include "srslte/common/bcd_helpers.h" #include "srslte/common/bcd_helpers.h"
#include "srslte/common/logmap.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srsue/hdr/stack/upper/nas.h" #include "srsue/hdr/stack/upper/nas.h"
@ -224,8 +225,8 @@ proc_outcome_t nas::rrc_connect_proc::react(nas::rrc_connect_proc::connection_re
* NAS * NAS
********************************************************************/ ********************************************************************/
nas::nas(srslte::log* log_, srslte::timer_handler* timers_) : nas::nas(srslte::timer_handler* timers_) :
nas_log(log_), nas_log(logmap::get("NAS ")),
pool(byte_buffer_pool::get_instance()), pool(byte_buffer_pool::get_instance()),
plmn_searcher(this), plmn_searcher(this),
rrc_connector(this), rrc_connector(this),

@ -21,6 +21,7 @@
#include "srslte/common/bcd_helpers.h" #include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h" #include "srslte/common/log_filter.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/ue_interfaces.h" #include "srslte/interfaces/ue_interfaces.h"
#include "srslte/upper/pdcp.h" #include "srslte/upper/pdcp.h"
#include "srslte/upper/pdcp_entity_lte.h" #include "srslte/upper/pdcp_entity_lte.h"
@ -197,14 +198,11 @@ class gw_dummy : public gw_interface_nas, public gw_interface_pdcp
int security_command_test() int security_command_test()
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
srslte::log_filter nas_log("NAS");
srslte::log_filter rrc_log("RRC"); srslte::log_filter rrc_log("RRC");
srslte::log_filter mac_log("MAC"); srslte::log_filter mac_log("MAC");
srslte::log_filter usim_log("USIM"); srslte::log_filter usim_log("USIM");
nas_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG); rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
nas_log.set_hex_limit(100000);
rrc_log.set_hex_limit(100000); rrc_log.set_hex_limit(100000);
srslte::timer_handler timers(10); srslte::timer_handler timers(10);
@ -222,12 +220,10 @@ int security_command_test()
// init USIM // init USIM
srsue::usim usim(&usim_log); srsue::usim usim(&usim_log);
bool net_valid = false;
uint8_t res[16];
usim.init(&args); usim.init(&args);
{ {
srsue::nas nas(&nas_log, &timers); srsue::nas nas(&timers);
nas_args_t cfg; nas_args_t cfg;
cfg.eia = "1,2,3"; cfg.eia = "1,2,3";
cfg.eea = "0,1,2,3"; cfg.eea = "0,1,2,3";
@ -264,17 +260,14 @@ int security_command_test()
int mme_attach_request_test() int mme_attach_request_test()
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
srslte::log_filter nas_log("NAS");
srslte::log_filter rrc_log("RRC"); srslte::log_filter rrc_log("RRC");
srslte::log_filter mac_log("MAC"); srslte::log_filter mac_log("MAC");
srslte::log_filter usim_log("USIM"); srslte::log_filter usim_log("USIM");
srslte::log_filter gw_log("GW"); srslte::log_filter gw_log("GW");
nas_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG); rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
usim_log.set_level(srslte::LOG_LEVEL_DEBUG); usim_log.set_level(srslte::LOG_LEVEL_DEBUG);
gw_log.set_level(srslte::LOG_LEVEL_DEBUG); gw_log.set_level(srslte::LOG_LEVEL_DEBUG);
nas_log.set_hex_limit(100000);
rrc_log.set_hex_limit(100000); rrc_log.set_hex_limit(100000);
usim_log.set_hex_limit(100000); usim_log.set_hex_limit(100000);
gw_log.set_hex_limit(100000); gw_log.set_hex_limit(100000);
@ -298,7 +291,7 @@ int mme_attach_request_test()
nas_args_t nas_cfg; nas_args_t nas_cfg;
nas_cfg.force_imsi_attach = true; nas_cfg.force_imsi_attach = true;
nas_cfg.apn_name = "test123"; nas_cfg.apn_name = "test123";
srsue::nas nas(&nas_log, &timers); srsue::nas nas(&timers);
srsue::gw gw; srsue::gw gw;
stack_dummy stack(&pdcp_dummy, &nas); stack_dummy stack(&pdcp_dummy, &nas);
@ -349,14 +342,11 @@ int mme_attach_request_test()
int esm_info_request_test() int esm_info_request_test()
{ {
int ret = SRSLTE_ERROR; int ret = SRSLTE_ERROR;
srslte::log_filter nas_log("NAS");
srslte::log_filter rrc_log("RRC"); srslte::log_filter rrc_log("RRC");
srslte::log_filter mac_log("MAC"); srslte::log_filter mac_log("MAC");
srslte::log_filter usim_log("USIM"); srslte::log_filter usim_log("USIM");
nas_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG); rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
nas_log.set_hex_limit(100000);
rrc_log.set_hex_limit(100000); rrc_log.set_hex_limit(100000);
srslte::timer_handler timers(10); srslte::timer_handler timers(10);
@ -373,15 +363,13 @@ int esm_info_request_test()
// init USIM // init USIM
srsue::usim usim(&usim_log); srsue::usim usim(&usim_log);
bool net_valid;
uint8_t res[16];
usim.init(&args); usim.init(&args);
srslte::byte_buffer_pool* pool; srslte::byte_buffer_pool* pool;
pool = byte_buffer_pool::get_instance(); pool = byte_buffer_pool::get_instance();
{ {
srsue::nas nas(&nas_log, &timers); srsue::nas nas(&timers);
nas_args_t cfg; nas_args_t cfg;
cfg.apn_name = "srslte"; cfg.apn_name = "srslte";
cfg.apn_user = "srsuser"; cfg.apn_user = "srsuser";
@ -408,14 +396,11 @@ int esm_info_request_test()
int dedicated_eps_bearer_test() int dedicated_eps_bearer_test()
{ {
srslte::log_filter nas_log("NAS");
srslte::log_filter rrc_log("RRC"); srslte::log_filter rrc_log("RRC");
srslte::log_filter mac_log("MAC"); srslte::log_filter mac_log("MAC");
srslte::log_filter usim_log("USIM"); srslte::log_filter usim_log("USIM");
nas_log.set_level(srslte::LOG_LEVEL_DEBUG);
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG); rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
nas_log.set_hex_limit(100000);
rrc_log.set_hex_limit(100000); rrc_log.set_hex_limit(100000);
srslte::timer_handler timers(10); srslte::timer_handler timers(10);
@ -436,7 +421,7 @@ int dedicated_eps_bearer_test()
srslte::byte_buffer_pool* pool = byte_buffer_pool::get_instance(); srslte::byte_buffer_pool* pool = byte_buffer_pool::get_instance();
srsue::nas nas(&nas_log, &timers); srsue::nas nas(&timers);
nas_args_t cfg = {}; nas_args_t cfg = {};
cfg.force_imsi_attach = true; // make sure we get a fresh security context cfg.force_imsi_attach = true; // make sure we get a fresh security context
nas.init(&usim, &rrc_dummy, &gw, cfg); nas.init(&usim, &rrc_dummy, &gw, cfg);
@ -493,6 +478,9 @@ 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::get_instance()->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");
return -1; return -1;

Loading…
Cancel
Save