diff --git a/lib/include/srsran/common/s1ap_pcap.h b/lib/include/srsran/common/s1ap_pcap.h index 819e4845e..f2a0b1164 100644 --- a/lib/include/srsran/common/s1ap_pcap.h +++ b/lib/include/srsran/common/s1ap_pcap.h @@ -14,25 +14,23 @@ #define SRSRAN_S1AP_PCAP_H #include "srsran/common/pcap.h" +#include namespace srsran { class s1ap_pcap { public: - s1ap_pcap() - { - enable_write = false; - pcap_file = NULL; - } + s1ap_pcap() = default; void enable(); - void open(const char* filename); + void open(const char* filename_); void close(); void write_s1ap(uint8_t* pdu, uint32_t pdu_len_bytes); private: - bool enable_write; - FILE* pcap_file; + bool enable_write = false; + std::string filename; + FILE* pcap_file = nullptr; }; } // namespace srsran diff --git a/lib/src/common/s1ap_pcap.cc b/lib/src/common/s1ap_pcap.cc index b6a91c1e3..ce06c5a6e 100644 --- a/lib/src/common/s1ap_pcap.cc +++ b/lib/src/common/s1ap_pcap.cc @@ -21,14 +21,15 @@ void s1ap_pcap::enable() { enable_write = true; } -void s1ap_pcap::open(const char* filename) +void s1ap_pcap::open(const char* filename_) { - pcap_file = DLT_PCAP_Open(S1AP_LTE_DLT, filename); + filename = filename_; + pcap_file = DLT_PCAP_Open(S1AP_LTE_DLT, filename.c_str()); enable_write = true; } void s1ap_pcap::close() { - fprintf(stdout, "Saving S1AP PCAP file\n"); + fprintf(stdout, "Saving S1AP PCAP file (DLT=%d) to %s\n", S1AP_LTE_DLT, filename.c_str()); DLT_PCAP_Close(pcap_file); }