| 1 | package DOCSIS::ConfigFile; | ||||||||||||||||||||||||||||
| 2 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use Carp qw(carp confess croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use constant CAN_TRANSLATE_OID => $ENV{DOCSIS_CAN_TRANSLATE_OID} // eval 'require SNMP;1' || 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.4
Condition60%3/5
($ENV{'DOCSIS_CAN_TRANSLATE_OID'} // eval 'require SNMP;1') || 0
$ENV{"DOCSIS_CAN_TRANSLATE_OID"} // eval "require SNMP;1"
MC/DC50%1/2
($ENV{'DOCSIS_CAN_TRANSLATE_OID'} // eval 'require SNMP;1') || 0
$ENV{"DOCSIS_CAN_TRANSLATE_OID"}
eval "require SNMP;1"
Truth table66%2/3
A // B
A= $ENV{"DOCSIS_CAN_TRANSLATE_OID"}B= eval "require SNMP;1"
| |||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use constant DEBUG => $ENV{DOCSIS_CONFIGFILE_DEBUG} || 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'DOCSIS_CONFIGFILE_DEBUG'} || 0
MC/DC0%0/1
$ENV{'DOCSIS_CONFIGFILE_DEBUG'} || 0
$ENV{'DOCSIS_CONFIGFILE_DEBUG'}
Truth table50%1/2
A
A= $ENV{'DOCSIS_CONFIGFILE_DEBUG'}
| |||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use if DEBUG, 'Data::Dumper'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 17 | if (CAN_TRANSLATE_OID) { | |||||||||||||||||||||||||||
| 11 | require File::Basename; | ||||||||||||||||||||||||||||
| 12 | require File::Spec; | ||||||||||||||||||||||||||||
| 13 | our $OID_DIR = File::Spec->rel2abs( | ||||||||||||||||||||||||||||
| 14 | File::Spec->catdir(File::Basename::dirname(__FILE__), 'ConfigFile', 'mibs')); | ||||||||||||||||||||||||||||
| 15 | warn "[DOCSIS] Adding OID directory $OID_DIR\n" if DEBUG; | ||||||||||||||||||||||||||||
| 16 | SNMP::addMibDirs($OID_DIR); | ||||||||||||||||||||||||||||
| 17 | SNMP::loadModules('ALL'); | ||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 17 | ▶ | use Digest::MD5 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 17 | ▶ | use Digest::HMAC_MD5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 17 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 17 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 17 | ▶ | use DOCSIS::ConfigFile::Decode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 17 | ▶ | use DOCSIS::ConfigFile::Encode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 17 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||
| 28 | 17 | our @EXPORT_OK = qw(decode_docsis encode_docsis); | |||||||||||||||||||||||||||
| 29 | 17 | our ($DEPTH, $CONFIG_TREE, @CMTS_MIC) = (0, {}); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 50 | ▶ | sub decode_docsis { | ||||||||||||||||||||||||||
|
Subroutine
decode_docsis: called CC=21 SCAR=30.8
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 50 | ▶ | my $options = ref $_[-1] eq 'HASH' ? $_[-1] : {}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 50 | my $bytes = shift; | |||||||||||||||||||||||||||
| 34 | 50 | ▶ | my $current = $options->{blueprint} || $CONFIG_TREE; | ||||||||||||||||||||||||||
|
Condition66%2/3
$options->{'blueprint'} || $DOCSIS::ConfigFile::CONFIG_TREE
MC/DC0%0/2
$options->{'blueprint'} || $DOCSIS::ConfigFile::CONFIG_TREE
$options->{'blueprint'}
$DOCSIS::ConfigFile::CONFIG_TREE
Truth table66%2/3
A || B
A= $options->{'blueprint'}B= $DOCSIS::ConfigFile::CONFIG_TREE
| |||||||||||||||||||||||||||||
| 35 | 50 | ▶ | my $pos = $options->{pos} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'pos'} || 0
MC/DC100%1/1
$options->{'pos'} || 0
$options->{'pos'}
Truth table100%2/2
A
A= $options->{'pos'}
| |||||||||||||||||||||||||||||
| 36 | 50 | my $data = {}; | |||||||||||||||||||||||||||
| 37 | 50 | my $end; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 50 | ▶ | if (ref $bytes eq 'SCALAR') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 3 | my ($file, $r) = ($$bytes, 0); | |||||||||||||||||||||||||||
| 41 | 3 | $bytes = ''; | |||||||||||||||||||||||||||
| 42 | 3 | ▶ | open my $BYTES, '<', $file or croak "Can't decode DOCSIS file $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | while ($r = sysread $BYTES, my $buf, 131072, 0) { $bytes .= $buf } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 3 | ▶ | croak "Can't decode DOCSIS file $file: $!" unless defined $r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 3 | warn "[DOCSIS] Decode @{[length $bytes]} bytes from $file\n" if DEBUG; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 50 | local $DEPTH = $DEPTH + 1 if DEBUG; | |||||||||||||||||||||||||||
| 49 | 50 | ▶ | $end = $options->{end} || length $bytes; | ||||||||||||||||||||||||||
|
Condition66%2/3
$options->{'end'} || length $bytes
MC/DC0%0/2
$options->{'end'} || length $bytes
$options->{'end'}
length $bytes
Truth table66%2/3
A || B
A= $options->{'end'}B= length $bytes
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 50 | ▶ | while ($pos < $end) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 266 | ▶ | my $code = unpack 'C', substr $bytes, $pos++, 1 or next; # next on $code=0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 231 | my ($length, $t, $name, $syminfo, $value); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 231 | for (keys %$current) { | |||||||||||||||||||||||||||
| 56 | 2867 | ▶ | next unless $code == $current->{$_}{code}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 231 | $name = $_; | |||||||||||||||||||||||||||
| 58 | 231 | $syminfo = $current->{$_}; | |||||||||||||||||||||||||||
| 59 | 231 | last; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 231 | ▶ | unless ($name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | carp "[DOCSIS] Internal error: No syminfo defined for code=$code."; | |||||||||||||||||||||||||||
| 64 | 0 | next; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 231 | ▶ | unless ($syminfo->{lsize}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 16 | warn sprintf "[DOCSIS]%sDecode %s type=%s (0x%02x), len=0\n", join('', (' ' x $DEPTH)), | |||||||||||||||||||||||||||
| 69 | $name, $code, $code | ||||||||||||||||||||||||||||
| 70 | if DEBUG; | ||||||||||||||||||||||||||||
| 71 | 16 | next; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Document: PKT-SP-PROV1.5-I03-070412 | ||||||||||||||||||||||||||||
| 75 | # Chapter: 9.1 MTA Configuration File | ||||||||||||||||||||||||||||
| 76 | 215 | ▶ | $t = $syminfo->{lsize} == 1 ? 'C' : 'n'; # 1=C, 2=n | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 215 | $length = unpack $t, substr $bytes, $pos, $syminfo->{lsize}; | |||||||||||||||||||||||||||
| 78 | 215 | $pos += $syminfo->{lsize}; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | warn sprintf "[DOCSIS]%sDecode %s type=%s (0x%02x), len=%s, with %s()\n", | ||||||||||||||||||||||||||||
| 81 | 215 | join('', (' ' x $DEPTH)), $name, $code, $code, $length, $syminfo->{func} // 'unknown' | |||||||||||||||||||||||||||
| 82 | if DEBUG; | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 215 | ▶ | if ($syminfo->{nested}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 85 | 31 | local @$options{qw(blueprint end pos)} = ($syminfo->{nested}, $length + $pos, $pos); | |||||||||||||||||||||||||||
| 86 | 31 | $value = decode_docsis($bytes, $options); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | elsif (my $f = DOCSIS::ConfigFile::Decode->can($syminfo->{func})) { | ||||||||||||||||||||||||||||
| 89 | 184 | $value = $f->(substr $bytes, $pos, $length); | |||||||||||||||||||||||||||
| 90 | 184 | ▶ | $value = {oid => @$value{qw(oid type value)}} if $name eq 'SnmpMibObject'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||
| 93 | 0 | confess | |||||||||||||||||||||||||||
| 94 | qq(Can't locate object method "$syminfo->{func}" via package "DOCSIS::ConfigFile::Decode"); | ||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 215 | $pos += $length; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 215 | ▶ | if (!exists $data->{$name}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 100 | 201 | $data->{$name} = $value; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | elsif (ref $data->{$name} eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 103 | 4 | push @{$data->{$name}}, $value; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||
| 106 | 10 | $data->{$name} = [$data->{$name}, $value]; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 50 | return $data; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 80 | ▶ | sub encode_docsis { | ||||||||||||||||||||||||||
|
Subroutine
encode_docsis: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 80 | my ($data, $options) = @_; | |||||||||||||||||||||||||||
| 115 | 80 | ▶ | my $current = $options->{blueprint} || $CONFIG_TREE; | ||||||||||||||||||||||||||
|
Condition66%2/3
$options->{'blueprint'} || $DOCSIS::ConfigFile::CONFIG_TREE
MC/DC0%0/2
$options->{'blueprint'} || $DOCSIS::ConfigFile::CONFIG_TREE
$options->{'blueprint'}
$DOCSIS::ConfigFile::CONFIG_TREE
Truth table66%2/3
A || B
A= $options->{'blueprint'}B= $DOCSIS::ConfigFile::CONFIG_TREE
| |||||||||||||||||||||||||||||
| 116 | 80 | my $mic = {}; | |||||||||||||||||||||||||||
| 117 | 80 | my $bytes = ''; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 80 | ▶ | local $options->{depth} = ($options->{depth} || 0) + 1; | ||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'depth'} || 0
MC/DC100%1/1
$options->{'depth'} || 0
$options->{'depth'}
Truth table100%2/2
A
A= $options->{'depth'}
| |||||||||||||||||||||||||||||
| 120 | 80 | local $DEPTH = $options->{depth} if DEBUG; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 80 | ▶ | if ($options->{depth} == 1 and defined $options->{mta_algorithm}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$options->{"depth"} == 1 and defined $options->{"mta_algorithm"}
MC/DC100%2/2
$options->{"depth"} == 1 and defined $options->{"mta_algorithm"}
$options->{"depth"} == 1
defined $options->{"mta_algorithm"}
Truth table100%3/3
A and B
A= $options->{"depth"} == 1B= defined $options->{"mta_algorithm"}
| |||||||||||||||||||||||||||||
| 123 | 3 | delete $data->{MtaConfigDelimiter}; | |||||||||||||||||||||||||||
| 124 | 3 | $bytes .= encode_docsis({MtaConfigDelimiter => 1}, {depth => 1}); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 80 | for my $name (sort { $current->{$a}{code} <=> $current->{$b}{code} } keys %$current) { | |||||||||||||||||||||||||||
| 128 | 1383 | ▶ | next unless defined $data->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 213 | my $syminfo = $current->{$name}; | |||||||||||||||||||||||||||
| 130 | 213 | my ($type, $length, $value); | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 213 | for my $item (_to_list($data->{$name}, $syminfo)) { | |||||||||||||||||||||||||||
| 133 | 243 | ▶ | if ($syminfo->{nested}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 134 | 50 | warn "[DOCSIS]@{[' 'x$DEPTH]}Encode $name with encode_docsis\n" if DEBUG; | |||||||||||||||||||||||||||
| 135 | 50 | local @$options{qw(blueprint)} = ($current->{$name}{nested}); | |||||||||||||||||||||||||||
| 136 | 50 | $value = encode_docsis($item, $options); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | elsif (my $f = DOCSIS::ConfigFile::Encode->can($syminfo->{func})) { | ||||||||||||||||||||||||||||
| 139 | 193 | warn "[DOCSIS]@{[' 'x$DEPTH]}Encode $name with $syminfo->{func}\n" if DEBUG; | |||||||||||||||||||||||||||
| 140 | 193 | ▶ | if ($syminfo->{func} =~ /_list$/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 141 | 1 | $value = pack 'C*', $f->({value => _validate($item, $syminfo)}); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | elsif ($name eq 'SnmpMibObject') { | ||||||||||||||||||||||||||||
| 144 | 10 | my @k = qw(type value); | |||||||||||||||||||||||||||
| 145 | 10 | local $item->{oid} = $item->{oid}; | |||||||||||||||||||||||||||
| 146 | $value = pack 'C*', | ||||||||||||||||||||||||||||
| 147 | 10 | $f->({value => {oid => delete $item->{oid}, map { shift(@k), $_ } %$item}}); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | else { | ||||||||||||||||||||||||||||
| 150 | 182 | local $syminfo->{name} = $name; | |||||||||||||||||||||||||||
| 151 | 182 | $value = pack 'C*', $f->({value => _validate($item, $syminfo)}); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||
| 155 | 0 | confess | |||||||||||||||||||||||||||
| 156 | qq(Can't locate object method "$syminfo->{func}" via package "DOCSIS::ConfigFile::Encode"); | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||
| 160 | 17 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 161 | 241 | $type = pack 'C', $syminfo->{code}; | |||||||||||||||||||||||||||
| 162 | 241 | ▶ | $length = $syminfo->{lsize} == 2 ? pack('n', length $value) : pack('C', length $value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 240 | $mic->{$name} = "$type$length$value"; | |||||||||||||||||||||||||||
| 166 | 240 | $bytes .= $mic->{$name}; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 77 | ▶ | return $bytes if $options->{depth} != 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 19 | ▶ | return _mta_eof($bytes, $options) if defined $options->{mta_algorithm}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 16 | return _cm_eof($bytes, $mic, $options); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 16 | ▶ | sub _cm_eof { | ||||||||||||||||||||||||||
|
Subroutine
_cm_eof: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 176 | 16 | my $mic = $_[1]; | |||||||||||||||||||||||||||
| 177 | 16 | my $options = $_[2]; | |||||||||||||||||||||||||||
| 178 | 16 | my $cmts_mic = ''; | |||||||||||||||||||||||||||
| 179 | 16 | my $pads = 4 - (1 + length $_[0]) % 4; | |||||||||||||||||||||||||||
| 180 | 16 | my $eod_pad; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 16 | $mic->{CmMic} = pack('C*', 6, 16) . Digest::MD5::md5($_[0]); | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 16 | ▶ | $cmts_mic .= $mic->{$_} || '' for @CMTS_MIC; | ||||||||||||||||||||||||||
|
Condition100%2/2
$mic->{$_} || ''
MC/DC100%1/1
$mic->{$_} || ''
$mic->{$_}
Truth table100%2/2
A
A= $mic->{$_}
| |||||||||||||||||||||||||||||
| 185 | $cmts_mic | ||||||||||||||||||||||||||||
| 186 | 16 | ▶ | = pack('C*', 7, 16) . Digest::HMAC_MD5::hmac_md5($cmts_mic, $options->{shared_secret} || ''); | ||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'shared_secret'} || ''
MC/DC100%1/1
$options->{'shared_secret'} || ''
$options->{'shared_secret'}
Truth table100%2/2
A
A= $options->{'shared_secret'}
| |||||||||||||||||||||||||||||
| 187 | 16 | $eod_pad = pack('C', 255) . ("\0" x $pads); | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 16 | return $_[0] . $mic->{CmMic} . $cmts_mic . $eod_pad; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 3 | ▶ | sub _mta_eof { | ||||||||||||||||||||||||||
|
Subroutine
_mta_eof: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 193 | 3 | ▶ | my $mta_algorithm = $_[1]->{mta_algorithm} || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$_[1]{'mta_algorithm'} || ''
MC/DC100%1/1
$_[1]{'mta_algorithm'} || ''
$_[1]{'mta_algorithm'}
Truth table100%2/2
A
A= $_[1]{'mta_algorithm'}
| |||||||||||||||||||||||||||||
| 194 | 3 | my $hash = ''; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 3 | ▶ | if ($mta_algorithm) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 2 | ▶ | croak "mta_algorithm must be empty string, md5 or sha1." | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | unless $mta_algorithm =~ /^(md5|sha1)$/; | ||||||||||||||||||||||||||||
| 199 | 2 | ▶ | $hash = $mta_algorithm eq 'md5' ? Digest::MD5::md5_hex($_[0]) : Digest::SHA::sha1_hex($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 2 | $hash | |||||||||||||||||||||||||||
| 201 | = encode_docsis( | ||||||||||||||||||||||||||||
| 202 | {SnmpMibObject => {oid => '1.3.6.1.4.1.4491.2.2.1.1.2.7.0', STRING => "0x$hash"}}, | ||||||||||||||||||||||||||||
| 203 | {depth => 1}); | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 3 | return $hash . $_[0] . encode_docsis({MtaConfigDelimiter => 255}, {depth => 1}); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 213 | ▶ | sub _to_list { | ||||||||||||||||||||||||||
|
Subroutine
_to_list: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 210 | 213 | ▶ | return $_[0] if $_[1]->{func} =~ /_list$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 212 | ▶ | return @{$_[0]} if ref $_[0] eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 206 | return $_[0]; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # _validate($value, $syminfo); | ||||||||||||||||||||||||||||
| 216 | 183 | ▶ | sub _validate { | ||||||||||||||||||||||||||
|
Subroutine
_validate: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 217 | 183 | ▶ | if ($_[1]->{limit}[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 148 | ▶ | if ($_[0] =~ /^-?\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 143 | ▶ | croak "[DOCSIS] $_[1]->{name} holds a too high value. ($_[0])" if $_[1]->{limit}[1] < $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 142 | ▶ | croak "[DOCSIS] $_[1]->{name} holds a too low value. ($_[0])" if $_[0] < $_[1]->{limit}[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||
| 223 | 5 | ▶ | my $length = ref $_[0] eq 'ARRAY' ? @{$_[0]} : length $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 5 | ▶ | croak "[DOCSIS] $_[1]->{name} is too long. ($_[0])" if $_[1]->{limit}[1] < $length; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 5 | ▶ | croak "[DOCSIS] $_[1]->{name} is too short. ($_[0])" if $length < $_[1]->{limit}[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 181 | return $_[0]; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 17 | @CMTS_MIC = qw( | |||||||||||||||||||||||||||
| 232 | DownstreamFrequency UpstreamChannelId NetworkAccess | ||||||||||||||||||||||||||||
| 233 | ClassOfService BaselinePrivacy VendorSpecific | ||||||||||||||||||||||||||||
| 234 | CmMic MaxCPE TftpTimestamp | ||||||||||||||||||||||||||||
| 235 | TftpModemAddress UsPacketClass DsPacketClass | ||||||||||||||||||||||||||||
| 236 | UsServiceFlow DsServiceFlow MaxClassifiers | ||||||||||||||||||||||||||||
| 237 | GlobalPrivacyEnable PHS SubMgmtControl | ||||||||||||||||||||||||||||
| 238 | SubMgmtCpeTable SubMgmtFilters TestMode | ||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 17 | $CONFIG_TREE = { | |||||||||||||||||||||||||||
| 242 | BaselinePrivacy => { | ||||||||||||||||||||||||||||
| 243 | code => 17, | ||||||||||||||||||||||||||||
| 244 | func => 'nested', | ||||||||||||||||||||||||||||
| 245 | lsize => 1, | ||||||||||||||||||||||||||||
| 246 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 247 | nested => { | ||||||||||||||||||||||||||||
| 248 | AuthGraceTime => {code => 3, func => 'uint', lsize => 1, limit => [1, 6047999]}, | ||||||||||||||||||||||||||||
| 249 | AuthRejectTimeout => {code => 7, func => 'uint', lsize => 1, limit => [1, 600]}, | ||||||||||||||||||||||||||||
| 250 | AuthTimeout => {code => 1, func => 'uint', lsize => 1, limit => [1, 30]}, | ||||||||||||||||||||||||||||
| 251 | OperTimeout => {code => 4, func => 'uint', lsize => 1, limit => [1, 10]}, | ||||||||||||||||||||||||||||
| 252 | ReAuthTimeout => {code => 2, func => 'uint', lsize => 1, limit => [1, 30]}, | ||||||||||||||||||||||||||||
| 253 | ReKeyTimeout => {code => 5, func => 'uint', lsize => 1, limit => [1, 10]}, | ||||||||||||||||||||||||||||
| 254 | SAMapMaxRetries => {code => 9, func => 'uint', lsize => 1, limit => [0, 10]}, | ||||||||||||||||||||||||||||
| 255 | SAMapWaitTimeout => {code => 8, func => 'uint', lsize => 1, limit => [1, 10]}, | ||||||||||||||||||||||||||||
| 256 | TEKGraceTime => {code => 6, func => 'uint', lsize => 1, limit => [1, 302399]}, | ||||||||||||||||||||||||||||
| 257 | }, | ||||||||||||||||||||||||||||
| 258 | }, | ||||||||||||||||||||||||||||
| 259 | ClassOfService => { | ||||||||||||||||||||||||||||
| 260 | code => 4, | ||||||||||||||||||||||||||||
| 261 | func => 'nested', | ||||||||||||||||||||||||||||
| 262 | lsize => 1, | ||||||||||||||||||||||||||||
| 263 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 264 | nested => { | ||||||||||||||||||||||||||||
| 265 | ClassID => {code => 1, func => 'uchar', lsize => 1, limit => [1, 16]}, | ||||||||||||||||||||||||||||
| 266 | GuaranteedUp => {code => 5, func => 'uint', lsize => 1, limit => [0, 10000000]}, | ||||||||||||||||||||||||||||
| 267 | MaxBurstUp => {code => 6, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 268 | MaxRateDown => {code => 2, func => 'uint', lsize => 1, limit => [0, 52000000]}, | ||||||||||||||||||||||||||||
| 269 | MaxRateUp => {code => 3, func => 'uint', lsize => 1, limit => [0, 10000000]}, | ||||||||||||||||||||||||||||
| 270 | PriorityUp => {code => 4, func => 'uchar', lsize => 1, limit => [0, 7]}, | ||||||||||||||||||||||||||||
| 271 | PrivacyEnable => {code => 7, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 272 | }, | ||||||||||||||||||||||||||||
| 273 | }, | ||||||||||||||||||||||||||||
| 274 | CmMic => {code => 6, func => 'mic', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 275 | CmtsMic => {code => 7, func => 'mic', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 276 | CpeMacAddress => {code => 14, func => 'ether', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 277 | DocsisTwoEnable => {code => 39, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 278 | DownstreamFrequency => {code => 1, func => 'uint', lsize => 1, limit => [88000000, 860000000]}, | ||||||||||||||||||||||||||||
| 279 | DsChannelList => { | ||||||||||||||||||||||||||||
| 280 | code => 41, | ||||||||||||||||||||||||||||
| 281 | func => 'nested', | ||||||||||||||||||||||||||||
| 282 | lsize => 1, | ||||||||||||||||||||||||||||
| 283 | limit => [1, 255], | ||||||||||||||||||||||||||||
| 284 | nested => { | ||||||||||||||||||||||||||||
| 285 | DefaultScanTimeout => {code => 3, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 286 | DsFreqRange => { | ||||||||||||||||||||||||||||
| 287 | code => 2, | ||||||||||||||||||||||||||||
| 288 | func => 'nested', | ||||||||||||||||||||||||||||
| 289 | lsize => 1, | ||||||||||||||||||||||||||||
| 290 | limit => [1, 255], | ||||||||||||||||||||||||||||
| 291 | nested => { | ||||||||||||||||||||||||||||
| 292 | DsFreqRangeEnd => {code => 3, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 293 | DsFreqRangeStart => {code => 2, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 294 | DsFreqRangeStepSize => {code => 4, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 295 | DsFreqRangeTimeout => {code => 1, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 296 | }, | ||||||||||||||||||||||||||||
| 297 | }, | ||||||||||||||||||||||||||||
| 298 | SingleDsChannel => { | ||||||||||||||||||||||||||||
| 299 | code => 1, | ||||||||||||||||||||||||||||
| 300 | func => 'nested', | ||||||||||||||||||||||||||||
| 301 | lsize => 1, | ||||||||||||||||||||||||||||
| 302 | limit => [1, 255], | ||||||||||||||||||||||||||||
| 303 | nested => { | ||||||||||||||||||||||||||||
| 304 | SingleDsFrequency => {code => 2, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 305 | SingleDsTimeout => {code => 1, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 306 | }, | ||||||||||||||||||||||||||||
| 307 | }, | ||||||||||||||||||||||||||||
| 308 | }, | ||||||||||||||||||||||||||||
| 309 | }, | ||||||||||||||||||||||||||||
| 310 | DsPacketClass => { | ||||||||||||||||||||||||||||
| 311 | code => 23, | ||||||||||||||||||||||||||||
| 312 | func => 'nested', | ||||||||||||||||||||||||||||
| 313 | lsize => 1, | ||||||||||||||||||||||||||||
| 314 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 315 | nested => { | ||||||||||||||||||||||||||||
| 316 | ActivationState => {code => 6, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 317 | ClassifierId => {code => 2, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 318 | ClassifierRef => {code => 1, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 319 | DscAction => {code => 7, func => 'uchar', lsize => 1, limit => [0, 2]}, | ||||||||||||||||||||||||||||
| 320 | IEEE802Classifier => { | ||||||||||||||||||||||||||||
| 321 | code => 11, | ||||||||||||||||||||||||||||
| 322 | func => 'nested', | ||||||||||||||||||||||||||||
| 323 | lsize => 1, | ||||||||||||||||||||||||||||
| 324 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 325 | nested => { | ||||||||||||||||||||||||||||
| 326 | UserPriority => {code => 1, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 327 | VlanID => {code => 2, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 328 | }, | ||||||||||||||||||||||||||||
| 329 | }, | ||||||||||||||||||||||||||||
| 330 | IpPacketClassifier => { | ||||||||||||||||||||||||||||
| 331 | code => 9, | ||||||||||||||||||||||||||||
| 332 | func => 'nested', | ||||||||||||||||||||||||||||
| 333 | lsize => 1, | ||||||||||||||||||||||||||||
| 334 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 335 | nested => { | ||||||||||||||||||||||||||||
| 336 | DstPortEnd => {code => 10, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 337 | DstPortStart => {code => 9, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 338 | IpDstAddr => {code => 5, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 339 | IpDstMask => {code => 6, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 340 | IpProto => {code => 2, func => 'ushort', lsize => 1, limit => [0, 257]}, | ||||||||||||||||||||||||||||
| 341 | IpSrcAddr => {code => 3, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 342 | IpSrcMask => {code => 4, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 343 | IpTos => {code => 1, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 344 | SrcPortEnd => {code => 8, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 345 | SrcPortStart => {code => 7, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 346 | }, | ||||||||||||||||||||||||||||
| 347 | }, | ||||||||||||||||||||||||||||
| 348 | LLCPacketClassifier => { | ||||||||||||||||||||||||||||
| 349 | code => 10, | ||||||||||||||||||||||||||||
| 350 | func => 'nested', | ||||||||||||||||||||||||||||
| 351 | lsize => 1, | ||||||||||||||||||||||||||||
| 352 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 353 | nested => { | ||||||||||||||||||||||||||||
| 354 | DstMacAddress => {code => 1, func => 'ether', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 355 | EtherType => {code => 3, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 356 | SrcMacAddress => {code => 2, func => 'ether', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 357 | }, | ||||||||||||||||||||||||||||
| 358 | }, | ||||||||||||||||||||||||||||
| 359 | RulePriority => {code => 5, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 360 | ServiceFlowId => {code => 4, func => 'uint', lsize => 1, limit => [1, 4294967295]}, | ||||||||||||||||||||||||||||
| 361 | ServiceFlowRef => {code => 3, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 362 | }, | ||||||||||||||||||||||||||||
| 363 | }, | ||||||||||||||||||||||||||||
| 364 | DsServiceFlow => { | ||||||||||||||||||||||||||||
| 365 | code => 25, | ||||||||||||||||||||||||||||
| 366 | func => 'nested', | ||||||||||||||||||||||||||||
| 367 | lsize => 1, | ||||||||||||||||||||||||||||
| 368 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 369 | nested => { | ||||||||||||||||||||||||||||
| 370 | ActQosParamsTimeout => {code => 12, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 371 | AdmQosParamsTimeout => {code => 13, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 372 | DsServiceFlowId => {code => 2, func => 'uint', lsize => 1, limit => [1, 4294967295]}, | ||||||||||||||||||||||||||||
| 373 | DsServiceFlowRef => {code => 1, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 374 | DsVendorSpecific => {code => 43, func => 'vendor', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 375 | MaxDsLatency => {code => 14, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 376 | MaxRateSustained => {code => 8, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 377 | MaxTrafficBurst => {code => 9, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 378 | MinReservedRate => {code => 10, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 379 | MinResPacketSize => {code => 11, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 380 | QosParamSetType => {code => 6, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 381 | ServiceClassName => {code => 4, func => 'stringz', lsize => 1, limit => [2, 16]}, | ||||||||||||||||||||||||||||
| 382 | TrafficPriority => {code => 7, func => 'uchar', lsize => 1, limit => [0, 7]}, | ||||||||||||||||||||||||||||
| 383 | }, | ||||||||||||||||||||||||||||
| 384 | }, | ||||||||||||||||||||||||||||
| 385 | GenericTLV => {code => 255, func => 'no_value', lsize => 0, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 386 | GlobalPrivacyEnable => {code => 29, func => 'uchar', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 387 | MaxClassifiers => {code => 28, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 388 | MaxCPE => {code => 18, func => 'uchar', lsize => 1, limit => [1, 254]}, | ||||||||||||||||||||||||||||
| 389 | MfgCVCData => {code => 32, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 390 | ModemCapabilities => { | ||||||||||||||||||||||||||||
| 391 | code => 5, | ||||||||||||||||||||||||||||
| 392 | func => 'nested', | ||||||||||||||||||||||||||||
| 393 | lsize => 1, | ||||||||||||||||||||||||||||
| 394 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 395 | nested => { | ||||||||||||||||||||||||||||
| 396 | BaselinePrivacySupport => {code => 6, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 397 | ConcatenationSupport => {code => 1, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 398 | DCCSupport => {code => 12, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 399 | DownstreamSAIDSupport => {code => 7, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 400 | FragmentationSupport => {code => 3, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 401 | IGMPSupport => {code => 5, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 402 | ModemDocsisVersion => {code => 2, func => 'uchar', lsize => 1, limit => [0, 2]}, | ||||||||||||||||||||||||||||
| 403 | PHSSupport => {code => 4, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 404 | UpstreamSIDSupport => {code => 8, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 405 | }, | ||||||||||||||||||||||||||||
| 406 | }, | ||||||||||||||||||||||||||||
| 407 | MtaConfigDelimiter => {code => 254, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 408 | NetworkAccess => {code => 3, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 409 | PHS => { | ||||||||||||||||||||||||||||
| 410 | code => 26, | ||||||||||||||||||||||||||||
| 411 | func => 'nested', | ||||||||||||||||||||||||||||
| 412 | lsize => 1, | ||||||||||||||||||||||||||||
| 413 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 414 | nested => { | ||||||||||||||||||||||||||||
| 415 | PHSClassifierId => {code => 2, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 416 | PHSClassifierRef => {code => 1, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 417 | PHSField => {code => 7, func => 'hexstr', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 418 | PHSIndex => {code => 8, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 419 | PHSMask => {code => 9, func => 'hexstr', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 420 | PHSServiceFlowId => {code => 4, func => 'uint', lsize => 1, limit => [1, 4294967295]}, | ||||||||||||||||||||||||||||
| 421 | PHSServiceFlowRef => {code => 3, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 422 | PHSSize => {code => 10, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 423 | PHSVerify => {code => 11, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 424 | }, | ||||||||||||||||||||||||||||
| 425 | }, | ||||||||||||||||||||||||||||
| 426 | SnmpCpeAccessControl => {code => 55, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 427 | SnmpMibObject => {code => 11, func => 'snmp_object', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 428 | SnmpV3Kickstart => { | ||||||||||||||||||||||||||||
| 429 | code => 34, | ||||||||||||||||||||||||||||
| 430 | func => 'nested', | ||||||||||||||||||||||||||||
| 431 | lsize => 1, | ||||||||||||||||||||||||||||
| 432 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 433 | nested => { | ||||||||||||||||||||||||||||
| 434 | SnmpV3MgrPublicNumber => {code => 2, func => 'hexstr', lsize => 1, limit => [1, 514]}, | ||||||||||||||||||||||||||||
| 435 | SnmpV3SecurityName => {code => 1, func => 'string', lsize => 1, limit => [1, 16]}, | ||||||||||||||||||||||||||||
| 436 | }, | ||||||||||||||||||||||||||||
| 437 | }, | ||||||||||||||||||||||||||||
| 438 | SnmpV3TrapReceiver => { | ||||||||||||||||||||||||||||
| 439 | code => 38, | ||||||||||||||||||||||||||||
| 440 | func => 'nested', | ||||||||||||||||||||||||||||
| 441 | lsize => 1, | ||||||||||||||||||||||||||||
| 442 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 443 | nested => { | ||||||||||||||||||||||||||||
| 444 | SnmpV3TrapRxFilterOID => {code => 6, func => 'ushort', lsize => 1, limit => [1, 5]}, | ||||||||||||||||||||||||||||
| 445 | SnmpV3TrapRxIP => {code => 1, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 446 | SnmpV3TrapRxPort => {code => 2, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 447 | SnmpV3TrapRxRetries => {code => 5, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 448 | SnmpV3TrapRxSecurityName => {code => 7, func => 'string', lsize => 1, limit => [1, 16]}, | ||||||||||||||||||||||||||||
| 449 | SnmpV3TrapRxTimeout => {code => 4, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 450 | SnmpV3TrapRxType => {code => 3, func => 'ushort', lsize => 1, limit => [1, 5]}, | ||||||||||||||||||||||||||||
| 451 | }, | ||||||||||||||||||||||||||||
| 452 | }, | ||||||||||||||||||||||||||||
| 453 | SubMgmtControl => {code => 35, func => 'hexstr', lsize => 1, limit => [3, 3]}, | ||||||||||||||||||||||||||||
| 454 | SubMgmtCpeTable => {code => 36, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 455 | SubMgmtFilters => {code => 37, func => 'ushort_list', lsize => 1, limit => [0, 20]}, | ||||||||||||||||||||||||||||
| 456 | SwUpgradeFilename => {code => 9, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 457 | SwUpgradeServer => {code => 21, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 458 | TestMode => {code => 40, func => 'hexstr', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 459 | TftpModemAddress => {code => 20, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 460 | TftpTimestamp => {code => 19, func => 'uint', lsize => 1, limit => [0, 4294967295]}, | ||||||||||||||||||||||||||||
| 461 | UpstreamChannelId => {code => 2, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 462 | UsPacketClass => { | ||||||||||||||||||||||||||||
| 463 | code => 22, | ||||||||||||||||||||||||||||
| 464 | func => 'nested', | ||||||||||||||||||||||||||||
| 465 | lsize => 1, | ||||||||||||||||||||||||||||
| 466 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 467 | nested => { | ||||||||||||||||||||||||||||
| 468 | ActivationState => {code => 6, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 469 | ClassifierId => {code => 2, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 470 | ClassifierRef => {code => 1, func => 'uchar', lsize => 1, limit => [1, 255]}, | ||||||||||||||||||||||||||||
| 471 | DscAction => {code => 7, func => 'uchar', lsize => 1, limit => [0, 2]}, | ||||||||||||||||||||||||||||
| 472 | IEEE802Classifier => { | ||||||||||||||||||||||||||||
| 473 | code => 11, | ||||||||||||||||||||||||||||
| 474 | func => 'nested', | ||||||||||||||||||||||||||||
| 475 | lsize => 1, | ||||||||||||||||||||||||||||
| 476 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 477 | nested => { | ||||||||||||||||||||||||||||
| 478 | UserPriority => {code => 1, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 479 | VlanID => {code => 2, func => 'ushort', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 480 | }, | ||||||||||||||||||||||||||||
| 481 | }, | ||||||||||||||||||||||||||||
| 482 | IpPacketClassifier => { | ||||||||||||||||||||||||||||
| 483 | code => 9, | ||||||||||||||||||||||||||||
| 484 | func => 'nested', | ||||||||||||||||||||||||||||
| 485 | lsize => 1, | ||||||||||||||||||||||||||||
| 486 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 487 | nested => { | ||||||||||||||||||||||||||||
| 488 | DstPortEnd => {code => 10, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 489 | DstPortStart => {code => 9, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 490 | IpDstAddr => {code => 5, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 491 | IpDstMask => {code => 6, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 492 | IpProto => {code => 2, func => 'ushort', lsize => 1, limit => [0, 257]}, | ||||||||||||||||||||||||||||
| 493 | IpSrcAddr => {code => 3, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 494 | IpSrcMask => {code => 4, func => 'ip', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 495 | IpTos => {code => 1, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 496 | SrcPortEnd => {code => 8, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 497 | SrcPortStart => {code => 7, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | }, | ||||||||||||||||||||||||||||
| 500 | LLCPacketClassifier => { | ||||||||||||||||||||||||||||
| 501 | code => 10, | ||||||||||||||||||||||||||||
| 502 | func => 'nested', | ||||||||||||||||||||||||||||
| 503 | lsize => 1, | ||||||||||||||||||||||||||||
| 504 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 505 | nested => { | ||||||||||||||||||||||||||||
| 506 | DstMacAddress => {code => 1, func => 'ether', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 507 | EtherType => {code => 3, func => 'hexstr', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 508 | SrcMacAddress => {code => 2, func => 'ether', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 509 | }, | ||||||||||||||||||||||||||||
| 510 | }, | ||||||||||||||||||||||||||||
| 511 | RulePriority => {code => 5, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 512 | ServiceFlowId => {code => 4, func => 'uint', lsize => 1, limit => [1, 4294967295]}, | ||||||||||||||||||||||||||||
| 513 | ServiceFlowRef => {code => 3, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 514 | }, | ||||||||||||||||||||||||||||
| 515 | }, | ||||||||||||||||||||||||||||
| 516 | UsServiceFlow => { | ||||||||||||||||||||||||||||
| 517 | code => 24, | ||||||||||||||||||||||||||||
| 518 | func => 'nested', | ||||||||||||||||||||||||||||
| 519 | lsize => 1, | ||||||||||||||||||||||||||||
| 520 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 521 | nested => { | ||||||||||||||||||||||||||||
| 522 | ActQosParamsTimeout => {code => 12, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 523 | AdmQosParamsTimeout => {code => 13, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 524 | GrantsPerInterval => {code => 22, func => 'uchar', lsize => 1, limit => [0, 127]}, | ||||||||||||||||||||||||||||
| 525 | IpTosOverwrite => {code => 23, func => 'hexstr', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 526 | MaxConcatenatedBurst => {code => 14, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 527 | MaxRateSustained => {code => 8, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 528 | MaxTrafficBurst => {code => 9, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 529 | MinReservedRate => {code => 10, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 530 | MinResPacketSize => {code => 11, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 531 | NominalGrantInterval => {code => 20, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 532 | NominalPollInterval => {code => 17, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 533 | QosParamSetType => {code => 6, func => 'uchar', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 534 | RequestOrTxPolicy => {code => 16, func => 'hexstr', lsize => 1, limit => [0, 255]}, | ||||||||||||||||||||||||||||
| 535 | SchedulingType => {code => 15, func => 'uchar', lsize => 1, limit => [0, 6]}, | ||||||||||||||||||||||||||||
| 536 | ServiceClassName => {code => 4, func => 'stringz', lsize => 1, limit => [2, 16]}, | ||||||||||||||||||||||||||||
| 537 | ToleratedGrantJitter => {code => 21, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 538 | ToleratedPollJitter => {code => 18, func => 'uint', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 539 | TrafficPriority => {code => 7, func => 'uchar', lsize => 1, limit => [0, 7]}, | ||||||||||||||||||||||||||||
| 540 | UnsolicitedGrantSize => {code => 19, func => 'ushort', lsize => 1, limit => [0, 65535]}, | ||||||||||||||||||||||||||||
| 541 | UsServiceFlowId => {code => 2, func => 'uint', lsize => 1, limit => [1, 4294967295]}, | ||||||||||||||||||||||||||||
| 542 | UsServiceFlowRef => {code => 1, func => 'ushort', lsize => 1, limit => [1, 65535]}, | ||||||||||||||||||||||||||||
| 543 | UsVendorSpecific => {code => 43, func => 'vendor', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 544 | }, | ||||||||||||||||||||||||||||
| 545 | }, | ||||||||||||||||||||||||||||
| 546 | eRouter => { | ||||||||||||||||||||||||||||
| 547 | code => 202, | ||||||||||||||||||||||||||||
| 548 | func => 'nested', | ||||||||||||||||||||||||||||
| 549 | lsize => 1, | ||||||||||||||||||||||||||||
| 550 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 551 | nested => { | ||||||||||||||||||||||||||||
| 552 | InitializationMode => {code => 1, func => 'uchar', lsize => 1, limit => [0, 3]}, | ||||||||||||||||||||||||||||
| 553 | ManagementServer => { | ||||||||||||||||||||||||||||
| 554 | code => 2, | ||||||||||||||||||||||||||||
| 555 | func => 'nested', | ||||||||||||||||||||||||||||
| 556 | lsize => 1, | ||||||||||||||||||||||||||||
| 557 | limit => [0, 0], | ||||||||||||||||||||||||||||
| 558 | nested => { | ||||||||||||||||||||||||||||
| 559 | EnableCWMP => {code => 1, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 560 | URL => {code => 2, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 561 | Username => {code => 3, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 562 | Password => {code => 4, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 563 | ConnectionRequestUsername => {code => 5, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 564 | ConnectionRequestPassword => {code => 6, func => 'string', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 565 | ACSOverride => {code => 7, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 566 | }, | ||||||||||||||||||||||||||||
| 567 | }, | ||||||||||||||||||||||||||||
| 568 | InitializationModeOverride => {code => 3, func => 'uchar', lsize => 1, limit => [0, 1]}, | ||||||||||||||||||||||||||||
| 569 | }, | ||||||||||||||||||||||||||||
| 570 | }, | ||||||||||||||||||||||||||||
| 571 | VendorSpecific => {code => 43, func => 'vendor', lsize => 1, limit => [0, 0]}, | ||||||||||||||||||||||||||||
| 572 | }; | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | =encoding utf8 | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | =head1 NAME | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | DOCSIS::ConfigFile - Decodes and encodes DOCSIS config files | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | L<DOCSIS::ConfigFile> is a class which provides functionality to decode and | ||||||||||||||||||||||||||||
| 583 | encode L<DOCSIS|http://www.cablelabs.com> (Data over Cable Service Interface | ||||||||||||||||||||||||||||
| 584 | Specifications) config files. | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | This module is used as a layer between any human readable data and | ||||||||||||||||||||||||||||
| 587 | the binary structure. | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | The files are usually served using a L<TFTP server|Mojo::TFTPd>, after a | ||||||||||||||||||||||||||||
| 590 | L<cable modem|http://en.wikipedia.org/wiki/Cable_modem> or MTA (Multimedia | ||||||||||||||||||||||||||||
| 591 | Terminal Adapter) has recevied an IP address from a L<DHCP|Net::ISC::DHCPd> | ||||||||||||||||||||||||||||
| 592 | server. These files are L<binary encode|DOCSIS::ConfigFile::Encode> using a | ||||||||||||||||||||||||||||
| 593 | variety of functions, but all the data in the file are constructed by TLVs | ||||||||||||||||||||||||||||
| 594 | (type-length-value) blocks. These can be nested and concatenated. | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | See the source code or L<https://thorsen.pm/docsisious> for list of | ||||||||||||||||||||||||||||
| 597 | supported parameters. | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | use DOCSIS::ConfigFile qw(encode_docsis decode_docsis); | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | $data = decode_docsis $bytes; | ||||||||||||||||||||||||||||
| 604 | $bytes = encode_docsis({ | ||||||||||||||||||||||||||||
| 605 | GlobalPrivacyEnable => 1, | ||||||||||||||||||||||||||||
| 606 | MaxCPE => 2, | ||||||||||||||||||||||||||||
| 607 | NetworkAccess => 1, | ||||||||||||||||||||||||||||
| 608 | BaselinePrivacy => { | ||||||||||||||||||||||||||||
| 609 | AuthTimeout => 10, | ||||||||||||||||||||||||||||
| 610 | ReAuthTimeout => 10, | ||||||||||||||||||||||||||||
| 611 | AuthGraceTime => 600, | ||||||||||||||||||||||||||||
| 612 | OperTimeout => 1, | ||||||||||||||||||||||||||||
| 613 | ReKeyTimeout => 1, | ||||||||||||||||||||||||||||
| 614 | TEKGraceTime => 600, | ||||||||||||||||||||||||||||
| 615 | AuthRejectTimeout => 60, | ||||||||||||||||||||||||||||
| 616 | SAMapWaitTimeout => 1, | ||||||||||||||||||||||||||||
| 617 | SAMapMaxRetries => 4 | ||||||||||||||||||||||||||||
| 618 | }, | ||||||||||||||||||||||||||||
| 619 | SnmpMibObject => [ | ||||||||||||||||||||||||||||
| 620 | {oid => "1.3.6.1.4.1.1.77.1.6.1.1.6.2", INTEGER => 1}, | ||||||||||||||||||||||||||||
| 621 | {oid => "1.3.6.1.4.1.1429.77.1.6.1.1.6.2", STRING => "bootfile.bin"} | ||||||||||||||||||||||||||||
| 622 | ], | ||||||||||||||||||||||||||||
| 623 | VendorSpecific => {id => "0x0011ee", options => [30 => "0xff", 31 => "0x00", 32 => "0x28"]} | ||||||||||||||||||||||||||||
| 624 | }); | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | =head1 OPTIONAL MODULE | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | You can install the L<SNMP.pm|SNMP> module to translate between SNMP | ||||||||||||||||||||||||||||
| 629 | OID formats. With the module installed, you can define the C<SnmpMibObject> | ||||||||||||||||||||||||||||
| 630 | like the example below, instead of using numeric OIDs: | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | encode_docsis({ | ||||||||||||||||||||||||||||
| 633 | SnmpMibObject => [ | ||||||||||||||||||||||||||||
| 634 | {oid => "docsDevNmAccessIp.1", IPADDRESS => "10.0.0.1"}, | ||||||||||||||||||||||||||||
| 635 | {oid => "docsDevNmAccessIpMask.1", IPADDRESS => "255.255.255.255"}, | ||||||||||||||||||||||||||||
| 636 | ] | ||||||||||||||||||||||||||||
| 637 | }); | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | =head1 WEB APPLICATION | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | There is an example web application bundled with this distribution called | ||||||||||||||||||||||||||||
| 642 | "Docsisious". To run this application, you need to install L<Mojolicious> and | ||||||||||||||||||||||||||||
| 643 | L<YAML::XS>: | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | $ curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org DOCSIS::ConfigFile Mojolicious; | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | After installing the modules above, you can run the web app like this: | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | $ docsisious --listen http://*:8000; | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | And then open your favorite browser at L<http://localhost:8000>. To see a live | ||||||||||||||||||||||||||||
| 652 | demo, you can visit L<https://thorsen.pm/docsisious>. | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | =head2 decode_docsis | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | $data = decode_docsis($byte_string); | ||||||||||||||||||||||||||||
| 659 | $data = decode_docsis(\$path_to_file); | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | Used to decode a DOCSIS config file into a data structure. The output | ||||||||||||||||||||||||||||
| 662 | C<$data> can be used as input to L</encode_docsis>. Note: C<$data> | ||||||||||||||||||||||||||||
| 663 | will only contain array-refs if the DOCSIS parameter occur more than | ||||||||||||||||||||||||||||
| 664 | once. | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | =head2 encode_docsis | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | $byte_string = encode_docsis(\%data, \%args); | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | Used to encode a data structure into a DOCSIS config file. Each of the keys | ||||||||||||||||||||||||||||
| 671 | in C<$data> can either hold a hash- or array-ref. An array-ref is used if | ||||||||||||||||||||||||||||
| 672 | the same DOCSIS parameter occur multiple times. These two formats will result | ||||||||||||||||||||||||||||
| 673 | in the same C<$byte_string>: | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | # Only one SnmpMibObject | ||||||||||||||||||||||||||||
| 676 | encode_docsis({ | ||||||||||||||||||||||||||||
| 677 | SnmpMibObject => { | ||||||||||||||||||||||||||||
| 678 | oid => "1.3.6.1.4.1.1429.77.1.6.1.1.6.2", STRING => "bootfile.bin" | ||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||
| 680 | }) | ||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | # Allow one or more SnmpMibObjects | ||||||||||||||||||||||||||||
| 683 | encode_docsis({ | ||||||||||||||||||||||||||||
| 684 | SnmpMibObject => [ | ||||||||||||||||||||||||||||
| 685 | {oid => "1.3.6.1.4.1.1429.77.1.6.1.1.6.2", STRING => "bootfile.bin"} | ||||||||||||||||||||||||||||
| 686 | ] | ||||||||||||||||||||||||||||
| 687 | }) | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | Possible C<%args>: | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | =over 4 | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | =item * mta_algorithm | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | This argument is required when encoding MTA config files. Can be set to | ||||||||||||||||||||||||||||
| 696 | either empty string, "sha1" or "md5". | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | =item * shared_secret | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | This argument is optional, but will be used as the shared secret used to | ||||||||||||||||||||||||||||
| 701 | increase security between the cable modem and CMTS. | ||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||
| 703 | =back | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | Copyright (C) 2014-2018, Jan Henning Thorsen | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 710 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | =head1 CREDITS | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | =head2 Font Awesome | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | C<docsisious> bundles L<Font Awesome|https://fontawesome.com/>. | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | Jan Henning Thorsen - C<jhthorsen@cpan.org> | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | =cut | ||||||||||||||||||||||||||||