line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Router Solicitation message wrapper, compliant to RFC 4861 |
3
|
|
|
|
|
|
|
# pvenegas@infoweapons.com |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# $Id: RouterSolicitation.pm,v b9194b248a66 2017/10/06 16:26:50 gomor $ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
package Net::Frame::Layer::ICMPv6::RouterSolicitation; |
9
|
2
|
|
|
2
|
|
916
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
|
|
71
|
|
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
87
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
17
|
use Net::Frame::Layer qw(:consts :subs); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
655
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @AS = qw( |
15
|
|
|
|
|
|
|
reserved |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
our @AA = qw( |
18
|
|
|
|
|
|
|
options |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
21
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
22
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray (\@AA); |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
19
|
use Net::Frame::Layer::ICMPv6 qw(:consts); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
575
|
|
25
|
2
|
|
|
2
|
|
20
|
use Bit::Vector; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
92
|
|
26
|
2
|
|
|
2
|
|
18
|
use Net::Frame::Layer::ICMPv6::Option; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1296
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
|
|
|
|
|
|
shift->SUPER::new( |
30
|
1
|
|
|
1
|
1
|
15
|
reserved => 0, |
31
|
|
|
|
|
|
|
options => [], |
32
|
|
|
|
|
|
|
@_, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getOptionsLength { |
37
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
38
|
0
|
|
|
|
|
0
|
my $len = 0; |
39
|
0
|
|
|
|
|
0
|
$len += $_->getLength for $self->options; |
40
|
0
|
|
|
|
|
0
|
return $len; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub getLength { |
44
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
45
|
0
|
|
|
|
|
0
|
return 4 + $self->getOptionsLength; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub pack { |
49
|
1
|
|
|
1
|
1
|
236
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
6
|
my $raw = $self->SUPER::pack('L', $self->reserved) |
52
|
|
|
|
|
|
|
or return; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
36
|
for ($self->options) { |
55
|
0
|
|
|
|
|
0
|
$raw .= $_->pack; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
21
|
return $self->raw($raw); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _unpackOptions { |
62
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
my ($payload) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
my @options = (); |
66
|
0
|
|
0
|
|
|
0
|
while (defined($payload) && length($payload)) { |
67
|
0
|
|
|
|
|
0
|
my $opt = Net::Frame::Layer::ICMPv6::Option->new(raw => $payload)->unpack; |
68
|
0
|
|
|
|
|
0
|
push @options, $opt; |
69
|
0
|
|
|
|
|
0
|
$payload = $opt->payload; |
70
|
0
|
|
|
|
|
0
|
$opt->payload(undef); |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
0
|
$self->options(\@options); |
73
|
0
|
|
|
|
|
0
|
return $payload; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub unpack { |
77
|
1
|
|
|
1
|
1
|
23
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
11
|
my ($reserved, $payload) = |
80
|
|
|
|
|
|
|
$self->SUPER::unpack('L a*', $self->raw) |
81
|
|
|
|
|
|
|
or return; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
36
|
$self->reserved($reserved); |
84
|
1
|
|
|
|
|
17
|
$self->payload($payload); |
85
|
|
|
|
|
|
|
|
86
|
1
|
50
|
33
|
|
|
19
|
if (defined($payload) && length($payload)) { |
87
|
0
|
|
|
|
|
0
|
$payload = $self->_unpackOptions($payload); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
5
|
$self->payload($payload); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
17
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub print { |
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $l = $self->layer; |
99
|
0
|
|
|
|
|
|
my $buf = sprintf "$l: reserved: 0x%02x", |
100
|
|
|
|
|
|
|
$self->reserved; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
for ($self->options) { |
103
|
0
|
|
|
|
|
|
$buf .= "\n" . $_->print; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return $buf; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |