diff --git a/lib/include/srslte/common/log.h b/lib/include/srslte/common/log.h index 04b73d3c6..3a80f5493 100644 --- a/lib/include/srslte/common/log.h +++ b/lib/include/srslte/common/log.h @@ -30,6 +30,7 @@ #ifndef SRSLTE_LOG_H #define SRSLTE_LOG_H +#include "srslte/common/standard_streams.h" #include #include #include @@ -118,7 +119,6 @@ public: int get_hex_limit() { return hex_limit; } // Pure virtual methods for logging - virtual void console(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; virtual void error(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; virtual void warning(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; virtual void info(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; diff --git a/lib/include/srslte/common/log_filter.h b/lib/include/srslte/common/log_filter.h index 7c46bfc26..821f2a229 100644 --- a/lib/include/srslte/common/log_filter.h +++ b/lib/include/srslte/common/log_filter.h @@ -51,7 +51,6 @@ public: void init(std::string layer, logger* logger_, bool tti = false); - void console(const char* message, ...) __attribute__((format(printf, 2, 3))); void error(const char* message, ...) __attribute__((format(printf, 2, 3))); void warning(const char* message, ...) __attribute__((format(printf, 2, 3))); void info(const char* message, ...) __attribute__((format(printf, 2, 3))); diff --git a/lib/include/srslte/common/log_helper.h b/lib/include/srslte/common/log_helper.h index 4cb6cd66c..cfa11bcb0 100644 --- a/lib/include/srslte/common/log_helper.h +++ b/lib/include/srslte/common/log_helper.h @@ -58,7 +58,7 @@ namespace srslte { #define Console(fmt, ...) \ do { \ if (log_h.get() != nullptr) { \ - log_h->console(fmt, ##__VA_ARGS__); \ + srslte::out_stream(fmt, ##__VA_ARGS__); \ } \ } while (0) diff --git a/lib/include/srslte/common/standard_streams.h b/lib/include/srslte/common/standard_streams.h index 6af3477a1..a685e0b84 100644 --- a/lib/include/srslte/common/standard_streams.h +++ b/lib/include/srslte/common/standard_streams.h @@ -24,10 +24,10 @@ namespace srslte { -/// Writes a message to a new line on the standard output stream. +/// Writes the formatted string to the standard output stream. void out_stream(const char* str, ...); -/// Writes a message to a new line on the standard error stream. +/// Writes the formatted string to the standard error stream. void err_stream(const char* str, ...); } // namespace srslte diff --git a/lib/src/common/CMakeLists.txt b/lib/src/common/CMakeLists.txt index c97b6250b..aac227f0e 100644 --- a/lib/src/common/CMakeLists.txt +++ b/lib/src/common/CMakeLists.txt @@ -35,6 +35,7 @@ set(SOURCES arch_select.cc rlc_pcap.cc s1ap_pcap.cc security.cc + standard_streams.cc thread_pool.cc threads.c tti_sync_cv.cc diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index 102817ffe..84fc1119f 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -141,17 +141,6 @@ void log_filter::all_log(srslte::LOG_LEVEL_ENUM level, } } -void log_filter::console(const char* message, ...) -{ - char args_msg[char_buff_size]; - va_list args; - va_start(args, message); - if (vsnprintf(args_msg, char_buff_size, message, args) > 0) - printf("%s", args_msg); // Print directly to stdout - fflush(stdout); - va_end(args); -} - #define all_log_expand(log_level) \ do { \ if (level >= log_level) { \ diff --git a/lib/src/common/standard_streams.cc b/lib/src/common/standard_streams.cc index 6d7b14165..f3199ef4a 100644 --- a/lib/src/common/standard_streams.cc +++ b/lib/src/common/standard_streams.cc @@ -20,6 +20,7 @@ */ #include "srslte/common/standard_streams.h" +#include #include using namespace srslte; diff --git a/lib/src/mac/CMakeLists.txt b/lib/src/mac/CMakeLists.txt index 1f46b6520..8db9e6a71 100644 --- a/lib/src/mac/CMakeLists.txt +++ b/lib/src/mac/CMakeLists.txt @@ -25,4 +25,4 @@ if (ENABLE_5GNR) endif(ENABLE_5GNR) add_library(srslte_mac STATIC ${SOURCES}) - +target_link_libraries(srslte_mac srslte_common) diff --git a/lib/src/mac/pdu.cc b/lib/src/mac/pdu.cc index e6989df73..8d9cab460 100644 --- a/lib/src/mac/pdu.cc +++ b/lib/src/mac/pdu.cc @@ -354,22 +354,23 @@ uint8_t* sch_pdu::write_packet(srslte::log_ref log_h) if (buffer_tx->N_bytes != pdu_len) { if (log_h) { - log_h->console("\n------------------------------\n"); + srslte::out_stream("\n------------------------------\n"); for (int i = 0; i < nof_subheaders; i++) { - log_h->console("SUBH %d is_sdu=%d, payload=%d\n", i, subheaders[i].is_sdu(), subheaders[i].get_payload_size()); + srslte::out_stream( + "SUBH %d is_sdu=%d, payload=%d\n", i, subheaders[i].is_sdu(), subheaders[i].get_payload_size()); } - log_h->console("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, " - "onepad=%d, multi=%d\n", - pdu_len, - header_sz + ce_payload_sz, - header_sz, - ce_payload_sz, - nof_subheaders, - last_sdu_idx, - onetwo_padding, - num_padding); + srslte::out_stream("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, " + "onepad=%d, multi=%d\n", + pdu_len, + header_sz + ce_payload_sz, + header_sz, + ce_payload_sz, + nof_subheaders, + last_sdu_idx, + onetwo_padding, + num_padding); ERROR("Expected PDU len %d bytes but wrote %d\n", pdu_len, buffer_tx->N_bytes); - log_h->console("------------------------------\n"); + srslte::out_stream("------------------------------\n"); log_h->error("Wrote PDU: pdu_len=%d, header_and_ce=%d (%d+%d), nof_subh=%d, last_sdu=%d, onepad=%d, " "multi=%d\n", diff --git a/lib/src/radio/CMakeLists.txt b/lib/src/radio/CMakeLists.txt index a3c9a1dbf..4f695fbcb 100644 --- a/lib/src/radio/CMakeLists.txt +++ b/lib/src/radio/CMakeLists.txt @@ -20,7 +20,7 @@ if(RF_FOUND) add_library(srslte_radio STATIC radio.cc radio_null.cc channel_mapping.cc) - target_link_libraries(srslte_radio srslte_rf) + target_link_libraries(srslte_radio srslte_rf srslte_common) endif(RF_FOUND) add_subdirectory(test) diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index de99922dd..a5423c151 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -96,7 +96,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) } if (!config_rf_channels(args)) { - log_h->console("Error configuring RF channels\n"); + srslte::out_stream("Error configuring RF channels\n"); return SRSLTE_ERROR; } @@ -124,7 +124,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) // Makes sure it is possible to have the same number of RF channels in each RF device if (nof_channels % device_args_list.size() != 0) { - log_h->console( + srslte::out_stream( "Error: The number of required RF channels (%d) is not divisible between the number of RF devices (%zd).\n", nof_channels, device_args_list.size()); @@ -175,7 +175,7 @@ int radio::init(const rf_args_t& args, phy_interface_radio* phy_) } else { // Set same gain than for RX until power control sets a gain set_tx_gain(args.rx_gain); - log_h->console("\nWarning: TX gain was not set. Using open-loop power control (not working properly)\n\n"); + srslte::out_stream("\nWarning: TX gain was not set. Using open-loop power control (not working properly)\n\n"); } // Set individual gains @@ -445,10 +445,10 @@ bool radio::open_dev(const uint32_t& device_idx, const std::string& device_name, dev_name = (char*)device_name.c_str(); } - log_h->console("Opening %d channels in RF device=%s with args=%s\n", - nof_channels_x_dev, - dev_name ? dev_name : "default", - dev_args ? dev_args : "default"); + srslte::out_stream("Opening %d channels in RF device=%s with args=%s\n", + nof_channels_x_dev, + dev_name ? dev_name : "default", + dev_args ? dev_args : "default"); if (srslte_rf_open_devname(rf_device, dev_name, dev_args, nof_channels_x_dev)) { log_h->error("Error opening RF device\n"); @@ -800,7 +800,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 160; } else { /* Interpolate from known values */ - log_h->console( + srslte::out_stream( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = uhd_default_tx_adv_samples + (int)(cur_tx_srate * uhd_default_tx_adv_offset_sec); @@ -822,7 +822,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 80; // to calc } else { /* Interpolate from known values */ - log_h->console( + srslte::out_stream( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = uhd_default_tx_adv_samples + (int)(cur_tx_srate * uhd_default_tx_adv_offset_sec); @@ -844,7 +844,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 102; } else { /* Interpolate from known values */ - log_h->console( + srslte::out_stream( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = lime_default_tx_adv_samples + (int)(cur_tx_srate * lime_default_tx_adv_offset_sec); @@ -871,7 +871,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) nsamples = 21; } else { /* Interpolate from known values */ - log_h->console( + srslte::out_stream( "\nWarning TX/RX time offset for sampling rate %.0f KHz not calibrated. Using interpolated value\n\n", cur_tx_srate); nsamples = blade_default_tx_adv_samples + (int)(blade_default_tx_adv_offset_sec * cur_tx_srate); @@ -881,7 +881,7 @@ double radio::get_dev_cal_tx_adv_sec(const std::string& device_name) } } else { nsamples = tx_adv_nsamples; - log_h->console("Setting manual TX/RX offset to %d samples\n", nsamples); + srslte::out_stream("Setting manual TX/RX offset to %d samples\n", nsamples); } // Calculate TX advance in seconds from samples and sampling rate diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 410e0727b..48b171ce0 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -62,7 +62,7 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, // Check supported config if (!check_valid_config()) { - log->console("Warning: Invalid PDCP config.\n"); + srslte::out_stream("Warning: Invalid PDCP config.\n"); } } diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index e4661f764..c2703a0be 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -37,13 +37,7 @@ rlc_am_lte::rlc_am_lte(srslte::log_ref log_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, srslte::timer_handler* timers_) : - log(log_), - rrc(rrc_), - pdcp(pdcp_), - timers(timers_), - lcid(lcid_), - tx(this), - rx(this) + log(log_), rrc(rrc_), pdcp(pdcp_), timers(timers_), lcid(lcid_), tx(this), rx(this) {} // Applies new configuration. Must be just reestablished or initiated @@ -810,13 +804,13 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true); if (pdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Could not allocate PDU in build_data_pdu()\n"); - log->console("tx_window size: %zd PDUs\n", tx_window.size()); - log->console("vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d\n", vt_a, vt_ms, vt_s, poll_sn); - log->console("retx_queue size: %zd PDUs\n", retx_queue.size()); + srslte::out_stream("Fatal Error: Could not allocate PDU in build_data_pdu()\n"); + srslte::out_stream("tx_window size: %zd PDUs\n", tx_window.size()); + srslte::out_stream("vt_a = %d, vt_ms = %d, vt_s = %d, poll_sn = %d\n", vt_a, vt_ms, vt_s, poll_sn); + srslte::out_stream("retx_queue size: %zd PDUs\n", retx_queue.size()); std::map::iterator txit; for (txit = tx_window.begin(); txit != tx_window.end(); txit++) { - log->console("tx_window - SN=%d\n", txit->first); + srslte::out_stream("tx_window - SN=%d\n", txit->first); } exit(-1); #else @@ -825,9 +819,9 @@ int rlc_am_lte::rlc_am_lte_tx::build_data_pdu(uint8_t* payload, uint32_t nof_byt #endif } rlc_amd_pdu_header_t header = {}; - header.dc = RLC_DC_FIELD_DATA_PDU; - header.fi = RLC_FI_FIELD_START_AND_END_ALIGNED; - header.sn = vt_s; + header.dc = RLC_DC_FIELD_DATA_PDU; + header.fi = RLC_FI_FIELD_START_AND_END_ALIGNED; + header.sn = vt_s; uint32_t head_len = rlc_am_packed_length(&header); uint32_t to_move = 0; @@ -1258,7 +1252,7 @@ void rlc_am_lte::rlc_am_lte_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_b pdu.buf = srslte::allocate_unique_buffer(*pool, true); if (pdu.buf == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Couldn't allocate PDU in handle_data_pdu().\n"); + srslte::out_stream("Fatal Error: Couldn't allocate PDU in handle_data_pdu().\n"); exit(-1); #else log->error("Fatal Error: Couldn't allocate PDU in handle_data_pdu().\n"); @@ -1365,7 +1359,7 @@ void rlc_am_lte::rlc_am_lte_rx::handle_data_pdu_segment(uint8_t* pa segment.buf = srslte::allocate_unique_buffer(*pool, true); if (segment.buf == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment().\n"); + srslte::out_stream("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment().\n"); exit(-1); #else log->error("Fatal Error: Couldn't allocate PDU in handle_data_pdu_segment().\n"); @@ -1434,7 +1428,7 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() rx_sdu = allocate_unique_buffer(*pool, true); if (rx_sdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)\n"); + srslte::out_stream("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)\n"); exit(-1); #else log->error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (1)\n"); @@ -1484,7 +1478,7 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() rx_sdu = allocate_unique_buffer(*pool, true); if (rx_sdu == nullptr) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)\n"); + srslte::out_stream("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)\n"); exit(-1); #else log->error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (2)\n"); @@ -1528,7 +1522,7 @@ void rlc_am_lte::rlc_am_lte_rx::reassemble_rx_sdus() rx_sdu = allocate_unique_buffer(*pool, true); if (rx_sdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)\n"); + srslte::out_stream("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)\n"); exit(-1); #else log->error("Fatal Error: Could not allocate PDU in reassemble_rx_sdus() (3)\n"); @@ -1854,7 +1848,7 @@ bool rlc_am_lte::rlc_am_lte_rx::add_segment_and_check(rlc_amd_rx_pdu_segments_t* unique_byte_buffer_t full_pdu = srslte::allocate_unique_buffer(*pool, true); if (full_pdu == NULL) { #ifdef RLC_AM_BUFFER_DEBUG - log->console("Fatal Error: Could not allocate PDU in add_segment_and_check()\n"); + srslte::out_stream("Fatal Error: Could not allocate PDU in add_segment_and_check()\n"); exit(-1); #else log->error("Fatal Error: Could not allocate PDU in add_segment_and_check()\n"); diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 74cdcef90..516efd22e 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -56,7 +56,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) // Validate arguments if (parse_args(args_)) { - log->console("Error processing arguments.\n"); + srslte::out_stream("Error processing arguments.\n"); return SRSLTE_ERROR; } @@ -68,32 +68,32 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) if (args.stack.type == "lte") { std::unique_ptr lte_stack(new enb_stack_lte(logger)); if (!lte_stack) { - log->console("Error creating eNB stack.\n"); + srslte::out_stream("Error creating eNB stack.\n"); return SRSLTE_ERROR; } std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio(logger)); if (!lte_radio) { - log->console("Error creating radio multi instance.\n"); + srslte::out_stream("Error creating radio multi instance.\n"); return SRSLTE_ERROR; } std::unique_ptr lte_phy = std::unique_ptr(new srsenb::phy(logger)); if (!lte_phy) { - log->console("Error creating LTE PHY instance.\n"); + srslte::out_stream("Error creating LTE PHY instance.\n"); return SRSLTE_ERROR; } // Init Radio if (lte_radio->init(args.rf, lte_phy.get())) { - log->console("Error initializing radio.\n"); + srslte::out_stream("Error initializing radio.\n"); return SRSLTE_ERROR; } // Only Init PHY if radio couldn't be initialized if (ret == SRSLTE_SUCCESS) { if (lte_phy->init(args.phy, phy_cfg, lte_radio.get(), lte_stack.get())) { - log->console("Error initializing PHY.\n"); + srslte::out_stream("Error initializing PHY.\n"); ret = SRSLTE_ERROR; } } @@ -101,7 +101,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) // Only init Stack if both radio and PHY could be initialized if (ret == SRSLTE_SUCCESS) { if (lte_stack->init(args.stack, rrc_cfg, lte_phy.get())) { - log->console("Error initializing stack.\n"); + srslte::out_stream("Error initializing stack.\n"); ret = SRSLTE_ERROR; } } @@ -118,7 +118,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) // Init layers if (nr_radio->init(args.rf, nullptr)) { - log->console("Error initializing radio.\n"); + srslte::out_stream("Error initializing radio.\n"); return SRSLTE_ERROR; } @@ -129,7 +129,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) args.phy.vnf_args.log_level = args.phy.log.phy_level; args.phy.vnf_args.log_hex_limit = args.phy.log.phy_hex_limit; if (nr_phy->init(args.phy, nr_phy_cfg, nr_stack.get())) { - log->console("Error initializing PHY.\n"); + srslte::out_stream("Error initializing PHY.\n"); return SRSLTE_ERROR; } @@ -138,7 +138,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) rrc_nr_cfg.coreless = args.stack.coreless; if (nr_stack->init(args.stack, rrc_nr_cfg, nr_phy.get())) { - log->console("Error initializing stack.\n"); + srslte::out_stream("Error initializing stack.\n"); return SRSLTE_ERROR; } @@ -146,7 +146,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) phy = std::move(nr_phy); radio = std::move(nr_radio); #else - log->console("ERROR: 5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); + srslte::out_stream("ERROR: 5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); log->error("5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); #endif } @@ -154,8 +154,8 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_) started = true; // set to true in any case to allow stopping the eNB if an error happened if (ret == SRSLTE_SUCCESS) { - log->console("\n==== eNodeB started ===\n"); - log->console("Type to view trace\n"); + srslte::out_stream("\n==== eNodeB started ===\n"); + srslte::out_stream("Type to view trace\n"); } else { // if any of the layers failed to start, make sure the rest is stopped in a controlled manner stop(); diff --git a/srsenb/src/phy/sf_worker.cc b/srsenb/src/phy/sf_worker.cc index 2741b2601..d2f453c4b 100644 --- a/srsenb/src/phy/sf_worker.cc +++ b/srsenb/src/phy/sf_worker.cc @@ -307,13 +307,13 @@ void sf_worker::start_plot() #ifdef ENABLE_GUI if (plot_worker_id == -1) { plot_worker_id = get_id(); - log_h->console("Starting plot for worker_id=%d\n", plot_worker_id); + srslte::out_stream("Starting plot for worker_id=%d\n", plot_worker_id); init_plots(this); } else { - log_h->console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); + srslte::out_stream("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); } #else - log_h->console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); + srslte::out_stream("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); #endif } diff --git a/srsenb/src/phy/txrx.cc b/srsenb/src/phy/txrx.cc index c8d492752..94849a710 100644 --- a/srsenb/src/phy/txrx.cc +++ b/srsenb/src/phy/txrx.cc @@ -105,7 +105,7 @@ void txrx::run_thread() double tx_freq_hz = worker_com->get_dl_freq_hz(cc_idx); double rx_freq_hz = worker_com->get_ul_freq_hz(cc_idx); uint32_t rf_port = worker_com->get_rf_port(cc_idx); - log_h->console( + srslte::out_stream( "Setting frequency: DL=%.1f Mhz, UL=%.1f MHz for cc_idx=%d\n", tx_freq_hz / 1e6f, rx_freq_hz / 1e6f, cc_idx); radio_h->set_tx_freq(rf_port, tx_freq_hz); radio_h->set_rx_freq(rf_port, rx_freq_hz); diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 0432cccdd..d27b47e51 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -531,12 +531,12 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx preamble_idx, time_adv, rnti); - log_h->console("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", - tti, - enb_cc_idx, - preamble_idx, - time_adv, - rnti); + srslte::out_stream("RACH: tti=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x\n", + tti, + enb_cc_idx, + preamble_idx, + time_adv, + rnti); }); // Allocate one new UE object in advance diff --git a/srsenb/src/stack/mac/scheduler.cc b/srsenb/src/stack/mac/scheduler.cc index 37b3a94f6..3f9b64049 100644 --- a/srsenb/src/stack/mac/scheduler.cc +++ b/srsenb/src/stack/mac/scheduler.cc @@ -27,7 +27,7 @@ #include "srslte/common/logmap.h" #include "srslte/srslte.h" -#define Console(fmt, ...) srslte::logmap::get("MAC ")->console(fmt, ##__VA_ARGS__) +#define Console(fmt, ...) srslte::out_stream(fmt, ##__VA_ARGS__) #define Error(fmt, ...) srslte::logmap::get("MAC ")->error(fmt, ##__VA_ARGS__) namespace srsenb { @@ -237,7 +237,8 @@ bool sched::ue_exists(uint16_t rnti) void sched::phy_config_enabled(uint16_t rnti, bool enabled) { // TODO: Check if correct use of last_tti - ue_db_access(rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); }, __PRETTY_FUNCTION__); } int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg_) @@ -254,7 +255,8 @@ uint32_t sched::get_dl_buffer(uint16_t rnti) { // TODO: Check if correct use of last_tti uint32_t ret = SRSLTE_ERROR; - ue_db_access(rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_new_data(); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [&ret](sched_ue& ue) { ret = ue.get_pending_dl_new_data(); }, __PRETTY_FUNCTION__); return ret; } @@ -262,7 +264,8 @@ uint32_t sched::get_ul_buffer(uint16_t rnti) { // TODO: Check if correct use of last_tti uint32_t ret = SRSLTE_ERROR; - ue_db_access(rnti, [this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(last_tti); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [this, &ret](sched_ue& ue) { ret = ue.get_pending_ul_new_data(last_tti); }, __PRETTY_FUNCTION__); return ret; } @@ -279,7 +282,8 @@ int sched::dl_mac_buffer_state(uint16_t rnti, uint32_t ce_code, uint32_t nof_cmd int sched::dl_ack_info(uint32_t tti, uint16_t rnti, uint32_t enb_cc_idx, uint32_t tb_idx, bool ack) { int ret = -1; - ue_db_access(rnti, [&](sched_ue& ue) { ret = ue.set_ack_info(tti, enb_cc_idx, tb_idx, ack); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [&](sched_ue& ue) { ret = ue.set_ack_info(tti, enb_cc_idx, tb_idx, ack); }, __PRETTY_FUNCTION__); return ret; } @@ -327,12 +331,14 @@ int sched::ul_buffer_add(uint16_t rnti, uint32_t lcid, uint32_t bytes) int sched::ul_phr(uint16_t rnti, int phr) { - return ue_db_access(rnti, [phr](sched_ue& ue) { ue.ul_phr(phr); }, __PRETTY_FUNCTION__); + return ue_db_access( + rnti, [phr](sched_ue& ue) { ue.ul_phr(phr); }, __PRETTY_FUNCTION__); } int sched::ul_sr_info(uint32_t tti, uint16_t rnti) { - return ue_db_access(rnti, [](sched_ue& ue) { ue.set_sr(); }, __PRETTY_FUNCTION__); + return ue_db_access( + rnti, [](sched_ue& ue) { ue.set_sr(); }, __PRETTY_FUNCTION__); } void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) @@ -343,28 +349,31 @@ void sched::set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) void sched::tpc_inc(uint16_t rnti) { - ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_inc(); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [](sched_ue& ue) { ue.tpc_inc(); }, __PRETTY_FUNCTION__); } void sched::tpc_dec(uint16_t rnti) { - ue_db_access(rnti, [](sched_ue& ue) { ue.tpc_dec(); }, __PRETTY_FUNCTION__); + ue_db_access( + rnti, [](sched_ue& ue) { ue.tpc_dec(); }, __PRETTY_FUNCTION__); } std::array sched::get_enb_ue_cc_map(uint16_t rnti) { std::array ret{}; ret.fill(-1); // -1 for inactive carriers - ue_db_access(rnti, - [this, &ret](sched_ue& ue) { - for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) { - auto p = ue.get_cell_index(enb_cc_idx); - if (p.second < SRSLTE_MAX_CARRIERS) { - ret[enb_cc_idx] = p.second; - } - } - }, - __PRETTY_FUNCTION__); + ue_db_access( + rnti, + [this, &ret](sched_ue& ue) { + for (size_t enb_cc_idx = 0; enb_cc_idx < carrier_schedulers.size(); ++enb_cc_idx) { + auto p = ue.get_cell_index(enb_cc_idx); + if (p.second < SRSLTE_MAX_CARRIERS) { + ret[enb_cc_idx] = p.second; + } + } + }, + __PRETTY_FUNCTION__); return ret; } diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index 90e1ebea4..a758202ca 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -136,9 +136,7 @@ void bc_sched::reset() *******************************************************/ ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map& ue_db_) : - cc_cfg(&cfg_), - log_h(srslte::logmap::get("MAC")), - ue_db(&ue_db_) + cc_cfg(&cfg_), log_h(srslte::logmap::get("MAC")), ue_db(&ue_db_) {} // Schedules RAR @@ -166,7 +164,7 @@ void ra_sched::dl_sched(sf_sched* tti_sched) prach_tti + PRACH_RAR_OFFSET + cc_cfg->cfg.prach_rar_window, tti_tx_dl); error_msg[len] = '\0'; - log_h->console("%s", error_msg); + srslte::out_stream("%s", error_msg); log_h->error("%s", error_msg); // Remove from pending queue and get next one if window has passed already pending_rars.pop_front(); diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 464cb4593..d9beebd0c 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -329,7 +329,7 @@ void ue::deallocate_pdu(const uint32_t ue_cc_idx, const uint32_t tti) pdus.deallocate(pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc)); pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc) = nullptr; } else { - log_h->console( + srslte::out_stream( "Error deallocating buffer for ue_cc_idx=%d, pid=%d. Not requested\n", ue_cc_idx, tti % nof_rx_harq_proc); } } @@ -340,7 +340,8 @@ void ue::push_pdu(const uint32_t ue_cc_idx, const uint32_t tti, uint32_t len) pdus.push(pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc), len); pending_buffers.at(ue_cc_idx).at(tti % nof_rx_harq_proc) = nullptr; } else { - log_h->console("Error pushing buffer for ue_cc_idx=%d, pid=%d. Not requested\n", ue_cc_idx, tti % nof_rx_harq_proc); + srslte::out_stream( + "Error pushing buffer for ue_cc_idx=%d, pid=%d. Not requested\n", ue_cc_idx, tti % nof_rx_harq_proc); } } @@ -348,10 +349,10 @@ bool ue::process_ce(srslte::sch_subh* subh) { uint32_t buff_size_idx[4] = {}; uint32_t buff_size_bytes[4] = {}; - float phr = 0; - int32_t idx = 0; - uint16_t old_rnti = 0; - bool is_bsr = false; + float phr = 0; + int32_t idx = 0; + uint16_t old_rnti = 0; + bool is_bsr = false; switch (subh->ul_sch_ce_type()) { case srslte::ul_sch_lcid::PHR_REPORT: phr = subh->get_phr(); diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 7f674a48b..e672bf371 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -82,8 +82,8 @@ void rrc::init(const rrc_cfg_t& cfg_, uint32_t n310 = cfg.sibs[1].sib2().ue_timers_and_consts.n310.to_number(); rrc_log->info("T310 %d, T311 %d, N310 %d \n", t310, t311, n310); if (cfg.inactivity_timeout_ms < t310 + t311 + n310) { - rrc_log->console("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n" - "This may break the UE's re-establishment procedure.\n"); + srslte::out_stream("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n" + "This may break the UE's re-establishment procedure.\n"); rrc_log->warning("Inactivity timeout is smaller than the sum of t310, t311 and n310. This may break the UE's " "re-establishment procedure.\n"); } @@ -335,7 +335,7 @@ void rrc::add_paging_id(uint32_t ueid, const asn1::s1ap::ue_paging_id_c& ue_pagi paging_elem.ue_id.set_imsi(); paging_elem.ue_id.imsi().resize(ue_paging_id.imsi().size()); memcpy(paging_elem.ue_id.imsi().data(), ue_paging_id.imsi().data(), ue_paging_id.imsi().size()); - rrc_log->console("Warning IMSI paging not tested\n"); + srslte::out_stream("Warning IMSI paging not tested\n"); } else { paging_elem.ue_id.set_s_tmsi(); paging_elem.ue_id.s_tmsi().mmec.from_number(ue_paging_id.s_tmsi().mmec[0]); @@ -551,7 +551,7 @@ void rrc::rem_user(uint16_t rnti) { auto user_it = users.find(rnti); if (user_it != users.end()) { - rrc_log->console("Disconnecting rnti=0x%x.\n", rnti); + srslte::out_stream("Disconnecting rnti=0x%x.\n", rnti); rrc_log->info("Disconnecting rnti=0x%x.\n", rnti); /* First remove MAC and GTPU to stop processing DL/UL traffic for this user diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 6f7ca80c6..c9d12c290 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -973,7 +973,7 @@ bool rrc::ue::rrc_mobility::needs_intraenb_ho(idle_st& s, const ho_meas_report_e void rrc::ue::rrc_mobility::s1_source_ho_st::wait_ho_req_ack_st::enter(s1_source_ho_st* f, const ho_meas_report_ev& ev) { - f->get_log()->console( + srslte::out_stream( "Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->parent_fsm()->rrc_ue->rnti, ev.target_eci); f->get_log()->info( "Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->parent_fsm()->rrc_ue->rnti, ev.target_eci); diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 8ac3efbdb..26204897b 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -180,7 +180,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) break; case ul_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg_complete: handle_rrc_reconf_complete(&ul_dcch_msg.msg.c1().rrc_conn_recfg_complete(), std::move(pdu)); - parent->rrc_log->console("User 0x%x connected\n", rnti); + srslte::out_stream("User 0x%x connected\n", rnti); state = RRC_STATE_REGISTERED; set_activity_timeout(UE_INACTIVITY_TIMEOUT); break; @@ -514,7 +514,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx_present = true; phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx = ri_idx; } else { - parent->rrc_log->console("\nWarning: Configured wrong M_ri parameter.\n\n"); + srslte::out_stream("\nWarning: Configured wrong M_ri parameter.\n\n"); } } else { phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx_present = false; diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index 3f82424e4..cb18a9278 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -74,7 +74,7 @@ int gtpu::init(std::string gtp_bind_addr_, if (bind(fd, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_in))) { snprintf(errbuf, sizeof(errbuf), "%s", strerror(errno)); gtpu_log->error("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf); - gtpu_log->console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf); + srslte::out_stream("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf); return SRSLTE_ERROR; } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index be3fb9ce9..34d958f81 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -93,7 +93,7 @@ srslte::proc_outcome_t s1ap::ue::ho_prep_proc_t::react(const ho_prep_fail_s& msg std::string cause = s1ap_ptr->get_cause(msg.protocol_ies.cause.value); procError("HO preparation Failure. Cause: %s\n", cause.c_str()); - s1ap_ptr->s1ap_log->console("HO preparation Failure. Cause: %s\n", cause.c_str()); + srslte::out_stream("HO preparation Failure. Cause: %s\n", cause.c_str()); return srslte::proc_outcome_t::error; } @@ -187,15 +187,15 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection() if (not s1ap_ptr->connect_mme()) { procInfo("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n", s1ap_ptr->mme_connect_timer.duration() / 1000); - s1ap_ptr->s1ap_log->console("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n", - s1ap_ptr->mme_connect_timer.duration() / 1000); + srslte::out_stream("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n", + s1ap_ptr->mme_connect_timer.duration() / 1000); s1ap_ptr->mme_connect_timer.run(); return srslte::proc_outcome_t::error; } if (not s1ap_ptr->setup_s1()) { procError("S1 setup failed. Exiting...\n"); - s1ap_ptr->s1ap_log->console("S1 setup failed\n"); + srslte::out_stream("S1 setup failed\n"); s1ap_ptr->running = false; return srslte::proc_outcome_t::error; } @@ -215,7 +215,7 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup return srslte::proc_outcome_t::success; } procError("S1Setup failed. Exiting...\n"); - s1ap_ptr->s1ap_log->console("S1setup failed\n"); + srslte::out_stream("S1setup failed\n"); return srslte::proc_outcome_t::error; } @@ -504,7 +504,7 @@ bool s1ap::handle_mme_rx_msg(srslte::unique_byte_buffer_t pdu, s1ap_log->debug("SCTP Notification %d\n", notification->sn_header.sn_type); if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) { s1ap_log->info("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); - s1ap_log->console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); + srslte::out_stream("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); s1ap_socket.reset(); } } else if (pdu->N_bytes == 0) { @@ -783,7 +783,7 @@ bool s1ap::handle_s1setupfailure(const asn1::s1ap::s1_setup_fail_s& msg) { std::string cause = get_cause(msg.protocol_ies.cause.value); s1ap_log->error("S1 Setup Failure. Cause: %s\n", cause.c_str()); - s1ap_log->console("S1 Setup Failure. Cause: %s\n", cause.c_str()); + srslte::out_stream("S1 Setup Failure. Cause: %s\n", cause.c_str()); return true; } @@ -818,7 +818,7 @@ bool s1ap::handle_ho_request(const asn1::s1ap::ho_request_s& msg) uint16_t rnti = SRSLTE_INVALID_RNTI; s1ap_log->info("Received S1 HO Request\n"); - s1ap_log->console("Received S1 HO Request\n"); + srslte::out_stream("Received S1 HO Request\n"); auto on_scope_exit = srslte::make_scope_exit([this, &rnti, msg]() { // If rnti is not allocated successfully, remove from s1ap and send handover failure @@ -930,7 +930,7 @@ bool s1ap::send_ho_req_ack(const asn1::s1ap::ho_request_s& msg, bool s1ap::handle_mme_status_transfer(const asn1::s1ap::mme_status_transfer_s& msg) { s1ap_log->info("Received S1 MMEStatusTransfer\n"); - s1ap_log->console("Received S1 MMEStatusTransfer\n"); + srslte::out_stream("Received S1 MMEStatusTransfer\n"); ue* u = find_s1apmsg_user(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value); if (u == nullptr) { diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index c6da19a45..746492151 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -70,7 +70,7 @@ int hss::init(hss_args_t* hss_args, srslte::log_filter* hss_log) /*Read user information from DB*/ if (read_db_file(hss_args->db_file) == false) { - m_hss_log->console("Error reading user database file %s\n", hss_args->db_file.c_str()); + srslte::out_stream("Error reading user database file %s\n", hss_args->db_file.c_str()); return -1; } @@ -80,7 +80,7 @@ int hss::init(hss_args_t* hss_args, srslte::log_filter* hss_log) db_file = hss_args->db_file; m_hss_log->info("HSS Initialized. DB file %s, MCC: %d, MNC: %d\n", hss_args->db_file.c_str(), mcc, mnc); - m_hss_log->console("HSS Initialized.\n"); + srslte::out_stream("HSS Initialized.\n"); return 0; } @@ -109,9 +109,9 @@ bool hss::read_db_file(std::string db_filename) m_hss_log->error("Error parsing UE database. Wrong number of columns in .csv\n"); m_hss_log->error("Columns: %zd, Expected %d.\n", split.size(), column_size); - m_hss_log->console("\nError parsing UE database. Wrong number of columns in user database CSV.\n"); - m_hss_log->console("Perhaps you are using an old user_db.csv?\n"); - m_hss_log->console("See 'srsepc/user_db.csv.example' for an example.\n\n"); + srslte::out_stream("\nError parsing UE database. Wrong number of columns in user database CSV.\n"); + srslte::out_stream("Perhaps you are using an old user_db.csv?\n"); + srslte::out_stream("See 'srsepc/user_db.csv.example' for an example.\n\n"); return false; } std::unique_ptr ue_ctx = std::unique_ptr(new hss_ue_ctx_t); @@ -260,7 +260,7 @@ bool hss::gen_auth_info_answer(uint64_t imsi, uint8_t* k_asme, uint8_t* autn, ui m_hss_log->debug("Generating AUTH info answer\n"); hss_ue_ctx_t* ue_ctx = get_ue_ctx(imsi); if (ue_ctx == nullptr) { - m_hss_log->console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); m_hss_log->error("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); return false; } @@ -435,7 +435,7 @@ bool hss::gen_update_loc_answer(uint64_t imsi, uint8_t* qci) std::map >::iterator ue_ctx_it = m_imsi_to_ue_ctx.find(imsi); if (ue_ctx_it == m_imsi_to_ue_ctx.end()) { m_hss_log->info("User not found. IMSI: %015" PRIu64 "\n", imsi); - m_hss_log->console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); return false; } const std::unique_ptr& ue_ctx = ue_ctx_it->second; @@ -449,7 +449,7 @@ bool hss::resync_sqn(uint64_t imsi, uint8_t* auts) m_hss_log->debug("Re-syncing SQN\n"); hss_ue_ctx_t* ue_ctx = get_ue_ctx(imsi); if (ue_ctx == nullptr) { - m_hss_log->console("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); m_hss_log->error("User not found at HSS. IMSI: %015" PRIu64 "\n", imsi); return false; } @@ -470,7 +470,7 @@ bool hss::resync_sqn(uint64_t imsi, uint8_t* auts) void hss::resync_sqn_xor(hss_ue_ctx_t* ue_ctx, uint8_t* auts) { m_hss_log->error("XOR SQN synchronization not supported yet\n"); - m_hss_log->console("XOR SQNs synchronization not supported yet\n"); + srslte::out_stream("XOR SQNs synchronization not supported yet\n"); return; } diff --git a/srsepc/src/mbms-gw/mbms-gw.cc b/srsepc/src/mbms-gw/mbms-gw.cc index 1dd84e615..92a1f0ec3 100644 --- a/srsepc/src/mbms-gw/mbms-gw.cc +++ b/srsepc/src/mbms-gw/mbms-gw.cc @@ -79,18 +79,18 @@ int mbms_gw::init(mbms_gw_args_t* args, srslte::log_ref mbms_gw_log) err = init_sgi_mb_if(args); if (err != SRSLTE_SUCCESS) { - m_mbms_gw_log->console("Error initializing SGi-MB.\n"); + srslte::out_stream("Error initializing SGi-MB.\n"); m_mbms_gw_log->error("Error initializing SGi-MB.\n"); return SRSLTE_ERROR_CANT_START; } err = init_m1_u(args); if (err != SRSLTE_SUCCESS) { - m_mbms_gw_log->console("Error initializing SGi-MB.\n"); + srslte::out_stream("Error initializing SGi-MB.\n"); m_mbms_gw_log->error("Error initializing SGi-MB.\n"); return SRSLTE_ERROR_CANT_START; } m_mbms_gw_log->info("MBMS GW Initiated\n"); - m_mbms_gw_log->console("MBMS GW Initiated\n"); + srslte::out_stream("MBMS GW Initiated\n"); return SRSLTE_SUCCESS; } @@ -288,12 +288,12 @@ void mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t* msg) // Write GTP-U header into packet if (!srslte::gtpu_write_header(&header, msg, m_mbms_gw_log)) { - m_mbms_gw_log->console("Error writing GTP-U header on PDU\n"); + srslte::out_stream("Error writing GTP-U header on PDU\n"); } int n = sendto(m_m1u, msg->msg, msg->N_bytes, 0, (sockaddr*)&m_m1u_multi_addr, sizeof(struct sockaddr)); if (n < 0) { - m_mbms_gw_log->console("Error writing to M1-U socket.\n"); + srslte::out_stream("Error writing to M1-U socket.\n"); } else { m_mbms_gw_log->debug("Sent %d Bytes\n", msg->N_bytes); } diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index a06461932..e5016540f 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -82,13 +82,13 @@ int mme::init(mme_args_t* args, /*Init GTP-C*/ m_mme_gtpc = mme_gtpc::get_instance(); if (!m_mme_gtpc->init(m_mme_gtpc_log)) { - m_s1ap_log->console("Error initializing GTP-C\n"); + srslte::out_stream("Error initializing GTP-C\n"); exit(-1); } /*Log successful initialization*/ m_s1ap_log->info("MME Initialized. MCC: 0x%x, MNC: 0x%x\n", args->s1ap_args.mcc, args->s1ap_args.mnc); - m_s1ap_log->console("MME Initialized. MCC: 0x%x, MNC: 0x%x\n", args->s1ap_args.mcc, args->s1ap_args.mnc); + srslte::out_stream("MME Initialized. MCC: 0x%x, MNC: 0x%x\n", args->s1ap_args.mcc, args->s1ap_args.mnc); return 0; } @@ -157,7 +157,7 @@ void mme::run_thread() m_s1ap_log->debug("SCTP Notification %d\n", notification->sn_header.sn_type); if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) { m_s1ap_log->info("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); - m_s1ap_log->console("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); + srslte::out_stream("SCTP Association Shutdown. Association: %d\n", sri.sinfo_assoc_id); m_s1ap->delete_enb_ctx(sri.sinfo_assoc_id); } } else { diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index b7d548ace..b6ca22028 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -48,7 +48,7 @@ bool mme_gtpc::init(srslte::log_filter* mme_gtpc_log) } m_mme_gtpc_log->info("MME GTP-C Initialized\n"); - m_mme_gtpc_log->console("MME GTP-C Initialized\n"); + srslte::out_stream("MME GTP-C Initialized\n"); return true; } @@ -88,7 +88,7 @@ bool mme_gtpc::init_s11() m_spgw_addr.sun_path[0] = '\0'; m_mme_gtpc_log->info("MME S11 Initialized\n"); - m_mme_gtpc_log->console("MME S11 Initialized\n"); + srslte::out_stream("MME S11 Initialized\n"); return true; } @@ -102,7 +102,7 @@ bool mme_gtpc::send_s11_pdu(const srslte::gtpc_pdu& pdu) n = sendto(m_s11, &pdu, sizeof(pdu), 0, (const sockaddr*)&m_spgw_addr, sizeof(m_spgw_addr)); if (n < 0) { m_mme_gtpc_log->error("Error sending to socket. Error %s\n", strerror(errno)); - m_mme_gtpc_log->console("Error sending to socket. Error %s\n", strerror(errno)); + srslte::out_stream("Error sending to socket. Error %s\n", strerror(errno)); return false; } else { m_mme_gtpc_log->debug("MME S11 Sent %d Bytes.\n", n); @@ -136,7 +136,7 @@ void mme_gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) bool mme_gtpc::send_create_session_request(uint64_t imsi) { m_mme_gtpc_log->info("Sending Create Session Request.\n"); - m_mme_gtpc_log->console("Sending Create Session Request.\n"); + srslte::out_stream("Sending Create Session Request.\n"); struct srslte::gtpc_pdu cs_req_pdu; // Initialize GTP-C message to zero std::memset(&cs_req_pdu, 0, sizeof(cs_req_pdu)); @@ -156,8 +156,8 @@ bool mme_gtpc::send_create_session_request(uint64_t imsi) m_mme_gtpc_log->info("Next MME control TEID: %d\n", m_next_ctrl_teid); m_mme_gtpc_log->info("Allocated MME control TEID: %d\n", cs_req->sender_f_teid.teid); - m_mme_gtpc_log->console("Creating Session Response -- IMSI: %" PRIu64 "\n", imsi); - m_mme_gtpc_log->console("Creating Session Response -- MME control TEID: %d\n", cs_req->sender_f_teid.teid); + srslte::out_stream("Creating Session Response -- IMSI: %" PRIu64 "\n", imsi); + srslte::out_stream("Creating Session Response -- MME control TEID: %d\n", cs_req->sender_f_teid.teid); // APN strncpy(cs_req->apn, m_s1ap->m_s1ap_args.mme_apn.c_str(), sizeof(cs_req->apn) - 1); @@ -204,7 +204,7 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) { struct srslte::gtpc_create_session_response* cs_resp = &cs_resp_pdu->choice.create_session_response; m_mme_gtpc_log->info("Received Create Session Response\n"); - m_mme_gtpc_log->console("Received Create Session Response\n"); + srslte::out_stream("Received Create Session Response\n"); if (cs_resp_pdu->header.type != srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE) { m_mme_gtpc_log->warning("Could not create GTPC session. Not a create session response\n"); // TODO Handle error @@ -236,11 +236,11 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) m_mme_gtpc_log->error("Did not receive SGW S1-U F-TEID in create session response\n"); return false; } - m_mme_gtpc_log->console("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid); + srslte::out_stream("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid); m_mme_gtpc_log->info("Create Session Response -- SPGW control TEID %d\n", sgw_ctr_fteid.teid); in_addr s1u_addr; s1u_addr.s_addr = cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid.ipv4; - m_mme_gtpc_log->console("Create Session Response -- SPGW S1-U Address: %s\n", inet_ntoa(s1u_addr)); + srslte::out_stream("Create Session Response -- SPGW S1-U Address: %s\n", inet_ntoa(s1u_addr)); m_mme_gtpc_log->info("Create Session Response -- SPGW S1-U Address: %s\n", inet_ntoa(s1u_addr)); // Check UE Ipv4 address was allocated @@ -264,7 +264,7 @@ bool mme_gtpc::handle_create_session_response(srslte::gtpc_pdu* cs_resp_pdu) // Save UE IP to nas ctxt emm_ctx->ue_ip.s_addr = cs_resp->paa.ipv4; - m_mme_gtpc_log->console("SPGW Allocated IP %s to IMSI %015" PRIu64 "\n", inet_ntoa(emm_ctx->ue_ip), emm_ctx->imsi); + srslte::out_stream("SPGW Allocated IP %s to IMSI %015" PRIu64 "\n", inet_ntoa(emm_ctx->ue_ip), emm_ctx->imsi); // Save SGW ctrl F-TEID in GTP-C context std::map::iterator it_g = m_imsi_to_gtpc_ctx.find(imsi); diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index 6e325e853..ed5799795 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -105,12 +105,12 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, for (int i = 0; i <= 14; i++) { imsi += attach_req.eps_mobile_id.imsi[i] * std::pow(10, 14 - i); } - nas_log->console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("Attach request -- IMSI: %015" PRIu64 "\n", imsi); nas_log->info("Attach request -- IMSI: %015" PRIu64 "\n", imsi); } else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) { m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi; imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); - nas_log->console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); + srslte::out_stream("Attach request -- M-TMSI: 0x%x\n", m_tmsi); nas_log->info("Attach request -- M-TMSI: 0x%x\n", m_tmsi); } else { nas_log->error("Unhandled Mobile Id type in attach request\n"); @@ -118,19 +118,19 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, } // Log Attach Request Information - nas_log->console("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id); + srslte::out_stream("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id); nas_log->info("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id); - nas_log->console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); + srslte::out_stream("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); nas_log->info("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); - nas_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", - attach_req.ue_network_cap.eea[0], - attach_req.ue_network_cap.eea[1], - attach_req.ue_network_cap.eea[2], - attach_req.ue_network_cap.eea[3], - attach_req.ue_network_cap.eea[4], - attach_req.ue_network_cap.eea[5], - attach_req.ue_network_cap.eea[6], - attach_req.ue_network_cap.eea[7]); + srslte::out_stream("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", + attach_req.ue_network_cap.eea[0], + attach_req.ue_network_cap.eea[1], + attach_req.ue_network_cap.eea[2], + attach_req.ue_network_cap.eea[3], + attach_req.ue_network_cap.eea[4], + attach_req.ue_network_cap.eea[5], + attach_req.ue_network_cap.eea[6], + attach_req.ue_network_cap.eea[7]); nas_log->info("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], @@ -140,15 +140,15 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]); - nas_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", - attach_req.ue_network_cap.eia[0], - attach_req.ue_network_cap.eia[1], - attach_req.ue_network_cap.eia[2], - attach_req.ue_network_cap.eia[3], - attach_req.ue_network_cap.eia[4], - attach_req.ue_network_cap.eia[5], - attach_req.ue_network_cap.eia[6], - attach_req.ue_network_cap.eia[7]); + srslte::out_stream("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", + attach_req.ue_network_cap.eia[0], + attach_req.ue_network_cap.eia[1], + attach_req.ue_network_cap.eia[2], + attach_req.ue_network_cap.eia[3], + attach_req.ue_network_cap.eia[4], + attach_req.ue_network_cap.eia[5], + attach_req.ue_network_cap.eia[6], + attach_req.ue_network_cap.eia[7]); nas_log->info("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], @@ -158,16 +158,16 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]); - nas_log->console("Attach Request -- MS Network Capabilities Present: %s\n", - attach_req.ms_network_cap_present ? "true" : "false"); + srslte::out_stream("Attach Request -- MS Network Capabilities Present: %s\n", + attach_req.ms_network_cap_present ? "true" : "false"); nas_log->info("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false"); - nas_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); + srslte::out_stream("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); nas_log->info("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); - nas_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); + srslte::out_stream("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); nas_log->info("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); - nas_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", - pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); + srslte::out_stream("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", + pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); nas_log->info("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); @@ -184,7 +184,7 @@ bool nas::handle_attach_request(uint32_t enb_ue_s1ap_id, } } else { nas_log->info("Attach Request -- Found previously attached UE.\n"); - nas_log->console("Attach Request -- Found previously attach UE.\n"); + srslte::out_stream("Attach Request -- Found previously attach UE.\n"); if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI) { nas::handle_imsi_attach_request_known_ue( nas_ctx, enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req, nas_rx, args, itf, nas_log); @@ -268,7 +268,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t nas_ctx->m_sec_ctx.autn, nas_ctx->m_sec_ctx.rand, nas_ctx->m_sec_ctx.xres)) { - nas_log->console("User not found. IMSI %015" PRIu64 "\n", nas_ctx->m_emm_ctx.imsi); + srslte::out_stream("User not found. IMSI %015" PRIu64 "\n", nas_ctx->m_emm_ctx.imsi); nas_log->info("User not found. IMSI %015" PRIu64 "\n", nas_ctx->m_emm_ctx.imsi); delete nas_ctx; return false; @@ -293,7 +293,7 @@ bool nas::handle_imsi_attach_request_unknown_ue(uint32_t pool->deallocate(nas_tx); nas_log->info("Downlink NAS: Sending Authentication Request\n"); - nas_log->console("Downlink NAS: Sending Authentication Request\n"); + srslte::out_stream("Downlink NAS: Sending Authentication Request\n"); return true; } @@ -429,15 +429,15 @@ bool nas::handle_guti_attach_request_known_ue(nas* hss_interface_nas* hss = itf.hss; gtpc_interface_nas* gtpc = itf.gtpc; - nas_log->console("Found UE context. IMSI: %015" PRIu64 ", old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n", - emm_ctx->imsi, - ecm_ctx->enb_ue_s1ap_id, - ecm_ctx->mme_ue_s1ap_id); + srslte::out_stream("Found UE context. IMSI: %015" PRIu64 ", old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n", + emm_ctx->imsi, + ecm_ctx->enb_ue_s1ap_id, + ecm_ctx->mme_ue_s1ap_id); // Check NAS integrity msg_valid = nas_ctx->integrity_check(nas_rx); if (msg_valid == true && emm_ctx->state == EMM_STATE_DEREGISTERED) { - nas_log->console( + srslte::out_stream( "GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d\n", sec_ctx->ul_nas_count, sec_ctx->dl_nas_count); nas_log->info( "GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d\n", sec_ctx->ul_nas_count, sec_ctx->dl_nas_count); @@ -471,13 +471,13 @@ bool nas::handle_guti_attach_request_known_ue(nas* // Re-generate K_eNB srslte::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); nas_log->info("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); - nas_log->console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); + srslte::out_stream("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); nas_log->info_hex(sec_ctx->k_enb, 32, "Key eNodeB (k_enb)\n"); // Send reply nas_tx = pool->allocate(); if (ecm_ctx->eit) { - nas_log->console("Secure ESM information transfer requested.\n"); + srslte::out_stream("Secure ESM information transfer requested.\n"); nas_log->info("Secure ESM information transfer requested.\n"); nas_ctx->pack_esm_information_request(nas_tx); s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx, *enb_sri); @@ -486,7 +486,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* uint8_t default_bearer = 5; hss->gen_update_loc_answer(emm_ctx->imsi, &nas_ctx->m_esm_ctx[default_bearer].qci); nas_log->debug("Getting subscription information -- QCI %d\n", nas_ctx->m_esm_ctx[default_bearer].qci); - nas_log->console("Getting subscription information -- QCI %d\n", nas_ctx->m_esm_ctx[default_bearer].qci); + srslte::out_stream("Getting subscription information -- QCI %d\n", nas_ctx->m_esm_ctx[default_bearer].qci); gtpc->send_create_session_request(emm_ctx->imsi); } sec_ctx->ul_nas_count++; @@ -495,7 +495,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* } else { if (emm_ctx->state != EMM_STATE_DEREGISTERED) { nas_log->error("Received GUTI-Attach Request from attached user.\n"); - nas_log->console("Received GUTI-Attach Request from attached user.\n"); + srslte::out_stream("Received GUTI-Attach Request from attached user.\n"); // Delete previous Ctx, restart authentication // Detaching previoulsy attached UE. @@ -537,12 +537,12 @@ bool nas::handle_guti_attach_request_known_ue(nas* s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id, ecm_ctx->mme_ue_s1ap_id); // NAS integrity failed. Re-start authentication process. - nas_log->console("GUTI Attach request NAS integrity failed.\n"); - nas_log->console("RE-starting authentication procedure.\n"); + srslte::out_stream("GUTI Attach request NAS integrity failed.\n"); + srslte::out_stream("RE-starting authentication procedure.\n"); // Get Authentication Vectors from HSS if (!hss->gen_auth_info_answer(emm_ctx->imsi, sec_ctx->k_asme, sec_ctx->autn, sec_ctx->rand, sec_ctx->xres)) { - nas_log->console("User not found. IMSI %015" PRIu64 "\n", emm_ctx->imsi); + srslte::out_stream("User not found. IMSI %015" PRIu64 "\n", emm_ctx->imsi); nas_log->info("User not found. IMSI %015" PRIu64 "\n", emm_ctx->imsi); return false; } @@ -556,7 +556,7 @@ bool nas::handle_guti_attach_request_known_ue(nas* s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx, *enb_sri); pool->deallocate(nas_tx); nas_log->info("Downlink NAS: Sent Authentication Request\n"); - nas_log->console("Downlink NAS: Sent Authentication Request\n"); + srslte::out_stream("Downlink NAS: Sent Authentication Request\n"); return true; } } @@ -571,9 +571,9 @@ bool nas::handle_service_request(uint32_t m_tmsi, srslte::log* nas_log) { nas_log->info("Service request -- S-TMSI 0x%x\n", m_tmsi); - nas_log->console("Service request -- S-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Service request -- S-TMSI 0x%x\n", m_tmsi); nas_log->info("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); - nas_log->console("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srslte::out_stream("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); bool mac_valid = false; LIBLTE_MME_SERVICE_REQUEST_MSG_STRUCT service_req; @@ -593,7 +593,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); if (imsi == 0) { - nas_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); nas_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); nas nas_tmp(args, itf, nas_log); nas_tmp.m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; @@ -608,7 +608,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, nas* nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi); if (nas_ctx == NULL || nas_ctx->m_emm_ctx.state != EMM_STATE_REGISTERED) { - nas_log->console("UE is not EMM-Registered.\n"); + srslte::out_stream("UE is not EMM-Registered.\n"); nas_log->error("UE is not EMM-Registered.\n"); nas nas_tmp(args, itf, nas_log); nas_tmp.m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; @@ -626,7 +626,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, mac_valid = nas_ctx->short_integrity_check(nas_rx); if (mac_valid) { - nas_log->console("Service Request -- Short MAC valid\n"); + srslte::out_stream("Service Request -- Short MAC valid\n"); nas_log->info("Service Request -- Short MAC valid\n"); if (ecm_ctx->state == ECM_STATE_CONNECTED) { nas_log->error("Service Request -- User is ECM CONNECTED\n"); @@ -642,7 +642,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id; // UE not connect. Connect normally. - nas_log->console("Service Request -- User is ECM DISCONNECTED\n"); + srslte::out_stream("Service Request -- User is ECM DISCONNECTED\n"); nas_log->info("Service Request -- User is ECM DISCONNECTED\n"); // Create ECM context @@ -660,14 +660,14 @@ bool nas::handle_service_request(uint32_t m_tmsi, nas_log->error("UE has no valid IP assigned upon reception of service request"); } - nas_log->console("UE previously assigned IP: %s\n", inet_ntoa(emm_ctx->ue_ip)); + srslte::out_stream("UE previously assigned IP: %s\n", inet_ntoa(emm_ctx->ue_ip)); // Re-generate K_eNB srslte::security_generate_k_enb(sec_ctx->k_asme, sec_ctx->ul_nas_count, sec_ctx->k_enb); nas_log->info("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); - nas_log->console("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); + srslte::out_stream("Generating KeNB with UL NAS COUNT: %d\n", sec_ctx->ul_nas_count); nas_log->info_hex(sec_ctx->k_enb, 32, "Key eNodeB (k_enb)\n"); - nas_log->console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid); + srslte::out_stream("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid); // Stop T3413 if running if (mme->is_nas_timer_running(T_3413, emm_ctx->imsi)) { @@ -679,7 +679,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, s1ap->send_initial_context_setup_request(imsi, 5); sec_ctx->ul_nas_count++; } else { - nas_log->console("Service Request -- Short MAC invalid\n"); + srslte::out_stream("Service Request -- Short MAC invalid\n"); nas_log->info("Service Request -- Short MAC invalid\n"); if (ecm_ctx->state == ECM_STATE_CONNECTED) { nas_log->error("Service Request -- User is ECM CONNECTED\n"); @@ -704,7 +704,7 @@ bool nas::handle_service_request(uint32_t m_tmsi, s1ap->send_downlink_nas_transport(ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id, nas_tx, *enb_sri); pool->deallocate(nas_tx); - nas_log->console("Service Request -- Short MAC invalid. Sending service reject.\n"); + srslte::out_stream("Service Request -- Short MAC invalid. Sending service reject.\n"); nas_log->warning("Service Request -- Short MAC invalid. Sending service reject.\n"); nas_log->info("Service Reject -- eNB_UE_S1AP_ID %d MME_UE_S1AP_ID %d.\n", enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); } @@ -720,9 +720,9 @@ bool nas::handle_detach_request(uint32_t m_tmsi, srslte::log* nas_log) { nas_log->info("Detach Request -- S-TMSI 0x%x\n", m_tmsi); - nas_log->console("Detach Request -- S-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Detach Request -- S-TMSI 0x%x\n", m_tmsi); nas_log->info("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); - nas_log->console("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srslte::out_stream("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); bool mac_valid = false; LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; @@ -740,14 +740,14 @@ bool nas::handle_detach_request(uint32_t m_tmsi, uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi); if (imsi == 0) { - nas_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); nas_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi); return true; } nas* nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi); if (nas_ctx == NULL) { - nas_log->console("Could not find UE context from IMSI\n"); + srslte::out_stream("Could not find UE context from IMSI\n"); nas_log->error("Could not find UE context from IMSI\n"); return true; } @@ -765,7 +765,7 @@ bool nas::handle_detach_request(uint32_t m_tmsi, esm_ctx.state = ERAB_DEACTIVATED; } - nas_log->console("Received. M-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Received. M-TMSI 0x%x\n", m_tmsi); // Received detach request as an initial UE message // eNB created new ECM context to send the detach request; this needs to be cleared. ecm_ctx->mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id(); @@ -785,11 +785,11 @@ bool nas::handle_tracking_area_update_request(uint32_t m_tmsi, srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); nas_log->info("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi); - nas_log->console("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi); + srslte::out_stream("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi); nas_log->info("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); - nas_log->console("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); + srslte::out_stream("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); - nas_log->console("Warning: Tracking area update requests are not handled yet.\n"); + srslte::out_stream("Warning: Tracking area update requests are not handled yet.\n"); nas_log->warning("Tracking area update requests are not handled yet.\n"); // Interfaces @@ -841,12 +841,12 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) for (int i = 0; i <= 14; i++) { imsi += attach_req.eps_mobile_id.imsi[i] * std::pow(10, 14 - i); } - m_nas_log->console("Attach request -- IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("Attach request -- IMSI: %015" PRIu64 "\n", imsi); m_nas_log->info("Attach request -- IMSI: %015" PRIu64 "\n", imsi); } else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) { m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi; imsi = m_s1ap->find_imsi_from_m_tmsi(m_tmsi); - m_nas_log->console("Attach request -- M-TMSI: 0x%x\n", m_tmsi); + srslte::out_stream("Attach request -- M-TMSI: 0x%x\n", m_tmsi); m_nas_log->info("Attach request -- M-TMSI: 0x%x\n", m_tmsi); } else { m_nas_log->error("Unhandled Mobile Id type in attach request\n"); @@ -895,7 +895,7 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer( m_emm_ctx.imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - m_nas_log->console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); return false; } @@ -916,7 +916,7 @@ bool nas::handle_attach_request(srslte::byte_buffer_t* nas_rx) m_pool->deallocate(nas_tx); m_nas_log->info("Downlink NAS: Sending Authentication Request\n"); - m_nas_log->console("Downlink NAS: Sending Authentication Request\n"); + srslte::out_stream("Downlink NAS: Sending Authentication Request\n"); return true; } else { m_nas_log->error("Attach request from known UE\n"); @@ -938,7 +938,7 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) } // Log received authentication response - m_nas_log->console("Authentication Response -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("Authentication Response -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info("Authentication Response -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info_hex(auth_resp.res, 8, "Authentication response -- RES"); m_nas_log->info_hex(m_sec_ctx.xres, 8, "Authentication response -- XRES"); @@ -953,7 +953,7 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) nas_tx = m_pool->allocate(); if (!ue_valid) { // Authentication rejected - m_nas_log->console("UE Authentication Rejected.\n"); + srslte::out_stream("UE Authentication Rejected.\n"); m_nas_log->warning("UE Authentication Rejected.\n"); // Send back Athentication Reject @@ -961,13 +961,13 @@ bool nas::handle_authentication_response(srslte::byte_buffer_t* nas_rx) m_nas_log->info("Downlink NAS: Sending Authentication Reject.\n"); } else { // Authentication accepted - m_nas_log->console("UE Authentication Accepted.\n"); + srslte::out_stream("UE Authentication Accepted.\n"); m_nas_log->info("UE Authentication Accepted.\n"); // Send Security Mode Command m_sec_ctx.ul_nas_count = 0; // Reset the NAS uplink counter for the right key k_enb derivation pack_security_mode_command(nas_tx); - m_nas_log->console("Downlink NAS: Sending NAS Security Mode Command.\n"); + srslte::out_stream("Downlink NAS: Sending NAS Security Mode Command.\n"); } // Send reply @@ -990,13 +990,13 @@ bool nas::handle_security_mode_complete(srslte::byte_buffer_t* nas_rx) // Log security mode complete m_nas_log->info("Security Mode Command Complete -- IMSI: %015" PRIu64 "\n", m_emm_ctx.imsi); - m_nas_log->console("Security Mode Command Complete -- IMSI: %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("Security Mode Command Complete -- IMSI: %015" PRIu64 "\n", m_emm_ctx.imsi); // Check wether secure ESM information transfer is required nas_tx = m_pool->allocate(); if (m_ecm_ctx.eit == true) { // Secure ESM information transfer is required - m_nas_log->console("Sending ESM information request\n"); + srslte::out_stream("Sending ESM information request\n"); m_nas_log->info("Sending ESM information request\n"); // Packing ESM information request @@ -1008,7 +1008,7 @@ bool nas::handle_security_mode_complete(srslte::byte_buffer_t* nas_rx) uint8_t default_bearer = 5; m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci); m_nas_log->debug("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); - m_nas_log->console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); + srslte::out_stream("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_gtpc->send_create_session_request(m_emm_ctx.imsi); } m_pool->deallocate(nas_tx); @@ -1037,8 +1037,8 @@ bool nas::handle_attach_complete(srslte::byte_buffer_t* nas_rx) return false; } - m_nas_log->console("Unpacked Attached Complete Message. IMSI %" PRIu64 "\n", m_emm_ctx.imsi); - m_nas_log->console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n", act_bearer.eps_bearer_id); + srslte::out_stream("Unpacked Attached Complete Message. IMSI %" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n", act_bearer.eps_bearer_id); if (act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) { m_nas_log->error("EPS Bearer ID out of range\n"); @@ -1056,7 +1056,7 @@ bool nas::handle_attach_complete(srslte::byte_buffer_t* nas_rx) m_s1ap->send_downlink_nas_transport(m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx, m_ecm_ctx.enb_sri); m_pool->deallocate(nas_tx); - m_nas_log->console("Sending EMM Information\n"); + srslte::out_stream("Sending EMM Information\n"); m_nas_log->info("Sending EMM Information\n"); } m_emm_ctx.state = EMM_STATE_REGISTERED; @@ -1078,18 +1078,18 @@ bool nas::handle_esm_information_response(srslte::byte_buffer_t* nas_rx) m_nas_log->info("ESM Info: EPS bearer id %d\n", esm_info_resp.eps_bearer_id); if (esm_info_resp.apn_present) { m_nas_log->info("ESM Info: APN %s\n", esm_info_resp.apn.apn); - m_nas_log->console("ESM Info: APN %s\n", esm_info_resp.apn.apn); + srslte::out_stream("ESM Info: APN %s\n", esm_info_resp.apn.apn); } if (esm_info_resp.protocol_cnfg_opts_present) { m_nas_log->info("ESM Info: %d Protocol Configuration Options\n", esm_info_resp.protocol_cnfg_opts.N_opts); - m_nas_log->console("ESM Info: %d Protocol Configuration Options\n", esm_info_resp.protocol_cnfg_opts.N_opts); + srslte::out_stream("ESM Info: %d Protocol Configuration Options\n", esm_info_resp.protocol_cnfg_opts.N_opts); } // Get subscriber info from HSS uint8_t default_bearer = 5; m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci); m_nas_log->debug("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); - m_nas_log->console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); + srslte::out_stream("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); // TODO The packging of GTP-C messages is not ready. // This means that GTP-U tunnels are created with function calls, as opposed to GTP-C. @@ -1114,14 +1114,14 @@ bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) } m_nas_log->info("ID response -- IMSI: %015" PRIu64 "\n", imsi); - m_nas_log->console("ID Response -- IMSI: %015" PRIu64 "\n", imsi); + srslte::out_stream("ID Response -- IMSI: %015" PRIu64 "\n", imsi); // Set UE's IMSI m_emm_ctx.imsi = imsi; // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer(imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - m_nas_log->console("User not found. IMSI %015" PRIu64 "\n", imsi); + srslte::out_stream("User not found. IMSI %015" PRIu64 "\n", imsi); m_nas_log->info("User not found. IMSI %015" PRIu64 "\n", imsi); return false; } @@ -1147,13 +1147,13 @@ bool nas::handle_identity_response(srslte::byte_buffer_t* nas_rx) m_pool->deallocate(nas_tx); m_nas_log->info("Downlink NAS: Sent Authentication Request\n"); - m_nas_log->console("Downlink NAS: Sent Authentication Request\n"); + srslte::out_stream("Downlink NAS: Sent Authentication Request\n"); return true; } bool nas::handle_tracking_area_update_request(srslte::byte_buffer_t* nas_rx) { - m_nas_log->console("Warning: Tracking Area Update Request messages not handled yet.\n"); + srslte::out_stream("Warning: Tracking Area Update Request messages not handled yet.\n"); m_nas_log->warning("Warning: Tracking Area Update Request messages not handled yet.\n"); srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance(); @@ -1187,29 +1187,29 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) switch (auth_fail.emm_cause) { case 20: - m_nas_log->console("MAC code failure\n"); + srslte::out_stream("MAC code failure\n"); m_nas_log->info("MAC code failure\n"); break; case 26: - m_nas_log->console("Non-EPS authentication unacceptable\n"); + srslte::out_stream("Non-EPS authentication unacceptable\n"); m_nas_log->info("Non-EPS authentication unacceptable\n"); break; case 21: - m_nas_log->console("Authentication Failure -- Synchronization Failure\n"); + srslte::out_stream("Authentication Failure -- Synchronization Failure\n"); m_nas_log->info("Authentication Failure -- Synchronization Failure\n"); if (auth_fail.auth_fail_param_present == false) { m_nas_log->error("Missing fail parameter\n"); return false; } if (!m_hss->resync_sqn(m_emm_ctx.imsi, auth_fail.auth_fail_param)) { - m_nas_log->console("Resynchronization failed. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("Resynchronization failed. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info("Resynchronization failed. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); return false; } // Get Authentication Vectors from HSS if (!m_hss->gen_auth_info_answer( m_emm_ctx.imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) { - m_nas_log->console("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info("User not found. IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); return false; } @@ -1227,7 +1227,7 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) m_pool->deallocate(nas_tx); m_nas_log->info("Downlink NAS: Sent Authentication Request\n"); - m_nas_log->console("Downlink NAS: Sent Authentication Request\n"); + srslte::out_stream("Downlink NAS: Sent Authentication Request\n"); // TODO Start T3460 Timer! break; } @@ -1237,7 +1237,7 @@ bool nas::handle_authentication_failure(srslte::byte_buffer_t* nas_rx) bool nas::handle_detach_request(srslte::byte_buffer_t* nas_msg) { - m_nas_log->console("Detach request -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); + srslte::out_stream("Detach request -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); m_nas_log->info("Detach request -- IMSI %015" PRIu64 "\n", m_emm_ctx.imsi); LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; @@ -1276,7 +1276,7 @@ bool nas::pack_authentication_request(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing Authentication Request\n"); - m_nas_log->console("Error packing Authentication Request\n"); + srslte::out_stream("Error packing Authentication Request\n"); return false; } return true; @@ -1290,7 +1290,7 @@ bool nas::pack_authentication_reject(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_reject_msg(&auth_rej, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing Authentication Reject\n"); - m_nas_log->console("Error packing Authentication Reject\n"); + srslte::out_stream("Error packing Authentication Reject\n"); return false; } return true; @@ -1330,7 +1330,7 @@ bool nas::pack_security_mode_command(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_security_mode_command_msg( &sm_cmd, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { - m_nas_log->console("Error packing Authentication Request\n"); + srslte::out_stream("Error packing Authentication Request\n"); return false; } @@ -1344,7 +1344,7 @@ bool nas::pack_security_mode_command(srslte::byte_buffer_t* nas_buffer) uint8_t key_enb[32]; srslte::security_generate_k_enb(m_sec_ctx.k_asme, m_sec_ctx.ul_nas_count, m_sec_ctx.k_enb); m_nas_log->info("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); - m_nas_log->console("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); + srslte::out_stream("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); m_nas_log->info_hex(m_sec_ctx.k_enb, 32, "Key eNodeB (k_enb)\n"); // Generate MAC for integrity protection @@ -1369,7 +1369,7 @@ bool nas::pack_esm_information_request(srslte::byte_buffer_t* nas_buffer) &esm_info_req, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing ESM information request\n"); - m_nas_log->console("Error packing ESM information request\n"); + srslte::out_stream("Error packing ESM information request\n"); return false; } @@ -1521,7 +1521,7 @@ bool nas::pack_identity_request(srslte::byte_buffer_t* nas_buffer) LIBLTE_ERROR_ENUM err = liblte_mme_pack_identity_request_msg(&id_req, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing Identity Request\n"); - m_nas_log->console("Error packing Identity REquest\n"); + srslte::out_stream("Error packing Identity REquest\n"); return false; } return true; @@ -1549,7 +1549,7 @@ bool nas::pack_emm_information(srslte::byte_buffer_t* nas_buffer) &emm_info, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing EMM Information\n"); - m_nas_log->console("Error packing EMM Information\n"); + srslte::out_stream("Error packing EMM Information\n"); return false; } @@ -1579,7 +1579,7 @@ bool nas::pack_service_reject(srslte::byte_buffer_t* nas_buffer, uint8_t emm_cau &service_rej, LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS, 0, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing Service Reject\n"); - m_nas_log->console("Error packing Service Reject\n"); + srslte::out_stream("Error packing Service Reject\n"); return false; } return true; @@ -1601,7 +1601,7 @@ bool nas::pack_tracking_area_update_reject(srslte::byte_buffer_t* nas_buffer, ui &tau_rej, LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS, 0, (LIBLTE_BYTE_MSG_STRUCT*)nas_buffer); if (err != LIBLTE_SUCCESS) { m_nas_log->error("Error packing Tracking Area Update Reject\n"); - m_nas_log->console("Error packing Tracking Area Update Reject\n"); + srslte::out_stream("Error packing Tracking Area Update Reject\n"); return false; } return true; @@ -1939,7 +1939,7 @@ bool nas::start_t3413() bool nas::expire_t3413() { m_nas_log->info("T3413 expired -- Could not page the ue.\n"); - m_nas_log->console("T3413 expired -- Could not page the ue.\n"); + srslte::out_stream("T3413 expired -- Could not page the ue.\n"); if (m_emm_ctx.state != EMM_STATE_REGISTERED) { m_nas_log->error("EMM invalid status upon T3413 expiration\n"); return false; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index def91b91d..8fd71d302 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -108,7 +108,7 @@ void s1ap::stop() std::map::iterator enb_it = m_active_enbs.begin(); while (enb_it != m_active_enbs.end()) { m_s1ap_log->info("Deleting eNB context. eNB Id: 0x%x\n", enb_it->second->enb_id); - m_s1ap_log->console("Deleting eNB context. eNB Id: 0x%x\n", enb_it->second->enb_id); + srslte::out_stream("Deleting eNB context. eNB Id: 0x%x\n", enb_it->second->enb_id); delete enb_it->second; m_active_enbs.erase(enb_it++); } @@ -116,7 +116,7 @@ void s1ap::stop() std::map::iterator ue_it = m_imsi_to_nas_ctx.begin(); while (ue_it != m_imsi_to_nas_ctx.end()) { m_s1ap_log->info("Deleting UE EMM context. IMSI: %015" PRIu64 "\n", ue_it->first); - m_s1ap_log->console("Deleting UE EMM context. IMSI: %015" PRIu64 "\n", ue_it->first); + srslte::out_stream("Deleting UE EMM context. IMSI: %015" PRIu64 "\n", ue_it->first); delete ue_it->second; m_imsi_to_nas_ctx.erase(ue_it++); } @@ -153,7 +153,7 @@ int s1ap::enb_listen() m_s1ap_log->info("S1-MME Initializing\n"); sock_fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); if (sock_fd == -1) { - m_s1ap_log->console("Could not create SCTP socket\n"); + srslte::out_stream("Could not create SCTP socket\n"); return -1; } @@ -164,7 +164,7 @@ int s1ap::enb_listen() evnts.sctp_shutdown_event = 1; if (setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof(evnts))) { close(sock_fd); - m_s1ap_log->console("Subscribing to sctp_data_io_events failed\n"); + srslte::out_stream("Subscribing to sctp_data_io_events failed\n"); return -1; } @@ -177,7 +177,7 @@ int s1ap::enb_listen() if (err != 0) { close(sock_fd); m_s1ap_log->error("Error binding SCTP socket\n"); - m_s1ap_log->console("Error binding SCTP socket\n"); + srslte::out_stream("Error binding SCTP socket\n"); return -1; } @@ -186,7 +186,7 @@ int s1ap::enb_listen() if (err != 0) { close(sock_fd); m_s1ap_log->error("Error in SCTP socket listen\n"); - m_s1ap_log->console("Error in SCTP socket listen\n"); + srslte::out_stream("Error in SCTP socket listen\n"); return -1; } @@ -211,7 +211,7 @@ bool s1ap::s1ap_tx_pdu(const asn1::s1ap::s1ap_pdu_c& pdu, struct sctp_sndrcvinfo ssize_t n_sent = sctp_send(m_s1mme, buf->msg, buf->N_bytes, enb_sri, MSG_NOSIGNAL); if (n_sent == -1) { - m_s1ap_log->console("Failed to send S1AP PDU. Error: %s\n", strerror(errno)); + srslte::out_stream("Failed to send S1AP PDU. Error: %s\n", strerror(errno)); m_s1ap_log->error("Failed to send S1AP PDU. Error: %s \n", strerror(errno)); return false; } @@ -279,7 +279,7 @@ void s1ap::handle_initiating_message(const asn1::s1ap::init_msg_s& msg, struct s break; default: m_s1ap_log->error("Unhandled S1AP intiating message: %s\n", msg.value.type().to_string().c_str()); - m_s1ap_log->console("Unhandled S1APintiating message: %s\n", msg.value.type().to_string().c_str()); + srslte::out_stream("Unhandled S1APintiating message: %s\n", msg.value.type().to_string().c_str()); } } @@ -335,7 +335,7 @@ void s1ap::delete_enb_ctx(int32_t assoc_id) } m_s1ap_log->info("Deleting eNB context. eNB Id: 0x%x\n", enb_id); - m_s1ap_log->console("Deleting eNB context. eNB Id: 0x%x\n", enb_id); + srslte::out_stream("Deleting eNB context. eNB Id: 0x%x\n", enb_id); // Delete connected UEs ctx release_ues_ecm_ctx_in_enb(assoc_id); @@ -429,11 +429,11 @@ nas* s1ap::find_nas_ctx_from_imsi(uint64_t imsi) void s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) { - m_s1ap_log->console("Releasing UEs context\n"); + srslte::out_stream("Releasing UEs context\n"); std::map >::iterator ues_in_enb = m_enb_assoc_to_ue_ids.find(enb_assoc); std::set::iterator ue_id = ues_in_enb->second.begin(); if (ue_id == ues_in_enb->second.end()) { - m_s1ap_log->console("No UEs to be released\n"); + srslte::out_stream("No UEs to be released\n"); } else { while (ue_id != ues_in_enb->second.end()) { std::map::iterator nas_ctx = m_mme_ue_s1ap_id_to_nas_ctx.find(*ue_id); @@ -446,7 +446,7 @@ void s1ap::release_ues_ecm_ctx_in_enb(int32_t enb_assoc) m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); emm_ctx->state = EMM_STATE_DEREGISTERED; } - m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); + srslte::out_stream("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); ecm_ctx->state = ECM_STATE_IDLE; ecm_ctx->mme_ue_s1ap_id = 0; ecm_ctx->enb_ue_s1ap_id = 0; @@ -532,7 +532,7 @@ void s1ap::activate_eps_bearer(uint64_t imsi, uint8_t ebi) mme_ue_s1ap_id, ebi, esm_ctx->state); - m_s1ap_log->console( + srslte::out_stream( "Could not be activate EPS Bearer, bearer in wrong state: MME S1AP Id %d, EPS Bearer id %d, state %d\n", mme_ue_s1ap_id, ebi, @@ -573,23 +573,23 @@ void s1ap::print_enb_ctx_info(const std::string& prefix, const enb_ctx_t& enb_ct std::string mnc_str, mcc_str; if (enb_ctx.enb_name_present) { - m_s1ap_log->console("%s - eNB Name: %s, eNB id: 0x%x\n", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); + srslte::out_stream("%s - eNB Name: %s, eNB id: 0x%x\n", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); m_s1ap_log->info("%s - eNB Name: %s, eNB id: 0x%x\n", prefix.c_str(), enb_ctx.enb_name.c_str(), enb_ctx.enb_id); } else { - m_s1ap_log->console("%s - eNB Id 0x%x\n", prefix.c_str(), enb_ctx.enb_id); + srslte::out_stream("%s - eNB Id 0x%x\n", prefix.c_str(), enb_ctx.enb_id); m_s1ap_log->info("%s - eNB Id 0x%x\n", prefix.c_str(), enb_ctx.enb_id); } srslte::mcc_to_string(enb_ctx.mcc, &mcc_str); srslte::mnc_to_string(enb_ctx.mnc, &mnc_str); m_s1ap_log->info("%s - MCC:%s, MNC:%s, PLMN: %d\n", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str(), enb_ctx.plmn); - m_s1ap_log->console("%s - MCC:%s, MNC:%s\n", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str()); + srslte::out_stream("%s - MCC:%s, MNC:%s\n", prefix.c_str(), mcc_str.c_str(), mnc_str.c_str()); for (int i = 0; i < enb_ctx.nof_supported_ta; i++) { for (int j = 0; i < enb_ctx.nof_supported_ta; i++) { m_s1ap_log->info("%s - TAC %d, B-PLMN 0x%x\n", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); - m_s1ap_log->console("%s - TAC %d, B-PLMN 0x%x\n", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); + srslte::out_stream("%s - TAC %d, B-PLMN 0x%x\n", prefix.c_str(), enb_ctx.tacs[i], enb_ctx.bplmns[i][j]); } } - m_s1ap_log->console("%s - Paging DRX %s\n", prefix.c_str(), enb_ctx.drx.to_string().c_str()); + srslte::out_stream("%s - Paging DRX %s\n", prefix.c_str(), enb_ctx.drx.to_string().c_str()); return; } diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index e218f6904..2c7bee7a0 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -144,7 +144,7 @@ bool s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas* nas_ctx, uint1 srslte::unique_byte_buffer_t nas_buffer = allocate_unique_buffer(*m_pool); if (emm_ctx->state == EMM_STATE_DEREGISTERED) { // Attach procedure initiated from an attach request - m_s1ap_log->console("Adding attach accept to Initial Context Setup Request\n"); + srslte::out_stream("Adding attach accept to Initial Context Setup Request\n"); m_s1ap_log->info("Adding attach accept to Initial Context Setup Request\n"); nas_ctx->pack_attach_accept(nas_buffer.get()); @@ -164,7 +164,7 @@ bool s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas* nas_ctx, uint1 struct in_addr addr; addr.s_addr = htonl(erab_ctx_req.transport_layer_address.to_number()); - m_s1ap_log->console("Sent Initial Context Setup Request. E-RAB id %d \n", erab_ctx_req.erab_id); + srslte::out_stream("Sent Initial Context Setup Request. E-RAB id %d \n", erab_ctx_req.erab_id); m_s1ap_log->info( "Initial Context -- S1-U TEID 0x%" PRIx64 ". IP %s \n", erab_ctx_req.gtp_teid.to_number(), inet_ntoa(addr)); m_s1ap_log->info("Initial Context Setup Request -- eNB UE S1AP Id %d, MME UE S1AP Id %" PRIu64 "\n", @@ -194,7 +194,7 @@ bool s1ap_ctx_mngmt_proc::handle_initial_context_setup_response( emm_ctx_t* emm_ctx = &nas_ctx->m_emm_ctx; ecm_ctx_t* ecm_ctx = &nas_ctx->m_ecm_ctx; - m_s1ap_log->console("Received Initial Context Setup Response\n"); + srslte::out_stream("Received Initial Context Setup Response\n"); // Setup E-RABs for (const asn1::s1ap::protocol_ie_single_container_s& ie_container : @@ -229,14 +229,13 @@ bool s1ap_ctx_mngmt_proc::handle_initial_context_setup_response( m_s1ap_log->info("E-RAB Context Setup. E-RAB id %d\n", esm_ctx->erab_id); m_s1ap_log->info("E-RAB Context -- eNB TEID 0x%x, eNB Address %s\n", esm_ctx->enb_fteid.teid, enb_addr_str); - m_s1ap_log->console("E-RAB Context Setup. E-RAB id %d\n", esm_ctx->erab_id); - m_s1ap_log->console( - "E-RAB Context -- eNB TEID 0x%x; eNB GTP-U Address %s\n", esm_ctx->enb_fteid.teid, enb_addr_str); + srslte::out_stream("E-RAB Context Setup. E-RAB id %d\n", esm_ctx->erab_id); + srslte::out_stream("E-RAB Context -- eNB TEID 0x%x; eNB GTP-U Address %s\n", esm_ctx->enb_fteid.teid, enb_addr_str); } if (emm_ctx->state == EMM_STATE_REGISTERED) { - m_s1ap_log->console("Initial Context Setup Response triggered from Service Request.\n"); - m_s1ap_log->console("Sending Modify Bearer Request.\n"); + srslte::out_stream("Initial Context Setup Response triggered from Service Request.\n"); + srslte::out_stream("Sending Modify Bearer Request.\n"); m_mme_gtpc->send_modify_bearer_request(emm_ctx->imsi, 5, &nas_ctx->m_esm_ctx[5].enb_fteid); } return true; @@ -247,12 +246,12 @@ bool s1ap_ctx_mngmt_proc::handle_ue_context_release_request(const asn1::s1ap::ue { uint32_t mme_ue_s1ap_id = ue_rel.protocol_ies.mme_ue_s1ap_id.value.value; m_s1ap_log->info("Received UE Context Release Request. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); - m_s1ap_log->console("Received UE Context Release Request. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); + srslte::out_stream("Received UE Context Release Request. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); nas* nas_ctx = m_s1ap->find_nas_ctx_from_mme_ue_s1ap_id(mme_ue_s1ap_id); if (nas_ctx == nullptr) { m_s1ap_log->info("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); - m_s1ap_log->console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); + srslte::out_stream("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); return false; } @@ -299,7 +298,7 @@ bool s1ap_ctx_mngmt_proc::send_ue_context_release_command(nas* nas_ctx) // the SPGW. In such cases, there is no need to send the GTP-C Release Access Bearers Request. if (active_erabs) { // There are active E-RABs, send release access mearers request - m_s1ap_log->console("There are active E-RABs, send release access bearers request\n"); + srslte::out_stream("There are active E-RABs, send release access bearers request\n"); m_s1ap_log->info("There are active E-RABs, send release access bearers request\n"); // The handle_release_access_bearers_response function will make sure to mark E-RABS DEACTIVATED @@ -339,19 +338,19 @@ bool s1ap_ctx_mngmt_proc::handle_ue_context_release_complete(const asn1::s1ap::u { uint32_t mme_ue_s1ap_id = rel_comp.protocol_ies.mme_ue_s1ap_id.value.value; m_s1ap_log->info("Received UE Context Release Complete. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); - m_s1ap_log->console("Received UE Context Release Complete. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); + srslte::out_stream("Received UE Context Release Complete. MME-UE S1AP Id %d\n", mme_ue_s1ap_id); nas* nas_ctx = m_s1ap->find_nas_ctx_from_mme_ue_s1ap_id(mme_ue_s1ap_id); if (nas_ctx == nullptr) { m_s1ap_log->info("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); - m_s1ap_log->console("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); + srslte::out_stream("No UE context to release found. MME-UE S1AP Id: %d\n", mme_ue_s1ap_id); return false; } // Delete UE context m_s1ap->release_ue_ecm_ctx(nas_ctx->m_ecm_ctx.mme_ue_s1ap_id); m_s1ap_log->info("UE Context Release Completed.\n"); - m_s1ap_log->console("UE Context Release Completed.\n"); + srslte::out_stream("UE Context Release Completed.\n"); return true; } } // namespace srsepc diff --git a/srsepc/src/mme/s1ap_mngmt_proc.cc b/srsepc/src/mme/s1ap_mngmt_proc.cc index 59a541d21..5f8ecc0bd 100644 --- a/srsepc/src/mme/s1ap_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_mngmt_proc.cc @@ -69,7 +69,7 @@ void s1ap_mngmt_proc::init(void) bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request_s& msg, struct sctp_sndrcvinfo* enb_sri) { - m_s1ap_log->console("Received S1 Setup Request.\n"); + srslte::out_stream("Received S1 Setup Request.\n"); m_s1ap_log->info("Received S1 Setup Request.\n"); enb_ctx_t enb_ctx = {}; @@ -97,11 +97,11 @@ bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request // Check matching PLMNs if (enb_ctx.plmn != m_s1ap->get_plmn()) { - m_s1ap_log->console("Sending S1 Setup Failure - Unknown PLMN\n"); + srslte::out_stream("Sending S1 Setup Failure - Unknown PLMN\n"); m_s1ap_log->warning("Sending S1 Setup Failure - Unknown PLMN\n"); send_s1_setup_failure(asn1::s1ap::cause_misc_opts::unknown_plmn, enb_sri); } else if (!tac_match) { - m_s1ap_log->console("Sending S1 Setup Failure - No matching TAC\n"); + srslte::out_stream("Sending S1 Setup Failure - No matching TAC\n"); m_s1ap_log->warning("Sending S1 Setup Failure - No matching TAC\n"); send_s1_setup_failure(asn1::s1ap::cause_misc_opts::unspecified, enb_sri); } else { @@ -116,7 +116,7 @@ bool s1ap_mngmt_proc::handle_s1_setup_request(const asn1::s1ap::s1_setup_request } send_s1_setup_response(m_s1ap_args, enb_sri); - m_s1ap_log->console("Sending S1 Setup Response\n"); + srslte::out_stream("Sending S1 Setup Response\n"); m_s1ap_log->info("Sending S1 Setup Response\n"); } return true; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 8be74d405..b7771e967 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -102,7 +102,7 @@ bool s1ap_nas_transport::handle_initial_ue_message(const asn1::s1ap::init_ue_msg uint32_t enb_ue_s1ap_id = init_ue.protocol_ies.enb_ue_s1ap_id.value.value; liblte_mme_parse_msg_header((LIBLTE_BYTE_MSG_STRUCT*)nas_msg, &pd, &msg_type); - m_s1ap_log->console("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); + srslte::out_stream("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); m_s1ap_log->info("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); if (init_ue.protocol_ies.s_tmsi_present) { @@ -111,31 +111,31 @@ bool s1ap_nas_transport::handle_initial_ue_message(const asn1::s1ap::init_ue_msg switch (msg_type) { case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST: - m_s1ap_log->console("Received Initial UE message -- Attach Request\n"); + srslte::out_stream("Received Initial UE message -- Attach Request\n"); m_s1ap_log->info("Received Initial UE message -- Attach Request\n"); err = nas::handle_attach_request(enb_ue_s1ap_id, enb_sri, nas_msg, m_nas_init, m_nas_if, m_s1ap->m_nas_log); break; case LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST: - m_s1ap_log->console("Received Initial UE message -- Service Request\n"); + srslte::out_stream("Received Initial UE message -- Service Request\n"); m_s1ap_log->info("Received Initial UE message -- Service Request\n"); err = nas::handle_service_request( m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, m_nas_init, m_nas_if, m_s1ap->m_nas_log); break; case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: - m_s1ap_log->console("Received Initial UE message -- Detach Request\n"); + srslte::out_stream("Received Initial UE message -- Detach Request\n"); m_s1ap_log->info("Received Initial UE message -- Detach Request\n"); err = nas::handle_detach_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, m_nas_init, m_nas_if, m_s1ap->m_nas_log); break; case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST: - m_s1ap_log->console("Received Initial UE message -- Tracking Area Update Request\n"); + srslte::out_stream("Received Initial UE message -- Tracking Area Update Request\n"); m_s1ap_log->info("Received Initial UE message -- Tracking Area Update Request\n"); err = nas::handle_tracking_area_update_request( m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, m_nas_init, m_nas_if, m_s1ap->m_nas_log); break; default: m_s1ap_log->info("Unhandled Initial UE Message 0x%x \n", msg_type); - m_s1ap_log->console("Unhandled Initial UE Message 0x%x \n", msg_type); + srslte::out_stream("Unhandled Initial UE Message 0x%x \n", msg_type); err = false; } m_pool->deallocate(nas_msg); @@ -244,17 +244,17 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr switch (msg_type) { case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST: m_s1ap_log->info("UL NAS: Attach Request\n"); - m_s1ap_log->console("UL NAS: Attach Resquest\n"); + srslte::out_stream("UL NAS: Attach Resquest\n"); nas_ctx->handle_attach_request(nas_msg); break; case LIBLTE_MME_MSG_TYPE_IDENTITY_RESPONSE: m_s1ap_log->info("UL NAS: Received Identity Response\n"); - m_s1ap_log->console("UL NAS: Received Identity Response\n"); + srslte::out_stream("UL NAS: Received Identity Response\n"); nas_ctx->handle_identity_response(nas_msg); break; case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE: m_s1ap_log->info("UL NAS: Received Authentication Response\n"); - m_s1ap_log->console("UL NAS: Received Authentication Response\n"); + srslte::out_stream("UL NAS: Received Authentication Response\n"); nas_ctx->handle_authentication_response(nas_msg); // In case of a successful authentication response, security mode command follows. // Reset counter for incoming security mode complete @@ -265,26 +265,26 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr // Authentication failure with the option sync failure can be sent not integrity protected case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_FAILURE: m_s1ap_log->info("UL NAS: Authentication Failure\n"); - m_s1ap_log->console("UL NAS: Authentication Failure\n"); + srslte::out_stream("UL NAS: Authentication Failure\n"); nas_ctx->handle_authentication_failure(nas_msg); break; // Detach request can be sent not integrity protected when "power off" option is used case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: m_s1ap_log->info("UL NAS: Detach Request\n"); - m_s1ap_log->console("UL NAS: Detach Request\n"); + srslte::out_stream("UL NAS: Detach Request\n"); // TODO: check integrity protection in detach request nas_ctx->handle_detach_request(nas_msg); break; case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMPLETE: m_s1ap_log->info("UL NAS: Received Security Mode Complete\n"); - m_s1ap_log->console("UL NAS: Received Security Mode Complete\n"); + srslte::out_stream("UL NAS: Received Security Mode Complete\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED_WITH_NEW_EPS_SECURITY_CONTEXT && mac_valid == true) { nas_ctx->handle_security_mode_complete(nas_msg); } else { // Security Mode Complete was not integrity protected - m_s1ap_log->console("Security Mode Complete %s. Discard message.\n", - (mac_valid ? "not integrity protected" : "invalid integrity")); + srslte::out_stream("Security Mode Complete %s. Discard message.\n", + (mac_valid ? "not integrity protected" : "invalid integrity")); m_s1ap_log->warning("Security Mode Complete %s. Discard message.\n", (mac_valid ? "not integrity protected" : "invalid integrity")); increase_ul_nas_cnt = false; @@ -292,25 +292,25 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr break; case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE: m_s1ap_log->info("UL NAS: Received Attach Complete\n"); - m_s1ap_log->console("UL NAS: Received Attach Complete\n"); + srslte::out_stream("UL NAS: Received Attach Complete\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED && mac_valid == true) { nas_ctx->handle_attach_complete(nas_msg); } else { // Attach Complete was not integrity protected - m_s1ap_log->console("Attach Complete not integrity protected. Discard message.\n"); + srslte::out_stream("Attach Complete not integrity protected. Discard message.\n"); m_s1ap_log->warning("Attach Complete not integrity protected. Discard message.\n"); increase_ul_nas_cnt = false; } break; case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE: m_s1ap_log->info("UL NAS: Received ESM Information Response\n"); - m_s1ap_log->console("UL NAS: Received ESM Information Response\n"); + srslte::out_stream("UL NAS: Received ESM Information Response\n"); if (sec_hdr_type == LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED && mac_valid == true) { nas_ctx->handle_esm_information_response(nas_msg); } else { // Attach Complete was not integrity protected - m_s1ap_log->console("ESM Information Response %s. Discard message.\n", - (mac_valid ? "not integrity protected" : "invalid integrity")); + srslte::out_stream("ESM Information Response %s. Discard message.\n", + (mac_valid ? "not integrity protected" : "invalid integrity")); m_s1ap_log->warning("ESM Information Response %s. Discard message.\n", (mac_valid ? "not integrity protected" : "invalid integrity")); increase_ul_nas_cnt = false; @@ -318,12 +318,12 @@ bool s1ap_nas_transport::handle_uplink_nas_transport(const asn1::s1ap::ul_nas_tr break; case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST: m_s1ap_log->info("UL NAS: Tracking Area Update Request\n"); - m_s1ap_log->console("UL NAS: Tracking Area Update Request\n"); + srslte::out_stream("UL NAS: Tracking Area Update Request\n"); nas_ctx->handle_tracking_area_update_request(nas_msg); break; default: m_s1ap_log->warning("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); - m_s1ap_log->console("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); + srslte::out_stream("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); m_pool->deallocate(nas_msg); return false; } diff --git a/srsepc/src/spgw/gtpc.cc b/srsepc/src/spgw/gtpc.cc index a2e2eb041..d55af5f49 100644 --- a/srsepc/src/spgw/gtpc.cc +++ b/srsepc/src/spgw/gtpc.cc @@ -69,14 +69,14 @@ int spgw::gtpc::init(spgw_args_t* args, // Init S11 interface err = init_s11(args); if (err != SRSLTE_SUCCESS) { - m_gtpc_log->console("Could not initialize the S11 interface.\n"); + srslte::out_stream("Could not initialize the S11 interface.\n"); return err; } // Init IP pool err = init_ue_ip(args, ip_to_imsi); if (err != SRSLTE_SUCCESS) { - m_gtpc_log->console("Could not initialize the IP pool.\n"); + srslte::out_stream("Could not initialize the IP pool.\n"); return err; } @@ -84,7 +84,7 @@ int spgw::gtpc::init(spgw_args_t* args, m_max_paging_queue = args->max_paging_queue; m_gtpc_log->info("SPGW S11 Initialized.\n"); - m_gtpc_log->console("SPGW S11 Initialized.\n"); + srslte::out_stream("SPGW S11 Initialized.\n"); return 0; } @@ -93,7 +93,7 @@ void spgw::gtpc::stop() std::map::iterator it = m_teid_to_tunnel_ctx.begin(); while (it != m_teid_to_tunnel_ctx.end()) { m_gtpc_log->info("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "\n", it->second->imsi); - m_gtpc_log->console("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "\n", it->second->imsi); + srslte::out_stream("Deleting SP-GW GTP-C Tunnel. IMSI: %015" PRIu64 "\n", it->second->imsi); delete it->second; m_teid_to_tunnel_ctx.erase(it++); } @@ -156,7 +156,7 @@ void spgw::gtpc::handle_s11_pdu(srslte::byte_buffer_t* msg) { // TODO add deserialization code here srslte::gtpc_pdu* pdu = (srslte::gtpc_pdu*)msg->msg; - m_gtpc_log->console("Received GTP-C PDU. Message type: %s\n", srslte::gtpc_msg_type_to_str(pdu->header.type)); + srslte::out_stream("Received GTP-C PDU. Message type: %s\n", srslte::gtpc_msg_type_to_str(pdu->header.type)); m_gtpc_log->debug("Received GTP-C PDU. Message type: %s\n", srslte::gtpc_msg_type_to_str(pdu->header.type)); switch (pdu->header.type) { case srslte::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST: @@ -192,9 +192,9 @@ void spgw::gtpc::handle_create_session_request(const struct srslte::gtpc_create_ // Check if IMSI has active GTP-C and/or GTP-U bool gtpc_present = m_imsi_to_ctr_teid.count(cs_req.imsi); if (gtpc_present) { - m_gtpc_log->console("SPGW: GTP-C context for IMSI %015" PRIu64 " already exists.\n", cs_req.imsi); + srslte::out_stream("SPGW: GTP-C context for IMSI %015" PRIu64 " already exists.\n", cs_req.imsi); delete_gtpc_ctx(m_imsi_to_ctr_teid[cs_req.imsi]); - m_gtpc_log->console("SPGW: Deleted previous context.\n"); + srslte::out_stream("SPGW: Deleted previous context.\n"); } m_gtpc_log->info("Creating new GTP-C context\n"); @@ -280,7 +280,7 @@ void spgw::gtpc::handle_modify_bearer_request(const struct srslte::gtpc_header& if (tunnel_ctx->paging_pending == true) { tunnel_ctx->paging_pending = false; m_gtpc_log->debug("Modify Bearer Request received after Downling Data Notification was sent\n"); - m_gtpc_log->console("Modify Bearer Request received after Downling Data Notification was sent\n"); + srslte::out_stream("Modify Bearer Request received after Downling Data Notification was sent\n"); m_gtpu->send_all_queued_packets(tunnel_ctx->dw_user_fteid, tunnel_ctx->paging_queue); } @@ -363,8 +363,8 @@ bool spgw::gtpc::send_downlink_data_notification(uint32_t spgw_ctr_teid) } tunnel_ctx->paging_pending = true; - m_gtpc_log->console("Found UE for Downlink Notification \n"); - m_gtpc_log->console("MME Ctr TEID 0x%x, IMSI: %015" PRIu64 "\n", tunnel_ctx->dw_ctrl_fteid.teid, tunnel_ctx->imsi); + srslte::out_stream("Found UE for Downlink Notification \n"); + srslte::out_stream("MME Ctr TEID 0x%x, IMSI: %015" PRIu64 "\n", tunnel_ctx->dw_ctrl_fteid.teid, tunnel_ctx->imsi); // Setup GTP-C header header->piggyback = false; @@ -450,11 +450,11 @@ spgw_tunnel_ctx_t* spgw::gtpc::create_gtpc_ctx(const struct srslte::gtpc_create_ uint8_t default_bearer_id = 5; - m_gtpc_log->console("SPGW: Allocated Ctrl TEID %" PRIu64 "\n", spgw_uplink_ctrl_teid); - m_gtpc_log->console("SPGW: Allocated User TEID %" PRIu64 "\n", spgw_uplink_user_teid); + srslte::out_stream("SPGW: Allocated Ctrl TEID %" PRIu64 "\n", spgw_uplink_ctrl_teid); + srslte::out_stream("SPGW: Allocated User TEID %" PRIu64 "\n", spgw_uplink_user_teid); struct in_addr ue_ip_; ue_ip_.s_addr = ue_ip; - m_gtpc_log->console("SPGW: Allocate UE IP %s\n", inet_ntoa(ue_ip_)); + srslte::out_stream("SPGW: Allocate UE IP %s\n", inet_ntoa(ue_ip_)); // Save the UE IP to User TEID map spgw_tunnel_ctx_t* tunnel_ctx = new spgw_tunnel_ctx_t{}; diff --git a/srsepc/src/spgw/gtpu.cc b/srsepc/src/spgw/gtpu.cc index 1663a0512..bb44cd731 100644 --- a/srsepc/src/spgw/gtpu.cc +++ b/srsepc/src/spgw/gtpu.cc @@ -66,19 +66,19 @@ int spgw::gtpu::init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc, s // Init SGi interface err = init_sgi(args); if (err != SRSLTE_SUCCESS) { - m_gtpu_log->console("Could not initialize the SGi interface.\n"); + srslte::out_stream("Could not initialize the SGi interface.\n"); return err; } // Init S1-U err = init_s1u(args); if (err != SRSLTE_SUCCESS) { - m_gtpu_log->console("Could not initialize the S1-U interface.\n"); + srslte::out_stream("Could not initialize the S1-U interface.\n"); return err; } m_gtpu_log->info("SPGW GTP-U Initialized.\n"); - m_gtpu_log->console("SPGW GTP-U Initialized.\n"); + srslte::out_stream("SPGW GTP-U Initialized.\n"); return SRSLTE_SUCCESS; } @@ -197,8 +197,8 @@ int spgw::gtpu::init_s1u(spgw_args_t* args) void spgw::gtpu::handle_sgi_pdu(srslte::byte_buffer_t* msg) { - bool usr_found = false; - bool ctr_found = false; + bool usr_found = false; + bool ctr_found = false; std::map::iterator gtpu_fteid_it; std::map::iterator gtpc_teid_it; diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index e2ec1749f..aa210dd56 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -79,18 +79,18 @@ int spgw::init(spgw_args_t* args, // Init GTP-U if (m_gtpu->init(args, this, m_gtpc, gtpu_log) != SRSLTE_SUCCESS) { - m_spgw_log->console("Could not initialize the SPGW's GTP-U.\n"); + srslte::out_stream("Could not initialize the SPGW's GTP-U.\n"); return SRSLTE_ERROR_CANT_START; } // Init GTP-C if (m_gtpc->init(args, this, m_gtpu, gtpc_log, ip_to_imsi) != SRSLTE_SUCCESS) { - m_spgw_log->console("Could not initialize the S1-U interface.\n"); + srslte::out_stream("Could not initialize the S1-U interface.\n"); return SRSLTE_ERROR_CANT_START; } m_spgw_log->info("SP-GW Initialized.\n"); - m_spgw_log->console("SP-GW Initialized.\n"); + srslte::out_stream("SP-GW Initialized.\n"); return SRSLTE_SUCCESS; } diff --git a/srsue/src/phy/cc_worker.cc b/srsue/src/phy/cc_worker.cc index a9bcd6140..47b97d90a 100644 --- a/srsue/src/phy/cc_worker.cc +++ b/srsue/src/phy/cc_worker.cc @@ -148,7 +148,7 @@ bool cc_worker::set_cell_unlocked(srslte_cell_t cell_) if (cell.frame_type == SRSLTE_TDD && ue_dl_cfg.chest_cfg.estimator_alg != SRSLTE_ESTIMATOR_ALG_INTERPOLATE) { chest_default_cfg.estimator_alg = SRSLTE_ESTIMATOR_ALG_INTERPOLATE; - log_h->console("Enabling subframe interpolation for TDD cells (recommended setting)\n"); + srslte::out_stream("Enabling subframe interpolation for TDD cells (recommended setting)\n"); } cell_initiated = true; @@ -213,7 +213,7 @@ void cc_worker::enable_pregen_signals_unlocked(bool enabled) bool cc_worker::work_dl_regular() { - bool dl_ack[SRSLTE_MAX_CODEWORDS] = {}; + bool dl_ack[SRSLTE_MAX_CODEWORDS] = {}; mac_interface_phy_lte::tb_action_dl_t dl_action = {}; @@ -578,7 +578,7 @@ void cc_worker::update_measurements(std::vector MAX_WORKERS) { - log_h->console("Error in PHY args: nof_phy_threads must be 1, 2 or 3\n"); + srslte::out_stream("Error in PHY args: nof_phy_threads must be 1, 2 or 3\n"); return false; } if (args_.snr_ema_coeff > 1.0) { - log_h->console("Error in PHY args: snr_ema_coeff must be 0<=w<=1\n"); + srslte::out_stream("Error in PHY args: snr_ema_coeff must be 0<=w<=1\n"); return false; } return true; @@ -272,7 +272,7 @@ void phy::set_activation_deactivation_scell(uint32_t cmd) Info("Received SCell Activation / Deactivation command: 0x%x\n", cmd); /* Implements 3GPP 36.321 section 6.1.3.8. Activation/Deactivation MAC Control Element*/ - log_h->console("SCELL Activation / Deactivation CMD: %x\n", cmd); + srslte::out_stream("SCELL Activation / Deactivation CMD: %x\n", cmd); log_h->info("SCELL Activation / Deactivation CMD: %x\n", cmd); for (uint32_t i = 1; i < SRSLTE_MAX_CARRIERS; i++) { @@ -459,7 +459,8 @@ bool phy::set_config(srslte::phy_cfg_t config_, uint32_t cc_idx) // Check parameters are valid if (cc_idx >= args.nof_carriers) { - log_h->console("Received SCell configuration for index %d but there are not enough CC workers available\n", cc_idx); + srslte::out_stream("Received SCell configuration for index %d but there are not enough CC workers available\n", + cc_idx); return false; } @@ -509,7 +510,8 @@ bool phy::set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) // Check parameters are valid if (cc_idx >= args.nof_carriers) { - log_h->console("Received SCell configuration for index %d but there are not enough CC workers available\n", cc_idx); + srslte::out_stream("Received SCell configuration for index %d but there are not enough CC workers available\n", + cc_idx); return false; } @@ -571,7 +573,7 @@ void phy::set_config_tdd(srslte_tdd_config_t& tdd_config_) tdd_config = tdd_config_; if (!tdd_config.configured) { - log_h->console("Setting TDD-config: %d, SS config: %d\n", tdd_config.sf_config, tdd_config.ss_config); + srslte::out_stream("Setting TDD-config: %d, SS config: %d\n", tdd_config.sf_config, tdd_config.ss_config); } tdd_config.configured = true; diff --git a/srsue/src/phy/prach.cc b/srsue/src/phy/prach.cc index bf8966364..f8359bf04 100644 --- a/srsue/src/phy/prach.cc +++ b/srsue/src/phy/prach.cc @@ -109,12 +109,13 @@ bool prach::set_cell(srslte_cell_t cell_, srslte_prach_cfg_t prach_cfg) return true; } - cell = cell_; - cfg = prach_cfg; + cell = cell_; + cfg = prach_cfg; // We must not reset preamble_idx here, MAC might have already called prepare_to_send() if (6 + prach_cfg.freq_offset > cell.nof_prb) { - log_h->console("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb); + srslte::out_stream( + "Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb); log_h->error("Error no space for PRACH: frequency offset=%d, N_rb_ul=%d\n", prach_cfg.freq_offset, cell.nof_prb); return false; } diff --git a/srsue/src/phy/search.cc b/srsue/src/phy/search.cc index 642aabfc0..dec2d4f66 100644 --- a/srsue/src/phy/search.cc +++ b/srsue/src/phy/search.cc @@ -113,7 +113,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::arrayconsole("."); + srslte::out_stream("."); if (force_N_id_2 >= 0 && force_N_id_2 < 3) { ret = srslte_ue_cellsearch_scan_N_id_2(&cs, force_N_id_2, &found_cells[force_N_id_2]); @@ -135,7 +135,7 @@ search::ret_code search::run(srslte_cell_t* cell_, std::arrayconsole("\n"); + srslte::out_stream("\n"); Info("SYNC: PSS/SSS detected: Mode=%s, PCI=%d, CFO=%.1f KHz, CP=%s\n", new_cell.frame_type ? "TDD" : "FDD", new_cell.id, diff --git a/srsue/src/phy/sf_worker.cc b/srsue/src/phy/sf_worker.cc index 9a2b23228..9f5d58ada 100644 --- a/srsue/src/phy/sf_worker.cc +++ b/srsue/src/phy/sf_worker.cc @@ -307,13 +307,13 @@ void sf_worker::start_plot() #ifdef ENABLE_GUI if (plot_worker_id == -1) { plot_worker_id = get_id(); - log_h->console("Starting plot for worker_id=%d\n", plot_worker_id); + srslte::out_stream("Starting plot for worker_id=%d\n", plot_worker_id); init_plots(this); } else { - log_h->console("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); + srslte::out_stream("Trying to start a plot but already started by worker_id=%d\n", plot_worker_id); } #else - log_h->console("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); + srslte::out_stream("Trying to start a plot but plots are disabled (ENABLE_GUI constant in sf_worker.cc)\n"); #endif } diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 0aeefcf38..3bd54c4fe 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -398,8 +398,8 @@ void sync::run_sfn_sync_state() srslte_cell_fprint(stdout, &temp_cell, 0); log_h->error("Detected cell during SFN synchronization differs from configured cell. Cell reselection to " "cells with different MIB is not supported\n"); - log_h->console("Detected cell during SFN synchronization differs from configured cell. Cell reselection " - "to cells with different MIB is not supported\n"); + srslte::out_stream("Detected cell during SFN synchronization differs from configured cell. Cell reselection " + "to cells with different MIB is not supported\n"); phy_state.state_exit(false); } stack->in_sync(); @@ -452,8 +452,8 @@ void sync::run_camping_in_sync_state(sf_worker* worker, srslte::rf_buffer_t& syn if (memcmp(&cell, &temp_cell, sizeof(srslte_cell_t)) != 0) { log_h->error("Detected cell during SFN synchronization differs from configured cell. Cell " "reselection to cells with different MIB is not supported\n"); - log_h->console("Detected cell during SFN synchronization differs from configured cell. Cell " - "reselection to cells with different MIB is not supported\n"); + srslte::out_stream("Detected cell during SFN synchronization differs from configured cell. Cell " + "reselection to cells with different MIB is not supported\n"); } else { log_h->info("SFN resynchronized successfully\n"); } @@ -562,7 +562,7 @@ void sync::run_idle_state() srslte_timestamp_t rx_time = {}; dummy_buffer.set_nof_samples(nsamples); if (radio_recv_fnc(dummy_buffer, &rx_time) == SRSLTE_SUCCESS) { - log_h->console("SYNC: Receiving from radio while in IDLE_RX\n"); + srslte::out_stream("SYNC: Receiving from radio while in IDLE_RX\n"); } // If radio is in locked state returns immediately. In that case, do a 1 ms sleep if (rx_time.frac_secs == 0 && rx_time.full_secs == 0) { diff --git a/srsue/src/stack/mac/proc_ra.cc b/srsue/src/stack/mac/proc_ra.cc index 628563b7a..66543f495 100644 --- a/srsue/src/stack/mac/proc_ra.cc +++ b/srsue/src/stack/mac/proc_ra.cc @@ -170,7 +170,7 @@ void ra_proc::state_pdcch_setup() ra_tti = info.tti_ra; ra_rnti = 1 + (ra_tti % 10) + (10 * info.f_id); rInfo("seq=%d, ra-rnti=0x%x, ra-tti=%d, f_id=%d\n", sel_preamble, ra_rnti, info.tti_ra, info.f_id); - log_h->console("Random Access Transmission: seq=%d, ra-rnti=0x%x\n", sel_preamble, ra_rnti); + srslte::out_stream("Random Access Transmission: seq=%d, ra-rnti=0x%x\n", sel_preamble, ra_rnti); rar_window_st = ra_tti + 3; rntis->rar_rnti = ra_rnti; state = RESPONSE_RECEPTION; @@ -521,7 +521,7 @@ void ra_proc::complete() rrc->ra_completed(); - log_h->console("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta); + srslte::out_stream("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta); rInfo("Random Access Complete. c-rnti=0x%x, ta=%d\n", rntis->crnti, current_ta); state = START_WAIT_COMPLETION; diff --git a/srsue/src/stack/mac/proc_sr.cc b/srsue/src/stack/mac/proc_sr.cc index dfb206792..7db3ba563 100644 --- a/srsue/src/stack/mac/proc_sr.cc +++ b/srsue/src/stack/mac/proc_sr.cc @@ -89,7 +89,7 @@ void sr_proc::step(uint32_t tti) Info("SR: Releasing PUCCH/SRS resources, sr_counter=%d, dsr_transmax=%d\n", sr_counter, sr_cfg.dsr_transmax); - log_h->console("Scheduling request failed: releasing RRC connection...\n"); + srslte::out_stream("Scheduling request failed: releasing RRC connection...\n"); rrc->release_pucch_srs(); ra->start_mac_order(); reset(); diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index f9afed3ef..b66aa7575 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -570,7 +570,7 @@ bool rrc::mbms_service_start(uint32_t serv, uint32_t port) for (uint32_t j = 0; j < pmch->mbms_session_info_list_r9.size(); j++) { mbms_session_info_r9_s* sess = &pmch->mbms_session_info_list_r9[j]; if (serv == sess->tmgi_r9.service_id_r9.to_number()) { - rrc_log->console("MBMS service started. Service id=%d, port=%d, lcid=%d\n", serv, port, sess->lc_ch_id_r9); + srslte::out_stream("MBMS service started. Service id=%d, port=%d, lcid=%d\n", serv, port, sess->lc_ch_id_r9); ret = true; add_mrb(sess->lc_ch_id_r9, port); } @@ -610,7 +610,7 @@ void rrc::radio_link_failure_push_cmd() void rrc::radio_link_failure_process() { // TODO: Generate and store failure report - rrc_log->console("Warning: Detected Radio-Link Failure\n"); + srslte::out_stream("Warning: Detected Radio-Link Failure\n"); if (state == RRC_STATE_CONNECTED) { if (security_is_activated) { @@ -657,7 +657,7 @@ void rrc::timer_expired(uint32_t timeout_id) rrc_log->info("Timer T310 expired: Radio Link Failure\n"); radio_link_failure_push_cmd(); } else if (timeout_id == t311.id()) { - rrc_log->console("Timer T311 expired: Going to RRC IDLE\n"); + srslte::out_stream("Timer T311 expired: Going to RRC IDLE\n"); if (connection_reest.is_idle()) { rrc_log->info("Timer T311 expired: Going to RRC IDLE\n"); start_go_idle(); @@ -678,7 +678,7 @@ void rrc::timer_expired(uint32_t timeout_id) } else if (timeout_id == t300.id()) { // Do nothing, handled in connection_request() } else if (timeout_id == t304.id()) { - rrc_log->console("Timer t304 expired: Handover failed\n"); + srslte::out_stream("Timer t304 expired: Handover failed\n"); rrc_log->info("Timer t304 expired: Handover failed\n"); ho_failed(); } else { @@ -795,10 +795,10 @@ void rrc::send_con_restablish_request(reest_cause_e cause, uint16_t crnti, uint1 rrc_conn_reest_req->ue_id.short_mac_i.from_number(mac_key[2] << 8 | mac_key[3]); rrc_conn_reest_req->reest_cause = cause; - rrc_log->console("RRC Connection Reestablishment to PCI=%d, EARFCN=%d (Cause: \"%s\")\n", - meas_cells.serving_cell().phy_cell.pci, - meas_cells.serving_cell().phy_cell.earfcn, - cause.to_string().c_str()); + srslte::console("RRC Connection Reestablishment to PCI=%d, EARFCN=%d (Cause: \"%s\")\n", + meas_cells.serving_cell().phy_cell.pci, + meas_cells.serving_cell().phy_cell.earfcn, + cause.to_string().c_str()); rrc_log->info("RRC Connection Reestablishment to PCI=%d, EARFCN=%d (Cause: \"%s\")\n", meas_cells.serving_cell().phy_cell.pci, meas_cells.serving_cell().phy_cell.earfcn, @@ -810,7 +810,7 @@ void rrc::send_con_restablish_complete() { rrc_log->debug("Preparing RRC Connection Reestablishment Complete\n"); - rrc_log->console("RRC Connected\n"); + srslte::out_stream("RRC Connected\n"); // Prepare ConnectionSetupComplete packet ul_dcch_msg_s ul_dcch_msg; @@ -1014,14 +1014,14 @@ void rrc::handle_rrc_con_reconfig(uint32_t lcid, const rrc_conn_recfg_s& reconfi void rrc::rrc_connection_release(const std::string& cause) { // Save idleModeMobilityControlInfo, etc. - rrc_log->console("Received RRC Connection Release (releaseCause: %s)\n", cause.c_str()); + srslte::out_stream("Received RRC Connection Release (releaseCause: %s)\n", cause.c_str()); start_go_idle(); } /* Actions upon leaving RRC_CONNECTED 5.3.12 */ void rrc::leave_connected() { - rrc_log->console("RRC IDLE\n"); + srslte::out_stream("RRC IDLE\n"); rrc_log->info("Leaving RRC_CONNECTED state\n"); state = RRC_STATE_IDLE; drb_up = false; @@ -1528,7 +1528,7 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu) // 5.3.3.8 rrc_conn_reject_r8_ies_s* reject_r8 = &c1->rrc_conn_reject().crit_exts.c1().rrc_conn_reject_r8(); rrc_log->info("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); - rrc_log->console("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); + srslte::out_stream("Received ConnectionReject. Wait time: %d\n", reject_r8->wait_time); t300.stop(); @@ -1549,7 +1549,7 @@ void rrc::parse_dl_ccch(unique_byte_buffer_t pdu) break; } case dl_ccch_msg_type_c::c1_c_::types::rrc_conn_reest: { - rrc_log->console("Reestablishment OK\n"); + srslte::out_stream("Reestablishment OK\n"); transaction_id = c1->rrc_conn_reest().rrc_transaction_id; rrc_conn_reest_s conn_reest_copy = c1->rrc_conn_reest(); task_sched.defer_task([this, conn_reest_copy]() { handle_con_reest(conn_reest_copy); }); @@ -2349,7 +2349,7 @@ void rrc::handle_con_setup(const rrc_conn_setup_s& setup) state = RRC_STATE_CONNECTED; t300.stop(); t302.stop(); - rrc_log->console("RRC Connected\n"); + srslte::out_stream("RRC Connected\n"); // Apply the Radio Resource configuration apply_rr_config_dedicated(&setup.crit_exts.c1().rrc_conn_setup_r8().rr_cfg_ded); diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 5bee821d5..aa41ef124 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -21,6 +21,7 @@ #include "srsue/hdr/stack/rrc/rrc_procedures.h" #include "srslte/common/security.h" +#include "srslte/common/standard_streams.h" #include "srslte/common/tti_point.h" #include "srsue/hdr/stack/rrc/rrc_meas.h" #include // for printing uint64_t @@ -367,8 +368,7 @@ proc_outcome_t rrc::si_acquire_proc::react(si_acq_timer_expired ev) *************************************/ rrc::serving_cell_config_proc::serving_cell_config_proc(rrc* parent_) : - rrc_ptr(parent_), - log_h(srslte::logmap::get("RRC")) + rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {} /* @@ -781,8 +781,7 @@ void rrc::plmn_search_proc::then(const srslte::proc_state_t& result) const *************************************/ rrc::connection_request_proc::connection_request_proc(rrc* parent_) : - rrc_ptr(parent_), - log_h(srslte::logmap::get("RRC")) + rrc_ptr(parent_), log_h(srslte::logmap::get("RRC")) {} proc_outcome_t rrc::connection_request_proc::init(srslte::establishment_cause_t cause_, @@ -970,7 +969,7 @@ proc_outcome_t rrc::process_pcch_proc::step() if (rrc_ptr->ue_identity == s_tmsi_paged) { if (RRC_STATE_IDLE == rrc_ptr->state) { Info("S-TMSI match in paging message\n"); - log_h->console("S-TMSI match in paging message\n"); + srslte::out_stream("S-TMSI match in paging message\n"); if (not rrc_ptr->nas->paging(&s_tmsi_paged)) { Error("Unable to start NAS paging proc\n"); return proc_outcome_t::error; @@ -1373,7 +1372,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_co srslte::proc_outcome_t rrc::connection_reest_proc::react(const t301_expiry& ev) { Info("Timer T301 expired: Going to RRC IDLE\n"); - rrc_ptr->rrc_log->console("Timer T301 expired: Going to RRC IDLE\n"); + srslte::out_stream("Timer T301 expired: Going to RRC IDLE\n"); rrc_ptr->start_go_idle(); return proc_outcome_t::error; @@ -1382,7 +1381,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::step() { if (rrc_ptr->t301.is_running() and not passes_cell_criteria()) { Info("Selected cell no longer suitable: Going to RRC IDLE\n"); - rrc_ptr->rrc_log->console("Selected cell no longer suitable: Going to RRC IDLE\n"); + srslte::out_stream("Selected cell no longer suitable: Going to RRC IDLE\n"); rrc_ptr->start_go_idle(); return proc_outcome_t::error; } @@ -1392,7 +1391,7 @@ srslte::proc_outcome_t rrc::connection_reest_proc::step() // 5.3.7.8 - Reception of RRCConnectionReestablishmentReject by the UE srslte::proc_outcome_t rrc::connection_reest_proc::react(const asn1::rrc::rrc_conn_reest_reject_s& reject_msg) { - rrc_ptr->rrc_log->console("Reestablishment Reject. Going to RRC IDLE\n"); + srslte::console("Reestablishment Reject. Going to RRC IDLE\n"); Info("Reestablishment Reject. Going to RRC IDLE\n"); rrc_ptr->t301.stop(); rrc_ptr->start_go_idle(); @@ -1434,9 +1433,9 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc asn1::rrc::mob_ctrl_info_s* mob_ctrl_info = &recfg_r8.mob_ctrl_info; Info("Received HO command to target PCell=%d\n", mob_ctrl_info->target_pci); - rrc_ptr->rrc_log->console("Received HO command to target PCell=%d, NCC=%d\n", - mob_ctrl_info->target_pci, - recfg_r8.security_cfg_ho.handov_type.intra_lte().next_hop_chaining_count); + srslte::out_stream("Received HO command to target PCell=%d, NCC=%d\n", + mob_ctrl_info->target_pci, + recfg_r8.security_cfg_ho.handov_type.intra_lte().next_hop_chaining_count); uint32_t target_earfcn = (mob_ctrl_info->carrier_freq_present) ? mob_ctrl_info->carrier_freq.dl_carrier_freq : rrc_ptr->meas_cells.serving_cell().get_earfcn(); @@ -1446,7 +1445,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc if (cell_to_ho != nullptr) { target_cell = cell_to_ho->phy_cell; } else { - rrc_ptr->rrc_log->console("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci); + srslte::out_stream("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci); Error("Could not find target cell earfcn=%d, pci=%d\n", rrc_ptr->meas_cells.serving_cell().get_earfcn(), mob_ctrl_info->target_pci); @@ -1587,7 +1586,7 @@ srslte::proc_outcome_t rrc::ho_proc::react(ra_completed_ev ev) void rrc::ho_proc::then(const srslte::proc_state_t& result) { Info("HO to PCI=%d, EARFCN=%d %ssuccessful\n", target_cell.pci, target_cell.earfcn, result.is_success() ? "" : "un"); - rrc_ptr->rrc_log->console("HO %ssuccessful\n", result.is_success() ? "" : "un"); + srslte::console("HO %ssuccessful\n", result.is_success() ? "" : "un"); rrc_ptr->t304.stop(); } diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index acaa7dea1..22168cddb 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -116,7 +116,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) // Init USIM first to allow early exit in case reader couldn't be found usim = usim_base::get_instance(&args.usim, usim_log.get()); if (usim->init(&args.usim)) { - usim_log->console("Failed to initialize USIM.\n"); + srslte::out_stream("Failed to initialize USIM.\n"); return SRSLTE_ERROR; } @@ -194,14 +194,14 @@ bool ue_stack_lte::switch_off() bool ue_stack_lte::enable_data() { // perform attach request - stack_log->console("Turning off airplane mode.\n"); + srslte::out_stream("Turning off airplane mode.\n"); return switch_on(); } bool ue_stack_lte::disable_data() { // generate detach request - stack_log->console("Turning on airplane mode.\n"); + srslte::out_stream("Turning on airplane mode.\n"); return nas.detach_request(false); } diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index e4110e60a..01bd90966 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -122,7 +122,7 @@ void gw::write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) log.warning("Packet to small to hold IPv4 header. Dropping packet with %d B\n", pdu->N_bytes); } else { // Only handle IPv4 and IPv6 packets - struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; + struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; if (ip_pkt->version == 4 || ip_pkt->version == 6) { int n = write(tun_fd, pdu->msg, pdu->N_bytes); if (n > 0 && (pdu->N_bytes != (uint32_t)n)) { @@ -232,7 +232,7 @@ void gw::run_thread() N_bytes = read(tun_fd, &pdu->msg[idx], SRSLTE_MAX_BUFFER_SIZE_BYTES - SRSLTE_BUFFER_HEADER_OFFSET - idx); } else { log.error("GW pdu buffer full - gw receive thread exiting.\n"); - log.console("GW pdu buffer full - gw receive thread exiting.\n"); + srslte::out_stream("GW pdu buffer full - gw receive thread exiting.\n"); break; } log.debug("Read %d bytes from TUN fd=%d, idx=%d\n", N_bytes, tun_fd, idx); @@ -298,7 +298,7 @@ void gw::run_thread() } } else { log.error("Failed to read from TUN interface - gw receive thread exiting.\n"); - log.console("Failed to read from TUN interface - gw receive thread exiting.\n"); + srslte::out_stream("Failed to read from TUN interface - gw receive thread exiting.\n"); break; } } @@ -322,8 +322,7 @@ int gw::init_if(char* err_str) netns_fd = open(netns.c_str(), O_RDONLY); if (netns_fd == -1) { err_str = strerror(errno); - log.error("Failed to find netns %s (%s): %s\n", - args.netns.c_str(), netns.c_str(), err_str); + log.error("Failed to find netns %s (%s): %s\n", args.netns.c_str(), netns.c_str(), err_str); return SRSLTE_ERROR_CANT_START; } if (setns(netns_fd, CLONE_NEWNET) == -1) { diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 5ba9ccca8..e630a635d 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -111,7 +111,7 @@ proc_outcome_t nas::plmn_search_proc::react(const plmn_search_complete_t& t) nas_ptr->known_plmns.push_back(t.found_plmns[i].plmn_id); nas_ptr->nas_log->info( "Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac); - nas_ptr->nas_log->console( + srslte::out_stream( "Found PLMN: Id=%s, TAC=%d\n", t.found_plmns[i].plmn_id.to_string().c_str(), t.found_plmns[i].tac); } nas_ptr->select_plmn(); @@ -341,7 +341,7 @@ void nas::timer_expired(uint32_t timeout_id) // Section 5.5.1.2.6 case c) attach_attempt_counter++; - nas_log->console("Attach failed (attempt %d/%d)\n", attach_attempt_counter, max_attach_attempts); + srslte::out_stream("Attach failed (attempt %d/%d)\n", attach_attempt_counter, max_attach_attempts); if (attach_attempt_counter < max_attach_attempts) { nas_log->info("Timer T3410 expired after attach attempt %d/%d: starting T3411\n", attach_attempt_counter, @@ -564,9 +564,9 @@ void nas::select_plmn() home_plmn.to_string().c_str(), known_plmns[0].to_string().c_str()); - nas_log->console("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n", - home_plmn.to_string().c_str(), - known_plmns[0].to_string().c_str()); + srslte::out_stream("Could not find Home PLMN Id=%s, trying to connect to PLMN Id=%s\n", + home_plmn.to_string().c_str(), + known_plmns[0].to_string().c_str()); plmn_is_selected = true; current_plmn = known_plmns[0]; } @@ -1104,11 +1104,11 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[2], act_def_eps_bearer_context_req.pdn_addr.addr[3]); - nas_log->console("Network attach successful. IP: %u.%u.%u.%u\n", - act_def_eps_bearer_context_req.pdn_addr.addr[0], - act_def_eps_bearer_context_req.pdn_addr.addr[1], - act_def_eps_bearer_context_req.pdn_addr.addr[2], - act_def_eps_bearer_context_req.pdn_addr.addr[3]); + srslte::out_stream("Network attach successful. IP: %u.%u.%u.%u\n", + act_def_eps_bearer_context_req.pdn_addr.addr[0], + act_def_eps_bearer_context_req.pdn_addr.addr[1], + act_def_eps_bearer_context_req.pdn_addr.addr[2], + act_def_eps_bearer_context_req.pdn_addr.addr[3]); // Setup GW char* err_str = nullptr; @@ -1118,7 +1118,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) nullptr, err_str)) { nas_log->error("%s - %s\n", gw_setup_failure_str.c_str(), err_str); - nas_log->console("%s\n", gw_setup_failure_str.c_str()); + srslte::out_stream("%s\n", gw_setup_failure_str.c_str()); } } else if (LIBLTE_MME_PDN_TYPE_IPV6 == act_def_eps_bearer_context_req.pdn_addr.pdn_type) { memcpy(ipv6_if_id, act_def_eps_bearer_context_req.pdn_addr.addr, 8); @@ -1133,15 +1133,15 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[6], act_def_eps_bearer_context_req.pdn_addr.addr[7]); - nas_log->console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", - act_def_eps_bearer_context_req.pdn_addr.addr[0], - act_def_eps_bearer_context_req.pdn_addr.addr[1], - act_def_eps_bearer_context_req.pdn_addr.addr[2], - act_def_eps_bearer_context_req.pdn_addr.addr[3], - act_def_eps_bearer_context_req.pdn_addr.addr[4], - act_def_eps_bearer_context_req.pdn_addr.addr[5], - act_def_eps_bearer_context_req.pdn_addr.addr[6], - act_def_eps_bearer_context_req.pdn_addr.addr[7]); + srslte::out_stream("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", + act_def_eps_bearer_context_req.pdn_addr.addr[0], + act_def_eps_bearer_context_req.pdn_addr.addr[1], + act_def_eps_bearer_context_req.pdn_addr.addr[2], + act_def_eps_bearer_context_req.pdn_addr.addr[3], + act_def_eps_bearer_context_req.pdn_addr.addr[4], + act_def_eps_bearer_context_req.pdn_addr.addr[5], + act_def_eps_bearer_context_req.pdn_addr.addr[6], + act_def_eps_bearer_context_req.pdn_addr.addr[7]); // Setup GW char* err_str = nullptr; if (gw->setup_if_addr(rrc->get_lcid_for_eps_bearer(act_def_eps_bearer_context_req.eps_bearer_id), @@ -1150,7 +1150,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) ipv6_if_id, err_str)) { nas_log->error("%s - %s\n", gw_setup_failure_str.c_str(), err_str); - nas_log->console("%s\n", gw_setup_failure_str.c_str()); + srslte::out_stream("%s\n", gw_setup_failure_str.c_str()); } } else if (LIBLTE_MME_PDN_TYPE_IPV4V6 == act_def_eps_bearer_context_req.pdn_addr.pdn_type) { memcpy(ipv6_if_id, act_def_eps_bearer_context_req.pdn_addr.addr, 8); @@ -1165,15 +1165,15 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[5], act_def_eps_bearer_context_req.pdn_addr.addr[6], act_def_eps_bearer_context_req.pdn_addr.addr[7]); - nas_log->console("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", - act_def_eps_bearer_context_req.pdn_addr.addr[0], - act_def_eps_bearer_context_req.pdn_addr.addr[1], - act_def_eps_bearer_context_req.pdn_addr.addr[2], - act_def_eps_bearer_context_req.pdn_addr.addr[3], - act_def_eps_bearer_context_req.pdn_addr.addr[4], - act_def_eps_bearer_context_req.pdn_addr.addr[5], - act_def_eps_bearer_context_req.pdn_addr.addr[6], - act_def_eps_bearer_context_req.pdn_addr.addr[7]); + srslte::out_stream("Network attach successful. IPv6 interface Id: %02x%02x:%02x%02x:%02x%02x:%02x%02x\n", + act_def_eps_bearer_context_req.pdn_addr.addr[0], + act_def_eps_bearer_context_req.pdn_addr.addr[1], + act_def_eps_bearer_context_req.pdn_addr.addr[2], + act_def_eps_bearer_context_req.pdn_addr.addr[3], + act_def_eps_bearer_context_req.pdn_addr.addr[4], + act_def_eps_bearer_context_req.pdn_addr.addr[5], + act_def_eps_bearer_context_req.pdn_addr.addr[6], + act_def_eps_bearer_context_req.pdn_addr.addr[7]); // IPv4 ip_addr |= act_def_eps_bearer_context_req.pdn_addr.addr[8] << 24u; ip_addr |= act_def_eps_bearer_context_req.pdn_addr.addr[9] << 16u; @@ -1187,11 +1187,11 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) act_def_eps_bearer_context_req.pdn_addr.addr[10], act_def_eps_bearer_context_req.pdn_addr.addr[11]); - nas_log->console("Network attach successful. IP: %u.%u.%u.%u\n", - act_def_eps_bearer_context_req.pdn_addr.addr[8], - act_def_eps_bearer_context_req.pdn_addr.addr[9], - act_def_eps_bearer_context_req.pdn_addr.addr[10], - act_def_eps_bearer_context_req.pdn_addr.addr[11]); + srslte::out_stream("Network attach successful. IP: %u.%u.%u.%u\n", + act_def_eps_bearer_context_req.pdn_addr.addr[8], + act_def_eps_bearer_context_req.pdn_addr.addr[9], + act_def_eps_bearer_context_req.pdn_addr.addr[10], + act_def_eps_bearer_context_req.pdn_addr.addr[11]); char* err_str = nullptr; if (gw->setup_if_addr(rrc->get_lcid_for_eps_bearer(act_def_eps_bearer_context_req.eps_bearer_id), @@ -1200,7 +1200,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) ipv6_if_id, err_str)) { nas_log->error("%s - %s\n", gw_setup_failure_str.c_str(), err_str); - nas_log->console("%s\n", gw_setup_failure_str.c_str()); + srslte::out_stream("%s\n", gw_setup_failure_str.c_str()); } } else { nas_log->error("PDN type not IPv4, IPv6 nor IPv4v6\n"); @@ -1277,7 +1277,7 @@ void nas::parse_attach_reject(uint32_t lcid, unique_byte_buffer_t pdu) liblte_mme_unpack_attach_reject_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &attach_rej); nas_log->warning("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); - nas_log->console("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); + srslte::out_stream("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); // stop T3410 if (t3410.is_running()) { @@ -1334,7 +1334,7 @@ void nas::parse_authentication_request(uint32_t lcid, unique_byte_buffer_t pdu, ctxt.ksi = auth_req.nas_ksi.nas_ksi; } else { nas_log->error("NAS mapped security context not currently supported\n"); - nas_log->console("Warning: NAS mapped security context not currently supported\n"); + srslte::out_stream("Warning: NAS mapped security context not currently supported\n"); } if (auth_result == AUTH_OK) { @@ -1351,7 +1351,7 @@ void nas::parse_authentication_request(uint32_t lcid, unique_byte_buffer_t pdu, send_authentication_failure(LIBLTE_MME_EMM_CAUSE_SYNCH_FAILURE, res); } else { nas_log->warning("Network authentication failure\n"); - nas_log->console("Warning: Network authentication failure\n"); + srslte::out_stream("Warning: Network authentication failure\n"); send_authentication_failure(LIBLTE_MME_EMM_CAUSE_MAC_FAILURE, nullptr); } } @@ -1503,7 +1503,7 @@ void nas::parse_service_reject(uint32_t lcid, unique_byte_buffer_t pdu) return; } - nas_log->console("Received service reject with EMM cause=0x%x.\n", service_reject.emm_cause); + srslte::out_stream("Received service reject with EMM cause=0x%x.\n", service_reject.emm_cause); if (service_reject.t3446_present) { nas_log->info( "Received service reject with EMM cause=0x%x and t3446=%d\n", service_reject.emm_cause, service_reject.t3446); @@ -1540,7 +1540,7 @@ void nas::parse_emm_information(uint32_t lcid, unique_byte_buffer_t pdu) liblte_mme_unpack_emm_information_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &emm_info); std::string str = emm_info_str(&emm_info); nas_log->info("Received EMM Information: %s\n", str.c_str()); - nas_log->console("%s\n", str.c_str()); + srslte::out_stream("%s\n", str.c_str()); ctxt.rx_count++; } @@ -1899,7 +1899,7 @@ void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT* msg) pdn_con_req.pdn_type = LIBLTE_MME_PDN_TYPE_IPV4V6; } else { nas_log->warning("Unsupported PDN prtocol. Defaulting to IPv4\n"); - nas_log->console("Unsupported PDN prtocol: %s. Defaulting to IPv4\n", cfg.apn_protocol.c_str()); + srslte::out_stream("Unsupported PDN prtocol: %s. Defaulting to IPv4\n", cfg.apn_protocol.c_str()); pdn_con_req.pdn_type = LIBLTE_MME_PDN_TYPE_IPV4; } diff --git a/srsue/src/stack/upper/pcsc_usim.cc b/srsue/src/stack/upper/pcsc_usim.cc index 96523dc44..14b703485 100644 --- a/srsue/src/stack/upper/pcsc_usim.cc +++ b/srsue/src/stack/upper/pcsc_usim.cc @@ -73,7 +73,7 @@ int pcsc_usim::init(usim_args_t* args) } } else { log->error("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15); - log->console("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15); + srslte::out_stream("Invalid length for IMSI: %zu should be %d\n", imsi_str.length(), 15); return ret; } @@ -87,7 +87,7 @@ int pcsc_usim::init(usim_args_t* args) } } else { log->error("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); - log->console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); + srslte::out_stream("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); return ret; } diff --git a/srsue/src/stack/upper/usim.cc b/srsue/src/stack/upper/usim.cc index a6585ed10..3d950f3d4 100644 --- a/srsue/src/stack/upper/usim.cc +++ b/srsue/src/stack/upper/usim.cc @@ -46,7 +46,7 @@ int usim::init(usim_args_t* args) str_to_hex(args->k, k); } else { usim_log->error("Invalid length for K: %zu should be %d\n", args->k.length(), 32); - usim_log->console("Invalid length for K: %zu should be %d\n", args->k.length(), 32); + srslte::out_stream("Invalid length for K: %zu should be %d\n", args->k.length(), 32); } if (auth_algo == auth_algo_milenage) { @@ -56,14 +56,14 @@ int usim::init(usim_args_t* args) compute_opc(k, op, opc); } else { usim_log->error("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); - usim_log->console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); + srslte::out_stream("Invalid length for OP: %zu should be %d\n", args->op.length(), 32); } } else { if (32 == args->opc.length()) { str_to_hex(args->opc, opc); } else { usim_log->error("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32); - usim_log->console("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32); + srslte::out_stream("Invalid length for OPc: %zu should be %d\n", args->opc.length(), 32); } } } @@ -76,7 +76,7 @@ int usim::init(usim_args_t* args) } } else { usim_log->error("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15); - usim_log->console("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15); + srslte::out_stream("Invalid length for IMSI: %zu should be %d\n", args->imsi.length(), 15); } if (15 == args->imei.length()) { @@ -87,7 +87,7 @@ int usim::init(usim_args_t* args) } } else { usim_log->error("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); - usim_log->console("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); + srslte::out_stream("Invalid length for IMEI: %zu should be %d\n", args->imei.length(), 15); } initiated = true; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 6f408f55d..40717dfc6 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -63,7 +63,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) // Validate arguments if (parse_args(args_)) { - log.console("Error processing arguments. Please check %s for more details.\n", args_.log.filename.c_str()); + srslte::out_stream("Error processing arguments. Please check %s for more details.\n", args_.log.filename.c_str()); return SRSLTE_ERROR; } @@ -71,47 +71,47 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) if (args.stack.type == "lte") { std::unique_ptr lte_stack(new ue_stack_lte()); if (!lte_stack) { - log.console("Error creating LTE stack instance.\n"); + srslte::out_stream("Error creating LTE stack instance.\n"); return SRSLTE_ERROR; } std::unique_ptr gw_ptr(new gw()); if (!gw_ptr) { - log.console("Error creating a GW instance.\n"); + srslte::out_stream("Error creating a GW instance.\n"); return SRSLTE_ERROR; } std::unique_ptr lte_phy = std::unique_ptr(new srsue::phy(logger)); if (!lte_phy) { - log.console("Error creating LTE PHY instance.\n"); + srslte::out_stream("Error creating LTE PHY instance.\n"); return SRSLTE_ERROR; } std::unique_ptr lte_radio = std::unique_ptr(new srslte::radio(logger)); if (!lte_radio) { - log.console("Error creating radio multi instance.\n"); + srslte::out_stream("Error creating radio multi instance.\n"); return SRSLTE_ERROR; } // init layers if (lte_radio->init(args.rf, lte_phy.get())) { - log.console("Error initializing radio.\n"); + srslte::out_stream("Error initializing radio.\n"); return SRSLTE_ERROR; } // from here onwards do not exit immediately if something goes wrong as sub-layers may already use interfaces if (lte_phy->init(args.phy, lte_stack.get(), lte_radio.get())) { - log.console("Error initializing PHY.\n"); + srslte::out_stream("Error initializing PHY.\n"); ret = SRSLTE_ERROR; } if (lte_stack->init(args.stack, logger, lte_phy.get(), gw_ptr.get())) { - log.console("Error initializing stack.\n"); + srslte::out_stream("Error initializing stack.\n"); ret = SRSLTE_ERROR; } if (gw_ptr->init(args.gw, logger, lte_stack.get())) { - log.console("Error initializing GW.\n"); + srslte::out_stream("Error initializing GW.\n"); ret = SRSLTE_ERROR; } @@ -130,22 +130,22 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) // Init layers if (nr_radio->init(args.rf, nullptr)) { - log.console("Error initializing radio.\n"); + srslte::out_stream("Error initializing radio.\n"); return SRSLTE_ERROR; } if (nr_phy->init(args.phy, nr_stack.get())) { - log.console("Error initializing PHY.\n"); + srslte::out_stream("Error initializing PHY.\n"); return SRSLTE_ERROR; } if (nr_stack->init(args.stack, nr_phy.get(), gw_ptr.get())) { - log.console("Error initializing stack.\n"); + srslte::out_stream("Error initializing stack.\n"); return SRSLTE_ERROR; } if (gw_ptr->init(args.gw, logger, nr_stack.get())) { - log.console("Error initializing GW.\n"); + srslte::out_stream("Error initializing GW.\n"); return SRSLTE_ERROR; } @@ -155,18 +155,18 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) phy = std::move(nr_phy); radio = std::move(nr_radio); #else - log.console("ERROR: 5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); + srslte::out_stream("ERROR: 5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); log.error("5G NR stack not compiled. Please, activate CMAKE HAVE_5GNR flag.\n"); #endif } else { - log.console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); + srslte::out_stream("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); ret = SRSLTE_ERROR; } if (phy) { - log.console("Waiting PHY to initialize ... "); + srslte::out_stream("Waiting PHY to initialize ... "); phy->wait_initialize(); - log.console("done!\n"); + srslte::out_stream("done!\n"); } return ret; @@ -230,7 +230,7 @@ int ue::parse_args(const all_args_t& args_) } } else { log.error("Error: dl_earfcn list is empty\n"); - log.console("Error: dl_earfcn list is empty\n"); + srslte::out_stream("Error: dl_earfcn list is empty\n"); return SRSLTE_ERROR; } diff --git a/srsue/test/ttcn3/hdr/ttcn3_port_handler.h b/srsue/test/ttcn3/hdr/ttcn3_port_handler.h index 39d66e362..b472b0265 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_port_handler.h +++ b/srsue/test/ttcn3/hdr/ttcn3_port_handler.h @@ -167,7 +167,7 @@ public: sock_fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); if (sock_fd == -1) { - log->console("Could not create SCTP socket\n"); + srslte::out_stream("Could not create SCTP socket\n"); return ret; } @@ -179,7 +179,7 @@ public: events.sctp_association_event = 1; if (setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(events))) { close(sock_fd); - log->console("Subscribing to sctp_data_io_events failed\n"); + srslte::out_stream("Subscribing to sctp_data_io_events failed\n"); return SRSLTE_ERROR; } @@ -195,7 +195,7 @@ public: if (ret != 0) { close(sock_fd); log->error("Error binding SCTP socket\n"); - log->console("Error binding SCTP socket\n"); + srslte::out_stream("Error binding SCTP socket\n"); return SRSLTE_ERROR; } @@ -204,7 +204,7 @@ public: if (ret != SRSLTE_SUCCESS) { close(sock_fd); log->error("Error in SCTP socket listen\n"); - log->console("Error in SCTP socket listen\n"); + srslte::out_stream("Error in SCTP socket listen\n"); return SRSLTE_ERROR; } diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 955df62e2..f22232026 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -142,7 +142,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({ut_fd, &ut}); - log->console("UT handler listening on SCTP port %d\n", UT_PORT); + srslte::out_stream("UT handler listening on SCTP port %d\n", UT_PORT); // SYS port int sys_fd = sys.init(this, &sys_log, listen_address, SYS_PORT); @@ -151,7 +151,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({sys_fd, &sys}); - log->console("SYS handler listening on SCTP port %d\n", SYS_PORT); + srslte::out_stream("SYS handler listening on SCTP port %d\n", SYS_PORT); // IPsock port int ip_sock_fd = ip_sock.init(&ip_sock_log, listen_address, IPSOCK_PORT); @@ -160,7 +160,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({ip_sock_fd, &ip_sock}); - log->console("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT); + srslte::out_stream("IPSOCK handler listening on SCTP port %d\n", IPSOCK_PORT); // IPctrl port int ip_ctrl_fd = ip_ctrl.init(&ip_ctrl_log, listen_address, IPCTRL_PORT); @@ -169,7 +169,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({ip_ctrl_fd, &ip_ctrl}); - log->console("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT); + srslte::out_stream("IPCTRL handler listening on SCTP port %d\n", IPCTRL_PORT); // add SRB fd int srb_fd = srb.init(this, &srb_log, listen_address, SRB_PORT); @@ -178,7 +178,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({srb_fd, &srb}); - log->console("SRB handler listening on SCTP port %d\n", SRB_PORT); + srslte::out_stream("SRB handler listening on SCTP port %d\n", SRB_PORT); // add DRB fd int drb_fd = drb.init(this, &drb_log, listen_address, DRB_PORT); @@ -187,7 +187,7 @@ int ttcn3_syssim::add_port_handler() return SRSLTE_ERROR; } event_handler.insert({drb_fd, &drb}); - log->console("DRB handler listening on SCTP port %d\n", DRB_PORT); + srslte::out_stream("DRB handler listening on SCTP port %d\n", DRB_PORT); return SRSLTE_SUCCESS; } @@ -221,19 +221,19 @@ void ttcn3_syssim::new_tti_indication(uint64_t res) ss_events_t ev = event_queue.wait_pop(); switch (ev) { case UE_SWITCH_ON: - log->console("Switching on UE ID=%d\n", run_id); + srslte::out_stream("Switching on UE ID=%d\n", run_id); ue->switch_on(); break; case UE_SWITCH_OFF: - log->console("Switching off UE ID=%d\n", run_id); + srslte::out_stream("Switching off UE ID=%d\n", run_id); ue->switch_off(); break; case ENABLE_DATA: - log->console("Enabling data for UE ID=%d\n", run_id); + srslte::out_stream("Enabling data for UE ID=%d\n", run_id); ue->enable_data(); break; case DISABLE_DATA: - log->console("Disabling data for UE ID=%d\n", run_id); + srslte::out_stream("Disabling data for UE ID=%d\n", run_id); ue->disable_data(); break; } @@ -413,7 +413,7 @@ void ttcn3_syssim::tc_start(const char* name) } log->info("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str()); - log->console("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str()); + srslte::out_stream("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str()); // Patch UE config local_args.stack.pcap.filename = get_filename_with_tc_name(args.stack.pcap.filename, run_id, tc_name); @@ -424,7 +424,7 @@ void ttcn3_syssim::tc_start(const char* name) ue->stop(); std::string err("Couldn't initialize UE.\n"); log->error("%s\n", err.c_str()); - log->console("%s\n", err.c_str()); + srslte::out_stream("%s\n", err.c_str()); return; } @@ -439,7 +439,7 @@ void ttcn3_syssim::tc_start(const char* name) void ttcn3_syssim::tc_end() { log->info("Deinitializing UE ID=%d\n", run_id); - log->console("Deinitializing UE ID=%d\n", run_id); + srslte::out_stream("Deinitializing UE ID=%d\n", run_id); ue->stop(); // stop TTI timer diff --git a/srsue/test/ttcn3/src/ttcn3_ue.cc b/srsue/test/ttcn3/src/ttcn3_ue.cc index d079ae5a9..674bf99d3 100644 --- a/srsue/test/ttcn3/src/ttcn3_ue.cc +++ b/srsue/test/ttcn3/src/ttcn3_ue.cc @@ -68,28 +68,28 @@ int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_ph if (args.stack.type == "lte") { stack = std::unique_ptr(new ue_stack_lte()); if (!stack) { - log.console("Error creating LTE stack instance.\n"); + srslte::out_stream("Error creating LTE stack instance.\n"); return SRSLTE_ERROR; } phy = std::unique_ptr(new srsue::lte_ttcn3_phy(logger)); if (!phy) { - log.console("Error creating LTE PHY instance.\n"); + srslte::out_stream("Error creating LTE PHY instance.\n"); return SRSLTE_ERROR; } } else { - log.console("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); + srslte::out_stream("Invalid stack type %s. Supported values are [lte].\n", args.stack.type.c_str()); return SRSLTE_ERROR; } // init layers if (phy->init(args.phy, stack.get(), syssim_)) { - log.console("Error initializing PHY.\n"); + srslte::out_stream("Error initializing PHY.\n"); return SRSLTE_ERROR; } if (stack->init(args.stack, logger, phy.get(), this)) { - log.console("Error initializing stack.\n"); + srslte::out_stream("Error initializing stack.\n"); return SRSLTE_ERROR; }