in reply to Re^2: Compensate for bad inet checksum routine
in thread Compensate for bad inet checksum routine

Argh. Meant to simplify by decrementing the last byte and explicity setting the the next to last byte to 255
sub prepchksum { my ($payload) = @_; printf "BEFORE = %s\n", (CORE::unpack "H*", $payload); if (length($payload)%2) { $payload =~ s#(.)$#\0$1#; printf "MID1 = %s\n", (CORE::unpack "H*", $payload); # Compensate off-by-one error if (ord(substr $payload, -1) >= 128) { $payload=~s#(.)(.)$#pack('CC',255, (ord($2)-1)&255)#e; } } printf "AFTER = %s\n", (CORE::unpack "H*", $payload); }