refactor - remove old log_filter and logmap libraries from the codebase

master
Francisco 4 years ago committed by Francisco Paisana
parent d35d7aef76
commit 3e9f93eb8a

@ -26,7 +26,6 @@
*******************************************************************************/
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
namespace srslte {

@ -1,150 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
/******************************************************************************
* File: log.h
*
* Description: Abstract logging service
*
* Reference:
*****************************************************************************/
#ifndef SRSLTE_LOG_H
#define SRSLTE_LOG_H
#include "srslte/common/standard_streams.h"
#include <algorithm>
#include <stdint.h>
#include <string>
namespace srslte {
typedef enum {
LOG_LEVEL_NONE = 0,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_N_ITEMS
} LOG_LEVEL_ENUM;
static const char log_level_text[LOG_LEVEL_N_ITEMS][16] = {"None ", "Error ", "Warning", "Info ", "Debug "};
static const char log_level_text_short[LOG_LEVEL_N_ITEMS][16] = {"[-]", "[E]", "[W]", "[I]", "[D]"};
class log
{
public:
log()
{
service_name = "";
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
add_string_en = false;
}
explicit log(std::string service_name_)
{
service_name = std::move(service_name_);
tti = 0;
level = LOG_LEVEL_NONE;
hex_limit = 0;
add_string_en = false;
}
log(const log&) = delete;
log& operator=(const log&) = delete;
virtual ~log() = default;
// This function shall be called at the start of every tti for printing tti
void step(uint32_t tti_)
{
tti = tti_;
add_string_en = false;
}
void prepend_string(std::string s)
{
add_string_en = true;
add_string_val = std::move(s);
}
uint32_t get_tti() { return tti; }
void set_level(LOG_LEVEL_ENUM l) { level = l; }
void set_level(std::string l) { set_level(get_level_from_string(std::move(l))); }
static srslte::LOG_LEVEL_ENUM get_level_from_string(std::string l)
{
std::transform(l.begin(), l.end(), l.begin(), ::toupper);
if ("NONE" == l) {
return srslte::LOG_LEVEL_NONE;
} else if ("ERROR" == l) {
return srslte::LOG_LEVEL_ERROR;
} else if ("WARNING" == l) {
return srslte::LOG_LEVEL_WARNING;
} else if ("INFO" == l) {
return srslte::LOG_LEVEL_INFO;
} else if ("DEBUG" == l) {
return srslte::LOG_LEVEL_DEBUG;
} else {
return srslte::LOG_LEVEL_NONE;
}
}
LOG_LEVEL_ENUM get_level() { return level; }
const std::string& get_service_name() const { return service_name; }
void set_hex_limit(int limit) { hex_limit = limit; }
int get_hex_limit() { return hex_limit; }
// Pure virtual methods for logging
virtual void error(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void warning(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void info(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void info_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void debug(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
virtual void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0;
// Same with hex dump
virtual void error_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("error_hex not implemented.\n");
}
virtual void warning_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("warning_hex not implemented.\n");
}
virtual void info_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("info_hex not implemented.\n");
}
virtual void debug_hex(const uint8_t*, int, const char*, ...) __attribute__((format(printf, 4, 5)))
{
error("debug_hex not implemented.\n");
}
protected:
uint32_t tti;
LOG_LEVEL_ENUM level;
int hex_limit;
bool add_string_en;
std::string add_string_val;
std::string service_name;
};
} // namespace srslte
#endif // SRSLTE_LOG_H

@ -1,90 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
/******************************************************************************
* File: log_filter.h
* Description: Log filter for a specific layer or element.
* Performs filtering based on log level, generates
* timestamped log strings and passes them to the
* common logger object.
*****************************************************************************/
#ifndef SRSLTE_LOG_FILTER_H
#define SRSLTE_LOG_FILTER_H
#include <stdarg.h>
#include <string>
#include "srslte/common/log.h"
#include "srslte/common/logger.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/phy/common/timestamp.h"
namespace srslte {
typedef std::string* str_ptr;
class log_filter : public srslte::log
{
public:
log_filter();
log_filter(std::string layer);
log_filter(std::string layer, logger* logger_, bool tti = false);
void init(std::string layer, logger* logger_, bool tti = false);
void error(const char* message, ...) __attribute__((format(printf, 2, 3)));
void warning(const char* message, ...) __attribute__((format(printf, 2, 3)));
void info(const char* message, ...) __attribute__((format(printf, 2, 3)));
void info_long(const char* message, ...) __attribute__((format(printf, 2, 3)));
void debug(const char* message, ...) __attribute__((format(printf, 2, 3)));
void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3)));
void error_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
void warning_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
void info_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
void debug_hex(const uint8_t* hex, int size, const char* message, ...) __attribute__((format(printf, 4, 5)));
class time_itf
{
public:
virtual srslte_timestamp_t get_time() = 0;
};
typedef enum { TIME, EPOCH } time_format_t;
void set_time_src(time_itf* source, time_format_t format);
protected:
std::unique_ptr<logger> default_logger;
logger* logger_h;
bool do_tti;
static const int char_buff_size = logger::preallocated_log_str_size - 64 * 3;
time_itf* time_src;
time_format_t time_format;
void all_log(srslte::LOG_LEVEL_ENUM level,
uint32_t tti,
char* msg,
const uint8_t* hex = nullptr,
int size = 0,
bool long_msg = false);
void now_time(char* buffer, const uint32_t buffer_len);
void get_tti_str(const uint32_t tti_, char* buffer, const uint32_t buffer_len);
std::string hex_string(const uint8_t* hex, int size);
};
} // namespace srslte
#endif // SRSLTE_LOG_FILTER_H

@ -21,37 +21,11 @@
namespace srslte {
#define Error(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->error(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Warning(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->warning(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Info(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->info(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Debug(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
log_h->debug(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Console(fmt, ...) \
do { \
if (log_h.get() != nullptr) { \
srslte::console(fmt, ##__VA_ARGS__); \
} \
} while (0)
#define Error(fmt, ...) logger.error(fmt, ##__VA_ARGS__)
#define Warning(fmt, ...) logger.warning(fmt, ##__VA_ARGS__)
#define Info(fmt, ...) logger.info(fmt, ##__VA_ARGS__)
#define Debug(fmt, ...) logger.debug(fmt, ##__VA_ARGS__)
#define Console(fmt, ...) srslte::console(fmt, ##__VA_ARGS__)
} // namespace srslte

@ -1,103 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
/******************************************************************************
* File: logger.h
* Description: Interface for logging output
*****************************************************************************/
#ifndef SRSLTE_LOGGER_H
#define SRSLTE_LOGGER_H
#include "buffer_pool.h"
#include <memory>
#include <stdio.h>
#include <string>
namespace srslte {
class logger
{
public:
const static uint32_t preallocated_log_str_size = 1024;
logger() : pool(16 * 1024) {}
virtual ~logger() = default;
class log_str
{
public:
log_str(const char* msg_ = nullptr, uint32_t size_ = 0)
{
size = size_ ? size_ : preallocated_log_str_size;
msg = new char[size];
if (msg_) {
strncpy(msg, msg_, size);
} else {
msg[0] = '\0';
}
}
log_str(const log_str&) = delete;
log_str& operator=(const log_str&) = delete;
~log_str() { delete[] msg; }
void reset() { msg[0] = '\0'; }
char* str() { return msg; }
uint32_t get_buffer_size() { return size; }
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
char debug_name[SRSLTE_BUFFER_POOL_LOG_NAME_LEN] = {};
#endif
private:
uint32_t size;
char* msg;
};
typedef buffer_pool<log_str> log_str_pool_t;
class log_str_deleter
{
public:
explicit log_str_deleter(log_str_pool_t* pool_ = nullptr) : pool(pool_) {}
void operator()(log_str* buf)
{
if (buf) {
if (pool) {
buf->reset();
pool->deallocate(buf);
} else {
delete buf;
}
}
}
private:
log_str_pool_t* pool;
};
typedef std::unique_ptr<log_str, log_str_deleter> unique_log_str_t;
void log_char(const char* msg) { log(unique_log_str_t(new log_str(msg), log_str_deleter())); }
virtual void log(unique_log_str_t msg) = 0;
log_str_pool_t& get_pool() { return pool; }
unique_log_str_t allocate_unique_log_str()
{
return unique_log_str_t(pool.allocate(), logger::log_str_deleter(&pool));
}
private:
log_str_pool_t pool;
};
} // namespace srslte
#endif // SRSLTE_LOGGER_H

@ -1,40 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#ifndef SRSLTE_LOGGER_SRSLOG_WRAPPER_H
#define SRSLTE_LOGGER_SRSLOG_WRAPPER_H
#include "srslte/common/logger.h"
namespace srslog {
class log_channel;
} // namespace srslog
namespace srslte {
/// This logger implementation uses the srsLog framework to write log entries.
class srslog_wrapper : public logger
{
public:
explicit srslog_wrapper(srslog::log_channel& chan) : chan(chan) {}
void log(unique_log_str_t msg) override;
private:
srslog::log_channel& chan;
};
} // namespace srslte
#endif // SRSLTE_LOGGER_SRSLOG_WRAPPER_H

@ -1,94 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#ifndef SRSLTE_LOGMAP_H
#define SRSLTE_LOGMAP_H
#include "srslte/common/log.h"
#include "srslte/common/logger.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/singleton.h"
#include <memory>
#include <mutex>
#include <unordered_map>
namespace srslte {
class log_ref
{
using ptr_type = std::unique_ptr<log>*;
public:
log_ref() = default;
explicit log_ref(ptr_type p) : ptr_(p) {}
explicit log_ref(const char* name);
// works like a log*
log* operator->() { return ptr_->get(); }
log* operator->() const { return ptr_->get(); }
// in case we want to obtain log*
log* operator*() { return ptr_->get(); }
log* get() { return ptr_->get(); }
// identity defined by ref address
bool operator==(const log_ref& l) { return ptr_ == l.ptr_; }
// to do checks like if(log_ref)
operator bool() { return ptr_ != nullptr; }
private:
ptr_type ptr_ = nullptr;
};
class logmap : public singleton_t<logmap>
{
public:
// Access to log map by servicename. If servicename does not exist, create a new log_filter with default cfg
// Access to the map is protected by a mutex
static log_ref get(std::string servicename);
// register manually created log
static void register_log(std::unique_ptr<log> log_ptr);
static std::unique_ptr<srslte::log> deregister_log(const std::string& servicename);
// set default logger
static void set_default_logger(logger* logger_);
// set default log level
static void set_default_log_level(LOG_LEVEL_ENUM l);
// set default hex limit
static void set_default_hex_limit(int hex_limit);
protected:
logmap();
private:
log_ref get_impl(std::string servicename);
// default cfg
std::unique_ptr<srslog_wrapper> stdout_channel;
logger* default_logger = nullptr;
srslte::LOG_LEVEL_ENUM default_log_level = LOG_LEVEL_WARNING;
int default_hex_limit = 1024;
// state
std::mutex mutex;
std::unordered_map<std::string, std::unique_ptr<log> > log_map;
};
} // namespace srslte
#endif // SRSLTE_LOGMAP_H

@ -18,7 +18,6 @@
#ifndef SRSLTE_NETSOURE_HANDLER_H
#define SRSLTE_NETSOURE_HANDLER_H
#include "srslte/common/log.h"
#include "srslte/common/threads.h"
#include "srslte/phy/io/netsource.h"
#include <array>
@ -61,8 +60,6 @@ public:
unique_byte_array_t rx_buf;
srslte_netsource_t net_source;
srslte::log* log = nullptr;
};
#endif // SRSLTE_NETSOURE_HANDLER_H

@ -17,73 +17,13 @@
#ifdef __cplusplus
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logmap.h"
#include "srslte/common/standard_streams.h"
#include "srslte/srslog/srslog.h"
#include <atomic>
#include <cstdio>
namespace srslte {
// Description: log filter that we can instantiate in a specific test scope, and cleans itself on scope exit
// useful if we want to define specific logging policies within a scope (e.g. null logger, count number of errors,
// exit on error, log special diagnostics on destruction). It restores the previous logger after exiting the scope
class test_log_filter : public srslte::log_filter
{
public:
explicit test_log_filter(std::string layer) : srslte::log_filter(std::move(layer))
{
set_level(srslte::LOG_LEVEL_DEBUG);
}
test_log_filter(const test_log_filter&) = delete;
test_log_filter(test_log_filter&&) = delete;
test_log_filter& operator=(const test_log_filter&) = delete;
test_log_filter& operator=(test_log_filter&&) = delete;
~test_log_filter() override = default;
void error(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
error_counter++;
if (level >= srslte::LOG_LEVEL_ERROR) {
char args_msg[char_buff_size];
va_list args;
va_start(args, message);
if (vsnprintf(args_msg, char_buff_size, message, args) > 0) {
all_log(srslte::LOG_LEVEL_ERROR, tti, args_msg);
}
va_end(args);
}
if (exit_on_error) {
exit(-1);
}
}
void warning(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
warn_counter++;
if (level >= srslte::LOG_LEVEL_WARNING) {
char args_msg[char_buff_size];
va_list args;
va_start(args, message);
if (vsnprintf(args_msg, char_buff_size, message, args) > 0) {
all_log(srslte::LOG_LEVEL_WARNING, tti, args_msg);
}
va_end(args);
}
}
virtual void log_diagnostics()
{
if (error_counter > 0 or warn_counter > 0) {
info("STATUS: counted %d errors and %d warnings.\n", error_counter, warn_counter);
}
}
bool exit_on_error = false;
uint32_t error_counter = 0, warn_counter = 0;
};
/// This custom sink intercepts log messages to count error and warning log entries.
class log_sink_spy : public srslog::sink
{
@ -188,106 +128,17 @@ private:
std::vector<std::string> entries;
};
// specialization of test_log_filter to store last logged message
class nullsink_log : public test_log_filter
{
public:
explicit nullsink_log(std::string layer) : test_log_filter(std::move(layer)) {}
void debug(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
va_list args;
va_start(args, message);
log_va_list(LOG_LEVEL_DEBUG, message, args);
va_end(args);
}
void info(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
va_list args;
va_start(args, message);
log_va_list(LOG_LEVEL_INFO, message, args);
va_end(args);
}
void warning(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
warn_counter++;
va_list args;
va_start(args, message);
log_va_list(LOG_LEVEL_WARNING, message, args);
va_end(args);
}
void error(const char* message, ...) override __attribute__((format(printf, 2, 3)))
{
error_counter++;
va_list args;
va_start(args, message);
log_va_list(LOG_LEVEL_ERROR, message, args);
va_end(args);
if (exit_on_error) {
exit(-1);
}
}
srslte::LOG_LEVEL_ENUM last_log_level = LOG_LEVEL_NONE;
std::string last_log_msg;
private:
void log_va_list(srslte::LOG_LEVEL_ENUM loglevel, const char* message, va_list argp)
{
last_log_level = loglevel;
if (level >= loglevel) {
char args_msg[char_buff_size];
if (vsnprintf(args_msg, char_buff_size, message, argp) > 0) {
last_log_msg = args_msg;
}
}
}
};
template <typename Log>
class scoped_log
{
public:
template <typename... Args>
explicit scoped_log(Args&&... args)
{
std::unique_ptr<Log> l{new Log{std::forward<Args>(args)...}};
// store previous log, and register the newly created one
prev_log = srslte::logmap::deregister_log(l->get_service_name());
current_log = l.get();
srslte::logmap::register_log(std::move(l));
}
scoped_log(scoped_log<Log>&&) noexcept = default;
~scoped_log()
{
srslte::logmap::deregister_log(current_log->get_service_name());
if (prev_log != nullptr) {
srslte::logmap::register_log(std::move(prev_log));
}
}
Log* operator->() { return current_log; }
Log* get() { return current_log; }
private:
Log* current_log = nullptr;
std::unique_ptr<srslte::log> prev_log;
};
} // namespace srslte
#define TESTERROR(fmt, ...) \
do { \
srslte::logmap::get("TEST")->error(fmt, ##__VA_ARGS__); \
srslog::fetch_basic_logger("TEST").error(fmt, ##__VA_ARGS__); \
return SRSLTE_ERROR; \
} while (0)
#define TESTWARN(fmt, ...) \
do { \
srslte::logmap::get("TEST")->warning(fmt, ##__VA_ARGS__); \
srslog::fetch_basic_logger("TEST").warning(fmt, ##__VA_ARGS__); \
} while (0)
#define CONDERROR(cond, fmt, ...) \

@ -13,6 +13,8 @@
#ifndef SRSLTE_ENB_GTPU_INTERFACES_H
#define SRSLTE_ENB_GTPU_INTERFACES_H
#include "srslte/common/byte_buffer.h"
namespace srsenb {
// GTPU interface for PDCP

@ -14,6 +14,7 @@
#define SRSLTE_UE_GW_INTERFACES_H
#include "srslte/asn1/liblte_mme.h"
#include "srslte/common/byte_buffer.h"
namespace srsue {

@ -14,6 +14,7 @@
#define SRSLTE_UE_PDCP_INTERFACES_H
#include "pdcp_interface_types.h"
#include "srslte/common/byte_buffer.h"
namespace srsue {
@ -39,11 +40,11 @@ class pdcp_interface_rlc
{
public:
/* RLC calls PDCP to push a PDCP PDU. */
virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_pcch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_bcch_bch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_pcch(srslte::unique_byte_buffer_t sdu) = 0;
virtual void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0;
virtual void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) = 0;
virtual void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sn) = 0;
};

@ -13,8 +13,8 @@
#ifndef SRSLTE_MAC_SCH_PDU_NR_H
#define SRSLTE_MAC_SCH_PDU_NR_H
#include "srslte/common/byte_buffer.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/config.h"
#include "srslte/srslog/srslog.h"
#include <memory>
@ -101,7 +101,7 @@ private:
static const uint8_t mac_ce_payload_len = 8 + 1; // Long BSR has max. 9 octets (see sizeof_ce() too)
std::array<uint8_t, mac_ce_payload_len> ce_write_buffer; // Buffer for CE payload
mac_sch_pdu_nr* parent = nullptr;
mac_sch_pdu_nr* parent = nullptr;
};
class mac_sch_pdu_nr
@ -135,9 +135,9 @@ private:
bool ulsch = false;
std::vector<mac_sch_subpdu_nr> subpdus;
byte_buffer_t* buffer = nullptr;
uint32_t pdu_len = 0;
uint32_t remaining_len = 0;
byte_buffer_t* buffer = nullptr;
uint32_t pdu_len = 0;
uint32_t remaining_len = 0;
srslog::basic_logger& logger;
};

@ -14,7 +14,6 @@
#define SRSLTE_PDU_H
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include <sstream>
#include <stdint.h>

@ -16,7 +16,6 @@
#include "srslte/adt/circular_buffer.h"
#include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/timers.h"
#include "srslte/mac/pdu.h"

@ -18,8 +18,8 @@
#include "fading.h"
#include "hst.h"
#include "rlf.h"
#include "srslte/common/log_filter.h"
#include "srslte/phy/common/phy_common.h"
#include "srslte/srslog/srslog.h"
#include <memory>
#include <string>

@ -15,12 +15,13 @@
#include "rf_buffer.h"
#include "rf_timestamp.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/phy/resampling/resampler.h"
#include "srslte/phy/rf/rf.h"
#include "srslte/radio/radio_base.h"
#include "srslte/srslog/srslog.h"
#include "srslte/srslte.h"
#include <list>
#include <string>

@ -19,7 +19,6 @@
#define SRSLTE_RADIO_BASE_H
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logger.h"
#include "srslte/radio/radio_metrics.h"
namespace srslte {

@ -19,8 +19,6 @@
#define SRSLTE_RADIO_NULL_H
#include "radio_base.h"
#include "srslte/common/logger.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/phy/rf/rf.h"
#include "srslte/radio/radio.h"

@ -15,7 +15,6 @@
#include "srslte/asn1/rrc_utils.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include <algorithm>
#include <cassert>

@ -28,7 +28,7 @@ class logger_impl : public T
{
static_assert(std::is_enum<Enum>::value, "Expected enum type");
using enum_base_type = typename std::underlying_type<Enum>::type;
using enum_base_type = typename std::underlying_type<Enum>::type;
static constexpr unsigned size = static_cast<enum_base_type>(Enum::LAST) - 1;
public:
@ -36,9 +36,7 @@ public:
explicit logger_impl(std::string id, Args&&... args) :
T{std::forward<Args>(args)...}, logger_id(std::move(id)), channels{&args...}
{
static_assert(
sizeof...(args) == size,
"Number of levels in enum does not match number of log channels");
static_assert(sizeof...(args) == size, "Number of levels in enum does not match number of log channels");
}
logger_impl(const logger_impl& other) = delete;
@ -93,16 +91,16 @@ private:
}
private:
const std::string logger_id;
const std::string logger_id;
const std::array<log_channel*, size> channels;
mutable detail::mutex m;
mutable detail::mutex m;
};
/// Type trait to detect if T is a logger.
template <typename T>
struct is_logger : std::false_type {};
template <typename T, typename Enum>
struct is_logger<logger_impl<T, Enum>> : std::true_type {};
struct is_logger<logger_impl<T, Enum> > : std::true_type {};
} // namespace detail
@ -173,6 +171,24 @@ inline basic_levels str_to_basic_level(std::string s)
return basic_levels::none;
}
/// Translates a logger basic level to the corresponding string.
inline const char* basic_level_to_string(basic_levels level)
{
switch (level) {
case basic_levels::debug:
return "DEBUG";
case basic_levels::info:
return "INFO";
case basic_levels::warning:
return "WARNING";
case basic_levels::error:
return "ERROR";
default:
break;
}
return "NONE";
}
} // namespace srslog
#endif // SRSLOG_LOGGER_H

@ -13,8 +13,9 @@
#ifndef SRSLTE_GTPU_H
#define SRSLTE_GTPU_H
#include "srslte/common/byte_buffer.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include <stdint.h>
namespace srslte {

@ -14,7 +14,6 @@
#define SRSLTE_PDCP_H
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/interfaces/ue_pdcp_interfaces.h"
#include "srslte/upper/pdcp_entity_lte.h"

@ -17,7 +17,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logmap.h"
#include "srslte/common/security.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/threads.h"
@ -112,9 +111,9 @@ public:
virtual void write_sdu(unique_byte_buffer_t sdu, int sn = -1) = 0;
// RLC interface
virtual void write_pdu(unique_byte_buffer_t pdu) = 0;
virtual void notify_delivery(const pdcp_sn_vector_t& pdcp_sns) = 0;
virtual void notify_failure(const pdcp_sn_vector_t& pdcp_sns) = 0;
virtual void write_pdu(unique_byte_buffer_t pdu) = 0;
virtual void notify_delivery(const pdcp_sn_vector_t& pdcp_sns) = 0;
virtual void notify_failure(const pdcp_sn_vector_t& pdcp_sns) = 0;
virtual void get_bearer_state(pdcp_lte_state_t* state) = 0;
virtual void set_bearer_state(const pdcp_lte_state_t& state) = 0;

@ -16,7 +16,6 @@
#include "srslte/adt/circular_array.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/security.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/ue_rrc_interfaces.h"

@ -17,7 +17,6 @@
#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/security.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/threads.h"

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/interfaces/ue_pdcp_interfaces.h"
#include "srslte/interfaces/ue_rlc_interfaces.h"

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_common.h"
#include <map>

@ -17,7 +17,6 @@
#include "srslte/adt/circular_array.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/timeout.h"
#include "srslte/interfaces/pdcp_interface_types.h"

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_am_base.h"
#include <map>

@ -14,7 +14,6 @@
#define SRSLTE_RLC_COMMON_H
#include "srslte/adt/circular_buffer.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/rlc_interface_types.h"
#include "srslte/upper/rlc_metrics.h"
#include <stdlib.h>

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_common.h"

@ -16,7 +16,6 @@
#include "srslte/adt/accumulators.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_common.h"

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_um_base.h"
#include <map>

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/upper/byte_buffer_queue.h"
#include "srslte/upper/rlc_um_base.h"

@ -16,9 +16,6 @@ set(SOURCES arch_select.cc
crash_handler.cc
gen_mch_tables.c
liblte_security.cc
log_filter.cc
logmap.cc
logger_srslog_wrapper.cc
mac_pcap.cc
mac_pcap_base.cc
nas_pcap.cc

@ -1,298 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include <cstdlib>
#include <inttypes.h>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string.h>
#include <sys/time.h>
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
namespace srslte {
#define CHARS_FOR_HEX_DUMP(size) \
(3 * size + size / 16 * 20) // 3 chars per byte, plus 20 per line for position and newline)
log_filter::log_filter() : log()
{
do_tti = false;
time_src = NULL;
time_format = TIME;
logger_h = NULL;
}
/// Creates a log channel that writes to stdout.
static srslog::log_channel* create_or_get_default_logger()
{
srslog::sink* s = srslog::create_stdout_sink();
if (!s) {
s = srslog::find_sink("stdout");
}
srslog::log_channel* log = srslog::create_log_channel("log_filter_default", *s);
if (!log) {
log = srslog::find_log_channel("log_filter_default");
}
srslog::init();
return log;
}
log_filter::log_filter(std::string layer) : log()
{
do_tti = false;
time_src = NULL;
time_format = TIME;
default_logger = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
init(layer, default_logger.get(), do_tti);
}
log_filter::log_filter(std::string layer, logger* logger_, bool tti) : log()
{
do_tti = false;
time_src = NULL;
time_format = TIME;
if (!logger_) {
default_logger = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
logger_ = default_logger.get();
}
init(std::move(layer), logger_, tti);
}
void log_filter::init(std::string layer, logger* logger_, bool tti)
{
// strip trailing white spaces
size_t last_char_pos = layer.find_last_not_of(' ');
if (last_char_pos != layer.size() - 1) {
layer.erase(last_char_pos + 1, layer.size());
}
service_name = std::move(layer);
logger_h = logger_;
do_tti = tti;
}
void log_filter::all_log(srslte::LOG_LEVEL_ENUM level,
uint32_t tti,
char* msg,
const uint8_t* hex,
int size,
bool long_msg)
{
char buffer_tti[16] = {};
if (logger_h) {
logger::unique_log_str_t log_str = nullptr;
if (long_msg || hex) {
// For long messages, dynamically allocate a new log_str with enough size outside the pool.
uint32_t log_str_msg_len = sizeof(buffer_tti) + 20 + strlen(msg) + CHARS_FOR_HEX_DUMP(size);
log_str = logger::unique_log_str_t(new logger::log_str(nullptr, log_str_msg_len), logger::log_str_deleter());
} else {
log_str = logger_h->allocate_unique_log_str();
}
if (log_str) {
if (do_tti) {
get_tti_str(tti, buffer_tti, sizeof(buffer_tti));
}
// Trim away a newline character at the end of the message.
if (msg[strlen(msg) - 1] == '\n') {
msg[strlen(msg) - 1] = '\0';
}
snprintf(log_str->str(),
log_str->get_buffer_size(),
"[%-4s] %s %s%s%s%s",
get_service_name().c_str(),
log_level_text_short[level],
do_tti ? buffer_tti : "",
add_string_en ? add_string_val.c_str() : "",
msg,
(hex_limit > 0 && hex && size > 0) ? hex_string(hex, size).c_str() : "");
logger_h->log(std::move(log_str));
} else {
logger_h->log_char("Error in Log: Not enough buffers in pool\n");
}
}
}
#define all_log_expand(log_level) \
do { \
if (level >= log_level) { \
char args_msg[char_buff_size]; \
va_list args; \
va_start(args, message); \
if (vsnprintf(args_msg, char_buff_size, message, args) > 0) \
all_log(log_level, tti, args_msg); \
va_end(args); \
} \
} while (0)
#define all_log_hex_expand(log_level) \
do { \
if (level >= log_level) { \
char args_msg[char_buff_size]; \
va_list args; \
va_start(args, message); \
if (vsnprintf(args_msg, char_buff_size, message, args) > 0) \
all_log(log_level, tti, args_msg, hex, size); \
va_end(args); \
} \
} while (0)
void log_filter::error(const char* message, ...)
{
all_log_expand(LOG_LEVEL_ERROR);
}
void log_filter::warning(const char* message, ...)
{
all_log_expand(LOG_LEVEL_WARNING);
}
void log_filter::info(const char* message, ...)
{
all_log_expand(LOG_LEVEL_INFO);
}
void log_filter::info_long(const char* message, ...)
{
if (level >= LOG_LEVEL_INFO) {
char* args_msg = NULL;
va_list args;
va_start(args, message);
if (vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_INFO, tti, args_msg, nullptr, strlen(args_msg), true);
va_end(args);
free(args_msg);
}
}
void log_filter::debug(const char* message, ...)
{
all_log_expand(LOG_LEVEL_DEBUG);
}
void log_filter::debug_long(const char* message, ...)
{
if (level >= LOG_LEVEL_DEBUG) {
char* args_msg = NULL;
va_list args;
va_start(args, message);
if (vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_DEBUG, tti, args_msg, nullptr, strlen(args_msg), true);
va_end(args);
free(args_msg);
}
}
void log_filter::error_hex(const uint8_t* hex, int size, const char* message, ...)
{
all_log_hex_expand(LOG_LEVEL_ERROR);
}
void log_filter::warning_hex(const uint8_t* hex, int size, const char* message, ...)
{
all_log_hex_expand(LOG_LEVEL_WARNING);
}
void log_filter::info_hex(const uint8_t* hex, int size, const char* message, ...)
{
all_log_hex_expand(LOG_LEVEL_INFO);
}
void log_filter::debug_hex(const uint8_t* hex, int size, const char* message, ...)
{
all_log_hex_expand(LOG_LEVEL_DEBUG);
}
void log_filter::set_time_src(time_itf* source, time_format_t format)
{
this->time_src = source;
this->time_format = format;
}
void log_filter::get_tti_str(const uint32_t tti_, char* buffer, const uint32_t buffer_len)
{
snprintf(buffer, buffer_len, "[%5d] ", tti_);
}
void log_filter::now_time(char* buffer, const uint32_t buffer_len)
{
timeval rawtime = {};
tm timeinfo = {};
char us[16];
srslte_timestamp_t now;
uint64_t usec_epoch;
if (buffer_len < 16) {
fprintf(stderr, "Error buffer provided for time too small\n");
return;
}
if (!time_src) {
gettimeofday(&rawtime, nullptr);
gmtime_r(&rawtime.tv_sec, &timeinfo);
if (time_format == TIME) {
strftime(buffer, buffer_len, "%H:%M:%S.", &timeinfo);
snprintf(us, 16, "%06ld", rawtime.tv_usec);
uint32_t dest_len = (uint32_t)strlen(buffer);
strncat(buffer, us, buffer_len - dest_len - 1);
} else {
usec_epoch = rawtime.tv_sec * 1000000UL + rawtime.tv_usec;
snprintf(buffer, buffer_len, "%" PRIu64, usec_epoch);
}
} else {
now = time_src->get_time();
if (time_format == TIME) {
snprintf(buffer, buffer_len, "%ld:%06u", now.full_secs, (uint32_t)(now.frac_secs * 1e6));
} else {
usec_epoch = now.full_secs * 1000000UL + (uint64_t)(now.frac_secs * 1e6);
snprintf(buffer, buffer_len, "%" PRIu64, usec_epoch);
}
}
}
std::string log_filter::hex_string(const uint8_t* hex, int size)
{
std::stringstream ss;
int c = 0;
ss << '\n' << std::hex << std::setfill('0');
if (hex_limit >= 0) {
size = (size > hex_limit) ? hex_limit : size;
}
while (c < size) {
ss << " " << std::setw(4) << static_cast<unsigned>(c) << ": ";
int tmp = (size - c < 16) ? size - c : 16;
for (int i = 0; i < tmp; i++) {
ss << std::setw(2) << static_cast<unsigned>(hex[c++]) << " ";
}
if (c != size) {
ss << "\n";
}
}
return ss.str();
}
} // namespace srslte

@ -1,21 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/srslog/log_channel.h"
using namespace srslte;
void srslog_wrapper::log(unique_log_str_t msg)
{
chan("%s", msg->str());
}

@ -1,120 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srslte/common/logmap.h"
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
using namespace srslte;
log_ref::log_ref(const char* name)
{
ptr_ = srslte::logmap::get(name).ptr_;
}
/// Creates a log channel that writes to stdout.
static srslog::log_channel* create_or_get_default_logger()
{
srslog::sink* s = srslog::create_stdout_sink();
if (!s) {
s = srslog::find_sink("stdout");
}
srslog::log_channel* log = srslog::create_log_channel("logmap_default", *s);
if (!log) {
log = srslog::find_log_channel("logmap_default");
}
srslog::init();
return log;
}
logmap::logmap()
{
stdout_channel = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
default_logger = stdout_channel.get();
}
// Access to log map by servicename. If servicename does not exist, create a new log_filter with default cfg
// Access to the map is protected by a mutex
log_ref SRSLTE_EXPORT logmap::get(std::string servicename)
{
logmap* pool = get_instance();
// strip trailing white spaces
size_t last_char_pos = servicename.find_last_not_of(' ');
if (last_char_pos != servicename.size() - 1) {
servicename.erase(last_char_pos + 1, servicename.size());
}
return pool->get_impl(std::move(servicename));
}
// register manually created log
void SRSLTE_EXPORT logmap::register_log(std::unique_ptr<log> log_ptr)
{
logmap* pool = get_instance();
std::lock_guard<std::mutex> lock(pool->mutex);
if (log_ptr != nullptr) {
pool->log_map[log_ptr->get_service_name()] = std::move(log_ptr);
}
}
std::unique_ptr<srslte::log> SRSLTE_EXPORT logmap::deregister_log(const std::string& servicename)
{
logmap* pool = get_instance();
std::unique_ptr<srslte::log> ret;
std::lock_guard<std::mutex> lock(pool->mutex);
auto it = pool->log_map.find(servicename);
if (it != pool->log_map.end()) {
ret = std::move(it->second);
pool->log_map.erase(it);
}
return ret;
}
// set default logger
void SRSLTE_EXPORT logmap::set_default_logger(logger* logger_)
{
logmap* pool = get_instance();
std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_logger = logger_;
}
// set default log level
void SRSLTE_EXPORT logmap::set_default_log_level(LOG_LEVEL_ENUM l)
{
logmap* pool = get_instance();
std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_log_level = l;
}
// set default hex limit
void SRSLTE_EXPORT logmap::set_default_hex_limit(int hex_limit)
{
logmap* pool = get_instance();
std::lock_guard<std::mutex> lock(pool->mutex);
pool->default_hex_limit = hex_limit;
}
log_ref logmap::get_impl(std::string servicename)
{
std::lock_guard<std::mutex> lock(mutex);
auto it = log_map.find(servicename);
if (it == log_map.end()) {
// create a new logger with default cfg
std::unique_ptr<log_filter> filter(new log_filter{std::move(servicename), default_logger});
filter->set_level(default_log_level);
filter->set_hex_limit(default_hex_limit);
auto ret = log_map.insert(std::make_pair(filter->get_service_name(), std::move(filter)));
return log_ref{&ret.first->second};
}
return log_ref{&it->second};
}

@ -11,6 +11,7 @@
*/
#include "srslte/common/mac_pcap.h"
#include "srslte/common/standard_streams.h"
#include "srslte/common/threads.h"
namespace srslte {

@ -9,12 +9,11 @@
* the distribution.
*
*/
#include <srslte/common/log_filter.h>
#include <srslte/common/logger_srslog_wrapper.h>
#include <srslte/common/thread_pool.h>
#include <srslte/common/tti_sempahore.h>
#include <srslte/phy/utils/random.h>
#include <srslte/srslog/srslog.h>
#include "srslte/common/common.h"
#include "srslte/common/thread_pool.h"
#include "srslte/common/tti_sempahore.h"
#include "srslte/phy/utils/random.h"
#include "srslte/srslog/srslog.h"
class dummy_radio
{

@ -15,6 +15,7 @@
#include <string.h>
#include <strings.h>
#include "srslte/common/standard_streams.h"
#include "srslte/mac/pdu.h"
extern "C" {

@ -11,6 +11,7 @@
*/
#include "srslte/radio/radio.h"
#include "srslte/common/standard_streams.h"
#include "srslte/common/string_helpers.h"
#include "srslte/config.h"
#include <list>

@ -13,6 +13,7 @@
#include "srslte/upper/pdcp_entity_lte.h"
#include "srslte/common/int_helpers.h"
#include "srslte/common/security.h"
#include "srslte/common/standard_streams.h"
#include "srslte/interfaces/ue_gw_interfaces.h"
#include "srslte/interfaces/ue_rlc_interfaces.h"
#include <bitset>

@ -11,6 +11,7 @@
*/
#include "srslte/adt/span.h"
#include "srslte/common/byte_buffer.h"
#include "srslte/common/test_common.h"
int test_span_access()

@ -22,6 +22,8 @@ using namespace asn1;
std::random_device rd;
std::mt19937 g(rd());
srslte::log_sink_spy* test_spy = nullptr;
int test_arrays()
{
/* Test Ext Array */
@ -586,13 +588,14 @@ int test_enum()
TESTASSERT(e == e2);
// Test fail path
srslte::scoped_log<srslte::nullsink_log> null_log("ASN1");
TESTASSERT(test_spy->get_error_counter() == 0 and test_spy->get_warning_counter() == 0);
bref = bit_ref(&buffer[0], sizeof(buffer));
bref2 = cbit_ref(&buffer[0], sizeof(buffer));
e = EnumTest::nulltype;
TESTASSERT(pack_enum(bref, e) == SRSASN_ERROR_ENCODE_FAIL);
buffer[0] = 255;
TESTASSERT(unpack_enum(e, bref2) == SRSASN_ERROR_DECODE_FAIL);
TESTASSERT(test_spy->get_error_counter() == 2 and test_spy->get_warning_counter() == 0);
return 0;
}
@ -643,8 +646,18 @@ int test_big_integers()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
// Setup the log spy to intercept error and warning log entries.
if (!srslog::install_custom_sink(
srslte::log_sink_spy::name(),
std::unique_ptr<srslte::log_sink_spy>(new srslte::log_sink_spy(srslog::get_default_log_formatter())))) {
return SRSLTE_ERROR;
}
test_spy = static_cast<srslte::log_sink_spy*>(srslog::find_sink(srslte::log_sink_spy::name()));
if (!test_spy) {
return SRSLTE_ERROR;
}
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", *test_spy, false);
asn1_logger.set_level(srslog::basic_levels::debug);
asn1_logger.set_hex_dump_max_size(-1);

@ -337,7 +337,6 @@ int test_session_res_setup_request()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
asn1_logger.set_level(srslog::basic_levels::debug);
asn1_logger.set_hex_dump_max_size(-1);

@ -16,8 +16,6 @@
#include "srslte/asn1/rrc_nr.h"
#include "srslte/asn1/rrc_nr_utils.h"
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/common/logmap.h"
#include "srslte/common/test_common.h"
using namespace srslte;
@ -70,7 +68,6 @@ int test_mac_rach_common_config()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
asn1_logger.set_level(srslog::basic_levels::debug);
asn1_logger.set_hex_dump_max_size(-1);

@ -693,7 +693,6 @@ int test_rrc_conn_reconf_r15_3()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
asn1_logger.set_level(srslog::basic_levels::debug);
asn1_logger.set_hex_dump_max_size(-1);

@ -355,10 +355,6 @@ int test_paging()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
srslte::logmap::set_default_hex_limit(4096);
TESTASSERT(srslte::logmap::get("ASN1")->get_level() == srslte::LOG_LEVEL_DEBUG);
// Setup the log spy to intercept error and warning log entries.
if (!srslog::install_custom_sink(
srslte::log_sink_spy::name(),

@ -11,13 +11,10 @@
*/
#include "srslte/asn1/liblte_mme.h"
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
#include <iostream>
#include <memory>
#include <srslte/common/buffer_pool.h>
#include <srslte/common/int_helpers.h>
#include <srslte/srslte.h>
#define TESTASSERT(cond) \
{ \

@ -12,7 +12,6 @@
#include "srslte/asn1/rrc/dl_ccch_msg.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h"
#include <iostream>
using namespace asn1;
@ -115,4 +114,4 @@ int main(int argc, char** argv)
TESTASSERT(rrc_reestablishment_reject_test() == 0);
return 0;
}
}

@ -12,7 +12,6 @@
#include "srslte/asn1/rrc/dl_dcch_msg.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h"
#include <iostream>
using namespace asn1;

@ -13,7 +13,6 @@
#include "srslte/asn1/rrc.h"
#include "srslte/asn1/rrc_utils.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h"
#include "srslte/interfaces/rrc_interface_types.h"
#include <iostream>

@ -13,10 +13,8 @@
#include "srslte/asn1/rrc/ul_dcch_msg.h"
#include "srslte/asn1/rrc_utils.h"
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h"
#include "srslte/interfaces/rrc_interface_types.h"
#include <iostream>
#include <srslte/srslte.h>
#define TESTASSERT(cond) \
{ \

@ -279,13 +279,15 @@ int test_cell_group_config()
asn1::rrc_nr::rach_cfg_common_s& rach_cfg_common =
cell_group_cfg.sp_cell_cfg.recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common.setup();
TESTASSERT(rach_cfg_common.rach_cfg_generic.prach_cfg_idx == 16);
TESTASSERT(rach_cfg_common.rach_cfg_generic.msg1_fdm == asn1::rrc_nr::rach_cfg_generic_s::msg1_fdm_opts::one);
TESTASSERT(rach_cfg_common.rach_cfg_generic.zero_correlation_zone_cfg == 0);
TESTASSERT(rach_cfg_common.rach_cfg_generic.preamb_rx_target_pwr == -110);
TESTASSERT(rach_cfg_common.rach_cfg_generic.preamb_trans_max == asn1::rrc_nr::rach_cfg_generic_s::preamb_trans_max_opts::n7);
TESTASSERT(rach_cfg_common.rach_cfg_generic.pwr_ramp_step == asn1::rrc_nr::rach_cfg_generic_s::pwr_ramp_step_opts::db4);
TESTASSERT(rach_cfg_common.rach_cfg_generic.preamb_trans_max ==
asn1::rrc_nr::rach_cfg_generic_s::preamb_trans_max_opts::n7);
TESTASSERT(rach_cfg_common.rach_cfg_generic.pwr_ramp_step ==
asn1::rrc_nr::rach_cfg_generic_s::pwr_ramp_step_opts::db4);
TESTASSERT(rach_cfg_common.rach_cfg_generic.ra_resp_win == asn1::rrc_nr::rach_cfg_generic_s::ra_resp_win_opts::sl10);
TESTASSERT(rach_cfg_common.ssb_per_rach_occasion_and_cb_preambs_per_ssb_present == true);
@ -297,7 +299,6 @@ int test_cell_group_config()
int main()
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false);
asn1_logger.set_level(srslog::basic_levels::debug);
asn1_logger.set_hex_dump_max_size(-1);
@ -313,7 +314,7 @@ int main()
TESTASSERT(test_ue_rrc_reconfiguration() == SRSLTE_SUCCESS);
TESTASSERT(test_radio_bearer_config() == SRSLTE_SUCCESS);
TESTASSERT(test_cell_group_config() == SRSLTE_SUCCESS);
srslog::flush();
printf("Success\n");
return 0;

@ -12,7 +12,6 @@
#include "../../../srsue/hdr/stack/rrc/rrc.h" // for rrc_args_t
#include "srslte/asn1/rrc/ul_dcch_msg.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/mac_pcap.h"
#include <iostream>
@ -169,4 +168,4 @@ int main(int argc, char** argv)
pcap.close();
#endif
return 0;
}
}

@ -39,9 +39,6 @@ add_executable(test_f12345 test_f12345.cc)
target_link_libraries(test_f12345 srslte_common ${CMAKE_THREAD_LIBS_INIT})
add_test(test_f12345 test_f12345)
add_executable(log_filter_test log_filter_test.cc)
target_link_libraries(log_filter_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_executable(timeout_test timeout_test.cc)
target_link_libraries(timeout_test srslte_phy ${CMAKE_THREAD_LIBS_INIT})
@ -63,10 +60,6 @@ add_executable(network_utils_test network_utils_test.cc)
target_link_libraries(network_utils_test srslte_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
add_test(network_utils_test network_utils_test)
add_executable(test_common_test test_common_test.cc)
target_link_libraries(test_common_test srslte_common)
add_test(test_common_test test_common_test)
add_executable(tti_point_test tti_point_test.cc)
target_link_libraries(tti_point_test srslte_common)
add_test(tti_point_test tti_point_test)
@ -90,4 +83,4 @@ add_executable(pnf_bridge pnf_bridge.cc)
target_link_libraries(pnf_bridge srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_executable(mac_pcap_net_test mac_pcap_net_test.cc)
target_link_libraries(mac_pcap_net_test srslte_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mac_pcap_net_test srslte_common ${SCTP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

@ -11,6 +11,7 @@
*/
#include "srslte/adt/choice_type.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/test_common.h"
struct C {

@ -1,219 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#define NTHREADS 100
#define NMSGS 100
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/logmap.h"
#include "srslte/common/test_common.h"
#include "srslte/srslog/srslog.h"
#include <stdio.h>
using namespace srslte;
typedef struct {
logger* l;
int thread_id;
} args_t;
void* thread_loop(void* a)
{
args_t* args = (args_t*)a;
char buf[100];
sprintf(buf, "LAYER%d", args->thread_id);
log_filter filter(buf, args->l);
filter.set_level(LOG_LEVEL_INFO);
for (int i = 0; i < NMSGS; i++) {
filter.error("Thread %d: %d", args->thread_id, i);
filter.warning("Thread %d: %d", args->thread_id, i);
filter.info("Thread %d: %d", args->thread_id, i);
filter.debug("Thread %d: %d", args->thread_id, i);
}
return NULL;
}
void* thread_loop_hex(void* a)
{
args_t* args = (args_t*)a;
char buf[100];
uint8_t hex[100];
for (int i = 0; i < 100; i++) {
hex[i] = i & 0xFF;
}
sprintf(buf, "LAYER%d", args->thread_id);
log_filter filter(buf, args->l);
filter.set_level(LOG_LEVEL_DEBUG);
filter.set_hex_limit(32);
for (int i = 0; i < NMSGS; i++) {
filter.error_hex(hex, 100, "Thread %d: %d", args->thread_id, i);
filter.warning_hex(hex, 100, "Thread %d: %d", args->thread_id, i);
filter.info_hex(hex, 100, "Thread %d: %d", args->thread_id, i);
filter.debug_hex(hex, 100, "Thread %d: %d", args->thread_id, i);
}
return NULL;
}
void write(std::string filename)
{
srslog::sink* s = srslog::create_file_sink(filename);
srslog::log_channel* chan = srslog::create_log_channel("write", *s);
srslte::srslog_wrapper l(*chan);
pthread_t threads[NTHREADS];
args_t args[NTHREADS];
for (int i = 0; i < NTHREADS; i++) {
args[i].l = &l;
args[i].thread_id = i;
pthread_create(&threads[i], NULL, &thread_loop_hex, &args[i]);
}
for (int i = 0; i < NTHREADS; i++) {
pthread_join(threads[i], NULL);
}
}
bool read(std::string filename)
{
bool pass = true;
bool written[NTHREADS][NMSGS];
int thread, msg;
for (int i = 0; i < NTHREADS; i++) {
for (int j = 0; j < NMSGS; j++) {
written[i][j] = false;
}
}
FILE* f = fopen(filename.c_str(), "r");
if (f != NULL) {
while (fscanf(f, "Thread %d: %d\n", &thread, &msg)) {
written[thread][msg] = true;
}
fclose(f);
}
for (int i = 0; i < NTHREADS; i++) {
for (int j = 0; j < NMSGS; j++) {
if (!written[i][j])
pass = false;
}
}
return pass;
}
int basic_hex_test()
{
srslog::sink* s = srslog::find_sink("stdout");
if (!s) {
return SRSLTE_ERROR;
}
srslog::log_channel* chan = srslog::create_log_channel("basic_hex_test", *s);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper l(*chan);
log_filter filter("layer", &l);
filter.set_level(LOG_LEVEL_DEBUG);
filter.set_hex_limit(500);
const uint32_t hex_len = 497;
uint8_t hex[hex_len];
for (uint32_t i = 0; i < hex_len; i++) {
hex[i] = i & 0xFF;
}
filter.debug_hex(hex, hex_len, "This is the long hex msg (%d B)\n", hex_len);
filter.debug("This is a message after the long hex msg that should not be cut\n");
return SRSLTE_SUCCESS;
}
int test_log_singleton()
{
srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG);
// TEST: Check if default setters are working
srslte::log_ref log1 = srslte::logmap::get("LAYER1");
TESTASSERT(log1->get_service_name() == "LAYER1");
TESTASSERT(log1->get_level() == LOG_LEVEL_DEBUG);
// TEST: register logger manually. Verify log_ref stays valid after overwrite
std::unique_ptr<srslte::log_filter> log_ptr2(new srslte::log_filter("LAYER2"));
log_ptr2->set_level(LOG_LEVEL_WARNING);
srslte::log_ref old_ref = srslte::logmap::get("LAYER2");
TESTASSERT(old_ref->get_level() == LOG_LEVEL_DEBUG);
srslte::logmap::register_log(std::move(log_ptr2));
srslte::log_ref new_ref = srslte::logmap::get("LAYER2");
TESTASSERT(new_ref->get_level() == LOG_LEVEL_WARNING);
TESTASSERT(old_ref == new_ref);
// TEST: padding working correctly
TESTASSERT(srslte::logmap::get("MAC").get() == srslte::logmap::get("MAC ").get());
log1->info("logmap test finished successfully\n");
return SRSLTE_SUCCESS;
}
int test_log_ref()
{
// Check if trailing whitespaces are correctly removed
srslte::log_ref t1_log{"T1"};
TESTASSERT(t1_log->get_service_name() == "T1");
TESTASSERT(t1_log.get() == srslte::logmap::get("T1").get());
TESTASSERT(t1_log.get() == srslte::logmap::get("T1 ").get());
{
scoped_log<srslte::nullsink_log> null_log{"T2"};
TESTASSERT(null_log->get_service_name() == "T2");
}
return SRSLTE_SUCCESS;
}
int full_test()
{
std::string f("log.txt");
write(f);
#if 0
bool result = read(f);
remove(f.c_str());
if(result) {
printf("Passed\n");
exit(0);
}else{
printf("Failed\n;");
exit(1);
}
#endif
return SRSLTE_SUCCESS;
}
int main(int argc, char** argv)
{
// Setup logging.
srslog::sink* log_sink = srslog::create_stdout_sink();
if (!log_sink) {
return SRSLTE_ERROR;
}
TESTASSERT(basic_hex_test() == SRSLTE_SUCCESS);
TESTASSERT(full_test() == SRSLTE_SUCCESS);
TESTASSERT(test_log_singleton() == SRSLTE_SUCCESS);
TESTASSERT(test_log_ref() == SRSLTE_SUCCESS);
return SRSLTE_SUCCESS;
}

@ -10,7 +10,6 @@
*
*/
#include "srslte/common/log_filter.h"
#include "srslte/common/network_utils.h"
#include <iostream>

@ -1,72 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srslte/common/test_common.h"
using srslte::nullsink_log;
using srslte::scoped_log;
int test_nullsink_log()
{
// Description: Test nullsink_log that only stores the last log message in a local std::string that can be checked
// This logger is useful to confirm that a certain action produced an expected error/warning,
// without contaminating the console/log file, and to check what error message was stored
scoped_log<nullsink_log> null_log("TEST");
TESTASSERT(srslte::logmap::get("TEST").get() == null_log.get());
TESTASSERT(null_log->error_counter == 0);
TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_NONE);
TESTASSERT(null_log->last_log_msg.empty());
null_log->error("ERROR MESSAGE"); // This message should not be seen in the console
TESTASSERT(null_log->error_counter == 1);
TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_ERROR);
TESTASSERT(null_log->last_log_msg == "ERROR MESSAGE");
return SRSLTE_SUCCESS;
}
int test_log_scoping()
{
// Description: Test whether we can use different global TEST loggers in different scopes
// on scope exit the previous logger should be recovered
// This behavior is useful for the cases we have one generic logger for all tests, but in a specific test
// we want to use a different one
scoped_log<nullsink_log> log1("TEST");
TESTASSERT(srslte::logmap::get("TEST").get() == log1.get());
log1->error("message1");
log1->error("message2");
TESTASSERT(log1->last_log_msg == "message2");
TESTASSERT(log1->error_counter == 2);
{
// the global test log should be overwriten here, and used by TESTASSERT macro
scoped_log<nullsink_log> log2("TEST");
TESTASSERT(srslte::logmap::get("TEST").get() == log2.get());
TESTASSERT(log2->error_counter == 0);
log2->error("error message in logger2\n");
TESTASSERT(log2->last_log_msg == "error message in logger2\n");
TESTASSERT(log2->error_counter == 1);
}
// the last logger should be recovered
TESTASSERT(srslte::logmap::get("TEST").get() == log1.get());
TESTASSERT(log1->error_counter == 2);
return 0;
}
int main()
{
TESTASSERT(test_nullsink_log() == 0);
TESTASSERT(test_log_scoping() == 0);
return 0;
}

@ -10,7 +10,6 @@
*
*/
#include "srslte/common/log_filter.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/test_common.h"
#include "srslte/config.h"

@ -12,7 +12,6 @@
#include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/logmap.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/test_common.h"
#include "srslte/mac/pdu.h"

@ -14,7 +14,6 @@
#define SRSLTE_PDCP_BASE_TEST_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/pdcp_interface_types.h"

@ -10,7 +10,7 @@
*
*/
#include "srslte/common/log_filter.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/rlc_pcap.h"
#include "srslte/common/test_common.h"
#include "srslte/common/threads.h"
@ -3415,10 +3415,6 @@ bool reestablish_test()
int main(int argc, char** argv)
{
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG);
srslte::logmap::set_default_hex_limit(4096);
TESTASSERT(srslte::logmap::get("RLC_AM_1")->get_level() == srslte::LOG_LEVEL_DEBUG);
// Setup the log message spy to intercept error and warning log entries from RLC
if (!srslog::install_custom_sink(srslte::log_sink_message_spy::name(),
std::unique_ptr<srslte::log_sink_message_spy>(
@ -3436,6 +3432,8 @@ int main(int argc, char** argv)
auto& logger_rrc2 = srslog::fetch_basic_logger("RLC_AM_2", *spy, false);
logger_rrc1.set_hex_dump_max_size(100);
logger_rrc2.set_hex_dump_max_size(100);
logger_rrc1.set_level(srslog::basic_levels::debug);
logger_rrc2.set_level(srslog::basic_levels::debug);
// start log backend
srslog::init();
@ -3606,4 +3604,4 @@ int main(int argc, char** argv)
};
return SRSLTE_SUCCESS;
}
}

@ -10,7 +10,6 @@
*
*/
#include "srslte/common/log_filter.h"
#include "srslte/upper/rlc.h"
#include <iostream>

@ -12,7 +12,6 @@
#include "srslte/common/block_queue.h"
#include "srslte/common/crash_handler.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/rlc_pcap.h"
#include "srslte/common/test_common.h"
#include "srslte/common/threads.h"
@ -104,7 +103,7 @@ void parse_args(stress_test_args_t* args, int argc, char* argv[])
("pdu_drop_rate", bpo::value<float>(&args->pdu_drop_rate)->default_value(0.1), "Rate at which RLC PDUs are dropped")
("pdu_cut_rate", bpo::value<float>(&args->pdu_cut_rate)->default_value(0.0), "Rate at which RLC PDUs are chopped in length")
("pdu_duplicate_rate", bpo::value<float>(&args->pdu_duplicate_rate)->default_value(0.0), "Rate at which RLC PDUs are duplicated")
("loglevel", bpo::value<uint32_t>(&args->log_level)->default_value(srslte::LOG_LEVEL_DEBUG), "Log level (1=Error,2=Warning,3=Info,4=Debug)")
("loglevel", bpo::value<uint32_t>(&args->log_level)->default_value((int)srslog::basic_levels::debug), "Log level (1=Error,2=Warning,3=Info,4=Debug)")
("singletx", bpo::value<bool>(&args->single_tx)->default_value(false), "If set to true, only one node is generating data")
("pcap", bpo::value<bool>(&args->write_pcap)->default_value(false), "Whether to write all RLC PDU to PCAP file")
("zeroseed", bpo::value<bool>(&args->zero_seed)->default_value(false), "Whether to initialize random seed to zero")
@ -130,7 +129,9 @@ void parse_args(stress_test_args_t* args, int argc, char* argv[])
if (args->log_level > 4) {
args->log_level = 4;
printf("Set log level to %d (%s)\n", args->log_level, srslte::log_level_text[args->log_level]);
printf("Set log level to %d (%s)\n",
args->log_level,
srslog::basic_level_to_string(static_cast<srslog::basic_levels>(args->log_level)));
}
// convert mode to upper case
@ -367,9 +368,9 @@ public:
void write_pdu_bcch_bch(unique_byte_buffer_t sdu) {}
void write_pdu_bcch_dlsch(unique_byte_buffer_t sdu) {}
void write_pdu_pcch(unique_byte_buffer_t sdu) {}
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t sdu) {}
void notify_delivery(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) {}
void notify_failure(uint32_t lcid, const srslte::pdcp_sn_vector_t& pdcp_sns) {}
void write_pdu_mch(uint32_t lcid_, srslte::unique_byte_buffer_t sdu) {}
void notify_delivery(uint32_t lcid_, const srslte::pdcp_sn_vector_t& pdcp_sns) {}
void notify_failure(uint32_t lcid_, const srslte::pdcp_sn_vector_t& pdcp_sns) {}
// RRC interface
void max_retx_attempted()
@ -431,7 +432,6 @@ private:
uint8_t next_expected_sdu = 0;
uint64_t rx_pdus = 0;
uint32_t lcid = 0;
srslte::log_filter log;
srslog::basic_logger& logger;
std::string name;

@ -11,7 +11,6 @@
*/
#include "rlc_test_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/config.h"
#include "srslte/interfaces/ue_pdcp_interfaces.h"
#include "srslte/upper/rlc.h"

@ -11,7 +11,6 @@
*/
#include "rlc_test_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/upper/rlc_um_lte.h"
#include <iostream>

@ -34,7 +34,6 @@
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/enb_command_interface.h"
@ -120,7 +119,7 @@ public:
virtual ~enb();
int init(const all_args_t& args_, srslte::logger* logger_);
int init(const all_args_t& args_);
void stop();
@ -139,7 +138,6 @@ private:
int parse_args(const all_args_t& args_, rrc_cfg_t& rrc_cfg);
srslte::logger* logger = nullptr;
srslog::sink& log_sink;
srslog::basic_logger& enb_log;
@ -157,8 +155,6 @@ private:
// System metrics processor.
srslte::sys_metrics_processor sys_proc;
srslte::LOG_LEVEL_ENUM level(std::string l);
std::string get_build_mode();
std::string get_build_info();
std::string get_build_string();

@ -13,7 +13,6 @@
#ifndef SRSENB_NR_CC_WORKER_H
#define SRSENB_NR_CC_WORKER_H
#include "srslte/common/log.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/phy/enb/enb_dl_nr.h"
#include "srslte/srslog/srslog.h"

@ -16,8 +16,6 @@
#include "lte/sf_worker.h"
#include "phy_common.h"
#include "srsenb/hdr/phy/enb_phy_base.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/trace.h"
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/radio_interfaces.h"

@ -17,13 +17,14 @@
#include "srsenb/hdr/phy/phy_ue_db.h"
#include "srslte/common/gen_mch_tables.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/log.h"
#include "srslte/common/standard_streams.h"
#include "srslte/common/thread_pool.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/radio_interfaces.h"
#include "srslte/phy/channel/channel.h"
#include "srslte/radio/radio.h"
#include <map>
#include <srslte/common/tti_sempahore.h>
#include <string.h>

@ -15,7 +15,6 @@
#include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_phy_interfaces.h"
#include "srslte/srslog/srslog.h"

@ -17,7 +17,6 @@
#include "prach_worker.h"
#include "srsenb/hdr/phy/lte/worker_pool.h"
#include "srsenb/hdr/phy/nr/worker_pool.h"
#include "srslte/common/log.h"
#include "srslte/config.h"
#include "srslte/phy/channel/channel.h"
#include "srslte/radio/radio.h"

@ -16,8 +16,6 @@
#include "srsenb/hdr/phy/enb_phy_base.h"
#include "srsenb/hdr/phy/phy_common.h"
#include "srslte/common/basic_vnf.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/interfaces/enb_metrics_interface.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/interfaces/radio_interfaces.h"
@ -62,4 +60,4 @@ private:
} // namespace srsenb
#endif // SRSGNB_NR_VNF_PHY_H
#endif // SRSGNB_NR_VNF_PHY_H

@ -40,7 +40,7 @@ class enb_stack_lte final : public enb_stack_base,
public srslte::thread
{
public:
enb_stack_lte(srslte::logger* logger_, srslog::sink& log_sink);
enb_stack_lte(srslog::sink& log_sink);
~enb_stack_lte() final;
// eNB stack base interface
@ -145,17 +145,6 @@ private:
srsenb::gtpu gtpu;
srsenb::s1ap s1ap;
srslte::logger* logger = nullptr;
// Radio and PHY log are in enb.cc
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;

@ -26,8 +26,6 @@
#include "upper/s1ap.h"
#include "upper/sdap.h"
#include "srslte/common/log_filter.h"
#include "enb_stack_base.h"
#include "srsenb/hdr/enb.h"
#include "srslte/interfaces/gnb_interfaces.h"
@ -81,6 +79,8 @@ private:
srsenb::stack_args_t args = {};
phy_interface_stack_nr* phy = nullptr;
srslog::basic_logger& rlc_logger;
// task scheduling
static const int STACK_MAIN_THREAD_PRIO = 4;
srslte::task_scheduler task_sched;

@ -15,7 +15,6 @@
#include "sched.h"
#include "srsenb/hdr/stack/mac/schedulers/sched_time_rr.h"
#include "srslte/common/log.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/mac_pcap_net.h"
#include "srslte/common/task_scheduler.h"
@ -41,8 +40,7 @@ public:
const cell_list_t& cells_,
phy_interface_stack_lte* phy,
rlc_interface_mac* rlc,
rrc_interface_mac* rrc,
srslte::log_ref log_h);
rrc_interface_mac* rrc);
void stop();
void start_pcap(srslte::mac_pcap* pcap_);
@ -120,7 +118,6 @@ private:
rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h = nullptr;
srslte::ext_task_sched_handle task_sched;
srslte::log_ref log_h;
cell_list_t cells = {};
mac_args_t args = {};

@ -14,7 +14,6 @@
#define SRSENB_MAC_NR_H
#include "srslte/common/block_queue.h"
#include "srslte/common/logmap.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/mac/mac_sch_pdu_nr.h"
@ -82,8 +81,8 @@ private:
rrc_interface_mac_nr* rrc_h = nullptr;
std::unique_ptr<srslte::mac_pcap> pcap = nullptr;
srslte::log_ref log_h;
mac_nr_args_t args = {};
srslog::basic_logger& logger;
bool started = false;

@ -15,7 +15,6 @@
#include "sched_grid.h"
#include "sched_ue.h"
#include "srslte/common/log.h"
#include "srslte/interfaces/sched_interface.h"
#include <atomic>
#include <map>

@ -17,7 +17,6 @@
#include "sched_phy_ch/sf_cch_allocator.h"
#include "sched_ue.h"
#include "srslte/adt/bounded_bitset.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include <deque>
#include <vector>

@ -14,7 +14,6 @@
#define SRSLTE_SCHED_HELPERS_H
#include "srsenb/hdr/stack/mac/sched_common.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"
@ -56,7 +55,7 @@ inline uint32_t cell_nof_prb_to_rbg(uint32_t nof_prbs)
case 100:
return 25;
default:
srslte::logmap::get("MAC")->error("Provided nof PRBs not valid");
srslog::fetch_basic_logger("MAC").error("Provided nof PRBs not valid");
return 0;
}
}
@ -78,7 +77,7 @@ inline uint32_t cell_nof_rbg_to_prb(uint32_t nof_rbgs)
case 25:
return 100;
default:
srslte::logmap::get("MAC")->error("Provided nof PRBs not valid");
srslog::fetch_basic_logger("MAC").error("Provided nof PRBs not valid");
return 0;
}
}

@ -14,7 +14,6 @@
#define SRSENB_SCHEDULER_UE_H
#include "sched_common.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
#include <map>
#include <vector>

@ -14,7 +14,6 @@
#define SRSENB_SCHEDULER_HARQ_H
#include "srslte/adt/bounded_bitset.h"
#include "srslte/common/log.h"
#include "srslte/common/tti_point.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/srslog/srslog.h"

@ -13,10 +13,10 @@
#ifndef SRSLTE_SCHED_LCH_H
#define SRSLTE_SCHED_LCH_H
#include "srslte/common/logmap.h"
#include "srslte/interfaces/sched_interface.h"
#include "srslte/mac/pdu.h"
#include "srslte/srslog/srslog.h"
#include <deque>
namespace srsenb {

@ -15,7 +15,6 @@
#include "srslte/adt/accumulators.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {

@ -16,7 +16,6 @@
#include "mac_metrics.h"
#include "srslte/adt/circular_array.h"
#include "srslte/common/block_queue.h"
#include "srslte/common/log.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/mac_pcap_net.h"
#include "srslte/interfaces/sched_interface.h"
@ -84,7 +83,6 @@ public:
rrc_interface_mac* rrc_,
rlc_interface_mac* rlc,
phy_interface_stack_lte* phy_,
srslte::log_ref log_,
srslog::basic_logger& logger,
uint32_t nof_cells_,
uint32_t nof_rx_harq_proc = SRSLTE_FDD_NOF_HARQ,
@ -168,7 +166,6 @@ private:
rlc_interface_mac* rlc = nullptr;
rrc_interface_mac* rrc = nullptr;
phy_interface_stack_lte* phy = nullptr;
srslte::log_ref log_h;
srslog::basic_logger& logger;
sched_interface* sched = nullptr;

@ -21,7 +21,6 @@
#include "srslte/adt/mem_pool.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/common/stack_procedure.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/timeout.h"

@ -15,7 +15,6 @@
#include "srsenb/hdr/stack/rrc/rrc_config.h"
#include "srslte/asn1/s1ap.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/enb_gtpu_interfaces.h"
#include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_rrc_interface_types.h"

@ -14,7 +14,7 @@
#define SRSLTE_RRC_CELL_CFG_H
#include "rrc_config.h"
#include "srslte/common/logmap.h"
#include "srslte/common/byte_buffer.h"
#include "srslte/srslog/srslog.h"
namespace srsenb {

@ -16,7 +16,6 @@
#include "rrc.h"
#include "rrc_ue.h"
#include "srslte/common/fsm.h"
#include "srslte/common/logmap.h"
#include <map>
namespace srsenb {

@ -20,7 +20,6 @@
#include "srslte/common/block_queue.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/common/task_scheduler.h"
#include "srslte/common/threads.h"
#include "srslte/common/timeout.h"
@ -128,11 +127,11 @@ private:
ngap_interface_rrc_nr* ngap = nullptr;
// args
srslte::log_ref m_log;
srslte::timer_handler* timers = nullptr;
// derived
uint32_t slot_dur_ms = 0;
uint32_t slot_dur_ms = 0;
srslog::basic_logger& logger;
// vars
std::map<uint16_t, std::unique_ptr<ue> > users;

@ -35,7 +35,6 @@
#define SRSENB_UE_RR_CFG_H
#include "srslte/asn1/rrc.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/rrc_interface_types.h"
namespace srsenb {
@ -46,15 +45,15 @@ class bearer_cfg_handler;
struct ue_var_cfg_t;
/// Fill RadioResourceConfigDedicated with data known at the RRCSetup/Reestablishment stage
void fill_rr_cfg_ded_setup(asn1::rrc::rr_cfg_ded_s& rr_cfg,
const rrc_cfg_t& enb_cfg,
const ue_cell_ded_list& ue_cell_list);
void fill_rr_cfg_ded_setup(asn1::rrc::rr_cfg_ded_s& rr_cfg,
const rrc_cfg_t& enb_cfg,
const ue_cell_ded_list& ue_cell_list);
/// Apply Reconf updates and update current state
void apply_reconf_updates(asn1::rrc::rrc_conn_recfg_r8_ies_s& recfg_r8,
ue_var_cfg_t& current_ue_cfg,
const rrc_cfg_t& enb_cfg,
const ue_cell_ded_list& ue_cell_list,
const ue_cell_ded_list& ue_cell_list,
bearer_cfg_handler& bearers,
const srslte::rrc_ue_capabilities_t& ue_caps,
bool phy_cfg_updated);

@ -12,10 +12,10 @@
#include <map>
#include <string.h>
#include <unordered_map>
#include "common_enb.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/logmap.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_gtpu_interfaces.h"
#include "srslte/phy/common/phy_common.h"

@ -10,9 +10,6 @@
*
*/
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/interfaces/ue_gw_interfaces.h"
#include "srslte/interfaces/ue_rlc_interfaces.h"
@ -104,7 +101,6 @@ private:
// args
pdcp_nr_args_t m_args = {};
srslte::log_ref m_log;
rlc_interface_pdcp_nr* m_rlc = nullptr;
rrc_interface_pdcp_nr* m_rrc = nullptr;
sdap_interface_pdcp_nr* m_sdap = nullptr;
@ -112,6 +108,7 @@ private:
std::map<uint32_t, user_interface> users;
srslte::task_sched_handle task_sched;
srslog::basic_logger& logger;
};
} // namespace srsenb

@ -13,9 +13,6 @@
#ifndef SRSENB_RLC_NR_H
#define SRSENB_RLC_NR_H
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/upper/rlc.h"
#include <map>
@ -80,11 +77,11 @@ private:
};
// args
srslte::log_ref m_log;
srslte::timer_handler* timers = nullptr;
mac_interface_rlc_nr* m_mac = nullptr;
pdcp_interface_rlc_nr* m_pdcp = nullptr;
rrc_interface_rlc_nr* m_rrc = nullptr;
srslog::basic_logger& logger;
// state
std::map<uint32_t, user_interface> users;

@ -18,7 +18,6 @@
#include "common_enb.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/common/s1ap_pcap.h"
#include "srslte/common/threads.h"
#include "srslte/interfaces/enb_interfaces.h"

@ -15,7 +15,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/gnb_interfaces.h"
#include "srslte/interfaces/ue_gw_interfaces.h"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save