mirror of https://github.com/dirtbags/netarch.git
fix IP checksum routine, finally
This commit is contained in:
parent
112d3cc880
commit
e0e0ea7aa8
|
@ -232,9 +232,7 @@ class TCP_Recreate(object):
|
||||||
dip)
|
dip)
|
||||||
shorts = struct.unpack('!HHHHHHHHHH', iphdr)
|
shorts = struct.unpack('!HHHHHHHHHH', iphdr)
|
||||||
shsum = sum(shorts)
|
shsum = sum(shorts)
|
||||||
shsum += shsum >> 16 # the carry
|
ipsum = struct.pack('!H', ((shsum + (shsum >> 16)) & 0xffff) ^ 0xffff)
|
||||||
shsum = ~shsum # one's compliment
|
|
||||||
ipsum = struct.pack('!H', shsum & 0xffff)
|
|
||||||
iphdr = iphdr[:10] + ipsum + iphdr[12:]
|
iphdr = iphdr[:10] + ipsum + iphdr[12:]
|
||||||
|
|
||||||
tcphdr = struct.pack('!HHLLBBHHH',
|
tcphdr = struct.pack('!HHLLBBHHH',
|
||||||
|
|
Loading…
Reference in New Issue