libpcap读取本地文件

本文介绍了如何利用libpcap库中的pcap_open_offline()和pcap_fopen_offline()函数来读取离线的pcap文件。这些文件与tcpdump和tcpslice生成的文件格式相同。此外,还提到了pcap_loop()函数,用于从实时捕获或文件中处理一定数量的网络包,直到达到指定计数、文件结束、调用pcap_breakloop()或发生错误。
摘要由CSDN通过智能技术生成

想法

  • 打开离线文件pcap_open_offline()
pcap_t *pcap_open_offline(const char *fname, char *errbuf);
pcap_t *pcap_fopen_offline(FILE *fp, char *errbuf);

is called to open a ”savefile” for reading.
fname specifies the name of the file to open. The file has the same format as those used by tcpdump(1) and tcpslice(1). The name “-” in a synonym for stdin.

Alternatively, you may call pcap_fopen_offline() to read dumped data from an existing open stream fp. Note that on Windows, that stream should be opened in binary mode.

  • pcap_loop - process packets from a live capture or savefile
typedef 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值