X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=make-probes.tcl;fp=make-probes.tcl;h=3466cdbc63ad8d865f6bdad6b240743b9cc9baaa;hb=02aa73e95e6c1c13994f278aee20e40cb31784c7;hp=a23edff8bf7d816b7011e26e365938c1489e023c;hpb=0ddc85f46b744e366e9b7634e8c284accf98f439;p=vinegar-ip.git 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} {