Lines 10-16
our $debug = 0;
Link Here
|
10 |
|
10 |
|
11 |
sub checksum { |
11 |
sub checksum { |
12 |
my $pkt = shift; |
12 |
my $pkt = shift; |
13 |
return (-unpack('%16U*', $pkt) & 0xFFFF); |
13 |
return (-unpack('%16C*', $pkt) & 0xFFFF); |
14 |
} |
14 |
} |
15 |
|
15 |
|
16 |
sub verify_cksum { |
16 |
sub verify_cksum { |
Lines 29-35
sub verify_cksum {
Link Here
|
29 |
# Convert the checksum back to hex and calculate the sum of the |
29 |
# Convert the checksum back to hex and calculate the sum of the |
30 |
# pack without the checksum. |
30 |
# pack without the checksum. |
31 |
$cksum = hex($1); |
31 |
$cksum = hex($1); |
32 |
$shortsum = unpack("%16U*", substr($pkt, 0, -4)); |
32 |
$shortsum = unpack("%16C*", substr($pkt, 0, -4)); |
33 |
|
33 |
|
34 |
# The checksum is valid if the hex sum, plus the checksum of the |
34 |
# The checksum is valid if the hex sum, plus the checksum of the |
35 |
# base packet short when truncated to 16 bits. |
35 |
# base packet short when truncated to 16 bits. |
36 |
- |
|
|