-1

Given the below declaration for pcap callback:

void my_callback(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)

How to ascertain the total number of bytes present in the packet? I need that value so that I can pass it to crc32() function.

bengaluriga
  • 319
  • 2
  • 5
  • 9

2 Answers2

3

according to this reference the information about the size of the packet is in the pcap_pkthdr's structure

YePhIcK
  • 5,816
  • 2
  • 27
  • 52
0

The information is in the pcap_pkthdr variable.

Given your callback, the full packet size is given by

header->len

and the captured packet size (which might be smaller if you've set a snaplen that happens to be smaller than actual packet size) is given by

header->caplen
niCk cAMel
  • 869
  • 1
  • 10
  • 26