fix IP checksum routine, finally

This commit is contained in:
Neale Pickett 2013-01-30 15:08:04 -07:00
parent b11cd39fd2
commit 2ab42e81ff
1 changed files with 2 additions and 2 deletions

4
ip.py
View File

@ -213,9 +213,9 @@ class TCP_Recreate:
0, # Header checksum 0, # Header checksum
sip, sip,
dip) dip)
shorts = struct.unpack('!hhhhhhhhhh', iphdr) shorts = struct.unpack('!HHHHHHHHHH', iphdr)
shsum = sum(shorts) shsum = sum(shorts)
ipsum = struct.pack('!h', (~shsum & 0xffff) - 2) # -2? WTF? ipsum = struct.pack('!H', ((shsum + (shsum >> 16)) & 0xffff) ^ 0xffff)
iphdr = iphdr[:10] + ipsum + iphdr[12:] iphdr = iphdr[:10] + ipsum + iphdr[12:]
tcphdr = struct.pack('!HHLLBBHHH', tcphdr = struct.pack('!HHLLBBHHH',