aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-04-29 18:40:30 +0200
committerlonkaars <loek@pipeframe.xyz>2024-04-29 18:40:30 +0200
commit4732f4233313a4150370c0b866335ef4eca3a026 (patch)
treec6f24da8ea58ae75858ee597d65f18cabe2f02a1
parentdbe3c25d117e7b7413f13b4ece768e8236650ab6 (diff)
better packet sniffer
-rw-r--r--makefile2
-rw-r--r--src/frontend/qt_sdl/LocalMP.cpp29
2 files changed, 16 insertions, 15 deletions
diff --git a/makefile b/makefile
index 930e85a..6ca562e 100644
--- a/makefile
+++ b/makefile
@@ -10,4 +10,4 @@ build/melonDS: build/build.ninja FORCE
@ninja -C build
run: build/melonDS
- @$<
+ @$< --boot always
diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp
index 18d1b65..b90ff05 100644
--- a/src/frontend/qt_sdl/LocalMP.cpp
+++ b/src/frontend/qt_sdl/LocalMP.cpp
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#ifdef __WIN32__
#include <windows.h>
@@ -246,9 +247,9 @@ void SemReset(int num)
bool Init()
{
- pcap_t* handle = pcap_open_dead(DLT_NULL, 1 << 16);
+ pcap_t* handle = pcap_open_dead(DLT_USER0, 1 << 16);
char filename[80];
- snprintf(filename, 79, "melon_instance_%d.pcap", InstanceID);
+ snprintf(filename, 79, "melon_%lu.pcap", time(NULL));
dumper = pcap_dump_open(handle, filename);
MPQueue = new QSharedMemory("melonNIFI");
@@ -397,6 +398,12 @@ void FIFORead(int fifo, void* buf, int len)
if (fifo == 0) PacketReadOffset = offset;
else ReplyReadOffset = offset;
+
+ struct pcap_pkthdr p;
+ p.len = len;
+ p.caplen = len;
+ gettimeofday(&p.ts, NULL);
+ pcap_dump((u_char*) dumper, &p, (u_char*) buf);
}
void FIFOWrite(int fifo, void* buf, int len)
@@ -433,6 +440,12 @@ void FIFOWrite(int fifo, void* buf, int len)
if (fifo == 0) header->PacketWriteOffset = offset;
else header->ReplyWriteOffset = offset;
+
+ struct pcap_pkthdr p;
+ p.len = len;
+ p.caplen = len;
+ gettimeofday(&p.ts, NULL);
+ pcap_dump((u_char*) dumper, &p, (u_char*) buf);
}
int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp)
@@ -488,12 +501,6 @@ 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;
}
@@ -545,12 +552,6 @@ 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;
}
}