From: ian Date: Sun, 3 Mar 2002 14:03:34 +0000 (+0000) Subject: Iteratively ones-c the checksum X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=02aa73e95e6c1c13994f278aee20e40cb31784c7;p=vinegar-ip.git Iteratively ones-c the checksum --- diff --git a/make-probes.tcl b/make-probes.tcl index a23edff..3466cdb 100755 --- a/make-probes.tcl +++ b/make-probes.tcl @@ -49,7 +49,10 @@ proc packet-csum-ip {packet} { set cs [expr "\$cs + 0x$this"] debug 7 [format "0x%s 0x%08x" $this $cs] } - return [expr {(($cs & 0xffff) + (($cs >> 16) & 0xffff)) ^ 0xffff}] + while {$cs > 0xffff} { + set cs [expr {($cs & 0xffff) + (($cs >> 16) & 0xffff)}] + } + return [expr {$cs ^ 0xffff}] } proc packet-fromstring {s} {