NAME

DOCSIS::ConfigFile::Decode - Decode functions for a DOCSIS config-file

SYNOPSIS

{
    oid => $str,
    type => $str,
    value = $str,
} = snmp_object($binary_str);

$bigint_object = bigint($binary_str);
$int = int($binary_str);
$uint = uint($binary_str);
$ushort = ushort($binary_str);
$uchar = uchar($binary_str);

(
    '0x001337' => [
        {
            type => 24, # vendor specific type
            value => 42, # vendor specific value
            length => 1, # the length of the value meassured in bytes
        },
        ...
    ],
) = vendorspec($binary_str);

$ip_str = ip($binary_str);
$hex_str = ether($binary_str);
$uint = ether($binary_str);
$str = string($binary_str);
$hex_str = string($binary_str);
$hex_str = hexstr($binary_str);
$hex_str = mic($binary_str);

DESCRIPTION

This module has functions which is used to decode binary data into either plain strings or complex data structures, dependent on the function called.

FUNCTIONS

snmp_object

Will take a binary string and decode it into a complex datastructure, with "oid", "type" and "value".

bigint

$bigint_obj = bigint($bytestring);

Returns a Math::BigInt object.

int

Will unpack the input string and return an integer, from -2147483648 to 2147483647.

uint

Will unpack the input string and return an integer, from 0 to 4294967295.

ushort

Will unpack the input string and return a short integer, from 0 to 65535.

uchar

Will unpack the input string and return a short integer, from 0 to 255.

vendorspec

Will unpack the input string and return a complex datastructure, representing the vendor specific data.

ip

Will unpack the input string and return a human readable IPv4 address.

ether

Will unpack the input string and return a MAC address in this format: "00112233" or "00112233445566".

string

Returns human-readable string, where special characters are "uri encoded". Example: "%" = "%25" and " " = "%20". It can also return the value from "hexstr" if it starts with a weird character, such as \x00.

stringz

Same as string above. However this string is zero-terminated in encoded form, but this function remove the last "\0" seen in the string.

hexstr

Will unpack the input string and a string with leading "0x", followed by hexidesimal characters.

mic

Returns a value, printed as hex.

no_value

This method will return an empty string. It is used by DOCSIS types, which has zero length.

vendor

Will byte-encode a complex vendorspec datastructure.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org