line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Fragment.pm 45 2014-04-09 07:51:48Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::IPv6::Fragment; |
5
|
2
|
|
|
2
|
|
2548
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
668
|
|
10
|
2
|
|
|
2
|
|
12
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
191
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @AS = qw( |
14
|
|
|
|
|
|
|
nextHeader |
15
|
|
|
|
|
|
|
reserved |
16
|
|
|
|
|
|
|
fragmentOffset |
17
|
|
|
|
|
|
|
res |
18
|
|
|
|
|
|
|
mFlag |
19
|
|
|
|
|
|
|
identification |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
22
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
11
|
use Net::Frame::Layer::IPv6 qw(:consts); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1960
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
shift->SUPER::new( |
28
|
1
|
|
|
1
|
1
|
34
|
nextHeader => NF_IPv6_PROTOCOL_TCP, |
29
|
|
|
|
|
|
|
reserved => 0, |
30
|
|
|
|
|
|
|
fragmentOffset => 0, |
31
|
|
|
|
|
|
|
res => 0, |
32
|
|
|
|
|
|
|
mFlag => 0, |
33
|
|
|
|
|
|
|
identification => 0, |
34
|
|
|
|
|
|
|
@_, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub getLength { 8 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub pack { |
41
|
1
|
|
|
1
|
1
|
321
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
8
|
my $fragmentOffset = Bit::Vector->new_Dec(13, $self->fragmentOffset); |
44
|
1
|
|
|
|
|
63
|
my $res = Bit::Vector->new_Dec( 2, $self->res); |
45
|
1
|
|
|
|
|
18
|
my $mFlag = Bit::Vector->new_Dec( 1, $self->mFlag); |
46
|
1
|
|
|
|
|
26
|
my $v16 = $fragmentOffset->Concat_List($res, $mFlag); |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
5
|
my $raw = $self->SUPER::pack('CCnN', |
49
|
|
|
|
|
|
|
$self->nextHeader, $self->reserved, $v16->to_Dec, $self->identification |
50
|
|
|
|
|
|
|
) or return; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
64
|
return $self->raw($raw); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unpack { |
56
|
1
|
|
|
1
|
1
|
21
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
5
|
my ($nextHeader, $reserved, $fragflags, $identification, $payload) = |
59
|
|
|
|
|
|
|
$self->SUPER::unpack('CCnN a*', $self->raw) |
60
|
|
|
|
|
|
|
or return; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
31
|
$self->nextHeader($nextHeader); |
63
|
1
|
|
|
|
|
11
|
$self->reserved($reserved); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
13
|
my $v16 = Bit::Vector->new_Dec(16, $fragflags); |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
11
|
$self->fragmentOffset($v16->Chunk_Read(13, 3)); |
68
|
1
|
|
|
|
|
25
|
$self->res ($v16->Chunk_Read( 2, 1)); |
69
|
1
|
|
|
|
|
13
|
$self->mFlag ($v16->Chunk_Read( 1, 0)); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
10
|
$self->identification($identification); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
13
|
$self->payload($payload); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
24
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub encapsulate { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
return $self->nextLayer if $self->nextLayer; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ($self->payload) { |
84
|
0
|
|
|
|
|
|
my $next = $self->nextHeader; |
85
|
0
|
|
|
|
|
|
return Net::Frame::Layer::IPv6->new(nextHeader => $self->nextHeader)->encapsulate; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return NF_LAYER_NONE; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub print { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $l = $self->layer; |
95
|
0
|
|
|
|
|
|
my $buf = sprintf |
96
|
|
|
|
|
|
|
"$l: nextHeader:0x%02x reserved:%d fragmentOffset:0x%04x\n". |
97
|
|
|
|
|
|
|
"$l: res:%d mFlag:%d identification:%d", |
98
|
|
|
|
|
|
|
$self->nextHeader, $self->reserved, $self->fragmentOffset, |
99
|
|
|
|
|
|
|
$self->res, $self->mFlag, $self->identification; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $buf; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |