What is pcap_pkthdr for?

Code snippet from 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 .... 

What is const struct pcap_pkthdr *header for ( definition ), when we need it, how is it populated (since the package itself does not have such information as shown below)?

alt text
(source: Lewis at www.dcs.gla.ac.uk )

+2
source share
1 answer

If you leave a comment, it would be much easier. It says:

 /* Callback function invoked by libpcap for every incoming packet */ 

It talks about typedef void(*) pcap_handler(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data) :

pkt_header - the associated header using the capture driver in the package. This is not a protocol header.

+3
source

Source: https://habr.com/ru/post/1309241/


All Articles