Эх сурвалжийг харах

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

ambrop7 15 жил өмнө
parent
commit
85c5855430
1 өөрчлөгдсөн 3 нэмэгдсэн , 1 устгасан
  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);
 }