From 53576bbb19a2f3271d3f403505617807b7e2d90d Mon Sep 17 00:00:00 2001 From: "Joe Atzberger (siptest" Date: Wed, 4 Jun 2008 18:14:49 -0500 Subject: [PATCH] Tweak verify_cksum. Signed-off-by: Joshua Ferraro --- C4/SIP/Sip/Checksum.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/C4/SIP/Sip/Checksum.pm b/C4/SIP/Sip/Checksum.pm index 8d046c6a00..e88567a929 100644 --- a/C4/SIP/Sip/Checksum.pm +++ b/C4/SIP/Sip/Checksum.pm @@ -6,10 +6,10 @@ use warnings; our @ISA = qw(Exporter); our @EXPORT_OK = qw(checksum verify_cksum); +our $debug = 0; sub checksum { my $pkt = shift; - return (-unpack('%16U*', $pkt) & 0xFFFF); } @@ -18,11 +18,17 @@ sub verify_cksum { my $cksum; my $shortsum; - return 0 if (substr($pkt, -6, 2) ne "AZ"); # No checksum at end + if ($pkt =~ /AZ(....)$/) { + $debug and warn "verify_cksum: sum ($1) detected"; + } else { + warn "verify_cksum: no sum detected"; + return 0; # No checksum at end + } + # return 0 if (substr($pkt, -6, 2) ne "AZ"); # Convert the checksum back to hex and calculate the sum of the # pack without the checksum. - $cksum = hex(substr($pkt, -4)); + $cksum = hex($1); $shortsum = unpack("%16U*", substr($pkt, 0, -4)); # The checksum is valid if the hex sum, plus the checksum of the @@ -33,7 +39,10 @@ sub verify_cksum { { no warnings qw(once); eval join('',) || die $@ unless caller(); + # FIXME: what the heck is this? } + +1; __END__ # -- 2.39.5