diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2012-02-22 15:05:36 -0800 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2012-02-22 15:47:22 -0800 |
commit | 008de3721a3729f49e1bc7dd093bf925567aa64d (patch) | |
tree | 1396c09b2508de6e615bff707547d552b37538dd /libnet/src | |
parent | e961f1520c1f9ddfb327567a801b0abe0a0da527 (diff) | |
download | libnet-008de3721a3729f49e1bc7dd093bf925567aa64d.tar.gz |
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.
Diffstat (limited to 'libnet/src')
-rw-r--r-- | libnet/src/libnet_checksum.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 |