来自here的代码片段:
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data)
{
....
/* retireve the position of the ip header */
ih = (ip_header *) (pkt_data +
14); //length of ethernet header
....
什么是const struct pcap_pkthdr *header
for( definition ),我们什么时候需要它,它是如何填充的(因为数据包本身没有这样的信息,如下所示)?
最佳答案
如果您保留评论,事情会容易一些。它说:
/* Callback function invoked by libpcap for every incoming packet */
Here它说的是typedef void(*) pcap_handler(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)
:
pkt_header
is the header associated by the capture driver to the packet. It is NOT a protocol header.
关于c - pcap_pkthdr 是做什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2797089/