From 5a95cbdfaed295302deb2c3d41df423f07efe9dc Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Fri, 26 Feb 2021 09:56:22 +0100 Subject: [PATCH] Disable rat assignment in pcap class --- lib/include/srslte/common/mac_pcap.h | 4 ++-- lib/src/common/mac_pcap.cc | 23 ++++++----------------- lib/test/mac/mac_pcap_test.cc | 6 ++---- lib/test/mac/mac_pdu_nr_test.cc | 2 +- lib/test/upper/rlc_um_nr_pdu_test.cc | 2 +- srsenb/src/stack/enb_stack_lte.cc | 2 +- srsenb/src/stack/mac/mac_nr.cc | 2 +- srsue/src/stack/ue_stack_lte.cc | 4 ++-- 8 files changed, 16 insertions(+), 29 deletions(-) diff --git a/lib/include/srslte/common/mac_pcap.h b/lib/include/srslte/common/mac_pcap.h index 83ff7dc3c..9176adbe6 100644 --- a/lib/include/srslte/common/mac_pcap.h +++ b/lib/include/srslte/common/mac_pcap.h @@ -27,7 +27,7 @@ namespace srslte { class mac_pcap : srslte::thread { public: - mac_pcap(srslte_rat_t rat); + mac_pcap(); ~mac_pcap(); void enable(bool enable); uint32_t open(std::string filename, uint32_t ue_id = 0); @@ -63,7 +63,6 @@ public: private: srslog::basic_logger& logger; bool running = false; - srslte_rat_t rat = srslte_rat_t::nulltype; uint32_t dlt = 0; // The DLT used for the PCAP file std::string filename; FILE* pcap_file = nullptr; @@ -87,6 +86,7 @@ private: typedef struct { // Different PCAP context for both RATs + srslte::srslte_rat_t rat; MAC_Context_Info_t context; mac_nr_context_info_t context_nr; unique_byte_buffer_t pdu; diff --git a/lib/src/common/mac_pcap.cc b/lib/src/common/mac_pcap.cc index 6875338f7..2d86701f4 100644 --- a/lib/src/common/mac_pcap.cc +++ b/lib/src/common/mac_pcap.cc @@ -17,9 +17,7 @@ namespace srslte { -mac_pcap::mac_pcap(srslte_rat_t rat_) : - logger(srslog::fetch_basic_logger("MAC")), thread("PCAP_WRITER_" + to_string(rat_)), rat(rat_) -{} +mac_pcap::mac_pcap() : logger(srslog::fetch_basic_logger("MAC")), thread("PCAP_WRITER_MAC") {} mac_pcap::~mac_pcap() { @@ -41,18 +39,7 @@ uint32_t mac_pcap::open(std::string filename_, uint32_t ue_id_) } // set DLT for selected RAT - switch (rat) { - case srslte_rat_t::lte: - dlt = UDP_DLT; - break; - case srslte_rat_t::nr: - dlt = UDP_DLT; - break; - default: - logger.error("Error opening PCAP. Unsupported RAT selected."); - return SRSLTE_ERROR; - } - + dlt = UDP_DLT; pcap_file = LTE_PCAP_Open(dlt, filename_.c_str()); if (pcap_file == nullptr) { logger.error("Couldn't open %s to write PCAP", filename_.c_str()); @@ -88,7 +75,7 @@ uint32_t mac_pcap::close() // close file handle { std::lock_guard lock(mutex); - srslte::console("Saving %s MAC PCAP (DLT=%d) to %s\n", to_string(rat).c_str(), dlt, filename.c_str()); + srslte::console("Saving MAC PCAP (DLT=%d) to %s\n", dlt, filename.c_str()); LTE_PCAP_Close(pcap_file); pcap_file = nullptr; } @@ -99,7 +86,7 @@ uint32_t mac_pcap::close() void mac_pcap::write_pdu(pcap_pdu_t& pdu) { if (pdu.pdu != nullptr) { - switch (rat) { + switch (pdu.rat) { case srslte_rat_t::lte: LTE_PCAP_MAC_UDP_WritePDU(pcap_file, &pdu.context, pdu.pdu->msg, pdu.pdu->N_bytes); break; @@ -150,6 +137,7 @@ void mac_pcap::pack_and_queue(uint8_t* payload, { if (running && payload != nullptr) { pcap_pdu_t pdu = {}; + pdu.rat = srslte::srslte_rat_t::lte; pdu.context.radioType = FDD_RADIO; pdu.context.direction = direction; pdu.context.rntiType = rnti_type; @@ -185,6 +173,7 @@ void mac_pcap::pack_and_queue_nr(uint8_t* payload, { if (running && payload != nullptr) { pcap_pdu_t pdu = {}; + pdu.rat = srslte_rat_t::nr; pdu.context_nr.radioType = FDD_RADIO; pdu.context_nr.direction = direction; pdu.context_nr.rntiType = rnti_type; diff --git a/lib/test/mac/mac_pcap_test.cc b/lib/test/mac/mac_pcap_test.cc index 2a4ef6ee0..c8fdd4c90 100644 --- a/lib/test/mac/mac_pcap_test.cc +++ b/lib/test/mac/mac_pcap_test.cc @@ -53,8 +53,7 @@ int mac_pcap_eutra_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = - std::unique_ptr(new srslte::mac_pcap(srslte::srslte_rat_t::lte)); + std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap()); TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") == SRSLTE_SUCCESS); TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") != SRSLTE_SUCCESS); // open again will fail @@ -82,8 +81,7 @@ int mac_pcap_nr_test() uint32_t num_threads = 10; uint32_t num_pdus_per_thread = 100; - std::unique_ptr pcap_handle = - std::unique_ptr(new srslte::mac_pcap(srslte::srslte_rat_t::nr)); + std::unique_ptr pcap_handle = std::unique_ptr(new srslte::mac_pcap()); TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") == SRSLTE_SUCCESS); TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") != SRSLTE_SUCCESS); // open again will fail diff --git a/lib/test/mac/mac_pdu_nr_test.cc b/lib/test/mac/mac_pdu_nr_test.cc index db0f13413..2b11559ae 100644 --- a/lib/test/mac/mac_pdu_nr_test.cc +++ b/lib/test/mac/mac_pdu_nr_test.cc @@ -608,7 +608,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test6() int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap(srslte::srslte_rat_t::nr)); + pcap_handle = std::unique_ptr(new srslte::mac_pcap()); pcap_handle->open("mac_nr_pdu_test.pcap"); #endif diff --git a/lib/test/upper/rlc_um_nr_pdu_test.cc b/lib/test/upper/rlc_um_nr_pdu_test.cc index a463ae610..c8e6ec037 100644 --- a/lib/test/upper/rlc_um_nr_pdu_test.cc +++ b/lib/test/upper/rlc_um_nr_pdu_test.cc @@ -222,7 +222,7 @@ int rlc_um_nr_pdu_unpack_test6() int main(int argc, char** argv) { #if PCAP - pcap_handle = std::unique_ptr(new srslte::mac_pcap(srslte::srslte_rat_t::nr)); + pcap_handle = std::unique_ptr(new srslte::mac_pcap()); pcap_handle->open("rlc_um_nr_pdu_test.pcap"); #endif diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index ad45e2a76..1414e7496 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -36,7 +36,7 @@ enb_stack_lte::enb_stack_lte(srslte::logger* logger_, srslog::sink& log_sink) : s1ap(&task_sched, s1ap_logger), rrc(&task_sched), logger(logger_), - mac_pcap(srslte_rat_t::lte) + mac_pcap() { get_background_workers().set_nof_workers(2); enb_task_queue = task_sched.make_task_queue(); diff --git a/srsenb/src/stack/mac/mac_nr.cc b/srsenb/src/stack/mac/mac_nr.cc index aabfa3748..de01a0f21 100644 --- a/srsenb/src/stack/mac/mac_nr.cc +++ b/srsenb/src/stack/mac/mac_nr.cc @@ -54,7 +54,7 @@ int mac_nr::init(const mac_nr_args_t& args_, log_h->set_hex_limit(args.log_hex_limit); if (args.pcap.enable) { - pcap = std::unique_ptr(new srslte::mac_pcap(srslte::srslte_rat_t::nr)); + pcap = std::unique_ptr(new srslte::mac_pcap()); pcap->open(args.pcap.filename); } diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 35dc03348..76c7c9a46 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -33,8 +33,8 @@ ue_stack_lte::ue_stack_lte() : rrc_logger(srslog::fetch_basic_logger("RRC", false)), usim_logger(srslog::fetch_basic_logger("USIM", false)), nas_logger(srslog::fetch_basic_logger("NAS", false)), - mac_pcap(srslte_rat_t::lte), - mac_nr_pcap(srslte_rat_t::nr), + mac_pcap(), + mac_nr_pcap(), usim(nullptr), phy(nullptr), rlc("RLC"),