Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Compensate for bad inet checksum routine

by kschwab (Vicar)
on Mar 29, 2013 at 17:19 UTC ( [id://1026176]=note: print w/replies, xml ) Need Help??


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); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1026176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-24 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found