Tweak verify_cksum.
authorJoe Atzberger (siptest <atz4sip@arwen.metavore.com>
Wed, 4 Jun 2008 23:14:49 +0000 (18:14 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 6 Jun 2008 03:43:37 +0000 (22:43 -0500)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/SIP/Sip/Checksum.pm

index 8d046c6..e88567a 100644 (file)
@@ -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('',<main::DATA>) || die $@ unless caller();
+       # FIXME: what the heck is this?
 }
+
+1;
 __END__
 
 #