line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Radius::Dictionary; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
193438
|
use v5.10; |
|
4
|
|
|
|
|
30
|
|
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
79
|
|
5
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
120
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
21
|
use base qw(Class::Accessor::Fast); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
2166
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(attr_id attr_name const_name const_value vnd_name vnd_id)); |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
13367
|
use Data::Radius::DictionaryParser (); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
2240
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
60
|
my ($class, %h) = @_; |
14
|
6
|
|
|
|
|
307
|
return bless({ %h }, $class); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _combine_existing_dicts { |
18
|
1
|
|
|
1
|
|
3
|
my ($class, @dict_paths) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
3
|
my @existing_paths; |
21
|
1
|
|
|
|
|
3
|
foreach my $dict_path ( @dict_paths ) { |
22
|
2
|
50
|
|
|
|
73
|
if ( -r $dict_path ) { |
23
|
2
|
|
|
|
|
9
|
push @existing_paths => $dict_path; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
6
|
return @existing_paths ? [ map { '$INCLUDE ' . $_ } @existing_paths ] : undef; |
|
2
|
|
|
|
|
11
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub from_multiple_files { |
31
|
1
|
|
|
1
|
0
|
1102
|
my ($class, @files) = @_; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
6
|
my $arref_of_includes = $class->_combine_existing_dicts(@files); |
34
|
1
|
50
|
33
|
|
|
9
|
if ( !$arref_of_includes || !@{$arref_of_includes} ) { |
|
1
|
|
|
|
|
5
|
|
35
|
0
|
|
|
|
|
0
|
warn 'No usable RADIUS dictionaries was provided'; |
36
|
0
|
|
|
|
|
0
|
return undef; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
8
|
return Data::Radius::DictionaryParser->new() |
40
|
|
|
|
|
|
|
->parse_str_array($arref_of_includes); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub load_file { |
44
|
5
|
|
|
5
|
0
|
2794
|
my ($class, $file) = @_; |
45
|
5
|
|
|
|
|
43
|
return Data::Radius::DictionaryParser->new()->parse_file($file); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub attribute { |
49
|
21
|
|
|
21
|
0
|
11002
|
my ($self, $attr_name) = @_; |
50
|
21
|
50
|
|
|
|
58
|
return undef if (! $attr_name); |
51
|
|
|
|
|
|
|
# hash-ref with {id, type, vendor, parent} |
52
|
21
|
|
|
|
|
549
|
return $self->attr_name()->{ $attr_name }; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub attribute_name { |
56
|
3
|
|
|
3
|
0
|
6
|
my ($self, $vendor_name, $id) = @_; |
57
|
3
|
|
50
|
|
|
61
|
return $self->attr_id()->{ $vendor_name // '' }{$id}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub tlv_attribute_name { |
61
|
3
|
|
|
3
|
0
|
6
|
my ($self, $parent, $id) = @_; |
62
|
3
|
|
|
|
|
9
|
return $parent->{tlv_attr_id}{ $id }; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub vendor_id { |
66
|
5
|
|
|
5
|
0
|
12
|
my ($self, $vendor_name) = @_; |
67
|
5
|
100
|
|
|
|
15
|
return undef if (! $vendor_name); |
68
|
1
|
|
|
|
|
31
|
return $self->vnd_name()->{ $vendor_name }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub vendor_name { |
72
|
0
|
|
|
0
|
0
|
0
|
my ($self, $vendor_id) = @_; |
73
|
0
|
0
|
|
|
|
0
|
return undef if (! $vendor_id); |
74
|
0
|
|
|
|
|
0
|
return $self->vnd_id()->{ $vendor_id }; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# VALUE Service-Type Login-User 1 |
78
|
|
|
|
|
|
|
# Convert 'Login-User' to 1 |
79
|
|
|
|
|
|
|
sub value { |
80
|
1
|
|
|
1
|
0
|
4
|
my ($self, $attr_name, $const_name) = @_; |
81
|
1
|
50
|
|
|
|
4
|
return undef if (! defined $const_name); |
82
|
1
|
50
|
|
|
|
22
|
return $self->const_value()->{ $attr_name } ? $self->const_value()->{ $attr_name }{ $const_name } : undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub constant { |
86
|
1
|
|
|
1
|
0
|
4
|
my ($self, $attr_name, $const_value) = @_; |
87
|
1
|
50
|
|
|
|
4
|
return undef if (! defined $const_value); |
88
|
1
|
50
|
|
|
|
31
|
return $self->const_name()->{ $attr_name } ? $self->const_name()->{ $attr_name }{ $const_value } : undef; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |