line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: PortId.pm 1640 2013-03-28 17:58:27Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::CDP::PortId; |
5
|
19
|
|
|
19
|
|
14557
|
use strict; use warnings; |
|
19
|
|
|
19
|
|
31
|
|
|
19
|
|
|
|
|
617
|
|
|
19
|
|
|
|
|
103
|
|
|
19
|
|
|
|
|
28
|
|
|
19
|
|
|
|
|
584
|
|
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
1578
|
use Net::Frame::Layer qw(:consts :subs); |
|
19
|
|
|
|
|
89621
|
|
|
19
|
|
|
|
|
5270
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @AS = qw( |
11
|
|
|
|
|
|
|
type |
12
|
|
|
|
|
|
|
length |
13
|
|
|
|
|
|
|
portId |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
16
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#no strict 'vars'; |
19
|
|
|
|
|
|
|
|
20
|
19
|
|
|
19
|
|
857
|
use Net::Frame::Layer::CDP::Constants qw(:consts); |
|
19
|
|
|
|
|
34
|
|
|
19
|
|
|
|
|
11311
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
|
|
|
|
|
|
shift->SUPER::new( |
24
|
2
|
|
|
2
|
1
|
224
|
type => NF_CDP_TYPE_PORT_ID, |
25
|
|
|
|
|
|
|
length => 19, |
26
|
|
|
|
|
|
|
portId => 'FastEthernet1/0', |
27
|
|
|
|
|
|
|
@_, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub getLength { |
32
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my $length = 4 + length($self->portId); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
return $length |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub pack { |
40
|
1
|
|
|
1
|
1
|
246
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
1
|
50
|
|
|
|
6
|
my $raw = $self->SUPER::pack('nna*', |
43
|
|
|
|
|
|
|
$self->type, |
44
|
|
|
|
|
|
|
$self->length, |
45
|
|
|
|
|
|
|
$self->portId, |
46
|
|
|
|
|
|
|
) or return; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
71
|
return $self->raw($raw); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub unpack { |
52
|
1
|
|
|
1
|
1
|
14
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
4
|
my ($type, $length, $tail) = |
55
|
|
|
|
|
|
|
$self->SUPER::unpack('nna*', $self->raw) |
56
|
|
|
|
|
|
|
or return; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
29
|
$self->type($type); |
59
|
1
|
|
|
|
|
11
|
$self->length($length); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
8
|
my $valLen = $length - 4; |
62
|
1
|
50
|
|
|
|
7
|
my ($portId, $payload) = |
63
|
|
|
|
|
|
|
$self->SUPER::unpack("a$valLen a*", $tail) |
64
|
|
|
|
|
|
|
or return; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
13
|
$self->portId($portId); |
67
|
1
|
|
|
|
|
14
|
$self->payload($payload); |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
10
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub computeLengths { |
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
$self->length(4 + length($self->portId)); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
return 1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub print { |
81
|
3
|
|
|
3
|
1
|
9
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
11
|
my $l = $self->layer; |
84
|
3
|
|
|
|
|
29
|
my $buf = sprintf |
85
|
|
|
|
|
|
|
"$l: type:0x%04x length:%d portId:%s", |
86
|
|
|
|
|
|
|
$self->type, $self->length, $self->portId; |
87
|
|
|
|
|
|
|
|
88
|
3
|
|
|
|
|
118
|
return $buf; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |