| DOCSIS-ConfigFile documentation | view source | Contained in the DOCSIS-ConfigFile distribution. |
DOCSIS::ConfigFile::Encode - Encode functions for a DOCSIS config-file.
@uchar = snmp_object({
value => { oid => $str, type => $str, value => $str },
});
@uchar = bigint({ value => $bigint });
@uchar = int({ value => $int });
@uchar = uint({ value => $uint });
@uchar = ushort({ value => $ushort });
@uchar = uchar({ value => $char });
@uchar = vendorspec({
value => '0x001337', # vendors ID
nested => [
{
type => $int, # vendor specific type
value => $int, # vendor specific value
},
],
});
@uchar = ip({ value => '1.2.3.4' });
@uchar = ether({ value => '0x0123456789abcdef' });
@uchar = ether({ value => $uint });
@uchar = string({ value => '0x0123456789abcdef' });
@uchar = string({ value => 'string containing percent: %25' });
@uchar = hexstr({ value => '0x0123456789abcdef' });
() = mic({ value => $any });
This module has functions which is used to encode "human" data into list of unsigned characters (0-255) (refered to as "bytes") later in the pod. This list can then be encoded into binary data using:
$bytestr = pack 'C*', @uchar;
This function encodes a human-readable SNMP oid into a list of bytes:
@bytes = (
#-type---length---------value-----type---
0x30, $total_length, # object
0x06, int(@oid), @oid, # oid
$type, int(@value), @value, # value
);
Returns a list of bytes representing the $bigint. This can be any
number (negative or positive) which can be representing using 64 bits.
Returns a list of bytes representing the $int. This can be any
number (negative or positive) which can be representing using 32 bits.
Returns a list of bytes representing the $uint. This can be any
positive number which can be representing using 32 bits.
Returns a list of bytes representing the $ushort. This can be any
positive number which can be representing using 16 bits.
Returns a list with one byte representing the $uchar. This can be any
positive number which can be representing using 8 bits.
Will byte-encode a complex vendorspec datastructure.
Returns a list of four bytes representing the $ip. The $ip must
be in in the format "1.2.3.4".
This function use either uint or hexstr to encode the input value. It will figure out the function to use by checking the input for either integer value or a string looking like a hex-string.
Returns a list of bytes representing the $str. Will use
hexstr to decode it if it looks like a hex string (a
string starting with leading "0x"). In other cases, it will
decode it itself. The input string might also be encoded
with a simple uri-encode format: "%20" will be translated
to a space, and "%25" will be translated into "%", before
encoded using ord().
Will encode any hex encoded string into a list of bytes. The string can have an optional leading "0x".
Cannot encode CM/CMTS mic without complete information about the config file, so this function returns an empty list.
This method will return an empty list. It is used by DOCSIS types, which has zero length.
| DOCSIS-ConfigFile documentation | view source | Contained in the DOCSIS-ConfigFile distribution. |