c - pcap_pkthdr 是做什么用的?

标签 c networking winpcap

来自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 ),我们什么时候需要它,它是如何填充的(因为数据包本身没有这样的信息,如下所示)?

alt text
(来源:lewis at www.dcs.gla.ac.uk)

最佳答案

如果您保留评论,事情会容易一些。它说:

/* 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/

相关文章:

带有 docker swarm 的 Hadoop 集群

windows - 如何安装和使用 WinPcap?

networking - 网络协议(protocol)模糊测试的框架?

ipad - 是否有任何 API 可以区分 3G 网络和 Wifi?

c++ - 使用 pcap 开发可移植网络分析器应用程序

c++ - TCP连接劫持

c - c99 中的 func() 与 func(void)

c - 有没有办法规范化不存在文件的文件路径?

c++ - 从子字符串生成优化字符串的算法

c - 图像的长宽比导致程序崩溃