line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Fragment.pm,v ee9a7f696b4d 2017/05/07 12:55:21 gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::IPv6::Fragment; |
5
|
2
|
|
|
2
|
|
1198
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
79
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.08'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
236
|
|
10
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
151
|
|
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
|
|
12
|
use Net::Frame::Layer::IPv6 qw(:consts); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1014
|
|
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
|
326
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
5
|
my $fragmentOffset = Bit::Vector->new_Dec(13, $self->fragmentOffset); |
44
|
1
|
|
|
|
|
50
|
my $res = Bit::Vector->new_Dec( 2, $self->res); |
45
|
1
|
|
|
|
|
16
|
my $mFlag = Bit::Vector->new_Dec( 1, $self->mFlag); |
46
|
1
|
|
|
|
|
30
|
my $v16 = $fragmentOffset->Concat_List($res, $mFlag); |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
8
|
my $raw = $self->SUPER::pack('CCnN', |
49
|
|
|
|
|
|
|
$self->nextHeader, $self->reserved, $v16->to_Dec, $self->identification |
50
|
|
|
|
|
|
|
) or return; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
90
|
return $self->raw($raw); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub unpack { |
56
|
1
|
|
|
1
|
1
|
36
|
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
|
|
|
|
|
57
|
$self->nextHeader($nextHeader); |
63
|
1
|
|
|
|
|
17
|
$self->reserved($reserved); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
18
|
my $v16 = Bit::Vector->new_Dec(16, $fragflags); |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
13
|
$self->fragmentOffset($v16->Chunk_Read(13, 3)); |
68
|
1
|
|
|
|
|
41
|
$self->res ($v16->Chunk_Read( 2, 1)); |
69
|
1
|
|
|
|
|
20
|
$self->mFlag ($v16->Chunk_Read( 1, 0)); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
17
|
$self->identification($identification); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
23
|
$self->payload($payload); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
22
|
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__ |