use logmap in the whole enb and ue

master
Francisco Paisana 5 years ago committed by Francisco Paisana
parent 9a264b62c4
commit 344eaf49ec

@ -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 <functional>
@ -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<void(srslte::unique_byte_buffer_t, const sockaddr_in&, const sctp_sndrcvinfo&, int)>;
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,7 +156,7 @@ private:
// args
std::string name;
srslte::log* log_h = nullptr;
srslte::log_ref log_h;
srslte::byte_buffer_pool* pool = nullptr;
// state

@ -23,7 +23,7 @@
#define SRSLTE_GTPU_H
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include <stdint.h>
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 &&

@ -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();
@ -72,7 +72,7 @@ private:
typedef std::pair<uint16_t, pdcp_entity_lte*> pdcp_map_pair_t;
srslte::timer_handler* timers = nullptr;
log* pdcp_log = nullptr;
srslte::log_ref pdcp_log;
pdcp_map_t pdcp_array, pdcp_array_mrb;
// cache valid lcids to be checked from separate thread

@ -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,7 +111,7 @@ 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;

@ -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();

@ -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_,
@ -88,7 +88,7 @@ private:
void reset_metrics();
byte_buffer_pool* pool = nullptr;
srslte::log* rlc_log = nullptr;
srslte::log_ref rlc_log;
srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr;
srslte::timer_handler* timers = nullptr;

@ -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
@ -271,7 +271,7 @@ private:
// Common variables needed/provided by parent class
srsue::rrc_interface_rlc* rrc = nullptr;
srslte::log* log = nullptr;
srslte::log_ref log;
srsue::pdcp_interface_rlc* pdcp = nullptr;
srslte::timer_handler* timers = nullptr;
uint32_t lcid = 0;

@ -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;

@ -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 = {};
@ -121,7 +121,7 @@ protected:
protected:
byte_buffer_pool* pool = nullptr;
srslte::log* log = nullptr;
srslte::log_ref log;
srslte::timer_handler* timers = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr;
@ -144,7 +144,7 @@ protected:
// Common variables needed by parent class
srsue::rrc_interface_rlc* rrc = nullptr;
srsue::pdcp_interface_rlc* pdcp = nullptr;
srslte::log* log = nullptr;
srslte::log_ref log;
srslte::timer_handler* timers = nullptr;
uint32_t lcid = 0;
rlc_config_t cfg = {};

@ -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_,

@ -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,19 +109,13 @@ 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 {
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) {
// Sets the data_io_event to be able to use sendrecv_info
@ -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 {
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 {
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 {
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");
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 {
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 {
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<void(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from)>;
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_))
@ -452,7 +394,7 @@ public:
private:
srslte::byte_buffer_pool* pool = nullptr;
srslte::log* log_h = 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_))
@ -502,7 +444,7 @@ public:
private:
srslte::byte_buffer_pool* pool = nullptr;
srslte::log* log_h = 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_)

@ -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;

@ -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()
{

@ -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() {}

@ -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_),

@ -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));

@ -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_,

@ -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_,

@ -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_,

@ -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_,

@ -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;

@ -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 <iostream>
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;
};

@ -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<pdcp_test_event_t> 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<pdcp_test_event_t> pdu_vec;
for (uint32_t tx_next : tx_nexts) {

@ -31,7 +31,7 @@ int test_rx(std::vector<pdcp_test_event_t> 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<pdcp_test_event_t> 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;
}

@ -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");

@ -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);

@ -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<LOG_LEVEL_ENUM>(args.log_level));
log2.set_level(static_cast<LOG_LEVEL_ENUM>(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<LOG_LEVEL_ENUM>(args.log_level));
log2->set_level(static_cast<LOG_LEVEL_ENUM>(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);

@ -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;

@ -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"
@ -150,12 +148,12 @@ private:
// 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 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;

@ -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);
@ -382,7 +381,7 @@ private:
pdcp_interface_rrc* pdcp = nullptr;
gtpu_interface_rrc* gtpu = nullptr;
s1ap_interface_rrc* s1ap = nullptr;
srslte::log* rrc_log = nullptr;
srslte::log_ref rrc_log;
// derived params
std::vector<std::unique_ptr<cell_ctxt_t> > cell_ctxt_list;

@ -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<const var_meas_cfg_t> ue_var_meas;

@ -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();
@ -71,7 +70,7 @@ private:
std::string gtp_bind_addr;
std::string mme_addr;
srsenb::pdcp_interface_gtpu* pdcp = nullptr;
srslte::log* gtpu_log = nullptr;
srslte::log_ref gtpu_log;
// Class to create
class m1u_handler
@ -89,7 +88,7 @@ private:
private:
gtpu* parent = nullptr;
pdcp_interface_gtpu* pdcp = nullptr;
srslte::log* gtpu_log = nullptr;
srslte::log_ref gtpu_log;
std::string m1u_multiaddr;
std::string m1u_if_addr;

@ -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;
};

@ -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;
};

@ -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, &gtpu);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers, &rrc_log);
rrc.init(rrc_cfg, phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &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,
&gtpu_log,
args.embms.enable);
started = true;

@ -36,7 +36,7 @@ using namespace asn1::rrc;
namespace srsenb {
rrc::rrc()
rrc::rrc() : rrc_log("RRC")
{
pending_paging.clear();
}
@ -50,8 +50,7 @@ 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)
srslte::timer_handler* timers_)
{
phy = phy_;
mac = mac_;
@ -59,7 +58,6 @@ void rrc::init(const rrc_cfg_t& cfg_,
pdcp = pdcp_;
gtpu = gtpu_;
s1ap = s1ap_;
rrc_log = log_rrc;
timers = timers_;
pool = srslte::byte_buffer_pool::get_instance();

@ -24,14 +24,14 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/ip.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
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();

@ -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;

@ -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<srslte::rlc> obj(new srslte::rlc(log_h));
std::unique_ptr<srslte::rlc> 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;

@ -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;
}

@ -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, &gtpu, &timers, rrc_log.get());
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers);
auto tic = [&timers, &rrc] {
timers.step_all();

@ -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, &gtpu, &timers, rrc_log.get());
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu, &timers);
auto tic = [&timers, &rrc] {
timers.step_all();

@ -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 <cstddef>
@ -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;

@ -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 <cstddef>
#include <queue>
@ -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;

@ -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 <cstddef>
#include <queue>
@ -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<std::string, uint64_t>& ip_to_imsi);

@ -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, &gtpu_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);
}

@ -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);
}

@ -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();

@ -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;

@ -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<std::string, uint64_t>& ip_to_imsi)

@ -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),

@ -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),

@ -243,13 +243,13 @@ 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_;

@ -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<srslte::log>{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<srslte::log>{new log_filter{"SS-RLC", logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{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 = {};

@ -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<nas_test>(new nas_test(stack));
pdcptest = std::unique_ptr<pdcp_test>(new pdcp_test(log_, &stack->timers));
pdcptest = std::unique_ptr<pdcp_test>(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<rrc_interface_phy_lte::phy_meas_t> 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<float> 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);

Loading…
Cancel
Save