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