NetworkCaptureLogger: PCAP support added

Log TCP/UDP read/write with fake packet.
This commit is contained in:
Sepalani 2017-08-29 22:14:01 +01:00
parent 906fbf6c8e
commit 82bb5d9915
12 changed files with 485 additions and 29 deletions

View file

@ -17,9 +17,6 @@ const u16 PCAP_VERSION_MAJOR = 2;
const u16 PCAP_VERSION_MINOR = 4;
const u32 PCAP_CAPTURE_LENGTH = 65535;
// TODO(delroth): Make this configurable at PCAP creation time?
const u32 PCAP_DATA_LINK_TYPE = 147; // Reserved for internal use.
// Designed to be directly written into the PCAP file. The PCAP format is
// endian independent, so this works just fine.
#pragma pack(push, 1)
@ -45,10 +42,10 @@ struct PCAPRecordHeader
} // namespace
void PCAP::AddHeader()
void PCAP::AddHeader(u32 link_type)
{
PCAPHeader hdr = {PCAP_MAGIC, PCAP_VERSION_MAJOR, PCAP_VERSION_MINOR, 0,
0, PCAP_CAPTURE_LENGTH, PCAP_DATA_LINK_TYPE};
0, PCAP_CAPTURE_LENGTH, link_type};
m_fp->WriteBytes(&hdr, sizeof(hdr));
}