Displaying 1 result from an estimated 1 matches for "b_checksum".
Did you mean:
d_checksum
2004 Sep 22
2
Grandstream bin cfg.txt generator
...t a binary dword
my $b_length = pack("N", $d_length);
# generate a checksum
my $d_checksum;
foreach ($b_length,$b_mac,$b_crlf,$b_crlf,$a_body) {
$d_checksum += unpack("%16n*", $_);
}
#$d_checksum %= 65536;
$d_checksum = 65536-$d_checksum;
# and make a binary word of that
my $b_checksum = pack("n", $d_checksum);
# and write the config back to disk, in a grandstream readable format
open F,">$f_out";
binmode F;
print F $b_length;
print F $b_checksum;
print F $b_mac;
print F $b_crlf;
print F $b_crlf;
print F $a_body;
close F;