line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::TacacsPlus::Packet::AuthorRequestBody; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::TacacsPlus::Packet::AuthorRequestBody - Tacacs+ authorization request body |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
The authorization REQUEST packet body |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
14
|
|
|
|
|
|
|
| authen_method | priv_lvl | authen_type | authen_service | |
15
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
16
|
|
|
|
|
|
|
| user len | port len | rem_addr len | arg_cnt | |
17
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
18
|
|
|
|
|
|
|
| arg 1 len | arg 2 len | ... | arg N len | |
19
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
20
|
|
|
|
|
|
|
| user ... |
21
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
22
|
|
|
|
|
|
|
| port ... |
23
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
24
|
|
|
|
|
|
|
| rem_addr ... |
25
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
26
|
|
|
|
|
|
|
| arg 1 ... |
27
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
28
|
|
|
|
|
|
|
| arg 2 ... |
29
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
30
|
|
|
|
|
|
|
| ... |
31
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
32
|
|
|
|
|
|
|
| arg N ... |
33
|
|
|
|
|
|
|
+----------------+----------------+----------------+----------------+ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
40
|
|
|
|
|
|
|
|
41
|
10
|
|
|
10
|
|
59
|
use strict; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
448
|
|
42
|
10
|
|
|
10
|
|
1168
|
use warnings; |
|
10
|
|
|
|
|
70
|
|
|
10
|
|
|
|
|
299
|
|
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
10
|
|
246
|
use 5.006; |
|
10
|
|
|
|
|
36
|
|
|
10
|
|
|
|
|
583
|
|
45
|
10
|
|
|
10
|
|
57
|
use Net::TacacsPlus::Constants 1.03; |
|
10
|
|
|
|
|
180
|
|
|
10
|
|
|
|
|
118
|
|
46
|
10
|
|
|
10
|
|
66
|
use Carp::Clan; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
122
|
|
47
|
|
|
|
|
|
|
|
48
|
10
|
|
|
10
|
|
2022
|
use base qw{ Class::Accessor::Fast }; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
8963
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw{ |
51
|
|
|
|
|
|
|
authen_method |
52
|
|
|
|
|
|
|
priv_lvl |
53
|
|
|
|
|
|
|
authen_type |
54
|
|
|
|
|
|
|
authen_service |
55
|
|
|
|
|
|
|
user |
56
|
|
|
|
|
|
|
port |
57
|
|
|
|
|
|
|
rem_addr |
58
|
|
|
|
|
|
|
args |
59
|
|
|
|
|
|
|
}); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 4 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item new( somekey => somevalue) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Construct tacacs+ authorization REQUEST packet body object |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Parameters: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
authen_method : TAC_PLUS_AUTHEN_METH_* |
72
|
|
|
|
|
|
|
priv_lvl : TAC_PLUS_PRIV_LVL_* |
73
|
|
|
|
|
|
|
authen_type : TAC_PLUS_AUTHEN_TYPE_* |
74
|
|
|
|
|
|
|
authen_service: TAC_PLUS_AUTHEN_SVC_* |
75
|
|
|
|
|
|
|
user : username |
76
|
|
|
|
|
|
|
port : port - default 'Virtual00' |
77
|
|
|
|
|
|
|
rem_addr : our ip address |
78
|
|
|
|
|
|
|
args : args arrayref |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new() { |
83
|
2
|
|
|
2
|
1
|
586
|
my $class = shift; |
84
|
2
|
|
|
|
|
16
|
my %params = @_; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#let the class accessor contruct the object |
87
|
2
|
|
|
|
|
21
|
my $self = $class->SUPER::new(\%params); |
88
|
|
|
|
|
|
|
|
89
|
2
|
100
|
|
|
|
35
|
if ($params{'raw_body'}) { |
90
|
1
|
|
|
|
|
6
|
$self->decode($params{'raw_body'}); |
91
|
1
|
|
|
|
|
2
|
delete $self->{'raw_body'}; |
92
|
1
|
|
|
|
|
4
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
50
|
|
|
|
7
|
$self->authen_method(TAC_PLUS_AUTHEN_METH_TACACSPLUS) if not defined $self->authen_method; |
96
|
1
|
50
|
|
|
|
21
|
$self->priv_lvl(TAC_PLUS_PRIV_LVL_MIN) if not defined $self->priv_lvl; |
97
|
1
|
50
|
|
|
|
21
|
$self->authen_type(TAC_PLUS_AUTHEN_TYPE_ASCII) if not defined $self->authen_type; |
98
|
1
|
50
|
|
|
|
11
|
$self->authen_service(TAC_PLUS_AUTHEN_SVC_LOGIN) if not defined $self->authen_service; |
99
|
1
|
50
|
|
|
|
11
|
$self->port('Virtual00') if not defined $self->port; |
100
|
1
|
50
|
|
|
|
12
|
$self->rem_addr('127.0.0.1') if not defined $self->rem_addr; |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
12
|
return $self; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item decode($raw_data) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Construct object from raw packet. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub decode { |
113
|
1
|
|
|
1
|
1
|
2
|
my ($self, $raw_data) = @_; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
3
|
my $length_user; |
116
|
|
|
|
|
|
|
my $length_port; |
117
|
0
|
|
|
|
|
0
|
my $length_rem_addr; |
118
|
0
|
|
|
|
|
0
|
my $args_count; |
119
|
0
|
|
|
|
|
0
|
my $payload; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
( |
122
|
1
|
|
|
|
|
10
|
$self->{'authen_method'}, |
123
|
|
|
|
|
|
|
$self->{'priv_lvl'}, |
124
|
|
|
|
|
|
|
$self->{'authen_type'}, |
125
|
|
|
|
|
|
|
$self->{'authen_service'}, |
126
|
|
|
|
|
|
|
$length_user, |
127
|
|
|
|
|
|
|
$length_port, |
128
|
|
|
|
|
|
|
$length_rem_addr, |
129
|
|
|
|
|
|
|
$args_count, |
130
|
|
|
|
|
|
|
$payload, |
131
|
|
|
|
|
|
|
) = unpack("C8a*", $raw_data); |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
7
|
my @args_unpack_strings = map { 'a'.$_ } unpack('C'.$args_count, $payload); |
|
3
|
|
|
|
|
9
|
|
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
4
|
$payload = substr($payload, $args_count); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
( |
138
|
1
|
|
|
|
|
11
|
$self->{'user'}, |
139
|
|
|
|
|
|
|
$self->{'port'}, |
140
|
|
|
|
|
|
|
$self->{'rem_addr'}, |
141
|
|
|
|
|
|
|
$payload, |
142
|
|
|
|
|
|
|
) = unpack( |
143
|
|
|
|
|
|
|
'a'.$length_user |
144
|
|
|
|
|
|
|
.'a'.$length_port |
145
|
|
|
|
|
|
|
.'a'.$length_rem_addr |
146
|
|
|
|
|
|
|
.'a*' |
147
|
|
|
|
|
|
|
, |
148
|
|
|
|
|
|
|
$payload |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
11
|
$self->{'args'} = [ unpack(join('', @args_unpack_strings), $payload) ]; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item raw() |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Return binary data of packet body. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub raw { |
162
|
1
|
|
|
1
|
1
|
1996
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
1
|
|
|
|
|
6
|
my $body = pack("C8", |
165
|
|
|
|
|
|
|
$self->{'authen_method'}, |
166
|
|
|
|
|
|
|
$self->{'priv_lvl'}, |
167
|
|
|
|
|
|
|
$self->{'authen_type'}, |
168
|
|
|
|
|
|
|
$self->{'authen_service'}, |
169
|
|
|
|
|
|
|
length($self->{'user'}), |
170
|
|
|
|
|
|
|
length($self->{'port'}), |
171
|
|
|
|
|
|
|
length($self->{'rem_addr'}), |
172
|
1
|
|
|
|
|
7
|
scalar(@{$self->{'args'}}), |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#add lengths of arguments |
176
|
1
|
|
|
|
|
4
|
$body .= pack("C".(scalar @{$self->{'args'}}), |
|
3
|
|
|
|
|
6
|
|
177
|
1
|
|
|
|
|
2
|
map { length($_) } @{$self->{'args'}} |
|
1
|
|
|
|
|
3
|
|
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
1
|
|
|
|
|
4
|
$body .= $self->{'user'} |
181
|
|
|
|
|
|
|
.$self->{'port'} |
182
|
|
|
|
|
|
|
.$self->{'rem_addr'} |
183
|
1
|
|
|
|
|
5
|
.join('', @{$self->{'args'}}) |
184
|
|
|
|
|
|
|
; |
185
|
|
|
|
|
|
|
|
186
|
1
|
|
|
|
|
3
|
return $body; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |