mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Merge pull request #9500 from sepalani/pcap-log-session
PCAP: Improve TCP session logging
This commit is contained in:
commit
e62c33c413
@ -701,6 +701,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
|||||||
WiiSocket& sock = WiiSockets[wii_fd];
|
WiiSocket& sock = WiiSockets[wii_fd];
|
||||||
sock.SetFd(fd);
|
sock.SetFd(fd);
|
||||||
sock.SetWiiFd(wii_fd);
|
sock.SetWiiFd(wii_fd);
|
||||||
|
PowerPC::debug_interface.NetworkLogger()->OnNewSocket(fd);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
int opt_no_sigpipe = 1;
|
int opt_no_sigpipe = 1;
|
||||||
|
@ -24,6 +24,10 @@ namespace Core
|
|||||||
NetworkCaptureLogger::NetworkCaptureLogger() = default;
|
NetworkCaptureLogger::NetworkCaptureLogger() = default;
|
||||||
NetworkCaptureLogger::~NetworkCaptureLogger() = default;
|
NetworkCaptureLogger::~NetworkCaptureLogger() = default;
|
||||||
|
|
||||||
|
void DummyNetworkCaptureLogger::OnNewSocket(s32 socket)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void DummyNetworkCaptureLogger::LogSSLRead(const void* data, std::size_t length, s32 socket)
|
void DummyNetworkCaptureLogger::LogSSLRead(const void* data, std::size_t length, s32 socket)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -81,6 +85,12 @@ PCAPSSLCaptureLogger::PCAPSSLCaptureLogger()
|
|||||||
|
|
||||||
PCAPSSLCaptureLogger::~PCAPSSLCaptureLogger() = default;
|
PCAPSSLCaptureLogger::~PCAPSSLCaptureLogger() = default;
|
||||||
|
|
||||||
|
void PCAPSSLCaptureLogger::OnNewSocket(s32 socket)
|
||||||
|
{
|
||||||
|
m_read_sequence_number[socket] = 0;
|
||||||
|
m_write_sequence_number[socket] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
PCAPSSLCaptureLogger::ErrorState PCAPSSLCaptureLogger::SaveState() const
|
PCAPSSLCaptureLogger::ErrorState PCAPSSLCaptureLogger::SaveState() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@ -193,8 +203,8 @@ void PCAPSSLCaptureLogger::LogIPv4(LogType log_type, const u8* data, u16 length,
|
|||||||
|
|
||||||
if (socket_type == SOCK_STREAM)
|
if (socket_type == SOCK_STREAM)
|
||||||
{
|
{
|
||||||
u32& sequence_number =
|
u32& sequence_number = (log_type == LogType::Read) ? m_read_sequence_number[socket] :
|
||||||
(log_type == LogType::Read) ? m_read_sequence_number : m_write_sequence_number;
|
m_write_sequence_number[socket];
|
||||||
Common::TCPHeader tcp_header(from, to, sequence_number, data, length);
|
Common::TCPHeader tcp_header(from, to, sequence_number, data, length);
|
||||||
sequence_number += static_cast<u32>(length);
|
sequence_number += static_cast<u32>(length);
|
||||||
Common::IPv4Header ip_header(tcp_header.Size() + length, tcp_header.IPProto(), from, to);
|
Common::IPv4Header ip_header(tcp_header.Size() + length, tcp_header.IPProto(), from, to);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -43,6 +44,8 @@ public:
|
|||||||
NetworkCaptureLogger& operator=(NetworkCaptureLogger&&) = delete;
|
NetworkCaptureLogger& operator=(NetworkCaptureLogger&&) = delete;
|
||||||
virtual ~NetworkCaptureLogger();
|
virtual ~NetworkCaptureLogger();
|
||||||
|
|
||||||
|
virtual void OnNewSocket(s32 socket) = 0;
|
||||||
|
|
||||||
virtual void LogSSLRead(const void* data, std::size_t length, s32 socket) = 0;
|
virtual void LogSSLRead(const void* data, std::size_t length, s32 socket) = 0;
|
||||||
virtual void LogSSLWrite(const void* data, std::size_t length, s32 socket) = 0;
|
virtual void LogSSLWrite(const void* data, std::size_t length, s32 socket) = 0;
|
||||||
|
|
||||||
@ -55,6 +58,8 @@ public:
|
|||||||
class DummyNetworkCaptureLogger : public NetworkCaptureLogger
|
class DummyNetworkCaptureLogger : public NetworkCaptureLogger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void OnNewSocket(s32 socket) override;
|
||||||
|
|
||||||
void LogSSLRead(const void* data, std::size_t length, s32 socket) override;
|
void LogSSLRead(const void* data, std::size_t length, s32 socket) override;
|
||||||
void LogSSLWrite(const void* data, std::size_t length, s32 socket) override;
|
void LogSSLWrite(const void* data, std::size_t length, s32 socket) override;
|
||||||
|
|
||||||
@ -79,6 +84,8 @@ public:
|
|||||||
PCAPSSLCaptureLogger();
|
PCAPSSLCaptureLogger();
|
||||||
~PCAPSSLCaptureLogger();
|
~PCAPSSLCaptureLogger();
|
||||||
|
|
||||||
|
void OnNewSocket(s32 socket) override;
|
||||||
|
|
||||||
void LogSSLRead(const void* data, std::size_t length, s32 socket) override;
|
void LogSSLRead(const void* data, std::size_t length, s32 socket) override;
|
||||||
void LogSSLWrite(const void* data, std::size_t length, s32 socket) override;
|
void LogSSLWrite(const void* data, std::size_t length, s32 socket) override;
|
||||||
|
|
||||||
@ -108,7 +115,7 @@ private:
|
|||||||
const sockaddr_in& to);
|
const sockaddr_in& to);
|
||||||
|
|
||||||
std::unique_ptr<Common::PCAP> m_file;
|
std::unique_ptr<Common::PCAP> m_file;
|
||||||
u32 m_read_sequence_number = 0;
|
std::map<s32, u32> m_read_sequence_number;
|
||||||
u32 m_write_sequence_number = 0;
|
std::map<s32, u32> m_write_sequence_number;
|
||||||
};
|
};
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
Loading…
x
Reference in New Issue
Block a user