From 008de3721a3729f49e1bc7dd093bf925567aa64d Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 22 Feb 2012 15:05:36 -0800 Subject: Always use an IPPROTO of TCP when calculating TCP checksums. This is consistent with how UDP and ICMP checksums are calculated, though it means that the checksum isn't calculated over the actual protocol number in the underlying IP header. --- libnet/src/libnet_checksum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnet/src/libnet_checksum.c b/libnet/src/libnet_checksum.c index e3e3600..6970d0d 100644 --- a/libnet/src/libnet_checksum.c +++ b/libnet/src/libnet_checksum.c @@ -275,7 +275,7 @@ libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const /* 8 = src and dst */ sum = libnet_in_cksum((uint16_t *)&iph_p->ip_src, 8); } - sum += ntohs(iph_p->ip_p + h_len); + sum += ntohs(IPPROTO_TCP + h_len); sum += libnet_in_cksum((uint16_t *)tcph_p, h_len); tcph_p->th_sum = LIBNET_CKSUM_CARRY(sum); #if 0 -- cgit v1.2.1