NAME
DOCSIS::ConfigFile::Encode - Encode functions for a DOCSIS config-file.
DESCRIPTION
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;
FUNCTIONS
bigint
Returns a list of bytes representing the $bigint
. This can be any number (negative or positive) which can be representing using 64 bits.
ether
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.
hexstr
Will encode any hex encoded string into a list of bytes. The string can have an optional leading "0x".
int
Returns a list of bytes representing the $int
. This can be any number (negative or positive) which can be representing using 32 bits.
ip
Returns a list of four bytes representing the $ip
. The $ip
must be in in the format "1.2.3.4".
objectid
Encodes MIB number as value of OBJECTID
can be in format: 1.2.3.4, .1.2.3.4
mic
Cannot encode CM/CMTS mic without complete information about the config file, so this function returns an empty list.
no_value
This method will return an empty list. It is used by DOCSIS types, which has zero length.
snmp_object
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
);
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()
.
stringz
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.
uchar
Returns a list with one byte representing the $uchar
. This can be any positive number which can be representing using 8 bits.
uint
Returns a list of bytes representing the $uint
. This can be any positive number which can be representing using 32 bits.
ushort
Returns a list of bytes representing the $ushort
. This can be any positive number which can be representing using 16 bits.
ushort_list
Returns a list of bytes representing the $ushort
. This can be any positive number which can be representing using 16 bits.
vendor
Will byte-encode a complex vendorspec datastructure.
vendorspec
Will byte-encode a complex vendorspec datastructure.