From 52a025ea5d663bbdc160cb20cefbccfca889516d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Thu, 12 May 2011 15:26:17 -0400 Subject: [PATCH] Fix checksum generation so that it actually works with clients. Signed-off-by: Jason Stephenson --- Sip/Checksum.pm | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Sip/Checksum.pm b/Sip/Checksum.pm index 85b17a2..f9b2ba8 100644 --- a/Sip/Checksum.pm +++ b/Sip/Checksum.pm @@ -65,21 +65,9 @@ sub debug_split_print { sub checksum { my $pkt = shift; - # my $u = unpack('%16U*', $pkt); my $u = unpack('%U*', $pkt); - my $check = uc substr sprintf("%x", ~$u+1), -4; - 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; - } - + my $check = ($u * -1) & 0xFFFF; return $check; - # return (-unpack('%16U*', $pkt) & 0xFFFF); } sub verify_cksum { -- 2.11.0