line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: IPNetPrefix.pm 1640 2013-03-28 17:58:27Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::CDP::IPNetPrefix; |
5
|
19
|
|
|
19
|
|
7884
|
use strict; use warnings; |
|
19
|
|
|
19
|
|
34
|
|
|
19
|
|
|
|
|
593
|
|
|
19
|
|
|
|
|
97
|
|
|
19
|
|
|
|
|
34
|
|
|
19
|
|
|
|
|
554
|
|
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
809
|
use Net::Frame::Layer qw(:consts :subs); |
|
19
|
|
|
|
|
66184
|
|
|
19
|
|
|
|
|
5297
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @AS = qw( |
11
|
|
|
|
|
|
|
type |
12
|
|
|
|
|
|
|
length |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
our @AA = qw( |
15
|
|
|
|
|
|
|
IpNetPrefix |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
18
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
19
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray(\@AA); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#no strict 'vars'; |
22
|
|
|
|
|
|
|
|
23
|
19
|
|
|
19
|
|
820
|
use Net::Frame::Layer::CDP::Constants qw(:consts); |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
16259
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
|
|
|
|
|
|
shift->SUPER::new( |
27
|
2
|
|
|
2
|
1
|
416
|
type => NF_CDP_TYPE_IPNET_PREFIX, |
28
|
|
|
|
|
|
|
length => 9, |
29
|
|
|
|
|
|
|
IpNetPrefix => ['127.0.0.1/8'], |
30
|
|
|
|
|
|
|
@_, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub getLength { |
35
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
my $length = 4; |
38
|
0
|
|
|
|
|
0
|
$length += 5 for $self->IpNetPrefix; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return $length |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub pack { |
44
|
1
|
|
|
1
|
1
|
227
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
5
|
my $raw = $self->SUPER::pack('nn', |
47
|
|
|
|
|
|
|
$self->type, |
48
|
|
|
|
|
|
|
$self->length |
49
|
|
|
|
|
|
|
) or return; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
51
|
for ($self->IpNetPrefix) { |
52
|
1
|
|
|
|
|
21
|
my ($prefix, $mask) = split /\//, $_; |
53
|
1
|
50
|
|
|
|
6
|
$raw .= $self->SUPER::pack('a4C', |
54
|
|
|
|
|
|
|
inetAton($prefix), |
55
|
|
|
|
|
|
|
$mask |
56
|
|
|
|
|
|
|
) or return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
37
|
return $self->raw($raw); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub unpack { |
63
|
1
|
|
|
1
|
1
|
14
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
3
|
my ($type, $length, $tail) = |
66
|
|
|
|
|
|
|
$self->SUPER::unpack('nna*', $self->raw) |
67
|
|
|
|
|
|
|
or return; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
29
|
$self->type($type); |
70
|
1
|
|
|
|
|
10
|
$self->length($length); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
8
|
my $valLen = $length - 4; |
73
|
1
|
50
|
|
|
|
6
|
my ($IpNetPrefix, $payload) = |
74
|
|
|
|
|
|
|
$self->SUPER::unpack("a$valLen a*", $tail) |
75
|
|
|
|
|
|
|
or return; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
11
|
my @prefixList; |
78
|
1
|
|
|
|
|
4
|
for (1..$valLen/5) { |
79
|
1
|
50
|
|
|
|
4
|
my ($prefix, $mask) = |
80
|
|
|
|
|
|
|
$self->SUPER::unpack("a4C", $IpNetPrefix) |
81
|
|
|
|
|
|
|
or return; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
13
|
$prefix = inetNtoa($prefix); |
84
|
1
|
|
|
|
|
10
|
$prefix .= "/$mask"; |
85
|
1
|
|
|
|
|
1
|
push @prefixList, $prefix; |
86
|
1
|
|
|
|
|
4
|
$IpNetPrefix = substr $IpNetPrefix, 5 |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
3
|
$self->IpNetPrefix(\@prefixList); |
90
|
1
|
|
|
|
|
16
|
$self->payload($payload); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
9
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub computeLengths { |
96
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
my $length = 4; |
99
|
0
|
|
|
|
|
0
|
$length += 5 for $self->IpNetPrefix; |
100
|
0
|
|
|
|
|
0
|
$self->length($length); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub print { |
106
|
3
|
|
|
3
|
1
|
15
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
16
|
my $l = $self->layer; |
109
|
3
|
|
|
|
|
45
|
my $buf = sprintf |
110
|
|
|
|
|
|
|
"$l: type:0x%04x length:%d", |
111
|
|
|
|
|
|
|
$self->type, $self->length; |
112
|
|
|
|
|
|
|
|
113
|
3
|
|
|
|
|
86
|
for ($self->IpNetPrefix) { |
114
|
3
|
|
|
|
|
54
|
$buf .= sprintf |
115
|
|
|
|
|
|
|
"\n$l: IpNetPrefix:%s", |
116
|
|
|
|
|
|
|
$_ |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
3
|
|
|
|
|
593
|
return $buf; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |