- Upgraded PDCP classes in lib to use srslog.

- Update tests to new changes.
master
faluco 4 years ago committed by faluco
parent 6359a2d948
commit f424f2e113

@ -66,7 +66,7 @@ private:
srsue::rrc_interface_pdcp* rrc = nullptr; srsue::rrc_interface_pdcp* rrc = nullptr;
srsue::gw_interface_pdcp* gw = nullptr; srsue::gw_interface_pdcp* gw = nullptr;
srslte::task_sched_handle task_sched; srslte::task_sched_handle task_sched;
srslte::log_ref pdcp_log; srslog::basic_logger& logger;
std::map<uint16_t, std::unique_ptr<pdcp_entity_base> > pdcp_array, pdcp_array_mrb; std::map<uint16_t, std::unique_ptr<pdcp_entity_base> > pdcp_array, pdcp_array_mrb;

@ -52,7 +52,7 @@ static const char pdcp_d_c_text[PDCP_D_C_N_ITEMS][20] = {"Control PDU", "Data PD
class pdcp_entity_base class pdcp_entity_base
{ {
public: public:
pdcp_entity_base(task_sched_handle task_sched_, srslte::log_ref log_); pdcp_entity_base(task_sched_handle task_sched_, srslog::basic_logger& logger);
pdcp_entity_base(pdcp_entity_base&&) = default; pdcp_entity_base(pdcp_entity_base&&) = default;
virtual ~pdcp_entity_base(); virtual ~pdcp_entity_base();
virtual void reset() = 0; virtual void reset() = 0;
@ -73,7 +73,7 @@ public:
} else { } else {
integrity_direction = direction; integrity_direction = direction;
} }
log->debug("LCID=%d, integrity=%s\n", lcid, srslte_direction_text[integrity_direction]); logger.debug("LCID=%d, integrity=%s", lcid, srslte_direction_text[integrity_direction]);
} }
void enable_encryption(srslte_direction_t direction = DIRECTION_TXRX) void enable_encryption(srslte_direction_t direction = DIRECTION_TXRX)
@ -86,7 +86,7 @@ public:
} else { } else {
encryption_direction = direction; encryption_direction = direction;
} }
log->debug("LCID=%d encryption=%s\n", lcid, srslte_direction_text[integrity_direction]); logger.debug("LCID=%d encryption=%s", lcid, srslte_direction_text[integrity_direction]);
} }
void enable_security_timed(srslte_direction_t direction, uint32_t sn) void enable_security_timed(srslte_direction_t direction, uint32_t sn)
@ -99,7 +99,7 @@ public:
enable_security_rx_sn = sn; enable_security_rx_sn = sn;
break; break;
default: default:
log->error("Timed security activation for direction %s not supported.\n", srslte_direction_text[direction]); logger.error("Timed security activation for direction %s not supported.", srslte_direction_text[direction]);
break; break;
} }
} }
@ -124,7 +124,7 @@ public:
uint32_t COUNT(uint32_t hfn, uint32_t sn); uint32_t COUNT(uint32_t hfn, uint32_t sn);
protected: protected:
srslte::log_ref log; srslog::basic_logger& logger;
srslte::task_sched_handle task_sched; srslte::task_sched_handle task_sched;
bool active = false; bool active = false;

@ -41,7 +41,7 @@ public:
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::task_sched_handle task_sched_, srslte::task_sched_handle task_sched_,
srslte::log_ref log_, srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
pdcp_config_t cfg_); pdcp_config_t cfg_);
~pdcp_entity_lte() override; ~pdcp_entity_lte() override;

@ -37,7 +37,7 @@ public:
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::task_sched_handle task_sched_, srslte::task_sched_handle task_sched_,
srslte::log_ref log_, srslog::basic_logger& logger,
uint32_t lcid, uint32_t lcid,
pdcp_config_t cfg_); pdcp_config_t cfg_);
~pdcp_entity_nr() final; ~pdcp_entity_nr() final;

@ -17,7 +17,9 @@
namespace srslte { namespace srslte {
pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) : task_sched(task_sched_), pdcp_log(logname) {} pdcp::pdcp(srslte::task_sched_handle task_sched_, const char* logname) :
task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname))
{}
pdcp::~pdcp() pdcp::~pdcp()
{ {
@ -79,7 +81,7 @@ void pdcp::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu)
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
pdcp_array.at(lcid)->write_sdu(std::move(sdu)); pdcp_array.at(lcid)->write_sdu(std::move(sdu));
} else { } else {
pdcp_log->warning("Writing sdu: lcid=%d. Deallocating sdu\n", lcid); logger.warning("Writing sdu: lcid=%d. Deallocating sdu", lcid);
} }
} }
@ -98,29 +100,29 @@ void pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
// create NR entity for 18bit SN length // create NR entity for 18bit SN length
#ifdef HAVE_5GNR #ifdef HAVE_5GNR
entity.reset(new pdcp_entity_nr{rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg}); entity.reset(new pdcp_entity_nr{rlc, rrc, gw, task_sched, logger, lcid, cfg});
#else #else
pdcp_log->error("Invalid PDCP configuration.\n"); logger.error("Invalid PDCP configuration.");
return; return;
#endif #endif
} else { } else {
entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg}); entity.reset(new pdcp_entity_lte{rlc, rrc, gw, task_sched, logger, lcid, cfg});
} }
if (not pdcp_array.insert(std::make_pair(lcid, std::move(entity))).second) { if (not pdcp_array.insert(std::make_pair(lcid, std::move(entity))).second) {
pdcp_log->error("Error inserting PDCP entity in to array.\n"); logger.error("Error inserting PDCP entity in to array.");
return; return;
} }
pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", logger.info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
lcid, lcid,
cfg.bearer_id, cfg.bearer_id,
cfg.sn_len); cfg.sn_len);
{ {
std::lock_guard<std::mutex> lock(cache_mutex); std::lock_guard<std::mutex> lock(cache_mutex);
valid_lcids_cached.insert(lcid); valid_lcids_cached.insert(lcid);
} }
} else { } else {
pdcp_log->info("Bearer %s already configured.\n", rrc->get_rb_name(lcid).c_str()); logger.info("Bearer %s already configured.", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -128,20 +130,20 @@ void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg)
{ {
if (not valid_mch_lcid(lcid)) { if (not valid_mch_lcid(lcid)) {
if (not pdcp_array_mrb if (not pdcp_array_mrb
.insert(std::make_pair(lcid, .insert(std::make_pair(
std::unique_ptr<pdcp_entity_lte>( lcid,
new pdcp_entity_lte(rlc, rrc, gw, task_sched, pdcp_log, lcid, cfg)))) std::unique_ptr<pdcp_entity_lte>(new pdcp_entity_lte(rlc, rrc, gw, task_sched, logger, lcid, cfg))))
.second) { .second) {
pdcp_log->error("Error inserting PDCP entity in to array\n."); logger.error("Error inserting PDCP entity in to array.");
return; return;
} }
pdcp_log->info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)\n", logger.info("Add %s (lcid=%d, bearer_id=%d, sn_len=%dbits)",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
lcid, lcid,
cfg.bearer_id, cfg.bearer_id,
cfg.sn_len); cfg.sn_len);
} else { } else {
pdcp_log->warning("Bearer %s already configured. Reconfiguration not supported\n", rrc->get_rb_name(lcid).c_str()); logger.warning("Bearer %s already configured. Reconfiguration not supported", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -153,9 +155,9 @@ void pdcp::del_bearer(uint32_t lcid)
} }
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
pdcp_array.erase(lcid); pdcp_array.erase(lcid);
pdcp_log->warning("Deleted PDCP bearer %s\n", rrc->get_rb_name(lcid).c_str()); logger.warning("Deleted PDCP bearer %s", rrc->get_rb_name(lcid).c_str());
} else { } else {
pdcp_log->warning("Can't delete bearer %s. Bearer doesn't exist.\n", rrc->get_rb_name(lcid).c_str()); logger.warning("Can't delete bearer %s. Bearer doesn't exist.", rrc->get_rb_name(lcid).c_str());
} }
} }
@ -168,20 +170,19 @@ void pdcp::change_lcid(uint32_t old_lcid, uint32_t new_lcid)
auto it = pdcp_array.find(old_lcid); auto it = pdcp_array.find(old_lcid);
std::unique_ptr<pdcp_entity_base> pdcp_entity = std::move(it->second); std::unique_ptr<pdcp_entity_base> pdcp_entity = std::move(it->second);
if (not pdcp_array.insert(std::make_pair(new_lcid, std::move(pdcp_entity))).second) { if (not pdcp_array.insert(std::make_pair(new_lcid, std::move(pdcp_entity))).second) {
pdcp_log->error("Error inserting PDCP entity into array\n."); logger.error("Error inserting PDCP entity into array.");
return; return;
} }
// erase from old position // erase from old position
pdcp_array.erase(it); pdcp_array.erase(it);
valid_lcids_cached.erase(old_lcid); valid_lcids_cached.erase(old_lcid);
valid_lcids_cached.insert(new_lcid); valid_lcids_cached.insert(new_lcid);
pdcp_log->warning("Changed LCID of PDCP bearer from %d to %d\n", old_lcid, new_lcid); logger.warning("Changed LCID of PDCP bearer from %d to %d", old_lcid, new_lcid);
} else { } else {
pdcp_log->error( logger.error("Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.",
"Can't change PDCP of bearer %s from %d to %d. Bearer doesn't exist or new LCID already occupied.\n", rrc->get_rb_name(old_lcid).c_str(),
rrc->get_rb_name(old_lcid).c_str(), old_lcid,
old_lcid, new_lcid);
new_lcid);
} }
} }
@ -254,7 +255,7 @@ void pdcp::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
pdcp_array.at(lcid)->write_pdu(std::move(pdu)); pdcp_array.at(lcid)->write_pdu(std::move(pdu));
} else { } else {
pdcp_log->warning("Writing pdu: lcid=%d. Deallocating pdu\n", lcid); logger.warning("Writing pdu: lcid=%d. Deallocating pdu", lcid);
} }
} }
@ -287,14 +288,14 @@ void pdcp::notify_delivery(uint32_t lcid, const std::vector<uint32_t>& pdcp_sns)
if (valid_lcid(lcid)) { if (valid_lcid(lcid)) {
pdcp_array.at(lcid)->notify_delivery(pdcp_sns); pdcp_array.at(lcid)->notify_delivery(pdcp_sns);
} else { } else {
pdcp_log->warning("Could not notify delivery: lcid=%d, nof_sn=%ld.\n", lcid, pdcp_sns.size()); logger.warning("Could not notify delivery: lcid=%d, nof_sn=%ld.", lcid, pdcp_sns.size());
} }
} }
bool pdcp::valid_lcid(uint32_t lcid) bool pdcp::valid_lcid(uint32_t lcid)
{ {
if (lcid >= SRSLTE_N_RADIO_BEARERS) { if (lcid >= SRSLTE_N_RADIO_BEARERS) {
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} }
@ -304,7 +305,7 @@ bool pdcp::valid_lcid(uint32_t lcid)
bool pdcp::valid_mch_lcid(uint32_t lcid) bool pdcp::valid_mch_lcid(uint32_t lcid)
{ {
if (lcid >= SRSLTE_N_MCH_LCIDS) { if (lcid >= SRSLTE_N_MCH_LCIDS) {
pdcp_log->error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid); logger.error("Radio bearer id must be in [0:%d] - %d", SRSLTE_N_RADIO_BEARERS, lcid);
return false; return false;
} }

@ -17,8 +17,8 @@
namespace srslte { namespace srslte {
pdcp_entity_base::pdcp_entity_base(task_sched_handle task_sched_, srslte::log_ref log_) : pdcp_entity_base::pdcp_entity_base(task_sched_handle task_sched_, srslog::basic_logger& logger) :
log(log_), task_sched(task_sched_) logger(logger), task_sched(task_sched_)
{} {}
pdcp_entity_base::~pdcp_entity_base() {} pdcp_entity_base::~pdcp_entity_base() {}
@ -27,14 +27,14 @@ void pdcp_entity_base::config_security(as_security_config_t sec_cfg_)
{ {
sec_cfg = sec_cfg_; sec_cfg = sec_cfg_;
log->info("Configuring security with %s and %s\n", logger.info("Configuring security with %s and %s",
integrity_algorithm_id_text[sec_cfg.integ_algo], integrity_algorithm_id_text[sec_cfg.integ_algo],
ciphering_algorithm_id_text[sec_cfg.cipher_algo]); ciphering_algorithm_id_text[sec_cfg.cipher_algo]);
log->debug_hex(sec_cfg.k_rrc_enc.data(), 32, "K_rrc_enc"); logger.debug(sec_cfg.k_rrc_enc.data(), 32, "K_rrc_enc");
log->debug_hex(sec_cfg.k_up_enc.data(), 32, "K_up_enc"); logger.debug(sec_cfg.k_up_enc.data(), 32, "K_up_enc");
log->debug_hex(sec_cfg.k_rrc_int.data(), 32, "K_rrc_int"); logger.debug(sec_cfg.k_rrc_int.data(), 32, "K_rrc_int");
log->debug_hex(sec_cfg.k_up_int.data(), 32, "K_up_int"); logger.debug(sec_cfg.k_up_int.data(), 32, "K_up_int");
} }
/**************************************************************************** /****************************************************************************
@ -67,13 +67,13 @@ void pdcp_entity_base::integrity_generate(uint8_t* msg, uint32_t msg_len, uint32
break; break;
} }
log->debug("Integrity gen input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n", logger.debug("Integrity gen input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s",
count, count,
cfg.bearer_id, cfg.bearer_id,
(cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink")); (cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"));
log->debug_hex(k_int, 32, "Integrity gen key:"); logger.debug(k_int, 32, "Integrity gen key:");
log->debug_hex(msg, msg_len, "Integrity gen input msg:"); logger.debug(msg, msg_len, "Integrity gen input msg:");
log->debug_hex(mac, 4, "MAC (generated)"); logger.debug(mac, 4, "MAC (generated)");
} }
bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac) bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac)
@ -105,24 +105,24 @@ bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t
break; break;
} }
log->debug("Integrity check input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s\n", logger.debug("Integrity check input: COUNT %" PRIu32 ", Bearer ID %d, Direction %s",
count, count,
cfg.bearer_id, cfg.bearer_id,
cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink");
log->debug_hex(k_int, 32, "Integrity check key:"); logger.debug(k_int, 32, "Integrity check key:");
log->debug_hex(msg, msg_len, "Integrity check input msg:"); logger.debug(msg, msg_len, "Integrity check input msg:");
if (sec_cfg.integ_algo != INTEGRITY_ALGORITHM_ID_EIA0) { if (sec_cfg.integ_algo != INTEGRITY_ALGORITHM_ID_EIA0) {
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
if (mac[i] != mac_exp[i]) { if (mac[i] != mac_exp[i]) {
log->error_hex(mac_exp, 4, "MAC mismatch (expected)"); logger.error(mac_exp, 4, "MAC mismatch (expected)");
log->error_hex(mac, 4, "MAC mismatch (found)"); logger.error(mac, 4, "MAC mismatch (found)");
is_valid = false; is_valid = false;
break; break;
} }
} }
if (is_valid) { if (is_valid) {
log->info_hex(mac_exp, 4, "MAC match"); logger.info(mac_exp, 4, "MAC match");
} }
} }
@ -141,12 +141,12 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c
k_enc = sec_cfg.k_up_enc.data(); k_enc = sec_cfg.k_up_enc.data();
} }
log->debug("Cipher encrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n", logger.debug("Cipher encrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s",
count, count,
cfg.bearer_id, cfg.bearer_id,
cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink"); cfg.tx_direction == SECURITY_DIRECTION_DOWNLINK ? "Downlink" : "Uplink");
log->debug_hex(k_enc, 32, "Cipher encrypt key:"); logger.debug(k_enc, 32, "Cipher encrypt key:");
log->debug_hex(msg, msg_len, "Cipher encrypt input msg"); logger.debug(msg, msg_len, "Cipher encrypt input msg");
switch (sec_cfg.cipher_algo) { switch (sec_cfg.cipher_algo) {
case CIPHERING_ALGORITHM_ID_EEA0: case CIPHERING_ALGORITHM_ID_EEA0:
@ -166,7 +166,7 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c
default: default:
break; break;
} }
log->debug_hex(ct, msg_len, "Cipher encrypt output msg"); logger.debug(ct, msg_len, "Cipher encrypt output msg");
} }
void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg) void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg)
@ -181,12 +181,12 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou
k_enc = sec_cfg.k_up_enc.data(); k_enc = sec_cfg.k_up_enc.data();
} }
log->debug("Cipher decrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s\n", logger.debug("Cipher decrypt input: COUNT: %" PRIu32 ", Bearer ID: %d, Direction %s",
count, count,
cfg.bearer_id, cfg.bearer_id,
(cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink"); (cfg.rx_direction == SECURITY_DIRECTION_DOWNLINK) ? "Downlink" : "Uplink");
log->debug_hex(k_enc, 32, "Cipher decrypt key:"); logger.debug(k_enc, 32, "Cipher decrypt key:");
log->debug_hex(ct, ct_len, "Cipher decrypt input msg"); logger.debug(ct, ct_len, "Cipher decrypt input msg");
switch (sec_cfg.cipher_algo) { switch (sec_cfg.cipher_algo) {
case CIPHERING_ALGORITHM_ID_EEA0: case CIPHERING_ALGORITHM_ID_EEA0:
@ -206,7 +206,7 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou
default: default:
break; break;
} }
log->debug_hex(msg, ct_len, "Cipher decrypt output msg"); logger.debug(msg, ct_len, "Cipher decrypt output msg");
} }
/**************************************************************************** /****************************************************************************
@ -223,7 +223,7 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu)
{ {
// Check PDU is long enough to extract header // Check PDU is long enough to extract header
if (pdu->N_bytes <= cfg.hdr_len_bytes) { if (pdu->N_bytes <= cfg.hdr_len_bytes) {
log->error("PDU too small to extract header\n"); logger.error("PDU too small to extract header");
return 0; return 0;
} }
@ -246,7 +246,7 @@ uint32_t pdcp_entity_base::read_data_header(const unique_byte_buffer_t& pdu)
rcvd_sn_32 = SN(rcvd_sn_32); rcvd_sn_32 = SN(rcvd_sn_32);
break; break;
default: default:
log->error("Cannot extract RCVD_SN, invalid SN length configured: %d\n", cfg.sn_len); logger.error("Cannot extract RCVD_SN, invalid SN length configured: %d", cfg.sn_len);
} }
return rcvd_sn_32; return rcvd_sn_32;
@ -262,7 +262,7 @@ void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu
{ {
// Add room for header // Add room for header
if (cfg.hdr_len_bytes > sdu->get_headroom()) { if (cfg.hdr_len_bytes > sdu->get_headroom()) {
log->error("Not enough space to add header\n"); logger.error("Not enough space to add header");
return; return;
} }
sdu->msg -= cfg.hdr_len_bytes; sdu->msg -= cfg.hdr_len_bytes;
@ -290,7 +290,7 @@ void pdcp_entity_base::write_data_header(const srslte::unique_byte_buffer_t& sdu
sdu->msg[0] |= 0x80; // Data PDU and SN LEN 18 implies DRB, D flag must be present sdu->msg[0] |= 0x80; // Data PDU and SN LEN 18 implies DRB, D flag must be present
break; break;
default: default:
log->error("Invalid SN length configuration: %d bits\n", cfg.sn_len); logger.error("Invalid SN length configuration: %d bits", cfg.sn_len);
} }
} }
@ -298,7 +298,7 @@ void pdcp_entity_base::extract_mac(const unique_byte_buffer_t& pdu, uint8_t* mac
{ {
// Check enough space for MAC // Check enough space for MAC
if (pdu->N_bytes < 4) { if (pdu->N_bytes < 4) {
log->error("PDU too small to extract MAC-I\n"); logger.error("PDU too small to extract MAC-I");
return; return;
} }
@ -311,7 +311,7 @@ void pdcp_entity_base::append_mac(const unique_byte_buffer_t& sdu, uint8_t* mac)
{ {
// Check enough space for MAC // Check enough space for MAC
if (sdu->N_bytes + 4 > sdu->get_tailroom()) { if (sdu->N_bytes + 4 > sdu->get_tailroom()) {
log->error("Not enough space to add MAC-I\n"); logger.error("Not enough space to add MAC-I");
return; return;
} }

@ -19,10 +19,10 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_,
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::task_sched_handle task_sched_, srslte::task_sched_handle task_sched_,
srslte::log_ref log_, srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
pdcp_config_t cfg_) : pdcp_config_t cfg_) :
pdcp_entity_base(task_sched_, log_), rlc(rlc_), rrc(rrc_), gw(gw_) pdcp_entity_base(task_sched_, logger), rlc(rlc_), rrc(rrc_), gw(gw_)
{ {
lcid = lcid_; lcid = lcid_;
cfg = cfg_; cfg = cfg_;
@ -43,13 +43,13 @@ pdcp_entity_lte::pdcp_entity_lte(srsue::rlc_interface_pdcp* rlc_,
maximum_pdcp_sn = (1 << cfg.sn_len) - 1; maximum_pdcp_sn = (1 << cfg.sn_len) - 1;
st.last_submitted_pdcp_rx_sn = maximum_pdcp_sn; st.last_submitted_pdcp_rx_sn = maximum_pdcp_sn;
log->info("Init %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); logger.info("Init %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id);
log->info("SN len bits: %d, SN len bytes: %d, reordering window: %d, Maximum SN: %d, discard timer: %d ms\n", logger.info("SN len bits: %d, SN len bytes: %d, reordering window: %d, Maximum SN: %d, discard timer: %d ms",
cfg.sn_len, cfg.sn_len,
cfg.hdr_len_bytes, cfg.hdr_len_bytes,
reordering_window, reordering_window,
maximum_pdcp_sn, maximum_pdcp_sn,
static_cast<uint32_t>(cfg.discard_timer)); static_cast<uint32_t>(cfg.discard_timer));
// Check supported config // Check supported config
if (!check_valid_config()) { if (!check_valid_config()) {
@ -65,7 +65,7 @@ pdcp_entity_lte::~pdcp_entity_lte()
// Reestablishment procedure: 36.323 5.2 // Reestablishment procedure: 36.323 5.2
void pdcp_entity_lte::reestablish() void pdcp_entity_lte::reestablish()
{ {
log->info("Re-establish %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id);
// For SRBs // For SRBs
if (is_srb()) { if (is_srb()) {
st.next_pdcp_tx_sn = 0; st.next_pdcp_tx_sn = 0;
@ -86,8 +86,8 @@ void pdcp_entity_lte::reestablish()
// Used to stop/pause the entity (called on RRC conn release) // Used to stop/pause the entity (called on RRC conn release)
void pdcp_entity_lte::reset() void pdcp_entity_lte::reset()
{ {
if (active and log) { if (active) {
log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str()); logger.debug("Reset %s", rrc->get_rb_name(lcid).c_str());
} }
active = false; active = false;
} }
@ -96,7 +96,7 @@ void pdcp_entity_lte::reset()
void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu) void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu)
{ {
if (rlc->sdu_queue_is_full(lcid)) { if (rlc->sdu_queue_is_full(lcid)) {
log->info_hex(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid).c_str()); logger.info(sdu->msg, sdu->N_bytes, "Dropping %s SDU due to full queue", rrc->get_rb_name(lcid).c_str());
return; return;
} }
@ -128,13 +128,13 @@ void pdcp_entity_lte::write_sdu(unique_byte_buffer_t sdu)
&sdu->msg[cfg.hdr_len_bytes], sdu->N_bytes - cfg.hdr_len_bytes, tx_count, &sdu->msg[cfg.hdr_len_bytes]); &sdu->msg[cfg.hdr_len_bytes], sdu->N_bytes - cfg.hdr_len_bytes, tx_count, &sdu->msg[cfg.hdr_len_bytes]);
} }
log->info_hex(sdu->msg, logger.info(sdu->msg,
sdu->N_bytes, sdu->N_bytes,
"TX %s PDU, SN=%d, integrity=%s, encryption=%s", "TX %s PDU, SN=%d, integrity=%s, encryption=%s",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
st.next_pdcp_tx_sn, st.next_pdcp_tx_sn,
srslte_direction_text[integrity_direction], srslte_direction_text[integrity_direction],
srslte_direction_text[encryption_direction]); srslte_direction_text[encryption_direction]);
// Set SDU metadata for RLC AM // Set SDU metadata for RLC AM
sdu->md.pdcp_sn = st.next_pdcp_tx_sn; sdu->md.pdcp_sn = st.next_pdcp_tx_sn;
@ -154,13 +154,13 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
{ {
// drop control PDUs // drop control PDUs
if (is_drb() && is_control_pdu(pdu)) { if (is_drb() && is_control_pdu(pdu)) {
log->info("Dropping PDCP control PDU\n"); logger.info("Dropping PDCP control PDU");
return; return;
} }
// Sanity check // Sanity check
if (pdu->N_bytes <= cfg.hdr_len_bytes) { if (pdu->N_bytes <= cfg.hdr_len_bytes) {
log->error("PDCP PDU smaller than required header size.\n"); logger.error("PDCP PDU smaller than required header size.");
return; return;
} }
@ -174,14 +174,14 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
enable_security_rx_sn = -1; enable_security_rx_sn = -1;
} }
log->info_hex(pdu->msg, logger.info(pdu->msg,
pdu->N_bytes, pdu->N_bytes,
"%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)", "%s Rx PDU SN=%d (%d B, integrity=%s, encryption=%s)",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
sn, sn,
pdu->N_bytes, pdu->N_bytes,
srslte_direction_text[integrity_direction], srslte_direction_text[integrity_direction],
srslte_direction_text[encryption_direction]); srslte_direction_text[encryption_direction]);
if (is_srb()) { if (is_srb()) {
handle_srb_pdu(std::move(pdu)); handle_srb_pdu(std::move(pdu));
@ -190,7 +190,7 @@ void pdcp_entity_lte::write_pdu(unique_byte_buffer_t pdu)
} else if (is_drb() && !rlc->rb_is_um(lcid)) { } else if (is_drb() && !rlc->rb_is_um(lcid)) {
handle_am_drb_pdu(std::move(pdu)); handle_am_drb_pdu(std::move(pdu));
} else { } else {
log->error("Invalid PDCP/RLC configuration"); logger.error("Invalid PDCP/RLC configuration");
} }
} }
@ -204,7 +204,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
// Read SN from header // Read SN from header
uint32_t sn = read_data_header(pdu); uint32_t sn = read_data_header(pdu);
log->debug("RX SRB PDU. Next_PDCP_RX_SN %d, SN %d", st.next_pdcp_rx_sn, sn); logger.debug("RX SRB PDU. Next_PDCP_RX_SN %d, SN %d", st.next_pdcp_rx_sn, sn);
// Estimate COUNT for integrity check and decryption // Estimate COUNT for integrity check and decryption
uint32_t count; uint32_t count;
@ -219,7 +219,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
cipher_decrypt(&pdu->msg[cfg.hdr_len_bytes], pdu->N_bytes - cfg.hdr_len_bytes, count, &pdu->msg[cfg.hdr_len_bytes]); cipher_decrypt(&pdu->msg[cfg.hdr_len_bytes], pdu->N_bytes - cfg.hdr_len_bytes, count, &pdu->msg[cfg.hdr_len_bytes]);
} }
log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn);
// Extract MAC // Extract MAC
uint8_t mac[4]; uint8_t mac[4];
@ -228,7 +228,7 @@ void pdcp_entity_lte::handle_srb_pdu(srslte::unique_byte_buffer_t pdu)
// Perfrom integrity checks // Perfrom integrity checks
if (integrity_direction == DIRECTION_RX || integrity_direction == DIRECTION_TXRX) { if (integrity_direction == DIRECTION_RX || integrity_direction == DIRECTION_TXRX) {
if (not integrity_verify(pdu->msg, pdu->N_bytes, count, mac)) { if (not integrity_verify(pdu->msg, pdu->N_bytes, count, mac)) {
log->error_hex(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid).c_str()); logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid).c_str());
return; // Discard return; // Discard
} }
} }
@ -266,7 +266,7 @@ void pdcp_entity_lte::handle_um_drb_pdu(srslte::unique_byte_buffer_t pdu)
cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg);
} }
log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); logger.debug(pdu->msg, pdu->N_bytes, "%s Rx PDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn);
st.next_pdcp_rx_sn = sn + 1; st.next_pdcp_rx_sn = sn + 1;
if (st.next_pdcp_rx_sn > maximum_pdcp_sn) { if (st.next_pdcp_rx_sn > maximum_pdcp_sn) {
@ -288,35 +288,35 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu)
int32_t sn_diff_last_submit = sn - st.last_submitted_pdcp_rx_sn; int32_t sn_diff_last_submit = sn - st.last_submitted_pdcp_rx_sn;
int32_t sn_diff_next_pdcp_rx_sn = sn - st.next_pdcp_rx_sn; int32_t sn_diff_next_pdcp_rx_sn = sn - st.next_pdcp_rx_sn;
log->debug("RX HFN: %d, SN=%d, Last_Submitted_PDCP_RX_SN=%d, Next_PDCP_RX_SN=%d\n", logger.debug("RX HFN: %d, SN=%d, Last_Submitted_PDCP_RX_SN=%d, Next_PDCP_RX_SN=%d",
st.rx_hfn, st.rx_hfn,
sn, sn,
st.last_submitted_pdcp_rx_sn, st.last_submitted_pdcp_rx_sn,
st.next_pdcp_rx_sn); st.next_pdcp_rx_sn);
// Handle PDU // Handle PDU
uint32_t count = 0; uint32_t count = 0;
if ((0 <= sn_diff_last_submit && sn_diff_last_submit > (int32_t)reordering_window) || if ((0 <= sn_diff_last_submit && sn_diff_last_submit > (int32_t)reordering_window) ||
(0 <= last_submit_diff_sn && last_submit_diff_sn < (int32_t)reordering_window)) { (0 <= last_submit_diff_sn && last_submit_diff_sn < (int32_t)reordering_window)) {
// discard // discard
log->debug("Discarding SN=%d (sn_diff_last_submit=%d, last_submit_diff_sn=%d, reordering_window=%d)\n", logger.debug("Discarding SN=%d (sn_diff_last_submit=%d, last_submit_diff_sn=%d, reordering_window=%d)",
sn, sn,
sn_diff_last_submit, sn_diff_last_submit,
last_submit_diff_sn, last_submit_diff_sn,
reordering_window); reordering_window);
return; // Discard return; // Discard
} }
if ((int32_t)(st.next_pdcp_rx_sn - sn) > (int32_t)reordering_window) { if ((int32_t)(st.next_pdcp_rx_sn - sn) > (int32_t)reordering_window) {
log->debug("(Next_PDCP_RX_SN - SN) is larger than re-ordering window.\n"); logger.debug("(Next_PDCP_RX_SN - SN) is larger than re-ordering window.");
st.rx_hfn++; st.rx_hfn++;
count = (st.rx_hfn << cfg.sn_len) | sn; count = (st.rx_hfn << cfg.sn_len) | sn;
st.next_pdcp_rx_sn = sn + 1; st.next_pdcp_rx_sn = sn + 1;
} else if (sn_diff_next_pdcp_rx_sn >= (int32_t)reordering_window) { } else if (sn_diff_next_pdcp_rx_sn >= (int32_t)reordering_window) {
log->debug("(SN - Next_PDCP_RX_SN) is larger or equal than re-ordering window.\n"); logger.debug("(SN - Next_PDCP_RX_SN) is larger or equal than re-ordering window.");
count = ((st.rx_hfn - 1) << cfg.sn_len) | sn; count = ((st.rx_hfn - 1) << cfg.sn_len) | sn;
} else if (sn >= st.next_pdcp_rx_sn) { } else if (sn >= st.next_pdcp_rx_sn) {
log->debug("SN is larger or equal than Next_PDCP_RX_SN.\n"); logger.debug("SN is larger or equal than Next_PDCP_RX_SN.");
count = (st.rx_hfn << cfg.sn_len) | sn; count = (st.rx_hfn << cfg.sn_len) | sn;
st.next_pdcp_rx_sn = sn + 1; st.next_pdcp_rx_sn = sn + 1;
if (st.next_pdcp_rx_sn > maximum_pdcp_sn) { if (st.next_pdcp_rx_sn > maximum_pdcp_sn) {
@ -324,13 +324,13 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu)
st.rx_hfn++; st.rx_hfn++;
} }
} else if (sn < st.next_pdcp_rx_sn) { } else if (sn < st.next_pdcp_rx_sn) {
log->debug("SN is smaller than Next_PDCP_RX_SN.\n"); logger.debug("SN is smaller than Next_PDCP_RX_SN.");
count = (st.rx_hfn << cfg.sn_len) | sn; count = (st.rx_hfn << cfg.sn_len) | sn;
} }
// Decrypt // Decrypt
cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg); cipher_decrypt(pdu->msg, pdu->N_bytes, count, pdu->msg);
log->debug_hex(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn); logger.debug(pdu->msg, pdu->N_bytes, "%s Rx SDU SN=%d", rrc->get_rb_name(lcid).c_str(), sn);
// Update info on last PDU submitted to upper layers // Update info on last PDU submitted to upper layers
st.last_submitted_pdcp_rx_sn = sn; st.last_submitted_pdcp_rx_sn = sn;
@ -344,7 +344,7 @@ void pdcp_entity_lte::handle_am_drb_pdu(srslte::unique_byte_buffer_t pdu)
***************************************************************************/ ***************************************************************************/
void pdcp_entity_lte::notify_delivery(const std::vector<uint32_t>& pdcp_sns) void pdcp_entity_lte::notify_delivery(const std::vector<uint32_t>& pdcp_sns)
{ {
log->debug("Received delivery notification from RLC. Number of PDU notified=%ld\n", pdcp_sns.size()); logger.debug("Received delivery notification from RLC. Number of PDU notified=%ld", pdcp_sns.size());
} }
/**************************************************************************** /****************************************************************************
@ -353,19 +353,19 @@ void pdcp_entity_lte::notify_delivery(const std::vector<uint32_t>& pdcp_sns)
bool pdcp_entity_lte::check_valid_config() bool pdcp_entity_lte::check_valid_config()
{ {
if (cfg.sn_len != PDCP_SN_LEN_5 && cfg.sn_len != PDCP_SN_LEN_7 && cfg.sn_len != PDCP_SN_LEN_12) { if (cfg.sn_len != PDCP_SN_LEN_5 && cfg.sn_len != PDCP_SN_LEN_7 && cfg.sn_len != PDCP_SN_LEN_12) {
log->error("Trying to configure bearer with invalid SN LEN=%d\n", cfg.sn_len); logger.error("Trying to configure bearer with invalid SN LEN=%d", cfg.sn_len);
return false; return false;
} }
if (cfg.sn_len == PDCP_SN_LEN_5 && is_drb()) { if (cfg.sn_len == PDCP_SN_LEN_5 && is_drb()) {
log->error("Trying to configure DRB bearer with SN LEN of 5\n"); logger.error("Trying to configure DRB bearer with SN LEN of 5");
return false; return false;
} }
if (cfg.sn_len == PDCP_SN_LEN_7 && (is_srb() || !rlc->rb_is_um(lcid))) { if (cfg.sn_len == PDCP_SN_LEN_7 && (is_srb() || !rlc->rb_is_um(lcid))) {
log->error("Trying to configure SRB or RLC AM bearer with SN LEN of 7\n"); logger.error("Trying to configure SRB or RLC AM bearer with SN LEN of 7");
return false; return false;
} }
if (cfg.sn_len == PDCP_SN_LEN_12 && is_srb()) { if (cfg.sn_len == PDCP_SN_LEN_12 && is_srb()) {
log->error("Trying to configure SRB with SN LEN of 12.\n"); logger.error("Trying to configure SRB with SN LEN of 12.");
return false; return false;
} }
return true; return true;

@ -19,10 +19,10 @@ pdcp_entity_nr::pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_,
srsue::rrc_interface_pdcp* rrc_, srsue::rrc_interface_pdcp* rrc_,
srsue::gw_interface_pdcp* gw_, srsue::gw_interface_pdcp* gw_,
srslte::task_sched_handle task_sched_, srslte::task_sched_handle task_sched_,
srslte::log_ref log_, srslog::basic_logger& logger,
uint32_t lcid_, uint32_t lcid_,
pdcp_config_t cfg_) : pdcp_config_t cfg_) :
pdcp_entity_base(task_sched_, log_), pdcp_entity_base(task_sched_, logger),
rlc(rlc_), rlc(rlc_),
rrc(rrc_), rrc(rrc_),
gw(gw_), gw(gw_),
@ -50,7 +50,7 @@ pdcp_entity_nr::~pdcp_entity_nr() {}
// Reestablishment procedure: 38.323 5.2 // Reestablishment procedure: 38.323 5.2
void pdcp_entity_nr::reestablish() void pdcp_entity_nr::reestablish()
{ {
log->info("Re-establish %s with bearer ID: %d\n", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id); logger.info("Re-establish %s with bearer ID: %d", rrc->get_rb_name(lcid).c_str(), cfg.bearer_id);
// TODO // TODO
} }
@ -58,23 +58,23 @@ void pdcp_entity_nr::reestablish()
void pdcp_entity_nr::reset() void pdcp_entity_nr::reset()
{ {
active = false; active = false;
log->debug("Reset %s\n", rrc->get_rb_name(lcid).c_str()); logger.debug("Reset %s", rrc->get_rb_name(lcid).c_str());
} }
// SDAP/RRC interface // SDAP/RRC interface
void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu) void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu)
{ {
// Log SDU // Log SDU
log->info_hex(sdu->msg, logger.info(sdu->msg,
sdu->N_bytes, sdu->N_bytes,
"TX %s SDU, integrity=%s, encryption=%s", "TX %s SDU, integrity=%s, encryption=%s",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
srslte_direction_text[integrity_direction], srslte_direction_text[integrity_direction],
srslte_direction_text[encryption_direction]); srslte_direction_text[encryption_direction]);
// Check for COUNT overflow // Check for COUNT overflow
if (tx_overflow) { if (tx_overflow) {
log->warning("TX_NEXT has overflowed. Dropping packet\n"); logger.warning("TX_NEXT has overflowed. Dropping packet");
return; return;
} }
if (tx_next + 1 == 0) { if (tx_next + 1 == 0) {
@ -88,7 +88,7 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu)
discard_timer.set(static_cast<uint32_t>(cfg.discard_timer), discard_fnc); discard_timer.set(static_cast<uint32_t>(cfg.discard_timer), discard_fnc);
discard_timer.run(); discard_timer.run();
discard_timers_map.insert(std::make_pair(tx_next, std::move(discard_timer))); discard_timers_map.insert(std::make_pair(tx_next, std::move(discard_timer)));
log->debug("Discard Timer set for SN %u. Timeout: %ums\n", tx_next, static_cast<uint32_t>(cfg.discard_timer)); logger.debug("Discard Timer set for SN %u. Timeout: %ums", tx_next, static_cast<uint32_t>(cfg.discard_timer));
} }
// Perform header compression TODO // Perform header compression TODO
@ -121,13 +121,13 @@ void pdcp_entity_nr::write_sdu(unique_byte_buffer_t sdu)
void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu) void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
{ {
// Log PDU // Log PDU
log->info_hex(pdu->msg, logger.info(pdu->msg,
pdu->N_bytes, pdu->N_bytes,
"RX %s PDU (%d B), integrity=%s, encryption=%s", "RX %s PDU (%d B), integrity=%s, encryption=%s",
rrc->get_rb_name(lcid).c_str(), rrc->get_rb_name(lcid).c_str(),
pdu->N_bytes, pdu->N_bytes,
srslte_direction_text[integrity_direction], srslte_direction_text[integrity_direction],
srslte_direction_text[encryption_direction]); srslte_direction_text[encryption_direction]);
// Sanity check // Sanity check
if (pdu->N_bytes <= cfg.hdr_len_bytes) { if (pdu->N_bytes <= cfg.hdr_len_bytes) {
@ -153,7 +153,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
} }
rcvd_count = COUNT(rcvd_hfn, rcvd_sn); rcvd_count = COUNT(rcvd_hfn, rcvd_sn);
log->debug("RCVD_HFN %u RCVD_SN %u, RCVD_COUNT %u\n", rcvd_hfn, rcvd_sn, rcvd_count); logger.debug("RCVD_HFN %u RCVD_SN %u, RCVD_COUNT %u", rcvd_hfn, rcvd_sn, rcvd_count);
// Decripting // Decripting
cipher_decrypt(pdu->msg, pdu->N_bytes, rcvd_count, pdu->msg); cipher_decrypt(pdu->msg, pdu->N_bytes, rcvd_count, pdu->msg);
@ -166,8 +166,8 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
// Check valid rcvd_count // Check valid rcvd_count
if (rcvd_count < rx_deliv) { if (rcvd_count < rx_deliv) {
log->debug("Out-of-order after time-out, duplicate or COUNT wrap-around\n"); logger.debug("Out-of-order after time-out, duplicate or COUNT wrap-around");
log->debug("RCVD_COUNT %u, RCVD_COUNT %u\n", rcvd_count, rx_deliv); logger.debug("RCVD_COUNT %u, RCVD_COUNT %u", rcvd_count, rx_deliv);
return; // Invalid count, drop. return; // Invalid count, drop.
} }
@ -205,7 +205,7 @@ void pdcp_entity_nr::write_pdu(unique_byte_buffer_t pdu)
// Notification of delivery // Notification of delivery
void pdcp_entity_nr::notify_delivery(const std::vector<uint32_t>& pdcp_sns) void pdcp_entity_nr::notify_delivery(const std::vector<uint32_t>& pdcp_sns)
{ {
log->debug("Received delivery notification from RLC. Nof SNs=%ld\n", pdcp_sns.size()); logger.debug("Received delivery notification from RLC. Nof SNs=%ld", pdcp_sns.size());
} }
/* /*
@ -219,11 +219,11 @@ void pdcp_entity_nr::deliver_all_consecutive_counts()
for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = reorder_queue.begin(); for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = reorder_queue.begin();
it != reorder_queue.end() && it->first == rx_deliv; it != reorder_queue.end() && it->first == rx_deliv;
reorder_queue.erase(it++)) { reorder_queue.erase(it++)) {
log->debug("Delivering SDU with RCVD_COUNT %u\n", it->first); logger.debug("Delivering SDU with RCVD_COUNT %u", it->first);
// Check RX_DELIV overflow // Check RX_DELIV overflow
if (rx_overflow) { if (rx_overflow) {
log->warning("RX_DELIV has overflowed. Droping packet\n"); logger.warning("RX_DELIV has overflowed. Droping packet");
return; return;
} }
if (rx_deliv + 1 == 0) { if (rx_deliv + 1 == 0) {
@ -244,7 +244,7 @@ void pdcp_entity_nr::deliver_all_consecutive_counts()
// Reordering Timer Callback (t-reordering) // Reordering Timer Callback (t-reordering)
void pdcp_entity_nr::reordering_callback::operator()(uint32_t timer_id) void pdcp_entity_nr::reordering_callback::operator()(uint32_t timer_id)
{ {
parent->log->debug("Reordering timer expired\n"); parent->logger.debug("Reordering timer expired");
// Deliver all PDCP SDU(s) with associeted COUNT value(s) < RX_REORD // Deliver all PDCP SDU(s) with associeted COUNT value(s) < RX_REORD
for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = parent->reorder_queue.begin(); for (std::map<uint32_t, unique_byte_buffer_t>::iterator it = parent->reorder_queue.begin();
@ -266,7 +266,7 @@ void pdcp_entity_nr::reordering_callback::operator()(uint32_t timer_id)
// Discard Timer Callback (discardTimer) // Discard Timer Callback (discardTimer)
void pdcp_entity_nr::discard_callback::operator()(uint32_t timer_id) void pdcp_entity_nr::discard_callback::operator()(uint32_t timer_id)
{ {
parent->log->debug("Discard timer expired for PDU with SN = %d\n", discard_sn); parent->logger.debug("Discard timer expired for PDU with SN = %d", discard_sn);
// Notify the RLC of the discard. It's the RLC to actually discard, if no segment was transmitted yet. // Notify the RLC of the discard. It's the RLC to actually discard, if no segment was transmitted yet.
parent->rlc->discard_sdu(parent->lcid, discard_sn); parent->rlc->discard_sdu(parent->lcid, discard_sn);

@ -34,32 +34,31 @@ int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte::
class rlc_dummy : public srsue::rlc_interface_pdcp class rlc_dummy : public srsue::rlc_interface_pdcp
{ {
public: public:
rlc_dummy(srslte::log_ref log_) : log(log_) {} explicit rlc_dummy(srslog::basic_logger& logger) : logger(logger) {}
void get_last_sdu(const srslte::unique_byte_buffer_t& pdu) void get_last_sdu(const srslte::unique_byte_buffer_t& pdu)
{ {
memcpy(pdu->msg, last_pdcp_pdu->msg, last_pdcp_pdu->N_bytes); memcpy(pdu->msg, last_pdcp_pdu->msg, last_pdcp_pdu->N_bytes);
pdu->N_bytes = last_pdcp_pdu->N_bytes; pdu->N_bytes = last_pdcp_pdu->N_bytes;
return;
} }
void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu) void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu)
{ {
log->info_hex(sdu->msg, sdu->N_bytes, "RLC SDU"); logger.info(sdu->msg, sdu->N_bytes, "RLC SDU");
last_pdcp_pdu.swap(sdu); last_pdcp_pdu.swap(sdu);
rx_count++; rx_count++;
} }
void discard_sdu(uint32_t lcid, uint32_t discard_sn) void discard_sdu(uint32_t lcid, uint32_t discard_sn)
{ {
log->info("Notifing RLC to discard SDU (SN=%u)\n", discard_sn); logger.info("Notifing RLC to discard SDU (SN=%u)", discard_sn);
discard_count++; discard_count++;
log->info("Discard_count=%" PRIu64 "\n", discard_count); logger.info("Discard_count=%" PRIu64 "", discard_count);
} }
uint64_t rx_count = 0; uint64_t rx_count = 0;
uint64_t discard_count = 0; uint64_t discard_count = 0;
private: private:
srslte::log_ref log; srslog::basic_logger& logger;
srslte::unique_byte_buffer_t last_pdcp_pdu; srslte::unique_byte_buffer_t last_pdcp_pdu;
bool rb_is_um(uint32_t lcid) { return false; } bool rb_is_um(uint32_t lcid) { return false; }
@ -69,7 +68,7 @@ private:
class rrc_dummy : public srsue::rrc_interface_pdcp class rrc_dummy : public srsue::rrc_interface_pdcp
{ {
public: public:
rrc_dummy(srslte::log_ref log_) { log = log_; } explicit rrc_dummy(srslog::basic_logger& logger) : logger(logger) {}
void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {} void write_pdu_bcch_bch(srslte::unique_byte_buffer_t pdu) {}
void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {} void write_pdu_bcch_dlsch(srslte::unique_byte_buffer_t pdu) {}
@ -78,7 +77,7 @@ public:
std::string get_rb_name(uint32_t lcid) { return "None"; } std::string get_rb_name(uint32_t lcid) { return "None"; }
srslte::log_ref log; srslog::basic_logger& logger;
// Members for testing // Members for testing
uint32_t rx_count = 0; uint32_t rx_count = 0;
@ -89,12 +88,11 @@ public:
{ {
memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes);
pdu->N_bytes = last_pdu->N_bytes; pdu->N_bytes = last_pdu->N_bytes;
return;
} }
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{ {
log->info_hex(pdu->msg, pdu->N_bytes, "RRC PDU"); logger.info(pdu->msg, pdu->N_bytes, "RRC PDU");
rx_count++; rx_count++;
last_pdu.swap(pdu); last_pdu.swap(pdu);
} }
@ -103,7 +101,7 @@ public:
class gw_dummy : public srsue::gw_interface_pdcp class gw_dummy : public srsue::gw_interface_pdcp
{ {
public: public:
gw_dummy(srslte::log_ref log_) : log(log_) {} explicit gw_dummy(srslog::basic_logger& logger) : logger(logger) {}
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {} void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) {}
uint32_t rx_count = 0; uint32_t rx_count = 0;
@ -112,17 +110,16 @@ public:
{ {
memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes); memcpy(pdu->msg, last_pdu->msg, last_pdu->N_bytes);
pdu->N_bytes = last_pdu->N_bytes; pdu->N_bytes = last_pdu->N_bytes;
return;
} }
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu)
{ {
log->info_hex(pdu->msg, pdu->N_bytes, "GW PDU"); logger.info(pdu->msg, pdu->N_bytes, "GW PDU");
rx_count++; rx_count++;
last_pdu.swap(pdu); last_pdu.swap(pdu);
} }
private: private:
srslte::log_ref log; srslog::basic_logger& logger;
srslte::unique_byte_buffer_t last_pdu; srslte::unique_byte_buffer_t last_pdu;
}; };

@ -59,8 +59,8 @@ srslte::pdcp_lte_state_t normal_init_state = {};
class pdcp_lte_test_helper class pdcp_lte_test_helper
{ {
public: public:
pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslte::log_ref log) : pdcp_lte_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) :
rlc(log), rrc(log), gw(log), pdcp(&rlc, &rrc, &gw, &stack.task_sched, log, 0, cfg) rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg)
{ {
pdcp.config_security(sec_cfg_); pdcp.config_security(sec_cfg_);
pdcp.enable_integrity(srslte::DIRECTION_TXRX); pdcp.enable_integrity(srslte::DIRECTION_TXRX);
@ -82,7 +82,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
srslte::pdcp_rb_type_t rb_type, srslte::pdcp_rb_type_t rb_type,
srslte::as_security_config_t sec_cfg, srslte::as_security_config_t sec_cfg,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg = {1, srslte::pdcp_config_t cfg = {1,
rb_type, rb_type,
@ -92,7 +92,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::infinity}; srslte::pdcp_discard_timer_t::infinity};
pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, log); pdcp_lte_test_helper pdcp_hlp(cfg, sec_cfg, logger);
srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp; srslte::pdcp_entity_lte* pdcp = &pdcp_hlp.pdcp;
rlc_dummy* rlc = &pdcp_hlp.rlc; rlc_dummy* rlc = &pdcp_hlp.rlc;
@ -116,12 +116,12 @@ std::vector<pdcp_test_event_t> gen_expected_pdus_vector(const srslte::unique_byt
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
srslte::pdcp_rb_type_t rb_type, srslte::pdcp_rb_type_t rb_type,
srslte::as_security_config_t sec_cfg_, srslte::as_security_config_t sec_cfg_,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
std::vector<pdcp_test_event_t> pdu_vec; std::vector<pdcp_test_event_t> pdu_vec;
for (uint32_t tx_next : tx_nexts) { for (uint32_t tx_next : tx_nexts) {
pdcp_test_event_t event; pdcp_test_event_t event;
event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, rb_type, sec_cfg_, log); event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, rb_type, sec_cfg_, logger);
event.ticks = 0; event.ticks = 0;
pdu_vec.push_back(std::move(event)); pdu_vec.push_back(std::move(event));
} }

@ -21,7 +21,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
srslte::pdcp_rb_type_t rb_type, srslte::pdcp_rb_type_t rb_type,
uint32_t n_sdus_exp, uint32_t n_sdus_exp,
const srslte::unique_byte_buffer_t& sdu_exp, const srslte::unique_byte_buffer_t& sdu_exp,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg_rx = {1, srslte::pdcp_config_t cfg_rx = {1,
@ -32,7 +32,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::infinity}; srslte::pdcp_discard_timer_t::infinity};
pdcp_lte_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); pdcp_lte_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger);
srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_rx.pdcp; srslte::pdcp_entity_lte* pdcp_rx = &pdcp_hlp_rx.pdcp;
gw_dummy* gw_rx = &pdcp_hlp_rx.gw; gw_dummy* gw_rx = &pdcp_hlp_rx.gw;
rrc_dummy* rrc_rx = &pdcp_hlp_rx.rrc; rrc_dummy* rrc_rx = &pdcp_hlp_rx.rrc;
@ -72,7 +72,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
* RX Test: PDCP Entity with SN LEN = 5 and 12. * RX Test: PDCP Entity with SN LEN = 5 and 12.
* PDCP entity configured with EIA2 and EEA2 * PDCP entity configured with EIA2 and EEA2
*/ */
int test_rx_all(srslte::log_ref log) int test_rx_all(srslog::basic_logger& logger)
{ {
// Test SDUs // Test SDUs
srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1
@ -88,14 +88,17 @@ int test_rx_all(srslte::log_ref log)
{ {
std::vector<uint32_t> test1_counts(2); // Test two packets std::vector<uint32_t> test1_counts(2); // Test two packets
std::iota(test1_counts.begin(), test1_counts.end(), 31); // Starting at COUNT 31 std::iota(test1_counts.begin(), test1_counts.end(), 31); // Starting at COUNT 31
std::vector<pdcp_test_event_t> test1_pdus = std::vector<pdcp_test_event_t> test1_pdus = gen_expected_pdus_vector(
gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, sec_cfg, log); tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, sec_cfg, logger);
srslte::pdcp_lte_state_t test1_init_state = { srslte::pdcp_lte_state_t test1_init_state = {
.next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 31, .last_submitted_pdcp_rx_sn = 30}; .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 31, .last_submitted_pdcp_rx_sn = 30};
TESTASSERT( TESTASSERT(test_rx(std::move(test1_pdus),
test_rx( test1_init_state,
std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_5, srslte::PDCP_RB_IS_SRB, 2, tst_sdu1, log) == srslte::PDCP_SN_LEN_5,
0); srslte::PDCP_RB_IS_SRB,
2,
tst_sdu1,
logger) == 0);
} }
/* /*
@ -106,14 +109,17 @@ int test_rx_all(srslte::log_ref log)
{ {
std::vector<uint32_t> test_counts(2); // Test two packets std::vector<uint32_t> test_counts(2); // Test two packets
std::iota(test_counts.begin(), test_counts.end(), 4095); // Starting at COUNT 4095 std::iota(test_counts.begin(), test_counts.end(), 4095); // Starting at COUNT 4095
std::vector<pdcp_test_event_t> test_pdus = std::vector<pdcp_test_event_t> test_pdus = gen_expected_pdus_vector(
gen_expected_pdus_vector(tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, log); tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger);
srslte::pdcp_lte_state_t test_init_state = { srslte::pdcp_lte_state_t test_init_state = {
.next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 4095, .last_submitted_pdcp_rx_sn = 4094}; .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 4095, .last_submitted_pdcp_rx_sn = 4094};
TESTASSERT( TESTASSERT(test_rx(std::move(test_pdus),
test_rx( test_init_state,
std::move(test_pdus), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 2, tst_sdu1, log) == srslte::PDCP_SN_LEN_12,
0); srslte::PDCP_RB_IS_DRB,
2,
tst_sdu1,
logger) == 0);
} }
/* /*
@ -123,8 +129,8 @@ int test_rx_all(srslte::log_ref log)
{ {
std::vector<uint32_t> test_counts(2); // Test two packets std::vector<uint32_t> test_counts(2); // Test two packets
std::iota(test_counts.begin(), test_counts.end(), 31); // Starting at COUNT 31 std::iota(test_counts.begin(), test_counts.end(), 31); // Starting at COUNT 31
std::vector<pdcp_test_event_t> test_pdus = std::vector<pdcp_test_event_t> test_pdus = gen_expected_pdus_vector(
gen_expected_pdus_vector(tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, log); tst_sdu1, test_counts, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, sec_cfg, logger);
srslte::pdcp_lte_state_t test_init_state = { srslte::pdcp_lte_state_t test_init_state = {
.next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31};
TESTASSERT(test_rx(std::move(test_pdus), TESTASSERT(test_rx(std::move(test_pdus),
@ -133,7 +139,7 @@ int test_rx_all(srslte::log_ref log)
srslte::PDCP_RB_IS_DRB, srslte::PDCP_RB_IS_DRB,
test_counts.size() - 1, test_counts.size() - 1,
tst_sdu1, tst_sdu1,
log) == 0); logger) == 0);
} }
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -141,7 +147,7 @@ int test_rx_all(srslte::log_ref log)
// Basic test to verify the correct handling of PDCP status PDUs on DRBs // Basic test to verify the correct handling of PDCP status PDUs on DRBs
// As long as we don't implement status reporting, the PDU shall be dropped // As long as we don't implement status reporting, the PDU shall be dropped
int test_rx_control_pdu(srslte::log_ref log) int test_rx_control_pdu(srslog::basic_logger& logger)
{ {
const uint8_t pdcp_status_report_long[] = {0x0a, 0xc9, 0x3c}; const uint8_t pdcp_status_report_long[] = {0x0a, 0xc9, 0x3c};
@ -158,7 +164,8 @@ int test_rx_control_pdu(srslte::log_ref log)
srslte::pdcp_lte_state_t test_init_state = { srslte::pdcp_lte_state_t test_init_state = {
.next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31};
TESTASSERT( TESTASSERT(
test_rx(std::move(pdu_vec), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 0, tst_sdu1, log) == test_rx(
std::move(pdu_vec), test_init_state, srslte::PDCP_SN_LEN_12, srslte::PDCP_RB_IS_DRB, 0, tst_sdu1, logger) ==
0); 0);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
@ -168,18 +175,20 @@ int test_rx_control_pdu(srslte::log_ref log)
int run_all_tests() int run_all_tests()
{ {
// Setup log // Setup log
srslte::log_ref log("PDCP LTE Test RX"); auto& logger = srslog::fetch_basic_logger("PDCP LTE Test RX", false);
log->set_level(srslte::LOG_LEVEL_DEBUG); logger.set_level(srslog::basic_levels::debug);
log->set_hex_limit(128); logger.set_hex_dump_max_size(128);
TESTASSERT(test_rx_all(log) == 0); TESTASSERT(test_rx_all(logger) == 0);
TESTASSERT(test_rx_control_pdu(log) == 0); TESTASSERT(test_rx_control_pdu(logger) == 0);
return 0; return 0;
} }
int main() int main()
{ {
srslog::init();
if (run_all_tests() != SRSLTE_SUCCESS) { if (run_all_tests() != SRSLTE_SUCCESS) {
fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); fprintf(stderr, "pdcp_nr_tests_rx() failed\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -87,8 +87,8 @@ pdcp_initial_state near_wraparound_init_state = {.tx_next = 4294967295,
class pdcp_nr_test_helper class pdcp_nr_test_helper
{ {
public: public:
pdcp_nr_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslte::log_ref log) : pdcp_nr_test_helper(srslte::pdcp_config_t cfg, srslte::as_security_config_t sec_cfg_, srslog::basic_logger& logger) :
rlc(log), rrc(log), gw(log), pdcp(&rlc, &rrc, &gw, &stack.task_sched, log, 0, cfg) rlc(logger), rrc(logger), gw(logger), pdcp(&rlc, &rrc, &gw, &stack.task_sched, logger, 0, cfg)
{ {
pdcp.config_security(sec_cfg_); pdcp.config_security(sec_cfg_);
pdcp.enable_integrity(srslte::DIRECTION_TXRX); pdcp.enable_integrity(srslte::DIRECTION_TXRX);
@ -115,7 +115,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t
uint32_t count, uint32_t count,
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
srslte::as_security_config_t sec_cfg, srslte::as_security_config_t sec_cfg,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg = {1, srslte::pdcp_config_t cfg = {1,
srslte::PDCP_RB_IS_DRB, srslte::PDCP_RB_IS_DRB,
@ -125,7 +125,7 @@ srslte::unique_byte_buffer_t gen_expected_pdu(const srslte::unique_byte_buffer_t
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::infinity}; srslte::pdcp_discard_timer_t::infinity};
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger);
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
rlc_dummy* rlc = &pdcp_hlp.rlc; rlc_dummy* rlc = &pdcp_hlp.rlc;
@ -147,12 +147,12 @@ std::vector<pdcp_test_event_t> gen_expected_pdus_vector(const srslte::unique_byt
const std::vector<uint32_t>& tx_nexts, const std::vector<uint32_t>& tx_nexts,
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
srslte::as_security_config_t sec_cfg_, srslte::as_security_config_t sec_cfg_,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
std::vector<pdcp_test_event_t> pdu_vec; std::vector<pdcp_test_event_t> pdu_vec;
for (uint32_t tx_next : tx_nexts) { for (uint32_t tx_next : tx_nexts) {
pdcp_test_event_t event; pdcp_test_event_t event;
event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, sec_cfg_, log); event.pkt = gen_expected_pdu(in_sdu, tx_next, pdcp_sn_len, sec_cfg_, logger);
event.ticks = 0; event.ticks = 0;
pdu_vec.push_back(std::move(event)); pdu_vec.push_back(std::move(event));
} }

@ -18,7 +18,7 @@
int test_tx_sdu_discard(const pdcp_initial_state& init_state, int test_tx_sdu_discard(const pdcp_initial_state& init_state,
srslte::pdcp_discard_timer_t discard_timeout, srslte::pdcp_discard_timer_t discard_timeout,
bool imediate_notify, bool imediate_notify,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg = {1, srslte::pdcp_config_t cfg = {1,
srslte::PDCP_RB_IS_DRB, srslte::PDCP_RB_IS_DRB,
@ -28,7 +28,7 @@ int test_tx_sdu_discard(const pdcp_initial_state& init_state,
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
discard_timeout}; discard_timeout};
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger);
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
rlc_dummy* rlc = &pdcp_hlp.rlc; rlc_dummy* rlc = &pdcp_hlp.rlc;
srsue::stack_test_dummy* stack = &pdcp_hlp.stack; srsue::stack_test_dummy* stack = &pdcp_hlp.stack;
@ -72,19 +72,19 @@ int test_tx_sdu_discard(const pdcp_initial_state& init_state,
* TX Test: PDCP Entity with SN LEN = 12 and 18. * TX Test: PDCP Entity with SN LEN = 12 and 18.
* PDCP entity configured with EIA2 and EEA2 * PDCP entity configured with EIA2 and EEA2
*/ */
int test_tx_discard_all(srslte::log_ref log) int test_tx_discard_all(srslog::basic_logger& logger)
{ {
/* /*
* TX Test 1: PDCP Entity with SN LEN = 12 * TX Test 1: PDCP Entity with SN LEN = 12
* Test TX PDU discard. * Test TX PDU discard.
*/ */
TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, false, log) == 0); TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, false, logger) == 0);
/* /*
* TX Test 2: PDCP Entity with SN LEN = 12 * TX Test 2: PDCP Entity with SN LEN = 12
* Test TX PDU discard. * Test TX PDU discard.
*/ */
// TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, true, log) == 0); // TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, true, logger) == 0);
return 0; return 0;
} }
@ -92,16 +92,18 @@ int test_tx_discard_all(srslte::log_ref log)
int run_all_tests() int run_all_tests()
{ {
// Setup log // Setup log
srslte::log_ref log("PDCP NR Test"); auto& logger = srslog::fetch_basic_logger("PDCP NR Test", false);
log->set_level(srslte::LOG_LEVEL_DEBUG); logger.set_level(srslog::basic_levels::debug);
log->set_hex_limit(128); logger.set_hex_dump_max_size(128);
TESTASSERT(test_tx_discard_all(log) == 0); TESTASSERT(test_tx_discard_all(logger) == 0);
return 0; return 0;
} }
int main() int main()
{ {
srslog::init();
if (run_all_tests() != SRSLTE_SUCCESS) { if (run_all_tests() != SRSLTE_SUCCESS) {
fprintf(stderr, "pdcp_nr_tests() failed\n"); fprintf(stderr, "pdcp_nr_tests() failed\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -20,7 +20,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
uint32_t n_sdus_exp, uint32_t n_sdus_exp,
const srslte::unique_byte_buffer_t& sdu_exp, const srslte::unique_byte_buffer_t& sdu_exp,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg_rx = {1, srslte::pdcp_config_t cfg_rx = {1,
@ -31,7 +31,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::infinity}; srslte::pdcp_discard_timer_t::infinity};
pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp_rx(cfg_rx, sec_cfg, logger);
srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp; srslte::pdcp_entity_nr* pdcp_rx = &pdcp_hlp_rx.pdcp;
gw_dummy* gw_rx = &pdcp_hlp_rx.gw; gw_dummy* gw_rx = &pdcp_hlp_rx.gw;
srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack; srsue::stack_test_dummy* stack = &pdcp_hlp_rx.stack;
@ -58,7 +58,7 @@ int test_rx(std::vector<pdcp_test_event_t> events,
* RX Test: PDCP Entity with SN LEN = 12 and 18. * RX Test: PDCP Entity with SN LEN = 12 and 18.
* PDCP entity configured with EIA2 and EEA2 * PDCP entity configured with EIA2 and EEA2
*/ */
int test_rx_all(srslte::log_ref log) int test_rx_all(srslog::basic_logger& logger)
{ {
// Test SDUs // Test SDUs
srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1 srslte::unique_byte_buffer_t tst_sdu1 = srslte::make_byte_buffer(); // SDU 1
@ -75,9 +75,9 @@ int test_rx_all(srslte::log_ref log)
std::vector<uint32_t> test1_counts(2); // Test two packets std::vector<uint32_t> test1_counts(2); // Test two packets
std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095 std::iota(test1_counts.begin(), test1_counts.end(), 4095); // Starting at COUNT 4095
std::vector<pdcp_test_event_t> test1_pdus = std::vector<pdcp_test_event_t> test1_pdus =
gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, log); gen_expected_pdus_vector(tst_sdu1, test1_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger);
pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0}; pdcp_initial_state test1_init_state = {.tx_next = 4095, .rx_next = 4095, .rx_deliv = 4095, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu1, log) == 0); TESTASSERT(test_rx(std::move(test1_pdus), test1_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu1, logger) == 0);
} }
/* /*
* RX Test 2: PDCP Entity with SN LEN = 12 * RX Test 2: PDCP Entity with SN LEN = 12
@ -89,10 +89,10 @@ int test_rx_all(srslte::log_ref log)
std::vector<uint32_t> test2_counts(2); // Test two packets std::vector<uint32_t> test2_counts(2); // Test two packets
std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::iota(test2_counts.begin(), test2_counts.end(), 4294967295); // Starting at COUNT 4294967295
std::vector<pdcp_test_event_t> test2_pdus = std::vector<pdcp_test_event_t> test2_pdus =
gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, log); gen_expected_pdus_vector(tst_sdu1, test2_counts, srslte::PDCP_SN_LEN_12, sec_cfg, logger);
pdcp_initial_state test2_init_state = { pdcp_initial_state test2_init_state = {
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, log) == 0); TESTASSERT(test_rx(std::move(test2_pdus), test2_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0);
} }
/* /*
* RX Test 3: PDCP Entity with SN LEN = 18 * RX Test 3: PDCP Entity with SN LEN = 18
@ -103,9 +103,9 @@ int test_rx_all(srslte::log_ref log)
std::vector<uint32_t> test3_counts(2); // Test two packets std::vector<uint32_t> test3_counts(2); // Test two packets
std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144 std::iota(test3_counts.begin(), test3_counts.end(), 262144); // Starting at COUNT 262144
std::vector<pdcp_test_event_t> test3_pdus = std::vector<pdcp_test_event_t> test3_pdus =
gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, log); gen_expected_pdus_vector(tst_sdu1, test3_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger);
pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0}; pdcp_initial_state test3_init_state = {.tx_next = 262144, .rx_next = 262144, .rx_deliv = 262144, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, log) == 0); TESTASSERT(test_rx(std::move(test3_pdus), test3_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu1, logger) == 0);
} }
/* /*
@ -117,10 +117,10 @@ int test_rx_all(srslte::log_ref log)
std::vector<uint32_t> test4_counts(2); // Test two packets std::vector<uint32_t> test4_counts(2); // Test two packets
std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295 std::iota(test4_counts.begin(), test4_counts.end(), 4294967295); // Starting at COUNT 4294967295
std::vector<pdcp_test_event_t> test4_pdus = std::vector<pdcp_test_event_t> test4_pdus =
gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, log); gen_expected_pdus_vector(tst_sdu1, test4_counts, srslte::PDCP_SN_LEN_18, sec_cfg, logger);
pdcp_initial_state test4_init_state = { pdcp_initial_state test4_init_state = {
.tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0}; .tx_next = 4294967295, .rx_next = 4294967295, .rx_deliv = 4294967295, .rx_reord = 0};
TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, log) == 0); TESTASSERT(test_rx(std::move(test4_pdus), test4_init_state, srslte::PDCP_SN_LEN_18, 1, tst_sdu1, logger) == 0);
} }
/* /*
@ -144,7 +144,7 @@ int test_rx_all(srslte::log_ref log)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test5_pdus.push_back(std::move(event_pdu2)); test5_pdus.push_back(std::move(event_pdu2));
test5_pdus.push_back(std::move(event_pdu1)); test5_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, log) == 0); TESTASSERT(test_rx(std::move(test5_pdus), test5_init_state, srslte::PDCP_SN_LEN_12, 2, tst_sdu2, logger) == 0);
} }
/* /*
@ -168,7 +168,7 @@ int test_rx_all(srslte::log_ref log)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test6_pdus.push_back(std::move(event_pdu2)); test6_pdus.push_back(std::move(event_pdu2));
test6_pdus.push_back(std::move(event_pdu1)); test6_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu2, log) == 0); TESTASSERT(test_rx(std::move(test6_pdus), test6_init_state, srslte::PDCP_SN_LEN_18, 2, tst_sdu2, logger) == 0);
} }
/* /*
@ -187,7 +187,7 @@ int test_rx_all(srslte::log_ref log)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test7_pdus.push_back(std::move(event_pdu1)); test7_pdus.push_back(std::move(event_pdu1));
TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu2, log) == 0); TESTASSERT(test_rx(std::move(test7_pdus), test7_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu2, logger) == 0);
} }
/* /*
@ -211,7 +211,7 @@ int test_rx_all(srslte::log_ref log)
// Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after) // Write PDUs out of order (first the pdu with COUNT 1 and COUNT 0 after)
test8_pdus.push_back(std::move(event_pdu1)); test8_pdus.push_back(std::move(event_pdu1));
test8_pdus.push_back(std::move(event_pdu2)); test8_pdus.push_back(std::move(event_pdu2));
TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, log) == 0); TESTASSERT(test_rx(std::move(test8_pdus), test8_init_state, srslte::PDCP_SN_LEN_12, 1, tst_sdu1, logger) == 0);
} }
return 0; return 0;
} }
@ -220,16 +220,18 @@ int test_rx_all(srslte::log_ref log)
int run_all_tests() int run_all_tests()
{ {
// Setup log // Setup log
srslte::log_ref log("PDCP NR Test RX"); auto& logger = srslog::fetch_basic_logger("PDCP NR Test RX", false);
log->set_level(srslte::LOG_LEVEL_DEBUG); logger.set_level(srslog::basic_levels::debug);
log->set_hex_limit(128); logger.set_hex_dump_max_size(128);
TESTASSERT(test_rx_all(log) == 0); TESTASSERT(test_rx_all(logger) == 0);
return 0; return 0;
} }
int main() int main()
{ {
srslog::init();
if (run_all_tests() != SRSLTE_SUCCESS) { if (run_all_tests() != SRSLTE_SUCCESS) {
fprintf(stderr, "pdcp_nr_tests_rx() failed\n"); fprintf(stderr, "pdcp_nr_tests_rx() failed\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

@ -20,7 +20,7 @@ int test_tx(uint32_t n_packets,
uint8_t pdcp_sn_len, uint8_t pdcp_sn_len,
uint64_t n_pdus_exp, uint64_t n_pdus_exp,
srslte::unique_byte_buffer_t pdu_exp, srslte::unique_byte_buffer_t pdu_exp,
srslte::log_ref log) srslog::basic_logger& logger)
{ {
srslte::pdcp_config_t cfg = {1, srslte::pdcp_config_t cfg = {1,
srslte::PDCP_RB_IS_DRB, srslte::PDCP_RB_IS_DRB,
@ -30,7 +30,7 @@ int test_tx(uint32_t n_packets,
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::infinity}; srslte::pdcp_discard_timer_t::infinity};
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, logger);
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
rlc_dummy* rlc = &pdcp_hlp.rlc; rlc_dummy* rlc = &pdcp_hlp.rlc;
@ -56,7 +56,7 @@ int test_tx(uint32_t n_packets,
* TX Test: PDCP Entity with SN LEN = 12 and 18. * TX Test: PDCP Entity with SN LEN = 12 and 18.
* PDCP entity configured with EIA2 and EEA2 * PDCP entity configured with EIA2 and EEA2
*/ */
int test_tx_all(srslte::log_ref log) int test_tx_all(srslog::basic_logger& logger)
{ {
uint64_t n_packets; uint64_t n_packets;
/* /*
@ -69,7 +69,8 @@ int test_tx_all(srslte::log_ref log)
srslte::unique_byte_buffer_t pdu_exp_count0_len12 = srslte::make_byte_buffer(); srslte::unique_byte_buffer_t pdu_exp_count0_len12 = srslte::make_byte_buffer();
pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
TESTASSERT( TESTASSERT(
test_tx(n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), log) == test_tx(
n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) ==
0); 0);
/* /*
@ -81,10 +82,12 @@ int test_tx_all(srslte::log_ref log)
n_packets = 2049; n_packets = 2049;
srslte::unique_byte_buffer_t pdu_exp_count2048_len12 = srslte::make_byte_buffer(); srslte::unique_byte_buffer_t pdu_exp_count2048_len12 = srslte::make_byte_buffer();
pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12)); pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12));
TESTASSERT( TESTASSERT(test_tx(n_packets,
test_tx( normal_init_state,
n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count2048_len12), log) == srslte::PDCP_SN_LEN_12,
0); n_packets,
std::move(pdu_exp_count2048_len12),
logger) == 0);
/* /*
* TX Test 3: PDCP Entity with SN LEN = 12 * TX Test 3: PDCP Entity with SN LEN = 12
@ -95,10 +98,12 @@ int test_tx_all(srslte::log_ref log)
n_packets = 4097; n_packets = 4097;
srslte::unique_byte_buffer_t pdu_exp_count4096_len12 = srslte::make_byte_buffer(); srslte::unique_byte_buffer_t pdu_exp_count4096_len12 = srslte::make_byte_buffer();
pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12)); pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12));
TESTASSERT( TESTASSERT(test_tx(n_packets,
test_tx( normal_init_state,
n_packets, normal_init_state, srslte::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count4096_len12), log) == srslte::PDCP_SN_LEN_12,
0); n_packets,
std::move(pdu_exp_count4096_len12),
logger) == 0);
/* /*
* TX Test 4: PDCP Entity with SN LEN = 18 * TX Test 4: PDCP Entity with SN LEN = 18
@ -110,7 +115,8 @@ int test_tx_all(srslte::log_ref log)
srslte::unique_byte_buffer_t pdu_exp_count0_len18 = srslte::make_byte_buffer(); srslte::unique_byte_buffer_t pdu_exp_count0_len18 = srslte::make_byte_buffer();
pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18)); pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18));
TESTASSERT( TESTASSERT(
test_tx(n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), log) == test_tx(
n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) ==
0); 0);
/* /*
@ -124,7 +130,7 @@ int test_tx_all(srslte::log_ref log)
pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18)); pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18));
TESTASSERT( TESTASSERT(
test_tx( test_tx(
n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), log) == n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), logger) ==
0); 0);
/* /*
@ -136,10 +142,12 @@ int test_tx_all(srslte::log_ref log)
n_packets = 262145; n_packets = 262145;
srslte::unique_byte_buffer_t pdu_exp_count262144_len18 = srslte::make_byte_buffer(); srslte::unique_byte_buffer_t pdu_exp_count262144_len18 = srslte::make_byte_buffer();
pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18)); pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18));
TESTASSERT( TESTASSERT(test_tx(n_packets,
test_tx( normal_init_state,
n_packets, normal_init_state, srslte::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count262144_len18), log) == srslte::PDCP_SN_LEN_18,
0); n_packets,
std::move(pdu_exp_count262144_len18),
logger) == 0);
/* /*
* TX Test 7: PDCP Entity with SN LEN = 12 * TX Test 7: PDCP Entity with SN LEN = 12
@ -154,7 +162,7 @@ int test_tx_all(srslte::log_ref log)
srslte::PDCP_SN_LEN_12, srslte::PDCP_SN_LEN_12,
1, 1,
std::move(pdu_exp_count4294967295_len12), std::move(pdu_exp_count4294967295_len12),
log) == 0); logger) == 0);
/* /*
* TX Test 8: PDCP Entity with SN LEN = 18 * TX Test 8: PDCP Entity with SN LEN = 18
@ -169,7 +177,7 @@ int test_tx_all(srslte::log_ref log)
srslte::PDCP_SN_LEN_18, srslte::PDCP_SN_LEN_18,
1, 1,
std::move(pdu_exp_count4294967295_len18), std::move(pdu_exp_count4294967295_len18),
log) == 0); logger) == 0);
return 0; return 0;
} }
@ -177,16 +185,18 @@ int test_tx_all(srslte::log_ref log)
int run_all_tests() int run_all_tests()
{ {
// Setup log // Setup log
srslte::log_ref log("PDCP NR Test TX"); auto& logger = srslog::fetch_basic_logger("PDCP NR Test TX", false);
log->set_level(srslte::LOG_LEVEL_DEBUG); logger.set_level(srslog::basic_levels::debug);
log->set_hex_limit(128); logger.set_hex_dump_max_size(128);
TESTASSERT(test_tx_all(log) == 0); TESTASSERT(test_tx_all(logger) == 0);
return 0; return 0;
} }
int main() int main()
{ {
srslog::init();
if (run_all_tests() != SRSLTE_SUCCESS) { if (run_all_tests() != SRSLTE_SUCCESS) {
fprintf(stderr, "pdcp_nr_tests_tx() failed\n"); fprintf(stderr, "pdcp_nr_tests_tx() failed\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;

Loading…
Cancel
Save