| 1 | # | ||||||||||
| 2 | # $Id: PPPLCP.pm 5 2015-01-14 06:47:16Z gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::PPPLCP; | ||||||||||
| 5 | 3 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '1.01'; | |||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use Net::Frame::Layer qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||
| 12 | |||||||||||
| 13 | 3 | our %EXPORT_TAGS = ( | |||||||||
| 14 | consts => [qw( | ||||||||||
| 15 | NF_PPPLCP_HDR_LEN | ||||||||||
| 16 | NF_PPPLCP_CODE_ECHO_REQUEST | ||||||||||
| 17 | NF_PPPLCP_CODE_ECHO_REPLY | ||||||||||
| 18 | )], | ||||||||||
| 19 | ); | ||||||||||
| 20 | our @EXPORT_OK = ( | ||||||||||
| 21 | 3 | @{$EXPORT_TAGS{consts}}, | |||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | use constant NF_PPPLCP_HDR_LEN => 8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 3 | ▶ | use constant NF_PPPLCP_CODE_ECHO_REQUEST => 0x09; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 3 | ▶ | use constant NF_PPPLCP_CODE_ECHO_REPLY => 0x0a; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 3 | our @AS = qw( | |||||||||
| 29 | code | ||||||||||
| 30 | identifier | ||||||||||
| 31 | length | ||||||||||
| 32 | magicNumber | ||||||||||
| 33 | ); | ||||||||||
| 34 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||
| 35 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 36 | |||||||||||
| 37 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | shift->SUPER::new( | ||||||||||
| 39 | 1 | code => NF_PPPLCP_CODE_ECHO_REQUEST, | |||||||||
| 40 | identifier => 1, | ||||||||||
| 41 | length => NF_PPPLCP_HDR_LEN, | ||||||||||
| 42 | magicNumber => 0xffffffff, | ||||||||||
| 43 | @_, | ||||||||||
| 44 | ); | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub getLength { shift->length } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub getPayloadLength { shift->getLength - NF_PPPLCP_HDR_LEN } | ||||||||
|
Subroutine
getPayloadLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 52 | 1 | my $self = shift; | |||||||||
| 53 | |||||||||||
| 54 | 1 | ▶ | $self->raw($self->SUPER::pack('CCnN', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | $self->code, | ||||||||||
| 56 | $self->identifier, | ||||||||||
| 57 | $self->length, | ||||||||||
| 58 | $self->magicNumber, | ||||||||||
| 59 | )) or return undef; | ||||||||||
| 60 | |||||||||||
| 61 | 1 | $self->raw; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 65 | 1 | my $self = shift; | |||||||||
| 66 | |||||||||||
| 67 | 1 | ▶ | my ($code, $identifier, $length, $magicNumber, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | $self->SUPER::unpack('CCnN a*', $self->raw) | ||||||||||
| 69 | or return undef; | ||||||||||
| 70 | |||||||||||
| 71 | 1 | $self->code($code); | |||||||||
| 72 | 1 | $self->identifier($identifier); | |||||||||
| 73 | 1 | $self->length($length); | |||||||||
| 74 | 1 | $self->magicNumber($magicNumber); | |||||||||
| 75 | |||||||||||
| 76 | 1 | $self->payload($payload); | |||||||||
| 77 | |||||||||||
| 78 | 1 | $self; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub encapsulate { shift->nextLayer } | ||||||||
|
Subroutine
encapsulate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | sub print { | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 84 | 0 | my $self = shift; | |||||||||
| 85 | |||||||||||
| 86 | 0 | my $l = $self->layer; | |||||||||
| 87 | 0 | sprintf "$l: code:0x%02x identifier:0x%02x length:%d magicNumber:0x%04x", | |||||||||
| 88 | $self->code, | ||||||||||
| 89 | $self->identifier, | ||||||||||
| 90 | $self->length, | ||||||||||
| 91 | $self->magicNumber, | ||||||||||
| 92 | ; | ||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 3 | 1; | |||||||||
| 96 | |||||||||||
| 97 | __END__ | ||||||||||