| 1 | package Data::Radius::Dictionary; | ||||||||||||||||||||||||||||
| 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 base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 7 | __PACKAGE__->mk_accessors(qw(attr_id attr_name const_name const_value vnd_name vnd_id)); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Data::Radius::DictionaryParser (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 9 | my ($class, %h) = @_; | |||||||||||||||||||||||||||
| 14 | 9 | return bless({ %h }, $class); | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub _combine_existing_dicts { | ||||||||||||||||||||||||||
|
Subroutine
_combine_existing_dicts: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 18 | 1 | my ($class, @dict_paths) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | my @existing_paths; | |||||||||||||||||||||||||||
| 21 | 1 | foreach my $dict_path ( @dict_paths ) { | |||||||||||||||||||||||||||
| 22 | 2 | ▶ | if ( -r $dict_path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | push @existing_paths => $dict_path; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | return @existing_paths ? [ map { '$INCLUDE ' . $_ } @existing_paths ] : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub from_multiple_files { | ||||||||||||||||||||||||||
|
Subroutine
from_multiple_files: called CC=3 SCAR=13.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 1 | my ($class, @files) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | my $arref_of_includes = $class->_combine_existing_dicts(@files); | |||||||||||||||||||||||||||
| 34 | 1 | ▶ | if ( !$arref_of_includes || !@{$arref_of_includes} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$arref_of_includes and @{$arref_of_includes;}
MC/DC0%0/2
$arref_of_includes and @{$arref_of_includes;}
$arref_of_includes
@{$arref_of_includes;}
Truth table33%1/3
A and B
A= $arref_of_includesB= @{$arref_of_includes;}
| |||||||||||||||||||||||||||||
| 35 | 0 | warn 'No usable RADIUS dictionaries was provided'; | |||||||||||||||||||||||||||
| 36 | 0 | return undef; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | return Data::Radius::DictionaryParser->new() | |||||||||||||||||||||||||||
| 40 | ->parse_str_array($arref_of_includes); | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 8 | ▶ | sub load_file { | ||||||||||||||||||||||||||
|
Subroutine
load_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 8 | my ($class, $file) = @_; | |||||||||||||||||||||||||||
| 45 | 8 | return Data::Radius::DictionaryParser->new()->parse_file($file); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 30 | ▶ | sub attribute { | ||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 30 | my ($self, $attr_name) = @_; | |||||||||||||||||||||||||||
| 50 | 30 | ▶ | return undef if (! $attr_name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | # hash-ref with {id, type, vendor, parent} | ||||||||||||||||||||||||||||
| 52 | 30 | return $self->attr_name()->{ $attr_name }; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 13 | ▶ | sub attribute_name { | ||||||||||||||||||||||||||
|
Subroutine
attribute_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 13 | my ($self, $vendor_name, $id) = @_; | |||||||||||||||||||||||||||
| 57 | 13 | ▶ | return $self->attr_id()->{ $vendor_name // '' }{$id}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$vendor_name // ""
MC/DC100%1/1
$vendor_name // ""
$vendor_name
Truth table100%2/2
A
A= $vendor_name
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 3 | ▶ | sub tlv_attribute_name { | ||||||||||||||||||||||||||
|
Subroutine
tlv_attribute_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 3 | my ($self, $parent, $id) = @_; | |||||||||||||||||||||||||||
| 62 | 3 | return $parent->{tlv_attr_id}{ $id }; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 14 | ▶ | sub vendor_id { | ||||||||||||||||||||||||||
|
Subroutine
vendor_id: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 14 | my ($self, $vendor_name) = @_; | |||||||||||||||||||||||||||
| 67 | 14 | ▶ | return undef if (! $vendor_name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 2 | return $self->vnd_name()->{ $vendor_name }; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub vendor_name { | ||||||||||||||||||||||||||
|
Subroutine
vendor_name: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 1 | my ($self, $vendor_id) = @_; | |||||||||||||||||||||||||||
| 73 | 1 | ▶ | return undef if (! $vendor_id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 1 | return $self->vnd_id()->{ $vendor_id }; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # VALUE Service-Type Login-User 1 | ||||||||||||||||||||||||||||
| 78 | # Convert 'Login-User' to 1 | ||||||||||||||||||||||||||||
| 79 | 5 | ▶ | sub value { | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 5 | my ($self, $attr_name, $const_name) = @_; | |||||||||||||||||||||||||||
| 81 | 5 | ▶ | return undef if (! defined $const_name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 5 | ▶ | return $self->const_value()->{ $attr_name } ? $self->const_value()->{ $attr_name }{ $const_name } : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 5 | ▶ | sub constant { | ||||||||||||||||||||||||||
|
Subroutine
constant: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 5 | my ($self, $attr_name, $const_value) = @_; | |||||||||||||||||||||||||||
| 87 | 5 | ▶ | return undef if (! defined $const_value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 5 | ▶ | return $self->const_name()->{ $attr_name } ? $self->const_name()->{ $attr_name }{ $const_value } : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 7 | 1; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||