Displaying 1 result from an estimated 1 matches for "d_checksum".
Did you mean:
do_checksum
2004 Sep 22
2
Grandstream bin cfg.txt generator
...# generate a d_length (length of the complete message, counting words, in dec)
# ( header is always 8 words lang ) + ( body in ascii (bytes) / 2 = in words )
my $d_length = 8 + (length($a_body)/2);
# make that 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...