DOCSIS::ConfigFile::Encode - Encode functions for a DOCSIS config-file.
DOCSIS::ConfigFile::Encode 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;
Returns a list of bytes representing the $bigint. This can be any number (negative or positive) which can be representing using 64 bits.
$bigint
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.
Will encode any hex encoded string into a list of bytes. The string can have an optional leading "0x".
Returns a list of bytes representing the $int. This can be any number (negative or positive) which can be representing using 32 bits.
$int
Returns a list of four bytes representing the $ip. The $ip must be in in the format "1.2.3.4".
$ip
Encodes MIB number as value of OBJECTID can be in format: 1.2.3.4, .1.2.3.4
OBJECTID
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.
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 $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().
$str
ord()
Returns a list of bytes representing the $str with a zero terminator at the end. The "\0" byte will be added unless seen as the last element in the list.
Only ServiceClassName needs this, see $DOCSIS::ConfigFile::TREE for more details.
$DOCSIS::ConfigFile::TREE
Returns a list with one byte representing the $uchar. This can be any positive number which can be representing using 8 bits.
$uchar
Returns a list of bytes representing the $uint. This can be any positive number which can be representing using 32 bits.
$uint
Returns a list of bytes representing the $ushort. This can be any positive number which can be representing using 16 bits.
$ushort
Will byte-encode a complex vendorspec datastructure.
DOCSIS::ConfigFile
To install DOCSIS::ConfigFile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DOCSIS::ConfigFile
CPAN shell
perl -MCPAN -e shell install DOCSIS::ConfigFile
For more information on module installation, please visit the detailed CPAN module installation guide.