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