Explorar el Código

misc/ipv4_proto.h: fix checksum (need to keep adding carry back)

ambrop7 hace 15 años
padre
commit
85c5855430
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      misc/ipv4_proto.h

+ 3 - 1
misc/ipv4_proto.h

@@ -73,7 +73,9 @@ static uint16_t ipv4_checksum (uint8_t *ip_hdr, uint16_t len)
         t += ntoh16(s[i].v);
     }
     
-    t = (t&0xFFFF) + (t >> 16);
+    while (t >> 16) {
+        t = (t & 0xFFFF) + (t >> 16);
+    }
     
     return hton16(~t);
 }