aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/qt_sdl/LocalMP.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp
index 7ea9868..18d1b65 100644
--- a/src/frontend/qt_sdl/LocalMP.cpp
+++ b/src/frontend/qt_sdl/LocalMP.cpp
@@ -38,6 +38,11 @@
#include "LocalMP.h"
#include "Platform.h"
+#include <pcap/pcap.h>
+#include <time.h>
+
+pcap_dumper_t* dumper;
+
using namespace melonDS;
using namespace melonDS::Platform;
@@ -241,6 +246,11 @@ void SemReset(int num)
bool Init()
{
+ pcap_t* handle = pcap_open_dead(DLT_NULL, 1 << 16);
+ char filename[80];
+ snprintf(filename, 79, "melon_instance_%d.pcap", InstanceID);
+ dumper = pcap_dump_open(handle, filename);
+
MPQueue = new QSharedMemory("melonNIFI");
if (!MPQueue->attach())
@@ -302,6 +312,8 @@ bool Init()
void DeInit()
{
+ pcap_dump_close(dumper);
+
if (MPQueue)
{
MPQueue->lock();
@@ -476,6 +488,12 @@ int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp)
}
}
+ struct pcap_pkthdr p;
+ p.len = len;
+ p.caplen = len;
+ gettimeofday(&p.ts, NULL);
+ pcap_dump((u_char*) dumper, &p, packet);
+
return len;
}
@@ -526,6 +544,13 @@ int RecvPacketGeneric(u8* packet, bool block, u64* timestamp)
if (timestamp) *timestamp = pktheader.Timestamp;
MPQueue->unlock();
+
+ struct pcap_pkthdr p;
+ p.len = pktheader.Length;
+ p.caplen = pktheader.Length;
+ gettimeofday(&p.ts, NULL);
+ pcap_dump((u_char*) dumper, &p, packet);
+
return pktheader.Length;
}
}