fix IP checksum routine, finally

This commit is contained in:
Neale Pickett 2013-01-30 15:08:04 -07:00 committed by pi-rho
parent 112d3cc880
commit e0e0ea7aa8
1 changed files with 1 additions and 3 deletions

View File

@ -232,9 +232,7 @@ class TCP_Recreate(object):
dip)
shorts = struct.unpack('!HHHHHHHHHH', iphdr)
shsum = sum(shorts)
shsum += shsum >> 16 # the carry
shsum = ~shsum # one's compliment
ipsum = struct.pack('!H', shsum & 0xffff)
ipsum = struct.pack('!H', ((shsum + (shsum >> 16)) & 0xffff) ^ 0xffff)
iphdr = iphdr[:10] + ipsum + iphdr[12:]
tcphdr = struct.pack('!HHLLBBHHH',