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