【发布时间】:2015-11-22 09:36:00
【问题描述】:
是否可以在实时捕获时捕获正确的 pcap 标头,还是仅放入文件中?所有文档都与文件有关...
我已经设法从 .pcap 文件中轻松提取幻数,在 Linux 中使用 libpcap 和 C,在 Windows 中使用 Java acc。到 [1][2]。 但是,当通过实时捕获(通过 printf 或调试)的标头结构时,字段值似乎搞砸了。例如 snaplen 值在时区字段中结束,其他值没有意义。
我正在使用
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
【问题讨论】:
标签: c header-files pcap libpcap