| 1 | package Data::Radius::DictionaryParser; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use IO::File (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | # parser state | ||||||||||||||||||||||||||||||||||||||
| 14 | 7 | my $begin_vendor = undef; | |||||||||||||||||||||||||||||||||||||
| 15 | 7 | my $begin_tlv = undef; | |||||||||||||||||||||||||||||||||||||
| 16 | # map id to name, {vendor => {id => name}} | ||||||||||||||||||||||||||||||||||||||
| 17 | 7 | my %dict_id = (); | |||||||||||||||||||||||||||||||||||||
| 18 | # map name to id | ||||||||||||||||||||||||||||||||||||||
| 19 | 7 | my %dict_attr = (); | |||||||||||||||||||||||||||||||||||||
| 20 | 7 | my %dict_const_name = (); | |||||||||||||||||||||||||||||||||||||
| 21 | 7 | my %dict_const_value = (); | |||||||||||||||||||||||||||||||||||||
| 22 | 7 | my %dict_vendor_name = (); | |||||||||||||||||||||||||||||||||||||
| 23 | 7 | my %dict_vendor_id = (); | |||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 7 | my %included_files = (); | |||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 28 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||
| 29 | 9 | cleanup(); | |||||||||||||||||||||||||||||||||||||
| 30 | 9 | return bless {}, $class; | |||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | 9 | ▶ | sub _create_dict_from_current_state { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_dict_from_current_state: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 34 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | 9 | return Data::Radius::Dictionary->new( | |||||||||||||||||||||||||||||||||||||
| 37 | attr_id => { %dict_id }, | ||||||||||||||||||||||||||||||||||||||
| 38 | attr_name => { %dict_attr }, | ||||||||||||||||||||||||||||||||||||||
| 39 | const_name => { %dict_const_name }, | ||||||||||||||||||||||||||||||||||||||
| 40 | const_value => { %dict_const_value }, | ||||||||||||||||||||||||||||||||||||||
| 41 | vnd_name => { %dict_vendor_name }, | ||||||||||||||||||||||||||||||||||||||
| 42 | vnd_id => { %dict_vendor_id }, | ||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub parse_str_array { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_str_array: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my ($self, $str_array) = @_; | |||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my $synthetic_fname = md5_hex( @{$str_array} ); | |||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | return if ( $included_files{$synthetic_fname} ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $included_files{$synthetic_fname} = 1; | |||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | # since it's not file on disk, all $INCLUDEs are built relative to CWD | ||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | my $include_dir = $ENV{PWD} // '/'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"PWD"} // "/"
MC/DC0%0/1
$ENV{"PWD"} // "/"
$ENV{"PWD"}
Truth table50%1/2
A
A= $ENV{"PWD"}
| |||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | 1 | for my $line ( @{$str_array} ) { | |||||||||||||||||||||||||||||||||||||
| 57 | 2 | $self->_parse_line($line, $include_dir); | |||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | 1 | return $self->_create_dict_from_current_state; | |||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | sub parse_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 64 | 8 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||
| 65 | 8 | $self->_load_file($file); | |||||||||||||||||||||||||||||||||||||
| 66 | 8 | return $self->_create_dict_from_current_state; | |||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | 173 | ▶ | sub _load_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_file: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||
| 70 | 173 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | 173 | ▶ | return undef if ( $included_files{$file} ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | 173 | ▶ | my $fh = IO::File->new($file, 'r') | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'IO::File'->new($file, 'r') || warn(sprintf('Failed to open file "%s": %s', $file, $!))
MC/DC0%0/1
'IO::File'->new($file, 'r') || warn(sprintf('Failed to open file "%s": %s', $file, $!))
'IO::File'->new($file, 'r')
Truth table50%1/2
A
A= 'IO::File'->new($file, 'r')
| |||||||||||||||||||||||||||||||||||||||
| 75 | || warn sprintf('Failed to open file "%s": %s', $file, $!); | ||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | 173 | $included_files{$file} = 1; | |||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | # INCLUDEs must be treated relatively to current file | ||||||||||||||||||||||||||||||||||||||
| 80 | 173 | my $include_dir = File::Basename::dirname($file); | |||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | 173 | ▶ | while ( my $line = $fh->getline ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | 24376 | $self->_parse_line($line, $include_dir); | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | 173 | $fh->close; | |||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||
| 88 | 173 | return 1; | |||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | sub cleanup { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 92 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | 9 | $begin_vendor = undef; | |||||||||||||||||||||||||||||||||||||
| 95 | 9 | $begin_tlv = undef; | |||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | 9 | %dict_id = (); | |||||||||||||||||||||||||||||||||||||
| 98 | 9 | %dict_attr = (); | |||||||||||||||||||||||||||||||||||||
| 99 | 9 | %dict_const_name = (); | |||||||||||||||||||||||||||||||||||||
| 100 | 9 | %dict_const_value = (); | |||||||||||||||||||||||||||||||||||||
| 101 | 9 | %dict_vendor_name = (); | |||||||||||||||||||||||||||||||||||||
| 102 | 9 | %dict_vendor_id = (); | |||||||||||||||||||||||||||||||||||||
| 103 | 9 | %included_files = (); | |||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | 9 | return undef; | |||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | 24378 | ▶ | sub _parse_line { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_line: called CC=27 SCAR=35.1
| |||||||||||||||||||||||||||||||||||||||
| 109 | 24378 | my ($self, $line, $include_dir) = @_; | |||||||||||||||||||||||||||||||||||||
| 110 | 24378 | ▶ | $include_dir //= $ENV{PWD}; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$include_dir //= $ENV{"PWD"}
MC/DC0%0/2
$include_dir //= $ENV{"PWD"}
$include_dir
$ENV{"PWD"}
Truth table33%1/3
A //= B
A= $include_dirB= $ENV{"PWD"}
| |||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | 24378 | my ($cmd, $name, $id, $type, $vendor, $has_tag, $has_options, $encrypt); | |||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | 24378 | $line =~ s/#.*$//; | |||||||||||||||||||||||||||||||||||||
| 115 | 24378 | ▶ | return undef if ( $line =~ /^\s*$/ ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 116 | 19148 | chomp $line; | |||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 19148 | ($cmd, $name, $id, $type, $vendor) = split(/\s+/, $line); | |||||||||||||||||||||||||||||||||||||
| 119 | 19148 | $cmd = lc($cmd); | |||||||||||||||||||||||||||||||||||||
| 120 | 19148 | $has_options = 0; | |||||||||||||||||||||||||||||||||||||
| 121 | 19148 | $has_tag = 0; | |||||||||||||||||||||||||||||||||||||
| 122 | 19148 | $encrypt = undef; | |||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | 19148 | ▶ | if ($cmd eq 'attribute') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 125 | # 'vendor' part can be an options - in FreeRADIUS dictionary format | ||||||||||||||||||||||||||||||||||||||
| 126 | 9006 | ▶ | if ($vendor) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 127 | # there could be combination of both options: | ||||||||||||||||||||||||||||||||||||||
| 128 | 2466 | ▶ | if ($vendor =~ /has_tag/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 129 | 273 | $has_tag = 1; | |||||||||||||||||||||||||||||||||||||
| 130 | 273 | $has_options = 1; | |||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||
| 132 | 2466 | ▶ | if ($vendor =~ /encrypt=(\d)/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 133 | #TODO encryption methods not supported now | ||||||||||||||||||||||||||||||||||||||
| 134 | 140 | $encrypt = $1; | |||||||||||||||||||||||||||||||||||||
| 135 | 140 | $has_options = 1; | |||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||
| 138 | 2466 | ▶ | if ($has_options) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 139 | 406 | $vendor = undef; | |||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | 9006 | ▶ | $vendor ||= $begin_vendor; | ||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$vendor ||= $begin_vendor
MC/DC100%2/2
$vendor ||= $begin_vendor
$vendor
$begin_vendor
Truth table100%3/3
A ||= B
A= $vendorB= $begin_vendor
| |||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||
| 145 | 9006 | ▶ | if (exists $dict_attr{ $name }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 146 | 0 | warn "Duplicated attribute name $name"; | |||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | 9006 | my $a_info = { | |||||||||||||||||||||||||||||||||||||
| 150 | id => $id, | ||||||||||||||||||||||||||||||||||||||
| 151 | name => $name, | ||||||||||||||||||||||||||||||||||||||
| 152 | type => $type, | ||||||||||||||||||||||||||||||||||||||
| 153 | vendor => $vendor, | ||||||||||||||||||||||||||||||||||||||
| 154 | has_tag => $has_tag, | ||||||||||||||||||||||||||||||||||||||
| 155 | encrypt => $encrypt, | ||||||||||||||||||||||||||||||||||||||
| 156 | }; | ||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 9006 | $dict_attr{ $name } = $a_info; | |||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||
| 160 | 9006 | ▶ | if ($begin_tlv) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 161 | 371 | $a_info->{parent} = $begin_tlv; | |||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | 371 | my $parent = $dict_attr{ $begin_tlv }; | |||||||||||||||||||||||||||||||||||||
| 164 | 371 | $parent->{tlv_attr_name}{ $name } = $a_info; | |||||||||||||||||||||||||||||||||||||
| 165 | 371 | $parent->{tlv_attr_id}{ $id } = $a_info; | |||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||
| 167 | else { | ||||||||||||||||||||||||||||||||||||||
| 168 | 8635 | ▶ | $dict_id{ $vendor // '' }{ $id } = $a_info; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$vendor // ""
MC/DC100%1/1
$vendor // ""
$vendor
Truth table100%2/2
A
A= $vendor
| |||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||
| 171 | elsif ($cmd eq 'value') { | ||||||||||||||||||||||||||||||||||||||
| 172 | # VALUE NAS-Port-Type Ethernet 15 | ||||||||||||||||||||||||||||||||||||||
| 173 | 9646 | my ($v_name, $v_val) = ($id, $type); | |||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | 9646 | ▶ | if (! exists $dict_attr{ $name }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 176 | 0 | warn "Value for unknown attribute $name"; | |||||||||||||||||||||||||||||||||||||
| 177 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | 9646 | $dict_const_name{$name}{$v_val} = $v_name; | |||||||||||||||||||||||||||||||||||||
| 181 | 9646 | $dict_const_value{$name}{$v_name} = $v_val; | |||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||
| 183 | elsif ($cmd eq 'vendor') { | ||||||||||||||||||||||||||||||||||||||
| 184 | # VENDOR Mikrotik 14988 | ||||||||||||||||||||||||||||||||||||||
| 185 | 121 | $dict_vendor_name{ $name } = $id; | |||||||||||||||||||||||||||||||||||||
| 186 | 121 | $dict_vendor_id{ $id } = $name; | |||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||
| 188 | elsif ($cmd eq 'begin-vendor') { | ||||||||||||||||||||||||||||||||||||||
| 189 | # BEGIN-VENDOR Huawei | ||||||||||||||||||||||||||||||||||||||
| 190 | 63 | ▶ | if (! exists $dict_vendor_name{ $name }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 191 | 0 | warn "BEGIN-VENDOR $name - vendor id is unknown"; | |||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||
| 193 | # set default vendor for all attributes below | ||||||||||||||||||||||||||||||||||||||
| 194 | 63 | $begin_vendor = $name; | |||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||
| 196 | elsif ($cmd eq 'end-vendor') { | ||||||||||||||||||||||||||||||||||||||
| 197 | # END-VENDOR Laurel | ||||||||||||||||||||||||||||||||||||||
| 198 | 63 | ▶ | if (! $begin_vendor) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 199 | 0 | warn "END-VENDOR found without BEGIN-VENDOR"; | |||||||||||||||||||||||||||||||||||||
| 200 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||
| 202 | 63 | $begin_vendor = undef; | |||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||
| 204 | elsif ($cmd eq 'begin-tlv') { | ||||||||||||||||||||||||||||||||||||||
| 205 | 42 | ▶ | if ($begin_tlv) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 206 | # no support for 2nd level | ||||||||||||||||||||||||||||||||||||||
| 207 | 0 | warn "Nested BEGIN-TLV found"; | |||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | # BEGIN-TLV WiMAX-PPAC | ||||||||||||||||||||||||||||||||||||||
| 211 | # must be defined attribute with type 'tlv' first | ||||||||||||||||||||||||||||||||||||||
| 212 | 42 | ▶ | if (! exists $dict_attr{ $name }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 213 | 0 | warn "Begin-tlv for unknown attribute $name"; | |||||||||||||||||||||||||||||||||||||
| 214 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||
| 216 | 42 | ▶ | if ($dict_attr{ $name }{type} ne 'tlv') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 217 | 0 | warn "Begin-tlv for attribute $name of non-tlv type"; | |||||||||||||||||||||||||||||||||||||
| 218 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||
| 220 | 42 | $begin_tlv = $name; | |||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||
| 222 | elsif ($cmd eq 'end-tlv') { | ||||||||||||||||||||||||||||||||||||||
| 223 | # END-TLV WiMAX-PPAC | ||||||||||||||||||||||||||||||||||||||
| 224 | 42 | ▶ | if (! $begin_tlv) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 225 | 0 | warn "END-TLV found without BEGIN-TLV"; | |||||||||||||||||||||||||||||||||||||
| 226 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||
| 228 | 42 | $begin_tlv = undef; | |||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||
| 230 | elsif ($cmd eq '$include') { | ||||||||||||||||||||||||||||||||||||||
| 231 | # $INCLUDE mikrotik | ||||||||||||||||||||||||||||||||||||||
| 232 | # $INCLUDE /absolute/path/to/mikrotik | ||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||
| 234 | # clear modifiers | ||||||||||||||||||||||||||||||||||||||
| 235 | 165 | ($begin_vendor, $begin_tlv) = (); | |||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||
| 237 | 165 | ▶ | if (File::Spec->file_name_is_absolute($name)) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 238 | 4 | $self->_load_file($name); | |||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | else { | ||||||||||||||||||||||||||||||||||||||
| 241 | 161 | $self->_load_file( File::Spec->catfile($include_dir, $name) ); | |||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||
| 244 | else { | ||||||||||||||||||||||||||||||||||||||
| 245 | 0 | warn "Unknown command: $cmd"; | |||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | 19148 | return undef; | |||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||
| 252 | 7 | 1; | |||||||||||||||||||||||||||||||||||||