line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Option.pm 45 2014-04-09 07:51:48Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::IPv6::Option; |
5
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1782
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @AS = qw( |
12
|
|
|
|
|
|
|
type |
13
|
|
|
|
|
|
|
length |
14
|
|
|
|
|
|
|
value |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
17
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
|
|
|
|
|
|
shift->SUPER::new( |
21
|
1
|
|
|
1
|
1
|
16
|
type => 1, |
22
|
|
|
|
|
|
|
length => 0, |
23
|
|
|
|
|
|
|
value => '', |
24
|
|
|
|
|
|
|
@_, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub getLength { |
29
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
0
|
if ($self->type == 0) { # Pad1, only type is used |
32
|
0
|
|
|
|
|
0
|
return 1; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return length($self->value) + 2; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub pack { |
39
|
1
|
|
|
1
|
1
|
167
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
5
|
my $raw = $self->SUPER::pack('C', $self->type) |
42
|
|
|
|
|
|
|
or return; |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
31
|
if ($self->type != 0) { # Not a Pad1 option |
45
|
1
|
50
|
|
|
|
21
|
$raw .= $self->SUPER::pack('Ca*', $self->length, $self->value) |
46
|
|
|
|
|
|
|
or return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
49
|
return $self->raw($raw); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub unpack { |
53
|
1
|
|
|
1
|
1
|
12
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
4
|
my ($type, $payload) = $self->SUPER::unpack('C a*', $self->raw) |
56
|
|
|
|
|
|
|
or return; |
57
|
1
|
|
|
|
|
22
|
$self->type($type); |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
10
|
if ($self->type != 0) { # Not a Pad1 option |
60
|
1
|
50
|
|
|
|
13
|
my ($length, $tail) = $self->SUPER::unpack('C a*', $payload) |
61
|
|
|
|
|
|
|
or return; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
12
|
my $value = ''; |
64
|
1
|
50
|
|
|
|
6
|
($value, $payload) = $self->SUPER::unpack("a$length a*", $tail) |
65
|
|
|
|
|
|
|
or return; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
13
|
$self->length($length); |
68
|
1
|
|
|
|
|
10
|
$self->value($value); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
14
|
$self->payload($payload); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
25
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub computeLengths { |
77
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $length = 0; |
80
|
0
|
0
|
|
|
|
|
if ($self->type != 0) { # Not a Pad1 option |
81
|
0
|
|
|
|
|
|
$length = length($self->value); |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
|
|
|
$self->length($length); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub print { |
89
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $buf = ''; |
92
|
0
|
|
|
|
|
|
my $l = $self->layer; |
93
|
0
|
0
|
|
|
|
|
if ($self->type == 0x00) { # Pad1 specific type |
94
|
0
|
|
|
|
|
|
$buf .= sprintf "$l: type:0x%02x", $self->type; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
0
|
|
|
|
|
|
$buf .= sprintf "$l: type:0x%02x length:%d value:%s", |
98
|
|
|
|
|
|
|
$self->type, $self->length, CORE::unpack('H*', $self->value); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $buf; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |