| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: NeighborSolicitation.pm,v bc01789674fd 2019/05/23 05:51:45 gomor $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::ICMPv6::NeighborSolicitation; | ||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | our @ISA = qw(Net::Frame::Layer); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | our @AS = qw( | |||||||||||||||||||||||||||
| 11 | reserved | ||||||||||||||||||||||||||||
| 12 | targetAddress | ||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||
| 14 | 3 | our @AA = qw( | |||||||||||||||||||||||||||
| 15 | options | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||
| 18 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||
| 19 | 3 | __PACKAGE__->cgBuildAccessorsArray (\@AA); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Net::Frame::Layer::ICMPv6::Option; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | shift->SUPER::new( | ||||||||||||||||||||||||||||
| 25 | 1 | reserved => 0, | |||||||||||||||||||||||||||
| 26 | targetAddress => '::1', | ||||||||||||||||||||||||||||
| 27 | options => [], | ||||||||||||||||||||||||||||
| 28 | @_, | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub getOptionsLength { | ||||||||||||||||||||||||||
|
Subroutine
getOptionsLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | 0 | my $len = 0; | |||||||||||||||||||||||||||
| 35 | 0 | $len += $_->getLength for $self->options; | |||||||||||||||||||||||||||
| 36 | 0 | return $len; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub getLength { | ||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | return 20 + $self->getOptionsLength; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||
|
Subroutine
pack: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | my $raw = $self->SUPER::pack('Na16', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | $self->reserved, inet6Aton($self->targetAddress), | ||||||||||||||||||||||||||||
| 49 | ) or return; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | for ($self->options) { | |||||||||||||||||||||||||||
| 52 | 0 | $raw .= $_->pack; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 1 | return $self->raw($raw); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub _unpackOptions { | ||||||||||||||||||||||||||
|
Subroutine
_unpackOptions: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 59 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | 0 | my ($payload) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my @options = (); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | while (defined($payload) && length($payload)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $payload and length $payload
MC/DC0%0/2
defined $payload and length $payload
defined $payload
length $payload
Truth table0%0/3
A and B
A= defined $payloadB= length $payload
| |||||||||||||||||||||||||||||
| 64 | 0 | my $opt = Net::Frame::Layer::ICMPv6::Option->new(raw => $payload)->unpack; | |||||||||||||||||||||||||||
| 65 | 0 | push @options, $opt; | |||||||||||||||||||||||||||
| 66 | 0 | $payload = $opt->payload; | |||||||||||||||||||||||||||
| 67 | 0 | $opt->payload(undef); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | $self->options(\@options); | |||||||||||||||||||||||||||
| 70 | 0 | return $payload; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | my ($reserved, $targetAddress, $payload) = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | $self->SUPER::unpack('Na16 a*', $self->raw) | ||||||||||||||||||||||||||||
| 78 | or return; | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | $self->reserved($reserved); | |||||||||||||||||||||||||||
| 81 | 1 | $self->targetAddress(inet6Ntoa($targetAddress)); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | if (defined($payload) && length($payload)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $payload and length $payload
MC/DC0%0/2
defined $payload and length $payload
defined $payload
length $payload
Truth table33%1/3
A and B
A= defined $payloadB= length $payload
| |||||||||||||||||||||||||||||
| 84 | 0 | $payload = $self->_unpackOptions($payload); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | return $self; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 0 | 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 | 3 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||