Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 43 void ip_packet::checksum(void *packet)
- 44 {
- 45 struct ip *ip_hdr = (struct ip*) packet;
- 46
- 47 uint16_t checksum = 0;
- 48 uint16_t *buffer;
- 49 for (int i = 0; i < ip_hdr->ip_len * 2; i++) {
- 50 buffer = (uint16_t*) ((char*) packet + i * sizeof (*buffer));
- 51 checksum += *buffer & 0xFFFF;
- 52 }
- 53 ip_hdr->ip_sum = checksum;
- 54 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement