| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: NeighborAdvertisement.pm,v bc01789674fd 2019/05/23 05:51:45 gomor $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::ICMPv6::NeighborAdvertisement; | ||||||||||||||||||||||||||||
| 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 | flags | ||||||||||||||||||||||||||||
| 12 | reserved | ||||||||||||||||||||||||||||
| 13 | targetAddress | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | 3 | our @AA = qw( | |||||||||||||||||||||||||||
| 16 | options | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||
| 19 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||
| 20 | 3 | __PACKAGE__->cgBuildAccessorsArray (\@AA); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use Net::Frame::Layer::ICMPv6 qw(:consts); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Bit::Vector; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use Net::Frame::Layer::ICMPv6::Option; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | shift->SUPER::new( | ||||||||||||||||||||||||||||
| 28 | 1 | flags => NF_ICMPv6_FLAG_SOLICITED, | |||||||||||||||||||||||||||
| 29 | reserved => 0, | ||||||||||||||||||||||||||||
| 30 | targetAddress => '::1', | ||||||||||||||||||||||||||||
| 31 | options => [], | ||||||||||||||||||||||||||||
| 32 | @_, | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub getOptionsLength { | ||||||||||||||||||||||||||
|
Subroutine
getOptionsLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | 0 | my $len = 0; | |||||||||||||||||||||||||||
| 39 | 0 | $len += $_->getLength for $self->options; | |||||||||||||||||||||||||||
| 40 | 0 | return $len; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub getLength { | ||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 45 | 0 | return 20 + $self->getOptionsLength; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||
|
Subroutine
pack: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | my $flags = Bit::Vector->new_Dec( 3, $self->flags); | |||||||||||||||||||||||||||
| 52 | 1 | my $reserved = Bit::Vector->new_Dec(29, $self->reserved); | |||||||||||||||||||||||||||
| 53 | 1 | my $v32 = $flags->Concat_List($reserved); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 1 | ▶ | my $raw = $self->SUPER::pack('Na16', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | $v32->to_Dec, inet6Aton($self->targetAddress), | ||||||||||||||||||||||||||||
| 57 | ) or return; | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | for ($self->options) { | |||||||||||||||||||||||||||
| 60 | 0 | $raw .= $_->pack; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | return $self->raw($raw); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub _unpackOptions { | ||||||||||||||||||||||||||
|
Subroutine
_unpackOptions: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | 0 | my ($payload) = @_; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my @options = (); | |||||||||||||||||||||||||||
| 71 | 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
| |||||||||||||||||||||||||||||
| 72 | 0 | my $opt = Net::Frame::Layer::ICMPv6::Option->new(raw => $payload)->unpack; | |||||||||||||||||||||||||||
| 73 | 0 | push @options, $opt; | |||||||||||||||||||||||||||
| 74 | 0 | $payload = $opt->payload; | |||||||||||||||||||||||||||
| 75 | 0 | $opt->payload(undef); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 0 | $self->options(\@options); | |||||||||||||||||||||||||||
| 78 | 0 | return $payload; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | my ($flagsReserved, $targetAddress, $payload) = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | $self->SUPER::unpack('Na16 a*', $self->raw) | ||||||||||||||||||||||||||||
| 86 | or return undef; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | my $v32 = Bit::Vector->new_Dec(32, $flagsReserved); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | $self->reserved($v32->Chunk_Read(29, 0)); | |||||||||||||||||||||||||||
| 91 | 1 | $self->flags ($v32->Chunk_Read( 3, 29)); | |||||||||||||||||||||||||||
| 92 | 1 | $self->targetAddress(inet6Ntoa($targetAddress)); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 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
| |||||||||||||||||||||||||||||
| 95 | 0 | $payload = $self->_unpackOptions($payload); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | return $self; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | my $l = $self->layer; | |||||||||||||||||||||||||||
| 107 | 0 | my $buf = sprintf "$l: flags:%02x reserved:%d\n". | |||||||||||||||||||||||||||
| 108 | "$l: targetAddress:%s", | ||||||||||||||||||||||||||||
| 109 | $self->flags, $self->reserved, $self->targetAddress; | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | for ($self->options) { | |||||||||||||||||||||||||||
| 112 | 0 | $buf .= "\n".$_->print; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | return $buf; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 3 | 1; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | __END__ | ||||||||||||||||||||||||||||