Domanda

Snippet di codice da qui :

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 di Quello che per ( definizione ), quando abbiamo bisogno esso, come è popolata (dal momento che non v'è alcuna informazioni nel pacchetto stesso, come di seguito)?

alt text
(fonte: Lewis al www.dcs.gla .ac.uk )

È stato utile?

Soluzione

Se avete tenuto il commento, sarebbe stato un po 'più facile. Dice:

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

Qui che dice di typedef void(*) pcap_handler(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data):

  

pkt_header è l'intestazione associata   dal driver di cattura al pacchetto.   NON è un protocollo di intestazione.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top