sub checksum {
my $pkt = shift;
- return (-unpack('%16U*', $pkt) & 0xFFFF);
+ return (-unpack('%16C*', $pkt) & 0xFFFF);
}
sub verify_cksum {
# Convert the checksum back to hex and calculate the sum of the
# pack without the checksum.
$cksum = hex($1);
- $shortsum = unpack("%16U*", substr($pkt, 0, -4));
+ $shortsum = unpack("%16C*", substr($pkt, 0, -4));
# The checksum is valid if the hex sum, plus the checksum of the
# base packet short when truncated to 16 bits.
return (($cksum + $shortsum) & 0xFFFF) == 0;
}
-{
- no warnings qw(once);
- eval join('',<main::DATA>) || die $@ unless caller();
- # FIXME: what the heck is this?
-}
-
1;
__END__