| 1 | # | ||||||||||||||||||||||
| 2 | # $Id: PWMCW.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||
| 4 | package Net::Frame::Layer::MPLS::PWMCW; | ||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 4 | our $VERSION = '1.00'; | |||||||||||||||||||||
| 8 | |||||||||||||||||||||||
| 9 | 4 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 4 | ▶ | use Exporter; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 4 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 4 | our %EXPORT_TAGS = ( | |||||||||||||||||||||
| 14 | consts => [qw( | ||||||||||||||||||||||
| 15 | NF_MPLS_PWNIBBLE_MCW | ||||||||||||||||||||||
| 16 | )], | ||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||
| 18 | our @EXPORT_OK = ( | ||||||||||||||||||||||
| 19 | 4 | @{$EXPORT_TAGS{consts}}, | |||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||
| 21 | |||||||||||||||||||||||
| 22 | 4 | ▶ | use constant NF_MPLS_PWNIBBLE_MCW => 0; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 4 | our @AS = qw( | |||||||||||||||||||||
| 25 | pwNibble | ||||||||||||||||||||||
| 26 | flags | ||||||||||||||||||||||
| 27 | frg | ||||||||||||||||||||||
| 28 | length | ||||||||||||||||||||||
| 29 | sequenceNumber | ||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||
| 31 | 4 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||
| 32 | 4 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | #no strict 'vars'; | ||||||||||||||||||||||
| 35 | 4 | ▶ | use Bit::Vector; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 1 | ▶ | sub new { | ||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 38 | shift->SUPER::new( | ||||||||||||||||||||||
| 39 | 1 | pwNibble => NF_MPLS_PWNIBBLE_MCW, | |||||||||||||||||||||
| 40 | flags => 0, | ||||||||||||||||||||||
| 41 | frg => 0, | ||||||||||||||||||||||
| 42 | length => 0, | ||||||||||||||||||||||
| 43 | sequenceNumber => 0, | ||||||||||||||||||||||
| 44 | @_, | ||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | 0 | ▶ | sub getLength { 4 } | ||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | 1 | ▶ | sub pack { | ||||||||||||||||||||
|
Subroutine
pack: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 51 | 1 | my $self = shift; | |||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | 1 | my $pwNibble = Bit::Vector->new_Dec(4, $self->pwNibble); | |||||||||||||||||||||
| 54 | 1 | my $flags = Bit::Vector->new_Dec(4, $self->flags); | |||||||||||||||||||||
| 55 | 1 | my $bvlist1 = $pwNibble->Concat_List($flags); | |||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | 1 | my $frg = Bit::Vector->new_Dec(2, $self->frg); | |||||||||||||||||||||
| 58 | 1 | my $length = Bit::Vector->new_Dec(6, $self->length); | |||||||||||||||||||||
| 59 | 1 | my $bvlist2 = $frg->Concat_List($length); | |||||||||||||||||||||
| 60 | |||||||||||||||||||||||
| 61 | 1 | ▶ | my $raw = $self->SUPER::pack('CCn', | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 62 | $bvlist1->to_Dec, | ||||||||||||||||||||||
| 63 | $bvlist2->to_Dec, | ||||||||||||||||||||||
| 64 | $self->sequenceNumber | ||||||||||||||||||||||
| 65 | ) or return; | ||||||||||||||||||||||
| 66 | |||||||||||||||||||||||
| 67 | 1 | return $self->raw($raw); | |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 1 | ▶ | sub unpack { | ||||||||||||||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 71 | 1 | my $self = shift; | |||||||||||||||||||||
| 72 | |||||||||||||||||||||||
| 73 | 1 | ▶ | my ($bv1, $bv2, $sequenceNumber, $payload) = | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 74 | $self->SUPER::unpack('CCn a*', $self->raw) | ||||||||||||||||||||||
| 75 | or return; | ||||||||||||||||||||||
| 76 | |||||||||||||||||||||||
| 77 | 1 | my $bvlist1 = Bit::Vector->new_Dec(8, $bv1); | |||||||||||||||||||||
| 78 | 1 | $self->pwNibble($bvlist1->Chunk_Read(4,4)); | |||||||||||||||||||||
| 79 | 1 | $self->flags ($bvlist1->Chunk_Read(4,0)); | |||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 1 | my $bvlist2 = Bit::Vector->new_Dec(8, $bv2); | |||||||||||||||||||||
| 82 | 1 | $self->frg ($bvlist2->Chunk_Read(2,6)); | |||||||||||||||||||||
| 83 | 1 | $self->length($bvlist2->Chunk_Read(6,0)); | |||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | 1 | $self->sequenceNumber($sequenceNumber); | |||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | 1 | $self->payload($payload); | |||||||||||||||||||||
| 88 | |||||||||||||||||||||||
| 89 | 1 | return $self; | |||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||
| 91 | |||||||||||||||||||||||
| 92 | 1 | ▶ | sub encapsulate { | ||||||||||||||||||||
|
Subroutine
encapsulate: called CC=7 SCAR=32.9
Pod
documented
| |||||||||||||||||||||||
| 93 | 1 | my $self = shift; | |||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | 1 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | 1 | ▶ | if ($self->payload) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 98 | 0 | my $payload = CORE::unpack('H', $self->payload); | |||||||||||||||||||||
| 99 | 0 | ▶ | if ($payload == NF_MPLS_PWNIBBLE_MCW) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 100 | 0 | return 'PWMCW::PWMCW'; | |||||||||||||||||||||
| 101 | } elsif ($payload == 1) { | ||||||||||||||||||||||
| 102 | 0 | return 'PWMCW::PWMCW'; | |||||||||||||||||||||
| 103 | } elsif ($payload == 4) { | ||||||||||||||||||||||
| 104 | 0 | return 'IPv4'; | |||||||||||||||||||||
| 105 | } elsif ($payload == 6) { | ||||||||||||||||||||||
| 106 | 0 | return 'IPv6'; | |||||||||||||||||||||
| 107 | } else { | ||||||||||||||||||||||
| 108 | 0 | return 'ETH'; | |||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||
| 111 | |||||||||||||||||||||||
| 112 | 1 | NF_LAYER_NONE; | |||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||
| 114 | |||||||||||||||||||||||
| 115 | 1 | ▶ | sub print { | ||||||||||||||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 116 | 1 | my $self = shift; | |||||||||||||||||||||
| 117 | |||||||||||||||||||||||
| 118 | 1 | my $l = $self->layer; | |||||||||||||||||||||
| 119 | 1 | my $buf = sprintf | |||||||||||||||||||||
| 120 | "$l: pwNibble:%d flags:%d frg:%d length:%d sequenceNumber:0x%04x", | ||||||||||||||||||||||
| 121 | $self->pwNibble, $self->flags, $self->frg, | ||||||||||||||||||||||
| 122 | $self->length, $self->sequenceNumber; | ||||||||||||||||||||||
| 123 | |||||||||||||||||||||||
| 124 | 1 | return $buf; | |||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||
| 126 | |||||||||||||||||||||||
| 127 | 4 | 1; | |||||||||||||||||||||
| 128 | |||||||||||||||||||||||
| 129 | __END__ | ||||||||||||||||||||||