mirror of https://github.com/dirtbags/netarch.git
fix IP checksum routine, finally
This commit is contained in:
parent
b11cd39fd2
commit
2ab42e81ff
4
ip.py
4
ip.py
|
@ -213,9 +213,9 @@ class TCP_Recreate:
|
|||
0, # Header checksum
|
||||
sip,
|
||||
dip)
|
||||
shorts = struct.unpack('!hhhhhhhhhh', iphdr)
|
||||
shorts = struct.unpack('!HHHHHHHHHH', iphdr)
|
||||
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:]
|
||||
|
||||
tcphdr = struct.pack('!HHLLBBHHH',
|
||||
|
|
Loading…
Reference in New Issue