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_01'; |
40
|
|
|
|
|
|
|
|
41
|
10
|
|
|
10
|
|
40
|
use strict; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
360
|
|
42
|
10
|
|
|
10
|
|
42
|
use warnings; |
|
10
|
|
|
|
|
40
|
|
|
10
|
|
|
|
|
228
|
|
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
10
|
|
145
|
use 5.006; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
415
|
|
45
|
10
|
|
|
10
|
|
43
|
use Net::TacacsPlus::Constants 1.03; |
|
10
|
|
|
|
|
145
|
|
|
10
|
|
|
|
|
81
|
|
46
|
10
|
|
|
10
|
|
44
|
use Carp::Clan; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
48
|
|
47
|
|
|
|
|
|
|
|
48
|
10
|
|
|
10
|
|
1372
|
use base qw{ Class::Accessor::Fast }; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
5073
|
|
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
|
463
|
my $class = shift; |
84
|
2
|
|
|
|
|
9
|
my %params = @_; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#let the class accessor contruct the object |
87
|
2
|
|
|
|
|
13
|
my $self = $class->SUPER::new(\%params); |
88
|
|
|
|
|
|
|
|
89
|
2
|
100
|
|
|
|
23
|
if ($params{'raw_body'}) { |
90
|
1
|
|
|
|
|
4
|
$self->decode($params{'raw_body'}); |
91
|
1
|
|
|
|
|
2
|
delete $self->{'raw_body'}; |
92
|
1
|
|
|
|
|
3
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
50
|
|
|
|
8
|
$self->authen_method(TAC_PLUS_AUTHEN_METH_TACACSPLUS) if not defined $self->authen_method; |
96
|
1
|
50
|
|
|
|
13
|
$self->priv_lvl(TAC_PLUS_PRIV_LVL_MIN) if not defined $self->priv_lvl; |
97
|
1
|
50
|
|
|
|
8
|
$self->authen_type(TAC_PLUS_AUTHEN_TYPE_ASCII) if not defined $self->authen_type; |
98
|
1
|
50
|
|
|
|
7
|
$self->authen_service(TAC_PLUS_AUTHEN_SVC_LOGIN) if not defined $self->authen_service; |
99
|
1
|
50
|
|
|
|
7
|
$self->port('Virtual00') if not defined $self->port; |
100
|
1
|
50
|
|
|
|
6
|
$self->rem_addr('127.0.0.1') if not defined $self->rem_addr; |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
7
|
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
|
1
|
my ($self, $raw_data) = @_; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
2
|
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
|
|
|
|
|
9
|
$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
|
|
|
|
|
5
|
my @args_unpack_strings = map { 'a'.$_ } unpack('C'.$args_count, $payload); |
|
3
|
|
|
|
|
6
|
|
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
4
|
$payload = substr($payload, $args_count); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
( |
138
|
1
|
|
|
|
|
9
|
$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
|
|
|
|
|
8
|
$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
|
1488
|
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
|
|
|
|
|
5
|
scalar(@{$self->{'args'}}), |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#add lengths of arguments |
176
|
1
|
|
|
|
|
3
|
$body .= pack("C".(scalar @{$self->{'args'}}), |
|
3
|
|
|
|
|
5
|
|
177
|
1
|
|
|
|
|
2
|
map { length($_) } @{$self->{'args'}} |
|
1
|
|
|
|
|
2
|
|
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
1
|
|
|
|
|
3
|
$body .= $self->{'user'} |
181
|
|
|
|
|
|
|
.$self->{'port'} |
182
|
|
|
|
|
|
|
.$self->{'rem_addr'} |
183
|
1
|
|
|
|
|
4
|
.join('', @{$self->{'args'}}) |
184
|
|
|
|
|
|
|
; |
185
|
|
|
|
|
|
|
|
186
|
1
|
|
|
|
|
3
|
return $body; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |