From 344eaf49ec832371e7f4c058bb105c33db0ddedb Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Wed, 25 Mar 2020 14:57:29 +0000 Subject: [PATCH] use logmap in the whole enb and ue --- lib/include/srslte/common/network_utils.h | 61 ++----- lib/include/srslte/upper/gtpu.h | 10 +- lib/include/srslte/upper/pdcp.h | 6 +- lib/include/srslte/upper/pdcp_entity_base.h | 10 +- lib/include/srslte/upper/pdcp_entity_lte.h | 2 +- lib/include/srslte/upper/rlc.h | 12 +- lib/include/srslte/upper/rlc_am_lte.h | 10 +- lib/include/srslte/upper/rlc_tm.h | 4 +- lib/include/srslte/upper/rlc_um_base.h | 14 +- lib/include/srslte/upper/rlc_um_lte.h | 2 +- lib/src/common/network_utils.cc | 168 +++++++------------- lib/src/upper/gtpu.cc | 4 +- lib/src/upper/pdcp.cc | 2 +- lib/src/upper/pdcp_entity_base.cc | 2 +- lib/src/upper/pdcp_entity_lte.cc | 2 +- lib/src/upper/rlc.cc | 2 +- lib/src/upper/rlc_am_lte.cc | 2 +- lib/src/upper/rlc_tm.cc | 2 +- lib/src/upper/rlc_um_base.cc | 2 +- lib/src/upper/rlc_um_lte.cc | 2 +- lib/test/common/network_utils_test.cc | 22 +-- lib/test/upper/pdcp_base_test.h | 14 +- lib/test/upper/pdcp_lte_test.h | 6 +- lib/test/upper/pdcp_lte_test_rx.cc | 12 +- lib/test/upper/rlc_am_test.cc | 162 +++++-------------- lib/test/upper/rlc_common_test.cc | 16 +- lib/test/upper/rlc_stress_test.cc | 16 +- lib/test/upper/rlc_um_test.cc | 14 +- srsenb/hdr/stack/enb_stack_lte.h | 16 +- srsenb/hdr/stack/rrc/rrc.h | 23 ++- srsenb/hdr/stack/rrc/rrc_mobility.h | 2 +- srsenb/hdr/stack/upper/gtpu.h | 13 +- srsenb/hdr/stack/upper/pdcp.h | 4 +- srsenb/hdr/stack/upper/rlc.h | 4 +- srsenb/src/stack/enb_stack_lte.cc | 42 ++--- srsenb/src/stack/rrc/rrc.cc | 22 ++- srsenb/src/stack/upper/gtpu.cc | 6 +- srsenb/src/stack/upper/pdcp.cc | 6 +- srsenb/src/stack/upper/rlc.cc | 4 +- srsenb/src/stack/upper/s1ap.cc | 4 +- srsenb/test/upper/erab_setup_test.cc | 2 +- srsenb/test/upper/rrc_mobility_test.cc | 2 +- srsepc/hdr/mbms-gw/mbms-gw.h | 6 +- srsepc/hdr/spgw/gtpu.h | 5 +- srsepc/hdr/spgw/spgw.h | 4 +- srsepc/src/main.cc | 10 +- srsepc/src/mbms-gw/main.cc | 10 +- srsepc/src/mbms-gw/mbms-gw.cc | 2 +- srsepc/src/spgw/gtpu.cc | 2 +- srsepc/src/spgw/spgw.cc | 2 +- srsue/src/stack/rrc/rrc.cc | 2 +- srsue/src/stack/ue_stack_lte.cc | 4 +- srsue/src/stack/upper/nas.cc | 12 +- srsue/test/ttcn3/hdr/ttcn3_syssim.h | 24 +-- srsue/test/upper/rrc_meas_test.cc | 88 +++++----- 55 files changed, 362 insertions(+), 540 deletions(-) diff --git a/lib/include/srslte/common/network_utils.h b/lib/include/srslte/common/network_utils.h index 9b8b3814e..88df00507 100644 --- a/lib/include/srslte/common/network_utils.h +++ b/lib/include/srslte/common/network_utils.h @@ -23,6 +23,7 @@ #define SRSLTE_RX_SOCKET_HANDLER_H #include "srslte/common/buffer_pool.h" +#include "srslte/common/logmap.h" #include "srslte/common/threads.h" #include @@ -53,21 +54,10 @@ int get_port(const sockaddr_in& addr); net_utils::socket_type get_addr_family(int fd); // Convenience socket functions -int open_socket(net_utils::addr_family ip, - net_utils::socket_type socket_type, - net_utils::protocol_type protocol, - srslte::log* log_ = nullptr); -bool bind_addr(int fd, const sockaddr_in& addr_in, srslte::log* log_ = nullptr); -bool bind_addr(int fd, - const char* bind_addr_str, - int port, - sockaddr_in* addr_result = nullptr, - srslte::log* log_ = nullptr); -bool connect_to(int fd, - const char* dest_addr_str, - int dest_port, - sockaddr_in* dest_sockaddr = nullptr, - srslte::log* log_ = nullptr); +int open_socket(net_utils::addr_family ip, net_utils::socket_type socket_type, net_utils::protocol_type protocol); +bool bind_addr(int fd, const sockaddr_in& addr_in); +bool bind_addr(int fd, const char* bind_addr_str, int port, sockaddr_in* addr_result = nullptr); +bool connect_to(int fd, const char* dest_addr_str, int dest_port, sockaddr_in* dest_sockaddr = nullptr); } // namespace net_utils @@ -93,15 +83,9 @@ public: std::string get_ip() const { return net_utils::get_ip(addr); } net_utils::socket_type get_family() const { return net_utils::get_addr_family(sockfd); } - bool bind_addr(const char* bind_addr_str, int port, srslte::log* log_ = nullptr); - bool connect_to(const char* dest_addr_str, - int dest_port, - sockaddr_in* dest_sockaddr = nullptr, - srslte::log* log_ = nullptr); - bool open_socket(net_utils::addr_family ip, - net_utils::socket_type socket_type, - net_utils::protocol_type protocol, - srslte::log* log_ = nullptr); + bool bind_addr(const char* bind_addr_str, int port); + bool connect_to(const char* dest_addr_str, int dest_port, sockaddr_in* dest_sockaddr = nullptr); + bool open_socket(net_utils::addr_family ip, net_utils::socket_type socket_type, net_utils::protocol_type protocol); protected: sockaddr_in addr = {}; @@ -110,25 +94,14 @@ protected: namespace net_utils { -bool sctp_init_client(socket_handler_t* socket, - net_utils::socket_type socktype, - const char* bind_addr_str, - srslte::log* log_); -bool sctp_init_server(socket_handler_t* socket, - net_utils::socket_type socktype, - const char* bind_addr_str, - int port, - srslte::log* log_); +bool sctp_init_client(socket_handler_t* socket, net_utils::socket_type socktype, const char* bind_addr_str); +bool sctp_init_server(socket_handler_t* socket, net_utils::socket_type socktype, const char* bind_addr_str, int port); // TODO: for TCP and UDP -bool tcp_make_server(socket_handler_t* socket, - const char* bind_addr_str, - int port, - int nof_connections = 1, - srslte::log* log_ = nullptr); -int tcp_accept(socket_handler_t* socket, sockaddr_in* destaddr, srslte::log* log_); -int tcp_read(int remotefd, void* buf, size_t nbytes, srslte::log* log_); -int tcp_send(int remotefd, const void* buf, size_t nbytes, srslte::log* log_); +bool tcp_make_server(socket_handler_t* socket, const char* bind_addr_str, int port, int nof_connections = 1); +int tcp_accept(socket_handler_t* socket, sockaddr_in* destaddr); +int tcp_read(int remotefd, void* buf, size_t nbytes); +int tcp_send(int remotefd, const void* buf, size_t nbytes); } // namespace net_utils @@ -156,7 +129,7 @@ public: using sctp_recv_callback_t = std::function; - rx_multisocket_handler(std::string name_, srslte::log* log_, int thread_prio = 65); + rx_multisocket_handler(std::string name_, srslte::log_ref log_, int thread_prio = 65); rx_multisocket_handler(rx_multisocket_handler&&) = delete; rx_multisocket_handler(const rx_multisocket_handler&) = delete; rx_multisocket_handler& operator=(const rx_multisocket_handler&) = delete; @@ -183,8 +156,8 @@ private: // args std::string name; - srslte::log* log_h = nullptr; - srslte::byte_buffer_pool* pool = nullptr; + srslte::log_ref log_h; + srslte::byte_buffer_pool* pool = nullptr; // state std::mutex socket_mutex; diff --git a/lib/include/srslte/upper/gtpu.h b/lib/include/srslte/upper/gtpu.h index 849ad4978..9ade8d6ce 100644 --- a/lib/include/srslte/upper/gtpu.h +++ b/lib/include/srslte/upper/gtpu.h @@ -23,7 +23,7 @@ #define SRSLTE_GTPU_H #include "srslte/common/common.h" -#include "srslte/common/log.h" +#include "srslte/common/logmap.h" #include namespace srslte { @@ -76,11 +76,11 @@ typedef struct { uint8_t next_ext_hdr_type; } gtpu_header_t; -bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslte::log* gtpu_log); -bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslte::log* gtpu_log); +bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslte::log_ref gtpu_log); +bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslte::log_ref gtpu_log); std::string gtpu_ntoa(uint32_t addr); -inline bool gtpu_supported_flags_check(gtpu_header_t* header, srslte::log* gtpu_log) +inline bool gtpu_supported_flags_check(gtpu_header_t* header, srslte::log_ref gtpu_log) { // flags if ((header->flags & GTPU_FLAGS_VERSION_MASK) != GTPU_FLAGS_VERSION_V1) { @@ -102,7 +102,7 @@ inline bool gtpu_supported_flags_check(gtpu_header_t* header, srslte::log* gtpu_ return true; } -inline bool gtpu_supported_msg_type_check(gtpu_header_t* header, srslte::log* gtpu_log) +inline bool gtpu_supported_msg_type_check(gtpu_header_t* header, srslte::log_ref gtpu_log) { // msg_tpye if (header->message_type != GTPU_MSG_DATA_PDU && header->message_type != GTPU_MSG_ECHO_REQUEST && diff --git a/lib/include/srslte/upper/pdcp.h b/lib/include/srslte/upper/pdcp.h index 1ec4d08e2..148d4668e 100644 --- a/lib/include/srslte/upper/pdcp.h +++ b/lib/include/srslte/upper/pdcp.h @@ -32,7 +32,7 @@ namespace srslte { class pdcp : public srsue::pdcp_interface_rlc, public srsue::pdcp_interface_rrc { public: - pdcp(srslte::timer_handler* timers_, log* log_); + pdcp(srslte::timer_handler* timers_, const char* logname); virtual ~pdcp(); void init(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_); void stop(); @@ -71,8 +71,8 @@ private: typedef std::map pdcp_map_t; typedef std::pair pdcp_map_pair_t; - srslte::timer_handler* timers = nullptr; - log* pdcp_log = nullptr; + srslte::timer_handler* timers = nullptr; + srslte::log_ref pdcp_log; pdcp_map_t pdcp_array, pdcp_array_mrb; // cache valid lcids to be checked from separate thread diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index b1c169652..9d9a7b92c 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -25,7 +25,7 @@ #include "srslte/common/buffer_pool.h" #include "srslte/common/common.h" #include "srslte/common/interfaces_common.h" -#include "srslte/common/log.h" +#include "srslte/common/logmap.h" #include "srslte/common/security.h" #include "srslte/common/threads.h" #include "srslte/common/timers.h" @@ -63,7 +63,7 @@ static const char srslte_direction_text[DIRECTION_N_ITEMS][6] = {"none", "tx", " class pdcp_entity_base { public: - pdcp_entity_base(srslte::timer_handler* timers_, srslte::log* log_); + pdcp_entity_base(srslte::timer_handler* timers_, srslte::log_ref log_); virtual ~pdcp_entity_base(); virtual void reset() = 0; virtual void reestablish() = 0; @@ -111,11 +111,11 @@ public: uint32_t COUNT(uint32_t hfn, uint32_t sn); protected: - srslte::log* log = nullptr; + srslte::log_ref log; srslte::timer_handler* timers = nullptr; - bool active = false; - uint32_t lcid = 0; + bool active = false; + uint32_t lcid = 0; srslte_direction_t integrity_direction = DIRECTION_NONE; srslte_direction_t encryption_direction = DIRECTION_NONE; diff --git a/lib/include/srslte/upper/pdcp_entity_lte.h b/lib/include/srslte/upper/pdcp_entity_lte.h index 6d397646e..6ffeb47e0 100644 --- a/lib/include/srslte/upper/pdcp_entity_lte.h +++ b/lib/include/srslte/upper/pdcp_entity_lte.h @@ -50,7 +50,7 @@ public: srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::timer_handler* timers_, - srslte::log* log_); + srslte::log_ref log_); ~pdcp_entity_lte(); void init(uint32_t lcid_, pdcp_config_t cfg_); void reset(); diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 522039e13..34ad76c74 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -40,7 +40,7 @@ namespace srslte { class rlc : public srsue::rlc_interface_mac, public srsue::rlc_interface_pdcp, public srsue::rlc_interface_rrc { public: - rlc(log* rlc_log_); + rlc(const char* logname); virtual ~rlc(); void init(srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, @@ -87,11 +87,11 @@ public: private: void reset_metrics(); - byte_buffer_pool* pool = nullptr; - srslte::log* rlc_log = nullptr; - srsue::pdcp_interface_rlc* pdcp = nullptr; - srsue::rrc_interface_rlc* rrc = nullptr; - srslte::timer_handler* timers = nullptr; + byte_buffer_pool* pool = nullptr; + srslte::log_ref rlc_log; + srsue::pdcp_interface_rlc* pdcp = nullptr; + srsue::rrc_interface_rlc* rrc = nullptr; + srslte::timer_handler* timers = nullptr; typedef std::map rlc_map_t; typedef std::pair rlc_map_pair_t; diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index 9daed7958..35f445bc6 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -64,7 +64,7 @@ struct rlc_amd_retx_t { class rlc_am_lte : public rlc_common { public: - rlc_am_lte(srslte::log* log_, + rlc_am_lte(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, @@ -138,7 +138,7 @@ private: rlc_am_lte* parent = nullptr; byte_buffer_pool* pool = nullptr; - srslte::log* log = nullptr; + srslte::log_ref log; /**************************************************************************** * Configurable parameters @@ -225,7 +225,7 @@ private: rlc_am_lte* parent = nullptr; byte_buffer_pool* pool = nullptr; - srslte::log* log = nullptr; + srslte::log_ref log; /**************************************************************************** * Configurable parameters @@ -270,8 +270,8 @@ private: }; // Common variables needed/provided by parent class - srsue::rrc_interface_rlc* rrc = nullptr; - srslte::log* log = nullptr; + srsue::rrc_interface_rlc* rrc = nullptr; + srslte::log_ref log; srsue::pdcp_interface_rlc* pdcp = nullptr; srslte::timer_handler* timers = nullptr; uint32_t lcid = 0; diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srslte/upper/rlc_tm.h index 4daffeb26..f92bcd280 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srslte/upper/rlc_tm.h @@ -34,7 +34,7 @@ namespace srslte { class rlc_tm : public rlc_common { public: - rlc_tm(srslte::log* log_, + rlc_tm(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, @@ -64,7 +64,7 @@ public: private: byte_buffer_pool* pool = nullptr; - srslte::log* log = nullptr; + srslte::log_ref log; uint32_t lcid = 0; srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::rrc_interface_rlc* rrc = nullptr; diff --git a/lib/include/srslte/upper/rlc_um_base.h b/lib/include/srslte/upper/rlc_um_base.h index fd46df1dc..9bba599ec 100644 --- a/lib/include/srslte/upper/rlc_um_base.h +++ b/lib/include/srslte/upper/rlc_um_base.h @@ -38,7 +38,7 @@ namespace srslte { class rlc_um_base : public rlc_common { public: - rlc_um_base(srslte::log* log_, + rlc_um_base(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, @@ -87,7 +87,7 @@ protected: protected: byte_buffer_pool* pool = nullptr; - srslte::log* log = nullptr; + srslte::log_ref log; std::string rb_name; rlc_config_t cfg = {}; @@ -120,8 +120,8 @@ protected: virtual void handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) = 0; protected: - byte_buffer_pool* pool = nullptr; - srslte::log* log = nullptr; + byte_buffer_pool* pool = nullptr; + srslte::log_ref log; srslte::timer_handler* timers = nullptr; srsue::pdcp_interface_rlc* pdcp = nullptr; srsue::rrc_interface_rlc* rrc = nullptr; @@ -142,9 +142,9 @@ protected: }; // Common variables needed by parent class - srsue::rrc_interface_rlc* rrc = nullptr; - srsue::pdcp_interface_rlc* pdcp = nullptr; - srslte::log* log = nullptr; + srsue::rrc_interface_rlc* rrc = nullptr; + srsue::pdcp_interface_rlc* pdcp = nullptr; + srslte::log_ref log; srslte::timer_handler* timers = nullptr; uint32_t lcid = 0; rlc_config_t cfg = {}; diff --git a/lib/include/srslte/upper/rlc_um_lte.h b/lib/include/srslte/upper/rlc_um_lte.h index 24374bb2c..dffff2885 100644 --- a/lib/include/srslte/upper/rlc_um_lte.h +++ b/lib/include/srslte/upper/rlc_um_lte.h @@ -43,7 +43,7 @@ typedef struct { class rlc_um_lte : public rlc_um_base { public: - rlc_um_lte(srslte::log* log_, + rlc_um_lte(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, diff --git a/lib/src/common/network_utils.cc b/lib/src/common/network_utils.cc index 1390edb7e..cd53937da 100644 --- a/lib/src/common/network_utils.cc +++ b/lib/src/common/network_utils.cc @@ -34,6 +34,8 @@ namespace srslte { namespace net_utils { +srslte::log_ref net_log{"COMMON"}; + //! Set IP:port for ipv4 bool set_sockaddr(sockaddr_in* addr, const char* ip_str, int port) { @@ -107,18 +109,12 @@ const char* protocol_to_string(protocol_type p) return ""; } -int open_socket(net_utils::addr_family ip_type, - net_utils::socket_type socket_type, - net_utils::protocol_type protocol, - srslte::log* log_) +int open_socket(net_utils::addr_family ip_type, net_utils::socket_type socket_type, net_utils::protocol_type protocol) { int fd = socket((int)ip_type, (int)socket_type, (int)protocol); if (fd == -1) { - if (log_ != nullptr) { - log_->error("Failed to open %s socket.\n", net_utils::protocol_to_string(protocol)); - } else { - perror("Could not create socket\n"); - } + net_log->error("Failed to open %s socket.\n", net_utils::protocol_to_string(protocol)); + perror("Could not create socket\n"); } if (protocol == protocol_type::SCTP) { @@ -128,81 +124,60 @@ int open_socket(net_utils::addr_family ip_type, evnts.sctp_data_io_event = 1; evnts.sctp_shutdown_event = 1; if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof(evnts)) != 0) { - if (log_ != nullptr) { - log_->error("Failed to subscribe to SCTP_SHUTDOWN event: %s\n", strerror(errno)); - } else { - perror("setsockopt"); - } + net_log->error("Failed to subscribe to SCTP_SHUTDOWN event: %s\n", strerror(errno)); + perror("setsockopt"); } } return fd; } -bool bind_addr(int fd, const sockaddr_in& addr_in, srslte::log* log_) +bool bind_addr(int fd, const sockaddr_in& addr_in) { if (fd < 0) { - if (log_ != nullptr) { - log_->error("Trying to bind to a closed socket\n"); - } + net_log->error("Trying to bind to a closed socket\n"); return false; } if (bind(fd, (struct sockaddr*)&addr_in, sizeof(addr_in)) != 0) { - if (log_ != nullptr) { - log_->error("Failed to bind on address %s: %s errno %d\n", get_ip(addr_in).c_str(), strerror(errno), errno); - } else { - perror("bind()"); - } + net_log->error("Failed to bind on address %s: %s errno %d\n", get_ip(addr_in).c_str(), strerror(errno), errno); + perror("bind()"); return false; } return true; } -bool bind_addr(int fd, const char* bind_addr_str, int port, sockaddr_in* addr_result, srslte::log* log_) +bool bind_addr(int fd, const char* bind_addr_str, int port, sockaddr_in* addr_result) { sockaddr_in addr_tmp{}; if (not net_utils::set_sockaddr(&addr_tmp, bind_addr_str, port)) { - if (log_ != nullptr) { - log_->error("Failed to convert IP address (%s) to sockaddr_in struct\n", bind_addr_str); - } + net_log->error("Failed to convert IP address (%s) to sockaddr_in struct\n", bind_addr_str); return false; } - bind_addr(fd, addr_tmp, log_); + bind_addr(fd, addr_tmp); if (addr_result != nullptr) { *addr_result = addr_tmp; } return true; } -bool connect_to(int fd, const char* dest_addr_str, int dest_port, sockaddr_in* dest_sockaddr, srslte::log* log_) +bool connect_to(int fd, const char* dest_addr_str, int dest_port, sockaddr_in* dest_sockaddr) { if (fd < 0) { - if (log_ != nullptr) { - log_->error("tried to connect to remote address with an invalid socket.\n"); - } else { - printf("ERROR: tried to connect to remote address with an invalid socket.\n"); - } + net_log->error("tried to connect to remote address with an invalid socket.\n"); return false; } sockaddr_in sockaddr_tmp{}; if (not net_utils::set_sockaddr(&sockaddr_tmp, dest_addr_str, dest_port)) { - if (log_ != nullptr) { - log_->error("Error converting IP address (%s) to sockaddr_in structure\n", dest_addr_str); - } else { - printf("Error converting IP address (%s) to sockaddr_in structure\n", dest_addr_str); - } + net_log->error("Error converting IP address (%s) to sockaddr_in structure\n", dest_addr_str); return false; } if (dest_sockaddr != nullptr) { *dest_sockaddr = sockaddr_tmp; } if (connect(fd, (const struct sockaddr*)&sockaddr_tmp, sizeof(sockaddr_tmp)) == -1) { - if (log_ != nullptr) { - log_->error("Failed to establish socket connection to %s\n", dest_addr_str); - } else { - perror("connect()"); - } + net_log->error("Failed to establish socket connection to %s\n", dest_addr_str); + perror("connect()"); return false; } return true; @@ -251,31 +226,25 @@ void socket_handler_t::reset() addr = {}; } -bool socket_handler_t::bind_addr(const char* bind_addr_str, int port, srslte::log* log_) +bool socket_handler_t::bind_addr(const char* bind_addr_str, int port) { - return net_utils::bind_addr(sockfd, bind_addr_str, port, &addr, log_); + return net_utils::bind_addr(sockfd, bind_addr_str, port, &addr); } -bool socket_handler_t::connect_to(const char* dest_addr_str, - int dest_port, - sockaddr_in* dest_sockaddr, - srslte::log* log_) +bool socket_handler_t::connect_to(const char* dest_addr_str, int dest_port, sockaddr_in* dest_sockaddr) { - return net_utils::connect_to(sockfd, dest_addr_str, dest_port, dest_sockaddr, log_); + return net_utils::connect_to(sockfd, dest_addr_str, dest_port, dest_sockaddr); } bool socket_handler_t::open_socket(net_utils::addr_family ip_type, net_utils::socket_type socket_type, - net_utils::protocol_type protocol, - srslte::log* log_) + net_utils::protocol_type protocol) { if (sockfd >= 0) { - if (log_ != nullptr) { - log_->error("Socket is already open.\n"); - } + net_utils::net_log->error("Socket is already open.\n"); return false; } - sockfd = net_utils::open_socket(ip_type, socket_type, protocol, log_); + sockfd = net_utils::open_socket(ip_type, socket_type, protocol); return sockfd >= 0; } @@ -285,42 +254,31 @@ bool socket_handler_t::open_socket(net_utils::addr_family ip_type, namespace net_utils { -bool sctp_init_socket(socket_handler_t* socket, - net_utils::socket_type socktype, - const char* bind_addr_str, - int port, - srslte::log* log_) +bool sctp_init_socket(socket_handler_t* socket, net_utils::socket_type socktype, const char* bind_addr_str, int port) { - if (not socket->open_socket(net_utils::addr_family::ipv4, socktype, net_utils::protocol_type::SCTP, log_)) { + if (not socket->open_socket(net_utils::addr_family::ipv4, socktype, net_utils::protocol_type::SCTP)) { return false; } - if (not socket->bind_addr(bind_addr_str, port, log_)) { + if (not socket->bind_addr(bind_addr_str, port)) { socket->reset(); return false; } return true; } -bool sctp_init_client(socket_handler_t* socket, - net_utils::socket_type socktype, - const char* bind_addr_str, - srslte::log* log_) +bool sctp_init_client(socket_handler_t* socket, net_utils::socket_type socktype, const char* bind_addr_str) { - return sctp_init_socket(socket, socktype, bind_addr_str, 0, log_); + return sctp_init_socket(socket, socktype, bind_addr_str, 0); } -bool sctp_init_server(socket_handler_t* socket, - net_utils::socket_type socktype, - const char* bind_addr_str, - int port, - srslte::log* log_) +bool sctp_init_server(socket_handler_t* socket, net_utils::socket_type socktype, const char* bind_addr_str, int port) { - if (not sctp_init_socket(socket, socktype, bind_addr_str, port, log_)) { + if (not sctp_init_socket(socket, socktype, bind_addr_str, port)) { return false; } // Listen for connections if (listen(socket->fd(), SOMAXCONN) != 0) { - log_->error("Failed to listen to incoming SCTP connections\n"); + net_log->error("Failed to listen to incoming SCTP connections\n"); return false; } return true; @@ -330,64 +288,51 @@ bool sctp_init_server(socket_handler_t* socket, * TCP Socket **************************************************************/ -bool tcp_make_server(socket_handler_t* socket, - const char* bind_addr_str, - int port, - int nof_connections, - srslte::log* log_) +bool tcp_make_server(socket_handler_t* socket, const char* bind_addr_str, int port, int nof_connections) { - if (not socket->open_socket(addr_family::ipv4, socket_type::stream, protocol_type::TCP, log_)) { + if (not socket->open_socket(addr_family::ipv4, socket_type::stream, protocol_type::TCP)) { return false; } - if (not socket->bind_addr(bind_addr_str, port, log_)) { + if (not socket->bind_addr(bind_addr_str, port)) { socket->reset(); return false; } // Listen for connections if (listen(socket->fd(), nof_connections) != 0) { - if (log_ != nullptr) { - log_->error("Failed to listen to incoming TCP connections\n"); - } + net_log->error("Failed to listen to incoming TCP connections\n"); return false; } return true; } -int tcp_accept(socket_handler_t* socket, sockaddr_in* destaddr, srslte::log* log_) +int tcp_accept(socket_handler_t* socket, sockaddr_in* destaddr) { socklen_t clilen = sizeof(destaddr); int connfd = accept(socket->fd(), (struct sockaddr*)&destaddr, &clilen); if (connfd < 0) { - if (log_ != nullptr) { - log_->error("Failed to accept connection\n"); - } + net_log->error("Failed to accept connection\n"); perror("accept"); return -1; } return connfd; } -int tcp_read(int remotefd, void* buf, size_t nbytes, srslte::log* log_) +int tcp_read(int remotefd, void* buf, size_t nbytes) { int n = ::read(remotefd, buf, nbytes); if (n == 0) { - if (log_ != nullptr) { - log_->info("TCP connection closed\n"); - close(remotefd); - } + net_log->info("TCP connection closed\n"); + close(remotefd); return 0; } if (n == -1) { - if (log_ != nullptr) { - log_->error("Failed to read from TCP socket."); - } else { - perror("TCP read"); - } + net_log->error("Failed to read from TCP socket."); + perror("TCP read"); } return n; } -int tcp_send(int remotefd, const void* buf, size_t nbytes, srslte::log* log_) +int tcp_send(int remotefd, const void* buf, size_t nbytes) { // Loop until all bytes are sent char* ptr = (char*)buf; @@ -395,11 +340,8 @@ int tcp_send(int remotefd, const void* buf, size_t nbytes, srslte::log* log_) while (nbytes_remaining > 0) { ssize_t i = ::send(remotefd, ptr, nbytes_remaining, 0); if (i < 1) { - if (log_ != nullptr) { - log_->error("Failed to send data to TCP socket\n"); - } else { - perror("Error calling send()\n"); - } + net_log->error("Failed to send data to TCP socket\n"); + perror("Error calling send()\n"); return i; } ptr += i; @@ -422,7 +364,7 @@ class recvfrom_pdu_task final : public rx_multisocket_handler::recv_task { public: using callback_t = std::function; - explicit recvfrom_pdu_task(srslte::byte_buffer_pool* pool_, srslte::log* log_, callback_t func_) : + explicit recvfrom_pdu_task(srslte::byte_buffer_pool* pool_, srslte::log_ref log_, callback_t func_) : pool(pool_), log_h(log_), func(std::move(func_)) @@ -451,8 +393,8 @@ public: } private: - srslte::byte_buffer_pool* pool = nullptr; - srslte::log* log_h = nullptr; + srslte::byte_buffer_pool* pool = nullptr; + srslte::log_ref log_h; callback_t func; }; @@ -461,7 +403,7 @@ class sctp_recvmsg_pdu_task final : public rx_multisocket_handler::recv_task public: using callback_t = std::function< void(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags)>; - explicit sctp_recvmsg_pdu_task(srslte::byte_buffer_pool* pool_, srslte::log* log_, callback_t func_) : + explicit sctp_recvmsg_pdu_task(srslte::byte_buffer_pool* pool_, srslte::log_ref log_, callback_t func_) : pool(pool_), log_h(log_), func(std::move(func_)) @@ -501,8 +443,8 @@ public: } private: - srslte::byte_buffer_pool* pool = nullptr; - srslte::log* log_h = nullptr; + srslte::byte_buffer_pool* pool = nullptr; + srslte::log_ref log_h; callback_t func; }; @@ -510,7 +452,7 @@ private: * Rx Multisocket Handler **************************************************************/ -rx_multisocket_handler::rx_multisocket_handler(std::string name_, srslte::log* log_, int thread_prio) : +rx_multisocket_handler::rx_multisocket_handler(std::string name_, srslte::log_ref log_, int thread_prio) : thread(name_), name(std::move(name_)), log_h(log_) diff --git a/lib/src/upper/gtpu.cc b/lib/src/upper/gtpu.cc index 7d235e60d..7ab1b520d 100644 --- a/lib/src/upper/gtpu.cc +++ b/lib/src/upper/gtpu.cc @@ -28,7 +28,7 @@ namespace srslte { * Header pack/unpack helper functions * Ref: 3GPP TS 29.281 v10.1.0 Section 5 ***************************************************************************/ -bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslte::log* gtpu_log) +bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslte::log_ref gtpu_log) { // flags if (!gtpu_supported_flags_check(header, gtpu_log)) { @@ -95,7 +95,7 @@ bool gtpu_write_header(gtpu_header_t* header, srslte::byte_buffer_t* pdu, srslte return true; } -bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslte::log* gtpu_log) +bool gtpu_read_header(srslte::byte_buffer_t* pdu, gtpu_header_t* header, srslte::log_ref gtpu_log) { uint8_t* ptr = pdu->msg; diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 004446d3f..7f9916ac2 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -23,7 +23,7 @@ namespace srslte { -pdcp::pdcp(srslte::timer_handler* timers_, srslte::log* log_) : timers(timers_), pdcp_log(log_) {} +pdcp::pdcp(srslte::timer_handler* timers_, const char* logname) : timers(timers_), pdcp_log(logname) {} pdcp::~pdcp() { diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index 5a2310a7b..538eaf3a8 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -26,7 +26,7 @@ namespace srslte { -pdcp_entity_base::pdcp_entity_base(srslte::timer_handler* timers_, srslte::log* log_) : log(log_), timers(timers_) {} +pdcp_entity_base::pdcp_entity_base(srslte::timer_handler* timers_, srslte::log_ref log_) : log(log_), timers(timers_) {} pdcp_entity_base::~pdcp_entity_base() {} diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index e7fdda3d4..8402ab074 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -28,7 +28,7 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_, srsue::rrc_interface_pdcp* rrc_, srsue::gw_interface_pdcp* gw_, srslte::timer_handler* timers_, - srslte::log* log_) : + srslte::log_ref log_) : pdcp_entity_base(timers_, log_), rlc(rlc_), rrc(rrc_), diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index ed62b8431..629690698 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -27,7 +27,7 @@ namespace srslte { -rlc::rlc(log* log_) : rlc_log(log_) +rlc::rlc(const char* logname) : rlc_log(logname) { pool = byte_buffer_pool::get_instance(); bzero(metrics_time, sizeof(metrics_time)); diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 7cc52b585..e3a83ed5b 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -32,7 +32,7 @@ namespace srslte { -rlc_am_lte::rlc_am_lte(srslte::log* log_, +rlc_am_lte::rlc_am_lte(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index 4f8cc2c4c..a625923d7 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -23,7 +23,7 @@ namespace srslte { -rlc_tm::rlc_tm(srslte::log* log_, +rlc_tm::rlc_tm(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, diff --git a/lib/src/upper/rlc_um_base.cc b/lib/src/upper/rlc_um_base.cc index 1fbc988ce..8baebf158 100644 --- a/lib/src/upper/rlc_um_base.cc +++ b/lib/src/upper/rlc_um_base.cc @@ -26,7 +26,7 @@ using namespace asn1::rrc; namespace srslte { -rlc_um_base::rlc_um_base(srslte::log* log_, +rlc_um_base::rlc_um_base(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, diff --git a/lib/src/upper/rlc_um_lte.cc b/lib/src/upper/rlc_um_lte.cc index 474e54105..851990fd6 100644 --- a/lib/src/upper/rlc_um_lte.cc +++ b/lib/src/upper/rlc_um_lte.cc @@ -28,7 +28,7 @@ using namespace asn1::rrc; namespace srslte { -rlc_um_lte::rlc_um_lte(srslte::log* log_, +rlc_um_lte::rlc_um_lte(srslte::log_ref log_, uint32_t lcid_, srsue::pdcp_interface_rlc* pdcp_, srsue::rrc_interface_rlc* rrc_, diff --git a/lib/test/common/network_utils_test.cc b/lib/test/common/network_utils_test.cc index f4bfe051a..74d2e0f2a 100644 --- a/lib/test/common/network_utils_test.cc +++ b/lib/test/common/network_utils_test.cc @@ -33,32 +33,32 @@ int test_socket_handler() { - srslte::log_filter log("S1AP"); - log.set_level(srslte::LOG_LEVEL_DEBUG); - log.set_hex_limit(128); + srslte::log_ref log("S1AP"); + log->set_level(srslte::LOG_LEVEL_DEBUG); + log->set_hex_limit(128); int counter = 0; srslte::socket_handler_t server_socket, client_socket, client_socket2; - srslte::rx_multisocket_handler sockhandler("RXSOCKETS", &log); + srslte::rx_multisocket_handler sockhandler("RXSOCKETS", log); int server_port = 36412; const char* server_addr = "127.0.100.1"; using namespace srslte::net_utils; - TESTASSERT(sctp_init_server(&server_socket, socket_type::seqpacket, server_addr, server_port, &log)); - log.info("Listening from fd=%d\n", server_socket.fd()); + TESTASSERT(sctp_init_server(&server_socket, socket_type::seqpacket, server_addr, server_port)); + log->info("Listening from fd=%d\n", server_socket.fd()); - TESTASSERT(sctp_init_client(&client_socket, socket_type::seqpacket, "127.0.0.1", &log)); - TESTASSERT(sctp_init_client(&client_socket2, socket_type::seqpacket, "127.0.0.2", &log)); + TESTASSERT(sctp_init_client(&client_socket, socket_type::seqpacket, "127.0.0.1")); + TESTASSERT(sctp_init_client(&client_socket2, socket_type::seqpacket, "127.0.0.2")); TESTASSERT(client_socket.connect_to(server_addr, server_port)); TESTASSERT(client_socket2.connect_to(server_addr, server_port)); // register server Rx handler auto pdu_handler = - [&log, + [log, &counter](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { if (pdu->N_bytes > 0) { - log.info_hex(pdu->msg, pdu->N_bytes, "Received msg from %s:", get_ip(from).c_str()); + log->info_hex(pdu->msg, pdu->N_bytes, "Received msg from %s:", get_ip(from).c_str()); counter++; } }; @@ -89,7 +89,7 @@ int test_socket_handler() 0); TESTASSERT(n_sent >= 0); usleep(1000); - log.info("Message %d sent.\n", i); + log->info("Message %d sent.\n", i); } uint32_t time_elapsed = 0; diff --git a/lib/test/upper/pdcp_base_test.h b/lib/test/upper/pdcp_base_test.h index 862e928be..d318b589c 100644 --- a/lib/test/upper/pdcp_base_test.h +++ b/lib/test/upper/pdcp_base_test.h @@ -22,12 +22,12 @@ #ifndef SRSLTE_PDCP_BASE_TEST_H #define SRSLTE_PDCP_BASE_TEST_H -#include "srslte/upper/pdcp_config.h" #include "srslte/common/buffer_pool.h" #include "srslte/common/log_filter.h" #include "srslte/common/security.h" #include "srslte/common/test_common.h" #include "srslte/interfaces/ue_interfaces.h" +#include "srslte/upper/pdcp_config.h" #include int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte::unique_byte_buffer_t& msg2) @@ -43,7 +43,7 @@ int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte:: class rlc_dummy : public srsue::rlc_interface_pdcp { public: - rlc_dummy(srslte::log* log_) : log(log_) {} + rlc_dummy(srslte::log_ref log_) : log(log_) {} void get_last_sdu(const srslte::unique_byte_buffer_t& pdu) { @@ -68,7 +68,7 @@ public: uint64_t discard_count = 0; private: - srslte::log* log; + srslte::log_ref log; srslte::unique_byte_buffer_t last_pdcp_pdu; bool rb_is_um(uint32_t lcid) { return false; } @@ -77,7 +77,7 @@ private: class rrc_dummy : public srsue::rrc_interface_pdcp { public: - rrc_dummy(srslte::log* log_) { log = log_; } + rrc_dummy(srslte::log_ref log_) { log = log_; } void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {} void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {} @@ -86,7 +86,7 @@ public: std::string get_rb_name(uint32_t lcid) { return "None"; } - srslte::log* log; + srslte::log_ref log; // Members for testing uint32_t rx_count = 0; @@ -111,7 +111,7 @@ public: class gw_dummy : public srsue::gw_interface_pdcp { public: - gw_dummy(srslte::log* log_) : log(log_) {} + gw_dummy(srslte::log_ref log_) : log(log_) {} void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} uint32_t rx_count = 0; @@ -130,7 +130,7 @@ public: } private: - srslte::log* log; + srslte::log_ref log; srslte::unique_byte_buffer_t last_pdu; }; diff --git a/lib/test/upper/pdcp_lte_test.h b/lib/test/upper/pdcp_lte_test.h index e04603ec9..4067f6c77 100644 --- a/lib/test/upper/pdcp_lte_test.h +++ b/lib/test/upper/pdcp_lte_test.h @@ -74,7 +74,7 @@ pdcp_lte_initial_state normal_init_state = {}; class pdcp_lte_test_helper { public: - pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg, srslte::log* log) : + pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg, srslte::log_ref log) : rlc(log), rrc(log), gw(log), @@ -109,7 +109,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t srslte::pdcp_rb_type_t rb_type, srslte::as_security_config_t sec_cfg, srslte::byte_buffer_pool* pool, - srslte::log* log) + srslte::log_ref log) { srslte::pdcp_config_t cfg = {1, rb_type, @@ -143,7 +143,7 @@ std::vector gen_expected_pdus_vector(const srslte::unique_byt srslte::pdcp_rb_type_t rb_type, srslte::as_security_config_t sec_cfg, srslte::byte_buffer_pool* pool, - srslte::log* log) + srslte::log_ref log) { std::vector pdu_vec; for (uint32_t tx_next : tx_nexts) { diff --git a/lib/test/upper/pdcp_lte_test_rx.cc b/lib/test/upper/pdcp_lte_test_rx.cc index cb5cd8f75..ef1ee28cf 100644 --- a/lib/test/upper/pdcp_lte_test_rx.cc +++ b/lib/test/upper/pdcp_lte_test_rx.cc @@ -31,7 +31,7 @@ int test_rx(std::vector events, uint32_t n_sdus_exp, const srslte::unique_byte_buffer_t& sdu_exp, srslte::byte_buffer_pool* pool, - srslte::log* log) + srslte::log_ref log) { srslte::pdcp_config_t cfg_rx = {1, @@ -78,7 +78,7 @@ int test_rx(std::vector events, * RX Test: PDCP Entity with SN LEN = 5 and 12. * PDCP entity configured with EIA2 and EEA2 */ -int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log) +int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log_ref log) { // Test SDUs srslte::unique_byte_buffer_t tst_sdu1 = allocate_unique_buffer(*pool); // SDU 1 @@ -137,11 +137,11 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log* log) int run_all_tests(srslte::byte_buffer_pool* pool) { // Setup log - srslte::log_filter log("PDCP LTE Test RX"); - log.set_level(srslte::LOG_LEVEL_DEBUG); - log.set_hex_limit(128); + srslte::log_ref log("PDCP LTE Test RX"); + log->set_level(srslte::LOG_LEVEL_DEBUG); + log->set_hex_limit(128); - TESTASSERT(test_rx_all(pool, &log) == 0); + TESTASSERT(test_rx_all(pool, log) == 0); return 0; } diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 4a5870984..2fb15868e 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -34,6 +34,9 @@ using namespace srsue; using namespace srslte; using namespace asn1::rrc; +srslte::log_ref rrc_log1("RLC_AM_1"); +srslte::log_ref rrc_log2("RLC_AM_2"); + class rlc_am_tester : public pdcp_interface_rlc, public rrc_interface_rlc { public: @@ -133,19 +136,12 @@ void basic_test_tx(rlc_am_lte* rlc, byte_buffer_t pdu_bufs[NBUFS]) bool meas_obj_test() { - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); - rlc_am_tester tester; timer_handler timers(8); byte_buffer_t pdu_bufs[NBUFS]; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); // before configuring entity assert(0 == rlc1.get_buffer_state()); @@ -199,17 +195,11 @@ bool meas_obj_test() bool concat_test() { - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -266,18 +256,12 @@ bool concat_test() bool segment_test(bool in_seq_rx) { - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -363,18 +347,12 @@ bool segment_test(bool in_seq_rx) bool retx_test() { - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -455,18 +433,12 @@ bool resegment_test_1() // PDUs: | 10 | 10 | 10 | 10 | 10 | // Retx PDU segments: | 5 | 5| - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -559,18 +531,12 @@ bool resegment_test_2() // PDUs: | 5 | 10 | 20 | 10 | 5 | // Retx PDU segments: | 10 | 10 | - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -661,17 +627,11 @@ bool resegment_test_3() // PDUs: | 5 | 5| 20 | 10 | 10 | // Retx PDU segments: | 10 | 10 | - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -757,17 +717,11 @@ bool resegment_test_4() // PDUs: | 5 | 5| 30 | 5 | 5| // Retx PDU segments: | 15 | 15 | - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -855,17 +809,11 @@ bool resegment_test_5() // PDUs: |2|3| 40 |3|2| // Retx PDU segments: | 20 | 20 | - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -953,18 +901,12 @@ bool resegment_test_6() // PDUs: |10|10|10| 270 | 54 | // Retx PDU segments: | 120 | 150 | - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1081,13 +1023,6 @@ bool resegment_test_7() const uint32_t N_PDU_BUFS = 5; const uint32_t sdu_size = 30; - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(100); - log2.set_hex_limit(100); - #if HAVE_PCAP rlc_pcap pcap; pcap.open("rlc_am_test7.pcap", 0); @@ -1097,8 +1032,8 @@ bool resegment_test_7() #endif srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1252,13 +1187,6 @@ bool resegment_test_8() const uint32_t N_PDU_BUFS = 5; const uint32_t sdu_size = 30; - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(100); - log2.set_hex_limit(100); - #if HAVE_PCAP rlc_pcap pcap; pcap.open("rlc_am_test8.pcap", 0); @@ -1268,8 +1196,8 @@ bool resegment_test_8() #endif srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1405,14 +1333,11 @@ bool resegment_test_8() bool reset_test() { - srslte::log_filter log1("RLC_AM_1"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1450,14 +1375,11 @@ bool reset_test() bool resume_test() { - srslte::log_filter log1("RLC_AM_1"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1495,13 +1417,10 @@ bool resume_test() bool stop_test() { - srslte::log_filter log1("RLC_AM_1"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1524,18 +1443,12 @@ bool stop_test() // be enough to fit all SNs that would need to be NACKed bool status_pdu_test() { - srslte::log_filter log1("RLC_AM_1"); - srslte::log_filter log2("RLC_AM_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); rlc_am_tester tester; srslte::timer_handler timers(8); int len = 0; - rlc_am_lte rlc1(&log1, 1, &tester, &tester, &timers); - rlc_am_lte rlc2(&log2, 1, &tester, &tester, &timers); + rlc_am_lte rlc1(rrc_log1, 1, &tester, &tester, &timers); + rlc_am_lte rlc2(rrc_log2, 1, &tester, &tester, &timers); if (not rlc1.configure(rlc_config_t::default_rlc_am_config())) { return -1; @@ -1647,6 +1560,11 @@ bool status_pdu_test() int main(int argc, char** argv) { + rrc_log1->set_level(srslte::LOG_LEVEL_DEBUG); + rrc_log2->set_level(srslte::LOG_LEVEL_DEBUG); + rrc_log1->set_hex_limit(-1); + rrc_log2->set_hex_limit(-1); + if (meas_obj_test()) { printf("basic_test failed\n"); exit(-1); @@ -1713,10 +1631,12 @@ int main(int argc, char** argv) }; byte_buffer_pool::get_instance()->cleanup(); + rrc_log1->set_hex_limit(100); + rrc_log2->set_hex_limit(100); if (resegment_test_7()) { printf("resegment_test_7 failed\n"); exit(-1); - }; + } byte_buffer_pool::get_instance()->cleanup(); if (resegment_test_8()) { @@ -1724,6 +1644,8 @@ int main(int argc, char** argv) exit(-1); }; byte_buffer_pool::get_instance()->cleanup(); + rrc_log1->set_hex_limit(-1); + rrc_log2->set_hex_limit(-1); if (reset_test()) { printf("reset_test failed\n"); diff --git a/lib/test/upper/rlc_common_test.cc b/lib/test/upper/rlc_common_test.cc index 3b73ea529..158899aa4 100644 --- a/lib/test/upper/rlc_common_test.cc +++ b/lib/test/upper/rlc_common_test.cc @@ -73,19 +73,19 @@ public: int meas_obj_test() { - srslte::log_filter log1("RLC_1"); - srslte::log_filter log2("RLC_2"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); + srslte::log_ref log1("RLC_1"); + srslte::log_ref log2("RLC_2"); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log2->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); + log2->set_hex_limit(-1); rlc_tester tester; srslte::timer_handler timers(1); int len = 0; - rlc rlc1(&log1); - rlc rlc2(&log2); + rlc rlc1(log1->get_service_name().c_str()); + rlc rlc2(log2->get_service_name().c_str()); rlc1.init(&tester, &tester, &timers, 0); rlc2.init(&tester, &tester, &timers, 0); diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 4be81634c..dba537aaf 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -394,12 +394,12 @@ private: void stress_test(stress_test_args_t args) { - srslte::log_filter log1("RLC_1"); - srslte::log_filter log2("RLC_2"); - log1.set_level(static_cast(args.log_level)); - log2.set_level(static_cast(args.log_level)); - log1.set_hex_limit(LOG_HEX_LIMIT); - log2.set_hex_limit(LOG_HEX_LIMIT); + srslte::log_ref log1("RLC_1"); + srslte::log_ref log2("RLC_2"); + log1->set_level(static_cast(args.log_level)); + log2->set_level(static_cast(args.log_level)); + log1->set_hex_limit(LOG_HEX_LIMIT); + log2->set_hex_limit(LOG_HEX_LIMIT); rlc_pcap pcap; uint32_t lcid = 1; @@ -458,8 +458,8 @@ void stress_test(stress_test_args_t args) srslte::timer_handler timers(8); - rlc rlc1(&log1); - rlc rlc2(&log2); + rlc rlc1(log1->get_service_name().c_str()); + rlc rlc2(log2->get_service_name().c_str()); rlc_tester tester1(&rlc1, "tester1", args, lcid); rlc_tester tester2(&rlc2, "tester2", args, lcid); diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index a8c17980e..e1c085cca 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -47,14 +47,14 @@ public: log1("RLC_UM_1"), log2("RLC_UM_2"), timers(16), - rlc1(&log1, 3, &tester, &tester, &timers), - rlc2(&log2, 3, &tester, &tester, &timers) + rlc1(log1, 3, &tester, &tester, &timers), + rlc2(log2, 3, &tester, &tester, &timers) { // setup logging - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log2.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); - log2.set_hex_limit(-1); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log2->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); + log2->set_hex_limit(-1); // configure RLC entities rlc_config_t cnfg = rlc_config_t::default_rlc_um_config(10); @@ -68,7 +68,7 @@ public: tester.set_expected_sdu_len(1); } - srslte::log_filter log1, log2; + srslte::log_ref log1, log2; srslte::timer_handler timers; rlc_um_tester tester; rlc_um_lte rlc1, rlc2; diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 57a473be5..8c9fe3a9c 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -34,8 +34,6 @@ #include "upper/rlc.h" #include "upper/s1ap.h" -#include "srslte/common/log_filter.h" - #include "enb_stack_base.h" #include "srsenb/hdr/enb.h" #include "srslte/common/multiqueue.h" @@ -149,13 +147,13 @@ private: srslte::byte_buffer_pool* pool = nullptr; // Radio and PHY log are in enb.cc - srslte::log_ref mac_log{"MAC "}; - srslte::log_filter rlc_log; - srslte::log_filter pdcp_log; - srslte::log_filter rrc_log; - srslte::log_filter s1ap_log; - srslte::log_filter gtpu_log; - srslte::log_filter stack_log; + srslte::log_ref mac_log{"MAC"}; + srslte::log_ref rlc_log{"RLC"}; + srslte::log_ref pdcp_log{"PDCP"}; + srslte::log_ref rrc_log{"RRC"}; + srslte::log_ref s1ap_log{"S1AP"}; + srslte::log_ref gtpu_log{"GTPU"}; + srslte::log_ref stack_log{"STCK"}; // RAT-specific interfaces phy_interface_stack_lte* phy = nullptr; diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index e714cd04f..37d7efa38 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -28,7 +28,7 @@ #include "srslte/common/block_queue.h" #include "srslte/common/buffer_pool.h" #include "srslte/common/common.h" -#include "srslte/common/log.h" +#include "srslte/common/logmap.h" #include "srslte/common/stack_procedure.h" #include "srslte/common/timeout.h" #include "srslte/interfaces/enb_interfaces.h" @@ -134,8 +134,7 @@ public: pdcp_interface_rrc* pdcp, s1ap_interface_rrc* s1ap, gtpu_interface_rrc* gtpu, - srslte::timer_handler* timers_, - srslte::log* log_rrc); + srslte::timer_handler* timers_); void stop(); void get_metrics(rrc_metrics_t& m); @@ -374,15 +373,15 @@ private: }; // class ue // args - srslte::timer_handler* timers = nullptr; - srslte::byte_buffer_pool* pool = nullptr; - phy_interface_rrc_lte* phy = nullptr; - mac_interface_rrc* mac = nullptr; - rlc_interface_rrc* rlc = nullptr; - pdcp_interface_rrc* pdcp = nullptr; - gtpu_interface_rrc* gtpu = nullptr; - s1ap_interface_rrc* s1ap = nullptr; - srslte::log* rrc_log = nullptr; + srslte::timer_handler* timers = nullptr; + srslte::byte_buffer_pool* pool = nullptr; + phy_interface_rrc_lte* phy = nullptr; + mac_interface_rrc* mac = nullptr; + rlc_interface_rrc* rlc = nullptr; + pdcp_interface_rrc* pdcp = nullptr; + gtpu_interface_rrc* gtpu = nullptr; + s1ap_interface_rrc* s1ap = nullptr; + srslte::log_ref rrc_log; // derived params std::vector > cell_ctxt_list; diff --git a/srsenb/hdr/stack/rrc/rrc_mobility.h b/srsenb/hdr/stack/rrc/rrc_mobility.h index 139a3fa10..6f7940d29 100644 --- a/srsenb/hdr/stack/rrc/rrc_mobility.h +++ b/srsenb/hdr/stack/rrc/rrc_mobility.h @@ -98,7 +98,7 @@ private: rrc* rrc_enb = nullptr; rrc::mobility_cfg* cfg = nullptr; srslte::byte_buffer_pool* pool = nullptr; - srslte::log* rrc_log = nullptr; + srslte::log_ref rrc_log; // vars std::shared_ptr ue_var_meas; diff --git a/srsenb/hdr/stack/upper/gtpu.h b/srsenb/hdr/stack/upper/gtpu.h index 6aef75f37..2e5591732 100644 --- a/srsenb/hdr/stack/upper/gtpu.h +++ b/srsenb/hdr/stack/upper/gtpu.h @@ -24,7 +24,7 @@ #include "common_enb.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/log.h" +#include "srslte/common/logmap.h" #include "srslte/common/threads.h" #include "srslte/interfaces/enb_interfaces.h" #include "srslte/srslte.h" @@ -45,7 +45,6 @@ public: std::string m1u_if_addr_, pdcp_interface_gtpu* pdcp_, stack_interface_gtpu_lte* stack_, - srslte::log* gtpu_log_, bool enable_mbsfn = false); void stop(); @@ -70,8 +69,8 @@ private: bool enable_mbsfn = false; std::string gtp_bind_addr; std::string mme_addr; - srsenb::pdcp_interface_gtpu* pdcp = nullptr; - srslte::log* gtpu_log = nullptr; + srsenb::pdcp_interface_gtpu* pdcp = nullptr; + srslte::log_ref gtpu_log; // Class to create class m1u_handler @@ -87,9 +86,9 @@ private: void handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); private: - gtpu* parent = nullptr; - pdcp_interface_gtpu* pdcp = nullptr; - srslte::log* gtpu_log = nullptr; + gtpu* parent = nullptr; + pdcp_interface_gtpu* pdcp = nullptr; + srslte::log_ref gtpu_log; std::string m1u_multiaddr; std::string m1u_if_addr; diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index 2bebba0a5..61baddbc4 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -33,7 +33,7 @@ namespace srsenb { class pdcp : public pdcp_interface_rlc, public pdcp_interface_gtpu, public pdcp_interface_rrc { public: - pdcp(srslte::timer_handler* timers, srslte::log* pdcp_log_); + pdcp(srslte::timer_handler* timers, const char* logname); virtual ~pdcp() {} void init(rlc_interface_pdcp* rlc_, rrc_interface_pdcp* rrc_, gtpu_interface_pdcp* gtpu_); void stop(); @@ -107,7 +107,7 @@ private: rrc_interface_pdcp* rrc; gtpu_interface_pdcp* gtpu; srslte::timer_handler* timers; - srslte::log* log_h; + srslte::log_ref log_h; srslte::byte_buffer_pool* pool; }; diff --git a/srsenb/hdr/stack/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h index b03aaf75c..e3b3f2548 100644 --- a/srsenb/hdr/stack/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -43,7 +43,7 @@ public: rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, srslte::timer_handler* timers_, - srslte::log* log_h); + srslte::log_ref log_h); void stop(); // rlc_interface_rrc @@ -94,7 +94,7 @@ private: mac_interface_rlc* mac; pdcp_interface_rlc* pdcp; rrc_interface_rlc* rrc; - srslte::log* log_h; + srslte::log_ref log_h; srslte::byte_buffer_pool* pool; srslte::timer_handler* timers; }; diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index ccd14cc06..8a6428f9f 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -32,7 +32,7 @@ namespace srsenb { enb_stack_lte::enb_stack_lte(srslte::logger* logger_) : timers(128), logger(logger_), - pdcp(&timers, &pdcp_log), + pdcp(&timers, "PDCP"), thread("STACK") { enb_queue_id = pending_tasks.add_queue(); @@ -74,27 +74,20 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) mac_log->set_level(args.log.mac_level); mac_log->set_hex_limit(args.log.mac_hex_limit); - rlc_log.init("RLC ", logger); - pdcp_log.init("PDCP", logger); - rrc_log.init("RRC ", logger); - gtpu_log.init("GTPU", logger); - s1ap_log.init("S1AP", logger); - stack_log.init("STCK", logger); - // Init logs - rlc_log.set_level(args.log.rlc_level); - pdcp_log.set_level(args.log.pdcp_level); - rrc_log.set_level(args.log.rrc_level); - gtpu_log.set_level(args.log.gtpu_level); - s1ap_log.set_level(args.log.s1ap_level); - stack_log.set_level(LOG_LEVEL_INFO); - - rlc_log.set_hex_limit(args.log.rlc_hex_limit); - pdcp_log.set_hex_limit(args.log.pdcp_hex_limit); - rrc_log.set_hex_limit(args.log.rrc_hex_limit); - gtpu_log.set_hex_limit(args.log.gtpu_hex_limit); - s1ap_log.set_hex_limit(args.log.s1ap_hex_limit); - stack_log.set_hex_limit(128); + rlc_log->set_level(args.log.rlc_level); + pdcp_log->set_level(args.log.pdcp_level); + rrc_log->set_level(args.log.rrc_level); + gtpu_log->set_level(args.log.gtpu_level); + s1ap_log->set_level(args.log.s1ap_level); + stack_log->set_level(LOG_LEVEL_INFO); + + rlc_log->set_hex_limit(args.log.rlc_hex_limit); + pdcp_log->set_hex_limit(args.log.pdcp_hex_limit); + rrc_log->set_hex_limit(args.log.rrc_hex_limit); + gtpu_log->set_hex_limit(args.log.gtpu_hex_limit); + s1ap_log->set_hex_limit(args.log.s1ap_hex_limit); + stack_log->set_hex_limit(128); // Set up pcap and trace if (args.mac_pcap.enable) { @@ -107,13 +100,13 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) } // Init Rx socket handler - rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", &stack_log)); + rx_sockets.reset(new srslte::rx_multisocket_handler("ENBSOCKETS", stack_log)); // Init all layers mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc, this, mac_log); - rlc.init(&pdcp, &rrc, &mac, &timers, &rlc_log); + rlc.init(&pdcp, &rrc, &mac, &timers, rlc_log); pdcp.init(&rlc, &rrc, >pu); - rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers, &rrc_log); + rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers); s1ap.init(args.s1ap, &rrc, &timers, this); gtpu.init(args.s1ap.gtp_bind_addr, args.s1ap.mme_addr, @@ -121,7 +114,6 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_) args.embms.m1u_if_addr, &pdcp, this, - >pu_log, args.embms.enable); started = true; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 0d4e8f5a6..ffb45686d 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -36,7 +36,7 @@ using namespace asn1::rrc; namespace srsenb { -rrc::rrc() +rrc::rrc() : rrc_log("RRC") { pending_paging.clear(); } @@ -50,17 +50,15 @@ void rrc::init(const rrc_cfg_t& cfg_, pdcp_interface_rrc* pdcp_, s1ap_interface_rrc* s1ap_, gtpu_interface_rrc* gtpu_, - srslte::timer_handler* timers_, - srslte::log* log_rrc) -{ - phy = phy_; - mac = mac_; - rlc = rlc_; - pdcp = pdcp_; - gtpu = gtpu_; - s1ap = s1ap_; - rrc_log = log_rrc; - timers = timers_; + srslte::timer_handler* timers_) +{ + phy = phy_; + mac = mac_; + rlc = rlc_; + pdcp = pdcp_; + gtpu = gtpu_; + s1ap = s1ap_; + timers = timers_; pool = srslte::byte_buffer_pool::get_instance(); diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index d96a4f284..24e6feb9f 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -24,14 +24,14 @@ #include #include #include +#include #include #include -#include using namespace srslte; namespace srsenb { -gtpu::gtpu() : m1u(this) {} +gtpu::gtpu() : m1u(this), gtpu_log("GTPU") {} bool gtpu::init(std::string gtp_bind_addr_, std::string mme_addr_, @@ -39,11 +39,9 @@ bool gtpu::init(std::string gtp_bind_addr_, std::string m1u_if_addr_, srsenb::pdcp_interface_gtpu* pdcp_, stack_interface_gtpu_lte* stack_, - srslte::log* gtpu_log_, bool enable_mbsfn_) { pdcp = pdcp_; - gtpu_log = gtpu_log_; gtp_bind_addr = gtp_bind_addr_; mme_addr = mme_addr_; pool = byte_buffer_pool::get_instance(); diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index da66423d8..597e5203f 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -24,9 +24,9 @@ namespace srsenb { -pdcp::pdcp(srslte::timer_handler* timers_, srslte::log* log_) : +pdcp::pdcp(srslte::timer_handler* timers_, const char* logname) : timers(timers_), - log_h(log_), + log_h(logname), pool(srslte::byte_buffer_pool::get_instance()) { } @@ -49,7 +49,7 @@ void pdcp::stop() void pdcp::add_user(uint16_t rnti) { if (users.count(rnti) == 0) { - srslte::pdcp* obj = new srslte::pdcp(timers, log_h); + srslte::pdcp* obj = new srslte::pdcp(timers, log_h->get_service_name().c_str()); obj->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].gtpu_itf); users[rnti].rlc_itf.rnti = rnti; users[rnti].gtpu_itf.rnti = rnti; diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index 0cc1b4743..e3e3075d1 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -28,7 +28,7 @@ void rlc::init(pdcp_interface_rlc* pdcp_, rrc_interface_rlc* rrc_, mac_interface_rlc* mac_, srslte::timer_handler* timers_, - srslte::log* log_h_) + srslte::log_ref log_h_) { pdcp = pdcp_; rrc = rrc_; @@ -56,7 +56,7 @@ void rlc::add_user(uint16_t rnti) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti) == 0) { - std::unique_ptr obj(new srslte::rlc(log_h)); + std::unique_ptr obj(new srslte::rlc(log_h->get_service_name().c_str())); obj->init(&users[rnti], &users[rnti], timers, RB_ID_SRB0); users[rnti].rnti = rnti; users[rnti].pdcp = pdcp; diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index e677b64ce..04d73cd6b 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -413,12 +413,12 @@ bool s1ap::connect_mme() // Init SCTP socket and bind it if (not srslte::net_utils::sctp_init_client( - &s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str(), s1ap_log.get())) { + &s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str())) { return false; } // Connect to the MME address - if (not s1ap_socket.connect_to(args.mme_addr.c_str(), MME_PORT, &mme_addr, s1ap_log.get())) { + if (not s1ap_socket.connect_to(args.mme_addr.c_str(), MME_PORT, &mme_addr)) { return false; } diff --git a/srsenb/test/upper/erab_setup_test.cc b/srsenb/test/upper/erab_setup_test.cc index 52345fc7b..684e1f528 100644 --- a/srsenb/test/upper/erab_setup_test.cc +++ b/srsenb/test/upper/erab_setup_test.cc @@ -46,7 +46,7 @@ int test_erab_setup(bool qci_exists) gtpu_dummy gtpu; rrc_log->set_level(srslte::LOG_LEVEL_INFO); rrc_log->set_hex_limit(1024); - rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers, rrc_log.get()); + rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers); auto tic = [&timers, &rrc] { timers.step_all(); diff --git a/srsenb/test/upper/rrc_mobility_test.cc b/srsenb/test/upper/rrc_mobility_test.cc index bee915ee2..cb7625500 100644 --- a/srsenb/test/upper/rrc_mobility_test.cc +++ b/srsenb/test/upper/rrc_mobility_test.cc @@ -282,7 +282,7 @@ int test_mobility_class(mobility_test_params test_params) gtpu_dummy gtpu; rrc_log->set_level(srslte::LOG_LEVEL_INFO); rrc_log->set_hex_limit(1024); - rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers, rrc_log.get()); + rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, >pu, &timers); auto tic = [&timers, &rrc] { timers.step_all(); diff --git a/srsepc/hdr/mbms-gw/mbms-gw.h b/srsepc/hdr/mbms-gw/mbms-gw.h index dd238e4f4..c91f9db1c 100644 --- a/srsepc/hdr/mbms-gw/mbms-gw.h +++ b/srsepc/hdr/mbms-gw/mbms-gw.h @@ -30,9 +30,9 @@ #include "srslte/asn1/gtpc.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/log.h" #include "srslte/common/log_filter.h" #include "srslte/common/logger_file.h" +#include "srslte/common/logmap.h" #include "srslte/common/threads.h" #include "srslte/srslte.h" #include @@ -64,7 +64,7 @@ class mbms_gw : public srslte::thread public: static mbms_gw* get_instance(void); static void cleanup(void); - int init(mbms_gw_args_t* args, srslte::log_filter* mbms_gw_log); + int init(mbms_gw_args_t* args, srslte::log_ref mbms_gw_log); void stop(); void run_thread(); @@ -82,7 +82,7 @@ private: /* Members */ bool m_running; srslte::byte_buffer_pool* m_pool; - srslte::log_filter* m_mbms_gw_log; + srslte::log_ref m_mbms_gw_log; bool m_sgi_mb_up; int m_sgi_mb_if; diff --git a/srsepc/hdr/spgw/gtpu.h b/srsepc/hdr/spgw/gtpu.h index 341b82626..337e86202 100644 --- a/srsepc/hdr/spgw/gtpu.h +++ b/srsepc/hdr/spgw/gtpu.h @@ -25,6 +25,7 @@ #include "srsepc/hdr/spgw/spgw.h" #include "srslte/asn1/gtpc.h" #include "srslte/common/buffer_pool.h" +#include "srslte/common/logmap.h" #include "srslte/interfaces/epc_interfaces.h" #include #include @@ -36,7 +37,7 @@ class spgw::gtpu : public gtpu_interface_gtpc public: gtpu(); virtual ~gtpu(); - int init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc, srslte::log_filter* gtpu_log); + int init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc, srslte::log_ref gtpu_log); void stop(); int init_sgi(spgw_args_t* args); @@ -71,7 +72,7 @@ public: // UE is attached without an active user-plane // for downlink notifications. - srslte::log_filter* m_gtpu_log; + srslte::log_ref m_gtpu_log; private: srslte::byte_buffer_pool* m_pool; diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 3de0ab1d3..9f69b7257 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -30,9 +30,9 @@ #include "srslte/asn1/gtpc.h" #include "srslte/common/buffer_pool.h" -#include "srslte/common/log.h" #include "srslte/common/log_filter.h" #include "srslte/common/logger_file.h" +#include "srslte/common/logmap.h" #include "srslte/common/threads.h" #include #include @@ -71,7 +71,7 @@ public: static spgw* get_instance(void); static void cleanup(void); int init(spgw_args_t* args, - srslte::log_filter* gtpu_log, + srslte::log_ref gtpu_log, srslte::log_filter* gtpc_log, srslte::log_filter* spgw_log, const std::map& ip_to_imsi); diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index b38652656..6803ac778 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -398,6 +398,7 @@ int main(int argc, char* argv[]) logger_file.log_char("\n--- Software Radio Systems EPC log ---\n\n"); logger = &logger_file; } + srslte::logmap::set_default_logger(logger); srslte::log_filter nas_log; nas_log.init("NAS ", logger); @@ -424,10 +425,9 @@ int main(int argc, char* argv[]) spgw_gtpc_log.set_level(level(args.log_args.spgw_gtpc_level)); spgw_gtpc_log.set_hex_limit(args.log_args.spgw_gtpc_hex_limit); - srslte::log_filter gtpu_log; - gtpu_log.init("GTPU", logger); - gtpu_log.set_level(level(args.log_args.mme_gtpc_level)); - gtpu_log.set_hex_limit(args.log_args.mme_gtpc_hex_limit); + srslte::log_ref gtpu_log{"GTPU"}; + gtpu_log->set_level(level(args.log_args.mme_gtpc_level)); + gtpu_log->set_hex_limit(args.log_args.mme_gtpc_hex_limit); srslte::log_filter spgw_log; spgw_log.init("SPGW", logger); @@ -447,7 +447,7 @@ int main(int argc, char* argv[]) } spgw* spgw = spgw::get_instance(); - if (spgw->init(&args.spgw_args, >pu_log, &spgw_gtpc_log, &spgw_log, hss->get_ip_to_imsi())) { + if (spgw->init(&args.spgw_args, gtpu_log, &spgw_gtpc_log, &spgw_log, hss->get_ip_to_imsi())) { cout << "Error initializing SP-GW" << endl; exit(1); } diff --git a/srsepc/src/mbms-gw/main.cc b/srsepc/src/mbms-gw/main.cc index f6dfa84e4..5b40e2fcb 100644 --- a/srsepc/src/mbms-gw/main.cc +++ b/srsepc/src/mbms-gw/main.cc @@ -204,14 +204,14 @@ int main(int argc, char* argv[]) logger_file.log_char("\n--- Software Radio Systems MBMS log ---\n\n"); logger = &logger_file; } + srslte::logmap::set_default_logger(logger); - srslte::log_filter mbms_gw_log; - mbms_gw_log.init("MBMS", logger); - mbms_gw_log.set_level(level(args.log_args.mbms_gw_level)); - mbms_gw_log.set_hex_limit(args.log_args.mbms_gw_hex_limit); + srslte::log_ref mbms_gw_log{"MBMS"}; + mbms_gw_log->set_level(level(args.log_args.mbms_gw_level)); + mbms_gw_log->set_hex_limit(args.log_args.mbms_gw_hex_limit); mbms_gw* mbms_gw = mbms_gw::get_instance(); - if (mbms_gw->init(&args.mbms_gw_args, &mbms_gw_log)) { + if (mbms_gw->init(&args.mbms_gw_args, mbms_gw_log)) { cout << "Error initializing MBMS-GW" << endl; exit(1); } diff --git a/srsepc/src/mbms-gw/mbms-gw.cc b/srsepc/src/mbms-gw/mbms-gw.cc index 33a92b82d..1dd84e615 100644 --- a/srsepc/src/mbms-gw/mbms-gw.cc +++ b/srsepc/src/mbms-gw/mbms-gw.cc @@ -69,7 +69,7 @@ void mbms_gw::cleanup(void) pthread_mutex_unlock(&mbms_gw_instance_mutex); } -int mbms_gw::init(mbms_gw_args_t* args, srslte::log_filter* mbms_gw_log) +int mbms_gw::init(mbms_gw_args_t* args, srslte::log_ref mbms_gw_log) { int err; m_pool = srslte::byte_buffer_pool::get_instance(); diff --git a/srsepc/src/spgw/gtpu.cc b/srsepc/src/spgw/gtpu.cc index 90dafe506..2f555e319 100644 --- a/srsepc/src/spgw/gtpu.cc +++ b/srsepc/src/spgw/gtpu.cc @@ -52,7 +52,7 @@ spgw::gtpu::~gtpu() return; } -int spgw::gtpu::init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc, srslte::log_filter* gtpu_log) +int spgw::gtpu::init(spgw_args_t* args, spgw* spgw, gtpc_interface_gtpu* gtpc, srslte::log_ref gtpu_log) { int err; diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 79494d778..2dc33e76b 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -66,7 +66,7 @@ void spgw::cleanup() } int spgw::init(spgw_args_t* args, - srslte::log_filter* gtpu_log, + srslte::log_ref gtpu_log, srslte::log_filter* gtpc_log, srslte::log_filter* spgw_log, const std::map& ip_to_imsi) diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index af3e4bb9b..5cf448751 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -88,7 +88,7 @@ rrc::rrc(stack_interface_rrc* stack_) : state(RRC_STATE_IDLE), last_state(RRC_STATE_CONNECTED), drb_up(false), - rrc_log(srslte::logmap::get("RRC")), + rrc_log("RRC"), cell_searcher(this), si_acquirer(this), serv_cell_cfg(this), diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 4ed2351c9..7c095f657 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -37,10 +37,10 @@ ue_stack_lte::ue_stack_lte() : logger(nullptr), usim(nullptr), phy(nullptr), - rlc(rlc_log.get()), + rlc("RLC"), mac("MAC "), rrc(this), - pdcp(&timers, pdcp_log.get()), + pdcp(&timers, "PDCP"), nas(this), thread("STACK"), pending_tasks(512), diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 1748c00ab..e1d5cda2a 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -243,17 +243,17 @@ nas::nas(srsue::stack_interface_nas* task_handler_) : t3410(task_handler_->get_unique_timer()), t3411(task_handler_->get_unique_timer()), t3421(task_handler_->get_unique_timer()), - reattach_timer(task_handler_->get_unique_timer()) + reattach_timer(task_handler_->get_unique_timer()), + nas_log{"NAS"} { } void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_nas* gw_, const nas_args_t& cfg_) { - nas_log = logmap::get("NAS "); - usim = usim_; - rrc = rrc_; - gw = gw_; - state = EMM_STATE_DEREGISTERED; + usim = usim_; + rrc = rrc_; + gw = gw_; + state = EMM_STATE_DEREGISTERED; if (!usim->get_home_plmn_id(&home_plmn)) { nas_log->error("Getting Home PLMN Id from USIM. Defaulting to 001-01\n"); diff --git a/srsue/test/ttcn3/hdr/ttcn3_syssim.h b/srsue/test/ttcn3/hdr/ttcn3_syssim.h index db19aa47b..418f82492 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_syssim.h +++ b/srsue/test/ttcn3/hdr/ttcn3_syssim.h @@ -50,7 +50,6 @@ class ttcn3_syssim : public syssim_interface_phy, public: ttcn3_syssim(srslte::logger_file* logger_file_, ttcn3_ue* ue_) : log{"SS "}, - ss_mac_log{"SS-MAC"}, mac_msg_ul(20, ss_mac_log), mac_msg_dl(20, ss_mac_log), timers(8), @@ -59,10 +58,10 @@ public: logger_file(logger_file_), pool(byte_buffer_pool::get_instance()), ue(ue_), - rlc(&ss_rlc_log), + rlc(ss_rlc_log->get_service_name().c_str()), signal_handler(&running), timer_handler(create_tti_timer(), [&](uint64_t res) { new_tti_indication(res); }), - pdcp(&timers, &ss_pdcp_log) + pdcp(&timers, ss_pdcp_log->get_service_name().c_str()) { if (ue->init(all_args_t{}, logger, this, "INIT_TEST") != SRSLTE_SUCCESS) { ue->stop(); @@ -80,6 +79,7 @@ public: if (args.log.filename == "stdout") { logger = &logger_stdout; } + srslte::logmap::set_default_logger(logger); // init and configure logging srslte::logmap::register_log(std::unique_ptr{new log_filter{"SS ", logger, true}}); @@ -88,8 +88,8 @@ public: ip_sock_log.init("IP_S", logger); ip_ctrl_log.init("IP_C", logger); srb_log.init("SRB ", logger); - ss_rlc_log.init("SS-RLC", logger); - ss_pdcp_log.init("SS-PDCP", logger); + srslte::logmap::register_log(std::unique_ptr{new log_filter{"SS-RLC", logger}}); + srslte::logmap::register_log(std::unique_ptr{new log_filter{"SS-PDCP", logger}}); log->set_level(args.log.all_level); ut_log.set_level(args.log.all_level); @@ -98,8 +98,8 @@ public: ip_ctrl_log.set_level(args.log.all_level); srb_log.set_level(args.log.all_level); ss_mac_log->set_level(args.log.all_level); - ss_rlc_log.set_level(args.log.all_level); - ss_pdcp_log.set_level(args.log.all_level); + ss_rlc_log->set_level(args.log.all_level); + ss_pdcp_log->set_level(args.log.all_level); log->set_hex_limit(args.log.all_hex_limit); ut_log.set_hex_limit(args.log.all_hex_limit); @@ -108,8 +108,8 @@ public: ip_ctrl_log.set_hex_limit(args.log.all_hex_limit); srb_log.set_hex_limit(args.log.all_hex_limit); ss_mac_log->set_hex_limit(args.log.all_hex_limit); - ss_rlc_log.set_hex_limit(args.log.all_hex_limit); - ss_pdcp_log.set_hex_limit(args.log.all_hex_limit); + ss_rlc_log->set_hex_limit(args.log.all_hex_limit); + ss_pdcp_log->set_hex_limit(args.log.all_hex_limit); // Init epoll socket and add FDs epoll_fd = epoll_create1(0); @@ -1183,9 +1183,9 @@ private: srslte::log_filter ip_sock_log; srslte::log_filter ip_ctrl_log; srslte::log_filter srb_log; - srslte::log_ref ss_mac_log; - srslte::log_filter ss_rlc_log; - srslte::log_filter ss_pdcp_log; + srslte::log_ref ss_mac_log{"SS-MAC"}; + srslte::log_ref ss_rlc_log{"SS-RLC"}; + srslte::log_ref ss_pdcp_log{"SS-PDCP"}; all_args_t args = {}; diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index f99ed2a8a..d92b75058 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -115,7 +115,7 @@ public: class pdcp_test : public srslte::pdcp { public: - pdcp_test(srslte::log* log_, srslte::timer_handler* t) : srslte::pdcp(t, log_) {} + pdcp_test(const char* logname, srslte::timer_handler* t) : srslte::pdcp(t, logname) {} void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = false) override { ul_dcch_msg_s ul_dcch_msg; @@ -170,11 +170,11 @@ class rrc_test : public rrc srsue::stack_dummy_interface* stack = nullptr; public: - rrc_test(srslte::log* log_, stack_dummy_interface* stack_) : rrc(stack_), stack(stack_) + rrc_test(srslte::log_ref log_, stack_dummy_interface* stack_) : rrc(stack_), stack(stack_) { pool = srslte::byte_buffer_pool::get_instance(); nastest = std::unique_ptr(new nas_test(stack)); - pdcptest = std::unique_ptr(new pdcp_test(log_, &stack->timers)); + pdcptest = std::unique_ptr(new pdcp_test(log_->get_service_name().c_str(), &stack->timers)); }; void init() { rrc::init(&phytest, nullptr, nullptr, pdcptest.get(), nastest.get(), nullptr, nullptr, {}); } @@ -265,16 +265,16 @@ private: // Test Cell sear int cell_select_test() { - srslte::log_filter log1("RRC_MEAS"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); + srslte::log_ref log1("RRC_MEAS"); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); printf("==========================================================\n"); printf("====== Cell Select Testing ===============\n"); printf("==========================================================\n"); stack_dummy_interface stack; - rrc_test rrctest(&log1, &stack); + rrc_test rrctest(log1, &stack); rrctest.init(); rrctest.connect(); @@ -295,16 +295,16 @@ int cell_select_test() // Tests the measObject configuration and the successful activation of PHY cells to search for int meas_obj_test() { - srslte::log_filter log1("RRC_MEAS"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); + srslte::log_ref log1("RRC_MEAS"); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); printf("==========================================================\n"); printf("====== Object Configuration Testing ===============\n"); printf("==========================================================\n"); stack_dummy_interface stack; - rrc_test rrctest(&log1, &stack); + rrc_test rrctest(log1, &stack); rrctest.init(); rrctest.connect(); @@ -315,7 +315,7 @@ int meas_obj_test() rrc_conn_recfg.meas_cfg_present = true; meas_cfg_s& meas_cfg = rrc_conn_recfg.meas_cfg; - log1.info("Test1: Remove non-existing measObject, reportConfig and measId\n"); + log1->info("Test1: Remove non-existing measObject, reportConfig and measId\n"); meas_cfg = {}; meas_cfg.meas_id_to_rem_list.push_back(3); meas_cfg.meas_obj_to_rem_list.push_back(3); @@ -327,7 +327,7 @@ int meas_obj_test() TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg)); TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0); - log1.info("Test2: Add measId pointing to non-existing measObject or reportConfig\n"); + log1->info("Test2: Add measId pointing to non-existing measObject or reportConfig\n"); meas_cfg = {}; meas_id_to_add_mod_s m = {}; m.meas_obj_id = 1; @@ -340,7 +340,7 @@ int meas_obj_test() TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg)); TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0); - log1.info("Test3: Add meaObject and report of unsupported type. Setup a supported report for later use\n"); + log1->info("Test3: Add meaObject and report of unsupported type. Setup a supported report for later use\n"); meas_cfg = {}; meas_obj_to_add_mod_s obj = {}; obj.meas_obj.set_meas_obj_utra(); @@ -369,7 +369,7 @@ int meas_obj_test() TESTASSERT(rrctest.send_meas_cfg(rrc_conn_recfg)); TESTASSERT(rrctest.phytest.meas_nof_freqs() == 0); - log1.info("Test4: Add 2 measObjects and 2 measId both pointing to the same measObject \n"); + log1->info("Test4: Add 2 measObjects and 2 measId both pointing to the same measObject \n"); meas_cfg = {}; for (int i = 0; i < 2; i++) { m = {}; @@ -405,7 +405,7 @@ int meas_obj_test() TESTASSERT(rrctest.phytest.meas_freq_started(100)); TESTASSERT(rrctest.phytest.meas_nof_cells(100) == 0); - log1.info("Test5: Add existing objects and measId. Now add measId for 2nd cell\n"); + log1->info("Test5: Add existing objects and measId. Now add measId for 2nd cell\n"); meas_cfg = {}; m = {}; m.meas_obj_id = 2; // same object @@ -436,7 +436,7 @@ int meas_obj_test() } // Reconfigure 2nd object only, we should see 8 cells now - log1.info("Test6: Add 1 cell to 1st object. Mixed add/mod and removal command.\n"); + log1->info("Test6: Add 1 cell to 1st object. Mixed add/mod and removal command.\n"); meas_cfg = {}; meas_cfg.meas_obj_to_add_mod_list_present = true; @@ -490,7 +490,7 @@ int meas_obj_test() TESTASSERT(rrctest.phytest.meas_cell_started(2, 23)); // was added TESTASSERT(rrctest.phytest.meas_cell_started(2, 24)); // was added - log1.info("Test7: PHY finds new neighbours in frequency 1 and 2, check RRC instructs to search them\n"); + log1->info("Test7: PHY finds new neighbours in frequency 1 and 2, check RRC instructs to search them\n"); std::vector phy_meas = {}; phy_meas.push_back({0, 0, 1, 31}); phy_meas.push_back({-1, 0, 1, 32}); @@ -526,13 +526,13 @@ int meas_obj_test() TESTASSERT(rrctest.phytest.meas_cell_started(2, 24)); // was added TESTASSERT(rrctest.phytest.meas_cell_started(2, 31)); - log1.info("Test8: Simulate a Release (reset() call) make sure resets correctly\n"); + log1->info("Test8: Simulate a Release (reset() call) make sure resets correctly\n"); rrctest.init(); rrctest.run_tti(1); rrctest.connect(); rrctest.run_tti(1); - log1.info("Test9: Config removal\n"); + log1->info("Test9: Config removal\n"); meas_cfg = {}; meas_cfg.meas_obj_to_rem_list.push_back(1); meas_cfg.meas_obj_to_rem_list.push_back(2); @@ -720,16 +720,16 @@ int a1event_report_test(uint32_t a1_rsrp_th, report_interv_e report_interv) { - srslte::log_filter log1("RRC_MEAS"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); + srslte::log_ref log1("RRC_MEAS"); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); printf("==========================================================\n"); printf("============ Report Testing A1 ===============\n"); printf("==========================================================\n"); stack_dummy_interface stack; - rrc_test rrctest(&log1, &stack); + rrc_test rrctest(log1, &stack); rrctest.init(); rrctest.connect(); @@ -754,20 +754,20 @@ int a1event_report_test(uint32_t a1_rsrp_th, // Entering condition during half timeToTrigger, should not trigger measurement for (int i = 0; i < ttt_iters / 2; i++) { - log1.info("Report %d/%d enter condition is true\n", i, ttt_iters / 2); + log1->info("Report %d/%d enter condition is true\n", i, ttt_iters / 2); enter_condition(rrctest, event_id, hyst, 0, {1, 2}); // Check doesn't generate measurement report TESTASSERT(!rrctest.get_meas_res(meas_res)); } - log1.info("Report leaving enter condition\n"); + log1->info("Report leaving enter condition\n"); // Not satisfy entering condition for 1 TTI middle_condition(rrctest, event_id, hyst, 0, {1}); TESTASSERT(!rrctest.get_meas_res(meas_res)); // Should go again all timeToTrigger, should not trigger measurement until end for (int i = 0; i < ttt_iters; i++) { - log1.info("Report %d/%d enter condition is true\n", i, ttt_iters); + log1->info("Report %d/%d enter condition is true\n", i, ttt_iters); enter_condition(rrctest, event_id, hyst, 0, {1, 2}); if (i < ttt_iters - 1) { // Check doesn't generate measurement report @@ -787,14 +787,14 @@ int a1event_report_test(uint32_t a1_rsrp_th, // Trigger again entering condition for the same cell it shouldn't trigger a new report, just keep sending the // periodic reports without restarting counter for (int i = 0; i < ttt_iters; i++) { - log1.info("Report %d/%d enter condition is true\n", i, ttt_iters); + log1->info("Report %d/%d enter condition is true\n", i, ttt_iters); enter_condition(rrctest, event_id, hyst, 0, {1}); } // Do not expect report if timer not expired TESTASSERT(!rrctest.get_meas_res(meas_res)); // Wait to generate all reports for (int i = 0; i < report_amount.to_number() - 1; i++) { - log1.info("Testing report %d/%d\n", i, report_amount.to_number()); + log1->info("Testing report %d/%d\n", i, report_amount.to_number()); int interval = report_interv.to_number(); if (i == 0) { // already stepped these iterations @@ -805,7 +805,7 @@ int a1event_report_test(uint32_t a1_rsrp_th, // Exit the enter condition in the last one, should still send the last report middle_condition(rrctest, event_id, hyst, 0, {1}); } else { - log1.info("Stepping timer %d/%d\n", j, interval); + log1->info("Stepping timer %d/%d\n", j, interval); rrctest.run_tti(1); } if (j < interval - 1) { @@ -824,7 +824,7 @@ int a1event_report_test(uint32_t a1_rsrp_th, } // Trigger again condition for (int i = 0; i < ttt_iters; i++) { - log1.info("Report %d/%d enter condition is true\n", i, ttt_iters); + log1->info("Report %d/%d enter condition is true\n", i, ttt_iters); enter_condition(rrctest, event_id, hyst, 0, {1}); } // Do not expect report @@ -832,14 +832,14 @@ int a1event_report_test(uint32_t a1_rsrp_th, // Leaving condition for timeToTrigger for (int i = 0; i < ttt_iters; i++) { - log1.info("Report %d/%d leaving condition is true\n", i, ttt_iters); + log1->info("Report %d/%d leaving condition is true\n", i, ttt_iters); exit_condition(rrctest, event_id, hyst, 0, {1}); // Check doesn't generate measurement report TESTASSERT(!rrctest.get_meas_res(meas_res)); } // Trigger again condition for (int i = 0; i < ttt_iters; i++) { - log1.info("Report %d/%d enter condition is true\n", i, ttt_iters); + log1->info("Report %d/%d enter condition is true\n", i, ttt_iters); enter_condition(rrctest, event_id, hyst, 0, {1}); } // Expect report @@ -854,16 +854,16 @@ int a1event_report_test(uint32_t a1_rsrp_th, int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) { - srslte::log_filter log1("RRC_MEAS"); - log1.set_level(srslte::LOG_LEVEL_DEBUG); - log1.set_hex_limit(-1); + srslte::log_ref log1("RRC_MEAS"); + log1->set_level(srslte::LOG_LEVEL_DEBUG); + log1->set_hex_limit(-1); printf("==========================================================\n"); printf("============ Report Testing A3 ===============\n"); printf("==========================================================\n"); stack_dummy_interface stack; - rrc_test rrctest(&log1, &stack); + rrc_test rrctest(log1, &stack); rrctest.init(); rrctest.connect(); @@ -889,14 +889,14 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) meas_results_s meas_res = {}; - log1.info("Test no-enter condition and no trigger report \n"); + log1->info("Test no-enter condition and no trigger report \n"); no_condition(rrctest, {0}, {1}); TESTASSERT(!rrctest.get_meas_res(meas_res)); no_condition(rrctest, {0, 1}, {1, 0}); TESTASSERT(!rrctest.get_meas_res(meas_res)); - log1.info("Test enter condition triggers report. 1 neighbour cell in enter + 1 in exit \n"); + log1->info("Test enter condition triggers report. 1 neighbour cell in enter + 1 in exit \n"); float offset = 0.5 * event_id.event_a3().a3_offset; std::vector rsrp = {}; rsrp.push_back(-60 + offset + 0.5 * hyst + (float)1e-2); @@ -915,11 +915,11 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) 81 + (hyst + a3_offset) / 2); // Next iteration in entering state does not trigger another report - log1.info("Test enter condition for the same cell does not trigger report\n"); + log1->info("Test enter condition for the same cell does not trigger report\n"); rrctest.run_tti(1); TESTASSERT(!rrctest.get_meas_res(meas_res)); - log1.info("Test enter condition for different earfcn triggers report\n"); + log1->info("Test enter condition for different earfcn triggers report\n"); enter_condition(rrctest, event_id, hyst, 2, {1, 3}); TESTASSERT(rrctest.get_meas_res(meas_res)); TESTASSERT(meas_res.meas_id == 2); @@ -932,7 +932,7 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) 81 + (hyst + a3_offset) / 2); // if a new cell enters conditions then expect another report - log1.info("Test a new cell enter condition triggers report\n"); + log1->info("Test a new cell enter condition triggers report\n"); enter_condition(rrctest, event_id, hyst, 1, {1, 3}); TESTASSERT(rrctest.get_meas_res(meas_res)); TESTASSERT(meas_res.meas_id == 1); @@ -946,14 +946,14 @@ int a3event_report_test(uint32_t a3_offset, uint32_t hyst, bool report_on_leave) 81 + (hyst + a3_offset) / 2); // cell pci=0 exists condition - log1.info("Test exit condition\n"); + log1->info("Test exit condition\n"); exit_condition(rrctest, event_id, hyst, 1, {1, 0}); if (report_on_leave) { TESTASSERT(rrctest.get_meas_res(meas_res)); } // 2 enters again, now expect report again - log1.info("Test trigger again the cell that exited\n"); + log1->info("Test trigger again the cell that exited\n"); enter_condition(rrctest, event_id, hyst, 1, {1, 0}); TESTASSERT(rrctest.get_meas_res(meas_res)); TESTASSERT(meas_res.meas_id == 1);