Is it possible to catch a correct pcap header on live capture or is it only put in files? All documentation relates to files...
I've managed to extract the magic number with ease from .pcap files using libpcap in Linux with C and Jnetpcap in windows with Java acc. to [1][2]. However, when going through the header struct on live capture (through printf or debug) the field values seem messed up. E.g snaplen value ends up in timezone field and other values make no sense.
I'm using
int pcap_loop(pcap_t *p, int cnt, pcap_handler my_callback, u_char *user)
void my_callback (u_char *args, const struct pcap_file_header *header, const u_char *packet)
Pcap.h:
struct pcap_file_header { bpf_u_int32 magic; u_short version_major; u_short version_minor; bpf_int32 thiszone; /* gmt to local correction */ bpf_u_int32 sigfigs; /* accuracy of timestamps */ bpf_u_int32 snaplen; /* max length saved portion of each pkt */ bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */ };
[1] http://www.tcpdump.org/pcap/pcap.html [2] http://www.tcpdump.org/manpages/pcap-savefile.5.txt