| 1 | package Net::TacacsPlus::Packet::AuthenReplyBody; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Net::TacacsPlus::Packet::AuthenReplyBody - Tacacs+ authentication replay body | ||||||||||
| 6 | |||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||
| 8 | |||||||||||
| 9 | 7. The authentication REPLY packet body | ||||||||||
| 10 | |||||||||||
| 11 | The TACACS+ daemon sends only one type of authentication packet (a | ||||||||||
| 12 | REPLY packet) to the client. The REPLY packet body looks as follows: | ||||||||||
| 13 | |||||||||||
| 14 | 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 | ||||||||||
| 15 | |||||||||||
| 16 | +----------------+----------------+----------------+----------------+ | ||||||||||
| 17 | | status | flags | server_msg len | | ||||||||||
| 18 | +----------------+----------------+----------------+----------------+ | ||||||||||
| 19 | | data len | server_msg ... | ||||||||||
| 20 | +----------------+----------------+----------------+----------------+ | ||||||||||
| 21 | | data ... | ||||||||||
| 22 | +----------------+----------------+ | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 11 | our $VERSION = '1.10'; | |||||||||
| 28 | |||||||||||
| 29 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | 11 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 11 | ▶ | use Net::TacacsPlus::Constants 1.03; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 11 | ▶ | use Carp::Clan; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 11 | ▶ | use base qw{ Class::Accessor::Fast }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 11 | __PACKAGE__->mk_accessors(qw{ | |||||||||
| 39 | status | ||||||||||
| 40 | flags | ||||||||||
| 41 | server_msg | ||||||||||
| 42 | data | ||||||||||
| 43 | }); | ||||||||||
| 44 | |||||||||||
| 45 | =head1 METHODS | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item new( somekey => somevalue) | ||||||||||
| 50 | |||||||||||
| 51 | Construct tacacs+ authentication packet body object | ||||||||||
| 52 | |||||||||||
| 53 | Parameters: | ||||||||||
| 54 | |||||||||||
| 55 | 'raw_body': raw body | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 60 | 2 | my $class = shift; | |||||||||
| 61 | 2 | my %params = @_; | |||||||||
| 62 | |||||||||||
| 63 | #let the class accessor contruct the object | ||||||||||
| 64 | 2 | my $self = $class->SUPER::new(\%params); | |||||||||
| 65 | |||||||||||
| 66 | 2 | ▶ | if ($params{'raw_body'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 1 | $self->decode($params{'raw_body'}); | |||||||||
| 68 | 1 | delete $self->{'raw_body'}; | |||||||||
| 69 | 1 | return $self; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | # set default values | ||||||||||
| 73 | 1 | ▶ | $self->server_msg('') if not defined $self->server_msg; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 1 | ▶ | $self->data('') if not defined $self->data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | |||||||||||
| 76 | 1 | return $self; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | =item decode($raw_data) | ||||||||||
| 80 | |||||||||||
| 81 | Extract $server_msg and data from raw packet. | ||||||||||
| 82 | |||||||||||
| 83 | =cut | ||||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | sub decode { | ||||||||
|
Subroutine
decode: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 86 | 1 | my ($self, $raw_data) = @_; | |||||||||
| 87 | |||||||||||
| 88 | 1 | my ($server_msg_len,$data_len,$payload); | |||||||||
| 89 | |||||||||||
| 90 | ( | ||||||||||
| 91 | $self->{'status'}, | ||||||||||
| 92 | 1 | $self->{'flags'}, | |||||||||
| 93 | $server_msg_len, | ||||||||||
| 94 | $data_len, | ||||||||||
| 95 | $payload, | ||||||||||
| 96 | ) = unpack("CCnna*", $raw_data); | ||||||||||
| 97 | |||||||||||
| 98 | 1 | ▶ | $payload = '' if not defined $payload; #payload can be empty | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | |||||||||||
| 100 | ( | ||||||||||
| 101 | $self->{'server_msg'}, | ||||||||||
| 102 | 1 | $self->{'data'} | |||||||||
| 103 | ) = unpack("a".$server_msg_len."a".$data_len,$payload); | ||||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | =item raw() | ||||||||||
| 108 | |||||||||||
| 109 | Return binary data of packet body. | ||||||||||
| 110 | |||||||||||
| 111 | =cut | ||||||||||
| 112 | |||||||||||
| 113 | 1 | ▶ | sub raw { | ||||||||
|
Subroutine
raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 114 | 1 | my $self = shift; | |||||||||
| 115 | |||||||||||
| 116 | my $body = pack("CCnna*a*", | ||||||||||
| 117 | $self->{'status'}, | ||||||||||
| 118 | $self->{'flags'}, | ||||||||||
| 119 | length($self->{'server_msg'}), | ||||||||||
| 120 | length($self->{'data'}), | ||||||||||
| 121 | $self->{'server_msg'}, | ||||||||||
| 122 | 1 | $self->{'data'}, | |||||||||
| 123 | ); | ||||||||||
| 124 | |||||||||||
| 125 | 1 | return $body; | |||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | 11 | 1; | |||||||||
| 129 | |||||||||||
| 130 | =back | ||||||||||
| 131 | |||||||||||
| 132 | =cut | ||||||||||
| 133 | |||||||||||