Without using libpcap, I am trying to write a log file that adheres to the pcap ( format ) file format . This file must be readable through WireShark. So far I have written this in C ++:
struct pcapFileHeader { uint32_t magic_number; uint16_t version_major; uint16_t version_minor; int16_t thiszone; uint32_t sigfigs; uint32_t snaplen; uint32_t network; }; ofstream fileout; fileout.open("file.pcap", ios::trunc); pcapFileHeader fileHeader; fileHeader.magic_number = 0xa1b2c3d4; fileHeader.version_major = 2; fileHeader.version_minor = 4; fileHeader.thiszone = 0; fileHeader.sigfigs = 0; fileHeader.snaplen = 65535;
So this should make the capture file empty, but when I open it in Wireshark, I am greeted:
The "hello.pcap" file seems to have been interrupted in the middle of the package or other data.
I tried to open the output file in binary mode, but that did not help. I would post this on the WireShark forum, but I think this is a user error, and not something wrong with WireShark.
Help would be greatly appreciated.
c ++ logging wireshark pcap libpcap
Scott
source share