Skip to content
Snippets Groups Projects
Commit 3a51db10 authored by Guillaume Valadon's avatar Guillaume Valadon
Browse files

UDP checksum computation fixed

parent a63c3774
No related branches found
No related tags found
No related merge requests found
......@@ -557,7 +557,10 @@ class UDP(Packet):
inet_aton(self.underlayer.dst),
self.underlayer.proto,
ln)
ck=checksum(psdhdr+p)
ck = checksum(psdhdr+p)
# According to RFC768 if the result checksum is 0, it should be set to 0xFFFF
if ck == 0:
ck = 0xFFFF
p = p[:6]+struct.pack("!H", ck)+p[8:]
elif isinstance(self.underlayer, scapy.layers.inet6.IPv6) or isinstance(self.underlayer, scapy.layers.inet6._IPv6ExtHdr):
ck = scapy.layers.inet6.in6_chksum(socket.IPPROTO_UDP, self.underlayer, p)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment