Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Sep 7, 2023
1 parent e9c99c5 commit 64d9f21
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
46 changes: 0 additions & 46 deletions cpp/devices/ctapdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ CTapDriver::~CTapDriver()
// Release TAP defice
close(m_hTAP);
}

if (m_pcap_dumper != nullptr) {
pcap_dump_close(m_pcap_dumper);
}

if (m_pcap != nullptr) {
pcap_close(m_pcap);
}
}

static bool ip_link(int fd, const char* ifname, bool up) {
Expand Down Expand Up @@ -359,22 +351,6 @@ bool CTapDriver::Init(const unordered_map<string, string>& const_params)
#endif
}

void CTapDriver::OpenDump(const string& path) {
if (m_pcap == nullptr) {
m_pcap = pcap_open_dead(DLT_EN10MB, 65535);
}
if (m_pcap_dumper != nullptr) {
pcap_dump_close(m_pcap_dumper);
}
m_pcap_dumper = pcap_dump_open(m_pcap, path.c_str());
if (m_pcap_dumper == nullptr) {
LOGERROR("Can't open pcap file: %s", pcap_geterr(m_pcap))
throw io_exception("Can't open pcap file");
}

LOGTRACE("%s Opened %s for dumping", __PRETTY_FUNCTION__, path.c_str())
}

bool CTapDriver::Enable() const
{
const int fd = socket(PF_INET, SOCK_DGRAM, 0);
Expand Down Expand Up @@ -479,17 +455,6 @@ int CTapDriver::Receive(uint8_t *buf)
dwReceived += 4;
}

if (m_pcap_dumper != nullptr) {
pcap_pkthdr h = {
.ts = {},
.caplen = dwReceived,
.len = dwReceived
};
gettimeofday(&h.ts, nullptr);
pcap_dump((u_char*)m_pcap_dumper, &h, buf);
LOGTRACE("%s Dumped %d byte packet (first byte: %02x last byte: %02x)", __PRETTY_FUNCTION__, dwReceived, buf[0], buf[dwReceived-1])
}

// Return the number of bytes
return dwReceived;
}
Expand All @@ -498,17 +463,6 @@ int CTapDriver::Send(const uint8_t *buf, int len)
{
assert(m_hTAP != -1);

if (m_pcap_dumper != nullptr) {
pcap_pkthdr h = {
.ts = {},
.caplen = (bpf_u_int32)len,
.len = (bpf_u_int32)len,
};
gettimeofday(&h.ts, nullptr);
pcap_dump((u_char*)m_pcap_dumper, &h, buf);
LOGTRACE("%s Dumped %d byte packet (first byte: %02x last byte: %02x)", __PRETTY_FUNCTION__, h.len, buf[0], buf[h.len-1])
}

// Start sending
return static_cast<int>(write(m_hTAP, buf, len));
}
4 changes: 0 additions & 4 deletions cpp/devices/ctapdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#pragma once

#include <pcap/pcap.h>
#include <net/ethernet.h>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -49,9 +48,6 @@ class CTapDriver

int m_hTAP = -1; // File handle

pcap_t *m_pcap = nullptr;
pcap_dumper_t *m_pcap_dumper = nullptr;

// Prioritized comma-separated list of interfaces to create the bridge for
vector<string> interfaces;

Expand Down
1 change: 1 addition & 0 deletions cpp/devices/scsi_daynaport.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "interfaces/byte_writer.h"
#include "primary_device.h"
#include "ctapdriver.h"
#include <net/ethernet.h>
#include <string>
#include <span>
#include <unordered_map>
Expand Down
1 change: 1 addition & 0 deletions cpp/test/ctapdriver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//---------------------------------------------------------------------------

#include "mocks.h"
#include <net/ethernet.h>
#include "devices/ctapdriver.h"

TEST(CTapDriverTest, Crc32)
Expand Down

0 comments on commit 64d9f21

Please sign in to comment.