| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id: MPLS.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
package Net::Frame::Layer::MPLS; |
|
5
|
2
|
|
|
2
|
|
11411
|
use strict; use warnings; |
|
|
2
|
|
|
2
|
|
7
|
|
|
|
2
|
|
|
|
|
61
|
|
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
95
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1032
|
use Net::Frame::Layer qw(:consts :subs); |
|
|
2
|
|
|
|
|
109728
|
|
|
|
2
|
|
|
|
|
378
|
|
|
10
|
2
|
|
|
2
|
|
15
|
use Exporter; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
192
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
14
|
|
|
|
|
|
|
consts => [qw( |
|
15
|
|
|
|
|
|
|
NF_MPLS_S_NO |
|
16
|
|
|
|
|
|
|
NF_MPLS_S_YES |
|
17
|
|
|
|
|
|
|
)], |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
|
20
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
11
|
use constant NF_MPLS_S_NO => 0; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
91
|
|
|
24
|
2
|
|
|
2
|
|
11
|
use constant NF_MPLS_S_YES => 1; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
120
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @AS = qw( |
|
27
|
|
|
|
|
|
|
label |
|
28
|
|
|
|
|
|
|
tc |
|
29
|
|
|
|
|
|
|
s |
|
30
|
|
|
|
|
|
|
ttl |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
|
33
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#no strict 'vars'; |
|
36
|
2
|
|
|
2
|
|
1067
|
use Bit::Vector; |
|
|
2
|
|
|
|
|
1491
|
|
|
|
2
|
|
|
|
|
79
|
|
|
37
|
2
|
|
|
2
|
|
747
|
use Net::Frame::Layer::MPLS::PWACH qw(:consts); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
315
|
|
|
38
|
2
|
|
|
2
|
|
726
|
use Net::Frame::Layer::MPLS::PWMCW qw(:consts); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
754
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
|
41
|
|
|
|
|
|
|
shift->SUPER::new( |
|
42
|
1
|
|
|
1
|
1
|
18
|
label => 0, |
|
43
|
|
|
|
|
|
|
tc => 0, |
|
44
|
|
|
|
|
|
|
s => NF_MPLS_S_YES, |
|
45
|
|
|
|
|
|
|
ttl => 255, |
|
46
|
|
|
|
|
|
|
@_, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
0
|
sub getLength { 4 } |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub pack { |
|
53
|
1
|
|
|
1
|
1
|
267
|
my $self = shift; |
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
5
|
my $label = Bit::Vector->new_Dec(20, $self->label); |
|
56
|
1
|
|
|
|
|
39
|
my $tc = Bit::Vector->new_Dec(3, $self->tc); |
|
57
|
1
|
|
|
|
|
19
|
my $s = Bit::Vector->new_Dec(1, $self->s); |
|
58
|
1
|
|
|
|
|
13
|
my $ttl = Bit::Vector->new_Dec(8, $self->ttl); |
|
59
|
1
|
|
|
|
|
19
|
my $bvlist = $label->Concat_List($tc, $s, $ttl); |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
50
|
|
|
|
11
|
my $raw = $self->SUPER::pack('N', |
|
62
|
|
|
|
|
|
|
$bvlist->to_Dec |
|
63
|
|
|
|
|
|
|
) or return; |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
28
|
return $self->raw($raw); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub unpack { |
|
69
|
1
|
|
|
1
|
1
|
34
|
my $self = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
7
|
my ($bv, $payload) = |
|
72
|
|
|
|
|
|
|
$self->SUPER::unpack('N a*', $self->raw) |
|
73
|
|
|
|
|
|
|
or return; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
51
|
my $bvlist = Bit::Vector->new_Dec(32, $bv); |
|
76
|
1
|
|
|
|
|
10
|
$self->label($bvlist->Chunk_Read(20,12)); |
|
77
|
1
|
|
|
|
|
15
|
$self->tc ($bvlist->Chunk_Read(3,9)); |
|
78
|
1
|
|
|
|
|
11
|
$self->s ($bvlist->Chunk_Read(1,8)); |
|
79
|
1
|
|
|
|
|
11
|
$self->ttl ($bvlist->Chunk_Read(8,0)); |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
13
|
$self->payload($payload); |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
11
|
return $self; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub encapsulate { |
|
87
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
8
|
return $self->nextLayer if $self->nextLayer; |
|
90
|
|
|
|
|
|
|
|
|
91
|
1
|
50
|
|
|
|
18
|
if (!$self->s) { |
|
92
|
0
|
|
|
|
|
0
|
return 'MPLS'; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
1
|
50
|
|
|
|
12
|
if ($self->payload) { |
|
95
|
0
|
|
|
|
|
0
|
my $payload = CORE::unpack('H', $self->payload); |
|
96
|
0
|
0
|
|
|
|
0
|
if ($payload == NF_MPLS_PWNIBBLE_MCW) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
return 'MPLS::PWMCW'; |
|
98
|
|
|
|
|
|
|
} elsif ($payload == NF_MPLS_PWNIBBLE_ACH) { |
|
99
|
0
|
|
|
|
|
0
|
return 'MPLS::PWACH'; |
|
100
|
|
|
|
|
|
|
} elsif ($payload == 4) { |
|
101
|
0
|
|
|
|
|
0
|
return 'IPv4'; |
|
102
|
|
|
|
|
|
|
} elsif ($payload == 6) { |
|
103
|
0
|
|
|
|
|
0
|
return 'IPv6'; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
12
|
NF_LAYER_NONE; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub print { |
|
111
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
|
112
|
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
5
|
my $l = $self->layer; |
|
114
|
1
|
|
|
|
|
21
|
my $buf = sprintf |
|
115
|
|
|
|
|
|
|
"$l: label:%d tc:%d s:%d ttl:%d", |
|
116
|
|
|
|
|
|
|
$self->label, $self->tc, $self->s, $self->ttl; |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
339
|
return $buf; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |