gpt4 book ai didi

c - pcap_pkthdr 有什么用?

转载 作者:行者123 更新时间:2023-12-04 06:53:27 26 4
gpt4 key购买 nike

来自 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com