diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
| commit | 3570c7f03a2aa90aa634f96c0af1969af610f14d (patch) | |
| tree | 4252e03c0e853ba7cffe022937698c854ad0eaa9 /Source/Core/Common/PcapFile.cpp | |
| parent | 2115e8a4a6814e32107b5205ff5c95bbd3c6e99c (diff) | |
Reformat all the things. Have fun with merge conflicts.
Diffstat (limited to 'Source/Core/Common/PcapFile.cpp')
| -rw-r--r-- | Source/Core/Common/PcapFile.cpp | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/Source/Core/Common/PcapFile.cpp b/Source/Core/Common/PcapFile.cpp index 0b34ce2daf..e7be008c68 100644 --- a/Source/Core/Common/PcapFile.cpp +++ b/Source/Core/Common/PcapFile.cpp @@ -8,8 +8,8 @@ #include "Common/FileUtil.h" #include "Common/PcapFile.h" -namespace { - +namespace +{ const u32 PCAP_MAGIC = 0xa1b2c3d4; const u16 PCAP_VERSION_MAJOR = 2; const u16 PCAP_VERSION_MINOR = 4; @@ -23,21 +23,21 @@ const u32 PCAP_DATA_LINK_TYPE = 147; // Reserved for internal use. #pragma pack(push, 1) struct PCAPHeader { - u32 magic_number; - u16 version_major; - u16 version_minor; - s32 tz_offset; // Offset in seconds from the GMT timezone. - u32 ts_accuracy; // In practice, 0. - u32 capture_length; // Size at which we truncate packets. - u32 data_link_type; + u32 magic_number; + u16 version_major; + u16 version_minor; + s32 tz_offset; // Offset in seconds from the GMT timezone. + u32 ts_accuracy; // In practice, 0. + u32 capture_length; // Size at which we truncate packets. + u32 data_link_type; }; struct PCAPRecordHeader { - u32 ts_sec; - u32 ts_usec; - u32 size_in_file; // Size after eventual truncation. - u32 real_size; // Size before eventual truncation. + u32 ts_sec; + u32 ts_usec; + u32 size_in_file; // Size after eventual truncation. + u32 real_size; // Size before eventual truncation. }; #pragma pack(pop) @@ -45,22 +45,19 @@ struct PCAPRecordHeader void PCAP::AddHeader() { - PCAPHeader hdr = { - PCAP_MAGIC, PCAP_VERSION_MAJOR, PCAP_VERSION_MINOR, - 0, 0, PCAP_CAPTURE_LENGTH, PCAP_DATA_LINK_TYPE - }; - m_fp->WriteBytes(&hdr, sizeof (hdr)); + PCAPHeader hdr = {PCAP_MAGIC, PCAP_VERSION_MAJOR, PCAP_VERSION_MINOR, 0, + 0, PCAP_CAPTURE_LENGTH, PCAP_DATA_LINK_TYPE}; + m_fp->WriteBytes(&hdr, sizeof(hdr)); } void PCAP::AddPacket(const u8* bytes, size_t size) { - std::chrono::system_clock::time_point now(std::chrono::system_clock::now()); - auto ts = now.time_since_epoch(); - PCAPRecordHeader rec_hdr = { - (u32)std::chrono::duration_cast<std::chrono::seconds>(ts).count(), - (u32)(std::chrono::duration_cast<std::chrono::microseconds>(ts).count() % 1000000), - (u32)size, (u32)size - }; - m_fp->WriteBytes(&rec_hdr, sizeof (rec_hdr)); - m_fp->WriteBytes(bytes, size); + std::chrono::system_clock::time_point now(std::chrono::system_clock::now()); + auto ts = now.time_since_epoch(); + PCAPRecordHeader rec_hdr = { + (u32)std::chrono::duration_cast<std::chrono::seconds>(ts).count(), + (u32)(std::chrono::duration_cast<std::chrono::microseconds>(ts).count() % 1000000), (u32)size, + (u32)size}; + m_fp->WriteBytes(&rec_hdr, sizeof(rec_hdr)); + m_fp->WriteBytes(bytes, size); } |
