Restore the debug code that was deleted in a previous commit,
authorJason Stephenson <jstephenson@mvlc.org>
Tue, 17 May 2011 18:01:08 +0000 (14:01 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 17 May 2011 18:14:11 +0000 (14:14 -0400)
per Joe Atzberger's suggestion.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Sip/Checksum.pm

index f9b2ba8..77b47a7 100644 (file)
@@ -65,9 +65,21 @@ sub debug_split_print {
 
 sub checksum {
     my $pkt   = shift;
+    # my $u   = unpack('%16U*', $pkt);
     my $u     = unpack('%U*', $pkt);
     my $check = ($u * -1) & 0xFFFF;
+    if ($debug) {
+        my $total = debug_split_print($pkt);
+        $total == $u or warn "Internal error: mismatch between $total and $u";
+        printf STDERR "# checksum('$pkt')\n# %34s  HEX  DECIMAL\n", 'BINARY';
+        debug_print("ascii sum",      $u  );
+        debug_print("binary invert", ~$u  );
+        debug_print("add one",       ~$u+1);
+        printf STDERR "# %39s\n", $check;
+    }
+
     return $check;
+    # return (-unpack('%16U*', $pkt) & 0xFFFF);
 }
 
 sub verify_cksum {