From 9dd6bb82982f165ea9cdaa2c1b38725d0a0292fe Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Tue, 17 May 2011 14:01:08 -0400 Subject: [PATCH] Restore the debug code that was deleted in a previous commit, per Joe Atzberger's suggestion. Signed-off-by: Jason Stephenson --- Sip/Checksum.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sip/Checksum.pm b/Sip/Checksum.pm index f9b2ba8..77b47a7 100644 --- a/Sip/Checksum.pm +++ b/Sip/Checksum.pm @@ -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 { -- 2.11.0