Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub pkt_escape {
- my $pkt = shift;
- my $esc = pack('C', 0x10);
- my $buf;
- for (my $i = 0; $i < length $pkt; $i++) {
- my $byte = unpack("x[$i]C", $pkt);
- if ($i > 4 && $i < length($pkt) - 4 && ($byte == 0x10 || $byte == 0x01 || $byte == 0x04 || $byte == 0x17)) {
- $buf .= $esc;
- }
- $buf .= pack('C', $byte);
- }
- return $buf;
- }
Advertisement
Add Comment
Please, Sign In to add comment