Merge pull request #7015 from lioncash/pcap

PcapFile: Namespace code under the Common namespace
This commit is contained in:
JosJuice 2018-05-30 07:45:09 +02:00 committed by GitHub
commit 6cb81ca851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View File

@ -8,6 +8,8 @@
#include "Common/File.h" #include "Common/File.h"
#include "Common/PcapFile.h" #include "Common/PcapFile.h"
namespace Common
{
namespace namespace
{ {
const u32 PCAP_MAGIC = 0xa1b2c3d4; const u32 PCAP_MAGIC = 0xa1b2c3d4;
@ -61,3 +63,4 @@ void PCAP::AddPacket(const u8* bytes, size_t size)
m_fp->WriteBytes(&rec_hdr, sizeof(rec_hdr)); m_fp->WriteBytes(&rec_hdr, sizeof(rec_hdr));
m_fp->WriteBytes(bytes, size); m_fp->WriteBytes(bytes, size);
} }
} // namespace Common

View File

@ -19,6 +19,8 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/File.h" #include "Common/File.h"
namespace Common
{
class PCAP final class PCAP final
{ {
public: public:
@ -38,3 +40,4 @@ private:
std::unique_ptr<File::IOFile> m_fp; std::unique_ptr<File::IOFile> m_fp;
}; };
} // namespace Common

View File

@ -40,15 +40,16 @@ struct DMAPacket
#pragma pack(pop) #pragma pack(pop)
PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(const std::string& pcap_filename) PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(const std::string& pcap_filename)
: m_pcap(new PCAP(new File::IOFile(pcap_filename, "wb"))) : m_pcap(new Common::PCAP(new File::IOFile(pcap_filename, "wb")))
{ {
} }
PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(PCAP* pcap) : m_pcap(pcap) PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(Common::PCAP* pcap) : m_pcap(pcap)
{ {
} }
PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(std::unique_ptr<PCAP>&& pcap) : m_pcap(std::move(pcap)) PCAPDSPCaptureLogger::PCAPDSPCaptureLogger(std::unique_ptr<Common::PCAP>&& pcap)
: m_pcap(std::move(pcap))
{ {
} }

View File

@ -9,7 +9,10 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
namespace Common
{
class PCAP; class PCAP;
}
namespace DSP namespace DSP
{ {
@ -56,8 +59,8 @@ public:
// Automatically creates a writeable file (truncate existing file). // Automatically creates a writeable file (truncate existing file).
PCAPDSPCaptureLogger(const std::string& pcap_filename); PCAPDSPCaptureLogger(const std::string& pcap_filename);
// Takes ownership of pcap. // Takes ownership of pcap.
PCAPDSPCaptureLogger(PCAP* pcap); PCAPDSPCaptureLogger(Common::PCAP* pcap);
PCAPDSPCaptureLogger(std::unique_ptr<PCAP>&& pcap); PCAPDSPCaptureLogger(std::unique_ptr<Common::PCAP>&& pcap);
void LogIFXRead(u16 address, u16 read_value) override { LogIFXAccess(true, address, read_value); } void LogIFXRead(u16 address, u16 read_value) override { LogIFXAccess(true, address, read_value); }
void LogIFXWrite(u16 address, u16 written_value) override void LogIFXWrite(u16 address, u16 written_value) override
@ -69,6 +72,6 @@ public:
private: private:
void LogIFXAccess(bool read, u16 address, u16 value); void LogIFXAccess(bool read, u16 address, u16 value);
std::unique_ptr<PCAP> m_pcap; std::unique_ptr<Common::PCAP> m_pcap;
}; };
} // namespace DSP } // namespace DSP