Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Netump Initial commit #7527

Merged
merged 6 commits into from
Aug 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update from comments
hreintke committed Aug 16, 2020
commit 18c8ff66229cc61acfdab477f65410f9a2e1b020
14 changes: 7 additions & 7 deletions libraries/Netdump/examples/Netdump/Netdump.ino
Original file line number Diff line number Diff line change
@@ -29,26 +29,26 @@ File tracefile;

std::map<PacketType, int> packetCount;

enum SerialOption {
enum class SerialOption : uint8_t {
AllFull,
LocalNone,
HTTPChar
};

void startSerial(int option) {
void startSerial(SerialOption option) {
switch (option) {
case AllFull : //All Packets, show packet summary.
case SerialOption::AllFull : //All Packets, show packet summary.
nd.printDump(Serial, Packet::PacketDetail::FULL);
break;

case LocalNone : // Only local IP traffic, full details
case SerialOption::LocalNone : // Only local IP traffic, full details
nd.printDump(Serial, Packet::PacketDetail::NONE,
[](Packet n) {
return (n.hasIP(WiFi.localIP()));
}
);
break;
case HTTPChar : // Only HTTP traffic, show packet content as chars
case SerialOption::HTTPChar : // Only HTTP traffic, show packet content as chars
nd.printDump(Serial, Packet::PacketDetail::CHAR,
[](Packet n) {
return (n.isHTTP());
@@ -79,7 +79,7 @@ void setup(void) {
WiFi.begin(ssid, password);

if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
Serial.println("WiFi Failed, stopping sketch");
while (1) {
delay(1000);
}
@@ -122,7 +122,7 @@ void setup(void) {
webServer.serveStatic("/", *filesystem, "/");
webServer.begin();

startSerial(AllFull); // Serial output examples, use enum SerialOption for selection
startSerial(SerialOption::AllFull); // Serial output examples, use enum SerialOption for selection

// startTcpDump(); // tcpdump option
// startTracefile(); // output to SPIFFS or LittleFS
4 changes: 2 additions & 2 deletions libraries/Netdump/src/Netdump.cpp
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ void Netdump::tcpDump(WiFiServer &tcpDumpServer, const Filter nf)

if (!packetBuffer)
{
packetBuffer = new char[tcpBuffersize];
packetBuffer = new char[tcpBufferSize];
}
bufferIndex = 0;

@@ -162,7 +162,7 @@ void Netdump::tcpDumpProcess(const Packet& np)
}
size_t incl_len = np.getPacketSize() > maxPcapLength ? maxPcapLength : np.getPacketSize();

if (bufferIndex + 16 + incl_len < tcpBuffersize) // only add if enough space available
if (bufferIndex + 16 + incl_len < tcpBufferSize) // only add if enough space available
{
struct timeval tv;
gettimeofday(&tv, nullptr);
2 changes: 1 addition & 1 deletion libraries/Netdump/src/Netdump.h
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ class Netdump
char* packetBuffer = nullptr;
size_t bufferIndex = 0;

static constexpr int tcpBuffersize = 2048;
static constexpr int tcpBufferSize = 2048;
static constexpr int maxPcapLength = 1024;
static constexpr uint32_t pcapMagic = 0xa1b2c3d4;
};
4 changes: 0 additions & 4 deletions libraries/Netdump/src/NetdumpIP.cpp
Original file line number Diff line number Diff line change
@@ -28,10 +28,6 @@ NetdumpIP::NetdumpIP()
{
}

NetdumpIP::~NetdumpIP()
{
}

NetdumpIP::NetdumpIP(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
{
setV4();
1 change: 0 additions & 1 deletion libraries/Netdump/src/NetdumpIP.h
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ class NetdumpIP
{
public:
NetdumpIP();
~NetdumpIP();

NetdumpIP(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
NetdumpIP(const uint8_t *address, bool V4 = true);
2 changes: 0 additions & 2 deletions libraries/Netdump/src/NetdumpPacket.h
Original file line number Diff line number Diff line change
@@ -43,8 +43,6 @@ class Packet
setPacketTypes();
};

Packet() {};

enum class PacketDetail
{
NONE,
4 changes: 0 additions & 4 deletions libraries/Netdump/src/PacketType.cpp
Original file line number Diff line number Diff line change
@@ -14,10 +14,6 @@ PacketType::PacketType()
{
}

PacketType::~PacketType()
{
}

String PacketType::toString() const
{
switch (ptype)
2 changes: 0 additions & 2 deletions libraries/Netdump/src/PacketType.h
Original file line number Diff line number Diff line change
@@ -41,8 +41,6 @@ class PacketType
PacketType();
PacketType(PType pt) : ptype(pt) {};

~PacketType();

operator PType() const
{
return ptype;