pcap.h函数功能及示例介绍:
1.pcap_findalldevs(&alldevs, errbuf),检索本机设备接口列表,存储至alldevs;
2.pcap_freealldevs(alldevs),释放接口列表;
3.adhandle=pcap_open_live(d->name, // name of the device
65536, // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1, // promiscuous mode (nonzero means promiscuous)
1000, // read timeout
errbuf // error buffer
)
在线模式,打开适配器的某个端口,如果端口号是65536表示全部端口,返回适配器指针;
4.adhandle = pcap_open_offline(argv[1], // name of the device
errbuf // error buffer