pcap: add dtor

this fixes issue if object is destroyed and PCAP is still open
master
Andre Puschmann 6 years ago
parent 67b6a40c1b
commit 414e55fafc

@ -30,7 +30,8 @@ namespace srslte {
class mac_pcap
{
public:
mac_pcap() {enable_write=false; ue_id=0; pcap_file = NULL; };
mac_pcap();
~mac_pcap();
void enable(bool en);
void open(const char *filename, uint32_t ue_id = 0);
void close();

@ -26,6 +26,13 @@
namespace srslte {
mac_pcap::mac_pcap() : enable_write(false), ue_id(0), pcap_file(nullptr) {}
mac_pcap::~mac_pcap()
{
close();
}
void mac_pcap::enable(bool en)
{
enable_write = true;
@ -39,8 +46,11 @@ void mac_pcap::open(const char* filename, uint32_t ue_id)
void mac_pcap::close()
{
enable_write = false;
fprintf(stdout, "Saving MAC PCAP file\n");
LTE_PCAP_Close(pcap_file);
if (pcap_file != nullptr) {
fprintf(stdout, "Saving MAC PCAP file\n");
LTE_PCAP_Close(pcap_file);
pcap_file = nullptr;
}
}
void mac_pcap::set_ue_id(uint16_t ue_id) {

Loading…
Cancel
Save