| 1 | package Net::IPAddress::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | '=' => 'new', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | '""' => 'str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 'cmp' => '_spaceship', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | '<=>' => '_spaceship', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | '+' => '_do_add', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | '-' => '_do_subtract', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | '<<' => '_shift_left', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | '>>' => '_shift_right', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | '&' => '_band', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | '|' => '_bor', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | '~' => '_neg', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Carp qw( carp cluck confess ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use List::MoreUtils qw( pairwise ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | constr => [qw( IP n32_to_ipv4 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | manip => [qw( explode_ip implode_ip ip_pad_prefix common_prefix prefix_mask ipv4_mask ipv4_flag )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | sort => [qw( radix_sort )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | compat => [qw( ip2num num2ip validaddr mask fqdn )] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my %EXPORT_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | for my $k (keys %EXPORT_TAGS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 12 | for my $v (@{$EXPORT_TAGS{ $k }}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 45 | undef $EXPORT_OK{ $v }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | our @EXPORT_OK = keys %EXPORT_OK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | $EXPORT_TAGS{ all } = [ @EXPORT_OK ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | our $DIE_ON_ERROR = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | our $PROMOTE_N32 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | our $REPAIR_V3_FORMAT = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | our $WARN_ON_REPAIR = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | our $VERSION = '4.004'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | our $fourish = qr/^(?:::ffff:0+:)?(\d+)\.(\d+)\.(\d+)\.(\d+)$/io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | our $broken_fourish = qr/^::ffff:(\d+)\.(\d+)\.(\d+)\.(\d+)$/io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | our $numberish = qr/^\d+$/o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | our $normalish = qr/^([0-9a-f]{32})$/io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | our $sixish = qr/^([0-9a-f:]+)(?:\%.*)?$/io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub _repair_v3_format { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my ($old) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repair_v3_format: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not grep({$_;} @$old[0..9]) and $old->[10] == 255 and $old->[11] == 255
not grep({$_;} @$old[0..9]) and $old->[10] == 255
MC/DC0%0/3
not grep({$_;} @$old[0..9]) and $old->[10] == 255 and $old->[11] == 255
not grep({$_;} @$old[0..9])
$old->[10] == 255
$old->[11] == 255
Truth table0%0/4
not(A) and B and C
A= not grep({$_;} @$old[0..9])B= $old->[10] == 255C= $old->[11] == 255
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | !(grep { $_ } @$old[ 0 .. 9 ]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | && $old->[ 10 ] == 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | && $old->[ 11 ] == 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($WARN_ON_REPAIR > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | local $Carp::Internal{ (__PACKAGE__) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | cluck('Repairing v3.x module data to v4.x data'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | elsif ($WARN_ON_REPAIR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | local $Carp::Internal{ (__PACKAGE__) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | carp('Repairing v3.x module data to v4.x data'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $old->[ 8 ] = 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $old->[ 9 ] = 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $old->[ 10 ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $old->[ 11 ] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub IP { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 272 | ▶ | return Net::IPAddress::Util->new($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IP: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1053 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=34 SCAR=45.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1053 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1053 | my ($address) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1053 | ▶ | unless (defined $address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return ERROR("Invalid argument undef() provided"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1053 | my $normal = [ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1053 | ▶ | if (ref($address) eq 'ARRAY' && @$address == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
Condition100%3/3
ref $address eq "ARRAY" and @$address == 16
MC/DC100%2/2
ref $address eq "ARRAY" and @$address == 16
ref $address eq "ARRAY"
@$address == 16
Truth table100%3/3
A and B
A= ref $address eq "ARRAY"B= @$address == 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 475 | $normal = $address; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ▶ | elsif (ref($address) eq 'ARRAY' && @$address == 4) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $address eq "ARRAY" and @$address == 4
MC/DC50%1/2
ref $address eq "ARRAY" and @$address == 4
ref $address eq "ARRAY"
@$address == 4
Truth table66%2/3
A and B
A= ref $address eq "ARRAY"B= @$address == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # FIXME Principal of least surprise here? Should feeding in 4 values make an IPv4? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 306 | $normal = [ unpack 'C16', pack 'N4', @$address ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 247 | ▶ | elsif (ref $address and eval { $address->isa(__PACKAGE__) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $address and eval {
do {
$address->isa(__PACKAGE__)
}
}
MC/DC50%1/2
ref $address and eval {
do {
$address->isa(__PACKAGE__)
}
}
ref $address
eval {
do {
$address->isa(__PACKAGE__)
}
}
Truth table66%2/3
A and B
A= ref $addressB= eval {
do {
$address->isa(__PACKAGE__)
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 247 | $normal = [ unpack 'C16', $address->{ address } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ($address =~ $fourish) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | $normal = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0xff, 0xff, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $1, $2, $3, $4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ▶ | elsif ($REPAIR_V3_FORMAT && $address =~ $broken_fourish) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Net::IPAddress::Util::REPAIR_V3_FORMAT and $address =~ /$Net::IPAddress::Util::broken_fourish/
MC/DC0%0/2
$Net::IPAddress::Util::REPAIR_V3_FORMAT and $address =~ /$Net::IPAddress::Util::broken_fourish/
$Net::IPAddress::Util::REPAIR_V3_FORMAT
$address =~ /$Net::IPAddress::Util::broken_fourish/
Truth table33%1/3
A and B
A= $Net::IPAddress::Util::REPAIR_V3_FORMATB= $address =~ /$Net::IPAddress::Util::broken_fourish/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($WARN_ON_REPAIR > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | local $Carp::Internal{ (__PACKAGE__) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | cluck('Repairing v3.x module data to v4.x data'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | elsif ($WARN_ON_REPAIR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | local $Carp::Internal{ (__PACKAGE__) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | carp('Repairing v3.x module data to v4.x data'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | $normal = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | 0, 0, 0, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0xff, 0xff, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | $1, $2, $3, $4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ▶ | elsif ($PROMOTE_N32 and $address =~ $numberish and $address >= 0 and $address <= (2 ** 32) - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
$Net::IPAddress::Util::PROMOTE_N32 and $address =~ /$Net::IPAddress::Util::numberish/ and $address >= 0 and $address <= 4294967295
$Net::IPAddress::Util::PROMOTE_N32 and $address =~ /$Net::IPAddress::Util::numberish/ and $address >= 0
$Net::IPAddress::Util::PROMOTE_N32 and $address =~ /$Net::IPAddress::Util::numberish/
MC/DC25%1/4
$Net::IPAddress::Util::PROMOTE_N32 and $address =~ /$Net::IPAddress::Util::numberish/ and $address >= 0 and $address <= 4294967295
$Net::IPAddress::Util::PROMOTE_N32
$address =~ /$Net::IPAddress::Util::numberish/
$address >= 0
$address <= 4294967295
Truth table40%2/5
A and B and C and D
A= $Net::IPAddress::Util::PROMOTE_N32B= $address =~ /$Net::IPAddress::Util::numberish/C= $address >= 0D= $address <= 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $normal = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0xff, 0xff, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | unpack('C4', pack('N', $address)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | elsif ("$address" =~ $normalish) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $fresh = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | eval "require Math::BigInt" or return ERROR("Could not load Math::BigInt: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $raw = Math::BigInt->from_hex("$fresh"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | while ($raw > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $word = $raw->copy->band(0xffffffff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | unshift @$normal, unpack('C4', pack('N', $word)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $raw = $raw->copy->brsft(32); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | while (@$normal < 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | unshift @$normal, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | eval "no Math::BigInt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | elsif ($address =~ $numberish) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | eval "require Math::BigInt" or return ERROR("Could not load Math::BigInt: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | my $raw = Math::BigInt->new("$address"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | while ($raw > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my $word = $raw->copy->band(0xffffffff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | unshift @$normal, unpack('C4', pack('N', $word)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | $raw = $raw->copy->brsft(32); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | while (@$normal < 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | unshift @$normal, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | eval "no Math::BigInt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$address =~ /$Net::IPAddress::Util::sixish/ and scalar grep({/::/o;} split(/[[:alnum:]]+/, $address, 0)) == 1 || scalar grep({/[[:alnum:]]+/;} split(/:/, $address, 0)) == 8
scalar grep({/::/o;} split(/[[:alnum:]]+/, $address, 0)) == 1 or scalar grep({/[[:alnum:]]+/;} split(/:/, $address, 0)) == 8
MC/DC0%0/3
$address =~ /$Net::IPAddress::Util::sixish/ and scalar grep({/::/o;} split(/[[:alnum:]]+/, $address, 0)) == 1 || scalar grep({/[[:alnum:]]+/;} split(/:/, $address, 0)) == 8
$address =~ /$Net::IPAddress::Util::sixish/
scalar grep({/::/o;} split(/[[:alnum:]]+/, $address, 0)) == 1
scalar grep({/[[:alnum:]]+/;} split(/:/, $address, 0)) == 8
Truth table50%2/4
A and B or C
A= $address =~ /$Net::IPAddress::Util::sixish/B= scalar grep({/::/o;} split(/[[:alnum:]]+/, $address, 0)) == 1C= scalar grep({/[[:alnum:]]+/;} split(/:/, $address, 0)) == 8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $address =~ $sixish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | and ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 26 | scalar(grep { /::/o } split(/[[:alnum:]]+/, $address)) == 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 8 | or scalar(grep { /[[:alnum:]]+/ } split(/:/, $address)) == 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # new() from IPv6 address, accepting and ignoring the Scope ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 8 | $address = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | my ($lhs, $rhs) = split /::/, $address; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | ▶ | $rhs = '' unless defined $rhs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | my $hex = '0' x 32; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 8 | $lhs = join '', map { substr('0000' . $_, -4) } split /:/, $lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | $rhs = join '', map { substr('0000' . $_, -4) } split /:/, $rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | substr($hex, 0, length($lhs)) = $lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 8 | substr($hex, - length($rhs), length($rhs)) = $rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | my @hex = split //, $hex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | ▶ | while (@hex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 128 | push @$normal, hex(join('', splice(@hex, 0, 2))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif (length($address) == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $normal = [ unpack('C16', $address) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return ERROR("Invalid argument `$address', a(n) " . (ref($address) || 'bare scalar') . ' provided'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $address || 'bare scalar'
MC/DC0%0/1
ref $address || 'bare scalar'
ref $address
Truth table0%0/2
A
A= ref $address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1053 | ▶ | if ($REPAIR_V3_FORMAT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $normal = _repair_v3_format($normal); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1053 | return bless { address => pack('C16', @$normal) } => $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | sub is_ipv4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 812 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ipv4: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 812 | my @octets = unpack 'C16', $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $octets[ 8 ] == 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | && $octets[ 9 ] == 0xff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | && $octets[ 10 ] == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | && $octets[ 11 ] == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 812 | ▶ | && (!grep { $_ } @octets[ 0 .. 7 ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%9/12
$octets[8] == 255 && $octets[9] == 255 && $octets[10] == 0 && $octets[11] == 0 && !grep({$_;} @octets[0..7])
$octets[8] == 255 and $octets[9] == 255 and $octets[10] == 0 and $octets[11] == 0
$octets[8] == 255 and $octets[9] == 255 and $octets[10] == 0
$octets[8] == 255 and $octets[9] == 255
MC/DC40%2/5
$octets[8] == 255 && $octets[9] == 255 && $octets[10] == 0 && $octets[11] == 0 && !grep({$_;} @octets[0..7])
$octets[8] == 255
$octets[9] == 255
$octets[10] == 0
$octets[11] == 0
!grep({$_;} @octets[0..7])
Truth table50%3/6
A and B and C and D && not(E)
A= $octets[8] == 255B= $octets[9] == 255C= $octets[10] == 0D= $octets[11] == 0E= !grep({$_;} @octets[0..7])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub ipv4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 527 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipv4: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 527 | return join '.', unpack 'C4', substr($self->{ address }, -4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | sub as_n32 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_n32: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | return unpack 'N', substr($self->{ address }, -4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub as_n128 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_n128: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | my ($keep) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | eval "require Math::BigInt" or return ERROR("Could not load Math::BigInt: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $accum = Math::BigInt->new('0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | my $factor = Math::BigInt->new('1')->blsft(Math::BigInt->new('32')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | for my $i (map { $_ * 4 } 0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | $accum->bmul($factor); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | $accum->badd(Math::BigInt->new('' . unpack 'N', substr($self->{ address }, $i, 4))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | eval "no Math::BigInt" unless $keep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | $rv = $keep ? $accum : "$accum"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | sub normal_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normal_form: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 24 | my $hex = join('', map { sprintf('%02x', $_) } unpack('C16', $self->{ address })); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 24 | $hex = substr(('0' x 32) . $hex, -32); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 24 | return lc $hex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | sub ipv6_expanded { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipv6_expanded: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 17 | my $hex = $self->normal_form(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 17 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 17 | ▶ | while ($hex =~ /(....)/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 136 | ▶ | $rv .= ':' if defined $rv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 136 | $rv .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 17 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | sub ipv6 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipv6: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 18 | ▶ | if ($self->is_ipv4()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | return '::ffff:0:'.$self->ipv4(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 17 | my $iv = $self->ipv6_expanded(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 17 | ▶ | my $rv = join(':', map { (my $x = $_) =~ s/^0+//; $x ||= '0'; $x } split ':', $iv); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$x ||= 0
MC/DC100%1/1
$x ||= 0
$x
Truth table100%2/2
A
A= $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 17 | $rv =~ s/[^[:xdigit:]]0(:0)+/::/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 17 | $rv =~ s/::+/::/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 17 | $rv =~ s/^0::/::/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 17 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub as_str { return str(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_str: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub as_string { return str(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | sub str { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 542 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
str: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 542 | ▶ | if ($self->is_ipv4()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 525 | return $self->ipv4(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 17 | return $self->ipv6(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | sub _spaceship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 216 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spaceship: called CC=6 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 216 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 216 | my $lhs = $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 216 | $lhs = [ unpack 'N4', $lhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 216 | ▶ | $rhs = eval { $rhs->{ address } } || pack('N4', (0, 0, 0, $rhs)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
MC/DC0%0/2
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
eval {
do {
$rhs->{'address'}
}
}
pack('N4', (0, 0, 0, $rhs))
Truth table33%1/3
A || B
A= eval {
do {
$rhs->{'address'}
}
}B= pack('N4', (0, 0, 0, $rhs))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 216 | $rhs = [ unpack 'N4', $rhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 216 | ▶ | ($lhs, $rhs) = ($rhs, $lhs) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 216 | ▶ | return (1 - (2 * $swapped)) * ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
$lhs->[0] <=> $rhs->[0] || $lhs->[1] <=> $rhs->[1] || $lhs->[2] <=> $rhs->[2] || $lhs->[3] <=> $rhs->[3]
$lhs->[0] <=> $rhs->[0] or $lhs->[1] <=> $rhs->[1] or $lhs->[2] <=> $rhs->[2]
$lhs->[0] <=> $rhs->[0] or $lhs->[1] <=> $rhs->[1]
MC/DC25%1/4
$lhs->[0] <=> $rhs->[0] || $lhs->[1] <=> $rhs->[1] || $lhs->[2] <=> $rhs->[2] || $lhs->[3] <=> $rhs->[3]
$lhs->[0] <=> $rhs->[0]
$lhs->[1] <=> $rhs->[1]
$lhs->[2] <=> $rhs->[2]
$lhs->[3] <=> $rhs->[3]
Truth table40%2/5
A or B or C || D
A= $lhs->[0] <=> $rhs->[0]B= $lhs->[1] <=> $rhs->[1]C= $lhs->[2] <=> $rhs->[2]D= $lhs->[3] <=> $rhs->[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $lhs->[ 0 ] <=> $rhs->[ 0 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | || $lhs->[ 1 ] <=> $rhs->[ 1 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | || $lhs->[ 2 ] <=> $rhs->[ 2 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | || $lhs->[ 3 ] <=> $rhs->[ 3 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | sub _do_add { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do_add: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 16 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 16 | my ($pow, $mask) = $self->_pow_mask; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 16 | my $lhs = $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 16 | $lhs = [ unpack 'N4', $lhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 16 | ▶ | $rhs = eval { $rhs->{ address } } || pack('N4', (0, 0, 0, $rhs)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
MC/DC0%0/2
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
eval {
do {
$rhs->{'address'}
}
}
pack('N4', (0, 0, 0, $rhs))
Truth table33%1/3
A || B
A= eval {
do {
$rhs->{'address'}
}
}B= pack('N4', (0, 0, 0, $rhs))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 16 | $rhs = [ unpack 'N4', $rhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 16 | ▶ | ($lhs, $rhs) = ($rhs, $lhs) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 16 | my @l = reverse @$lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 16 | my @r = reverse @$rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 16 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 16 | for my $digit (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 64 | my $answer = $l[$digit] + $r[$digit]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 64 | ▶ | if ($answer > (2 ** 32) - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $r[$digit + 1] += int($answer / (2 ** 32)) if exists $r[$digit + 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $answer = $answer % (2 ** 32); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 64 | push @rv, $answer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 16 | @rv = $self->_mask_out($pow, $mask, reverse @rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 16 | my $retval = Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 16 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | sub _do_subtract { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do_subtract: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 8 | my ($pow, $mask) = $self->_pow_mask; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 8 | my $lhs = $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 8 | $lhs = [ unpack 'N4', $lhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 8 | ▶ | $rhs = eval { $rhs->{ address } } || pack('N4', (0, 0, 0, $rhs)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
MC/DC0%0/2
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
eval {
do {
$rhs->{'address'}
}
}
pack('N4', (0, 0, 0, $rhs))
Truth table33%1/3
A || B
A= eval {
do {
$rhs->{'address'}
}
}B= pack('N4', (0, 0, 0, $rhs))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 8 | $rhs = [ unpack 'N4', $rhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 8 | ▶ | ($lhs, $rhs) = ($rhs, $lhs) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 8 | my @l = reverse @$lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 8 | my @r = reverse @$rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | for my $digit (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 32 | my $answer = $l[$digit] - $r[$digit]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 32 | ▶ | if ($answer < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $answer += (2 ** 32) - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $r[$digit + 1] -= 1 if exists $r[$digit + 1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 32 | push @rv, $answer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 8 | @rv = $self->_mask_out($pow, $mask, reverse @rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 8 | my $retval = Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 8 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | sub _shift_left { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shift_left: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my ($pow, $mask) = $self->_pow_mask; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my @l = reverse unpack('C16', $self->{ address }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | for my $octet (0 .. 15) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $rv[$octet] += $l[$octet] << $rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ($rv[$octet] > 255) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $lsb = $rv[$octet] % 256; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | $rv[$octet + 1] += ($rv[$octet] - $lsb) >> 8 if $octet < 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $rv[$octet] = $lsb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | @rv = $self->_mask_out($pow, $mask, @rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | sub _shift_right { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shift_right: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my ($pow, $mask) = $self->_pow_mask; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my @l = unpack('C16', $self->{ address }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | for my $octet (0 .. 15) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $rv[$octet] += $l[$octet] >> $rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if (int($rv[$octet]) - $rv[$octet]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $msb = int($rv[$octet]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $lsb = $rv[$octet] << $rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $rv[$octet] = $msb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $rv[$octet + 1] += $lsb if $octet < 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | @rv = $self->_mask_out($pow, $mask, unpack('C16', pack('N4', @rv))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | return Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | sub _band { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 141 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_band: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 141 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 141 | ▶ | ($self, $rhs) = ($rhs, $self) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 141 | my $lhs = $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 141 | $lhs = [ unpack 'N4', $lhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 141 | ▶ | $rhs = eval { $rhs->{ address } } || pack('N4', (0, 0, 0, $rhs)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
MC/DC0%0/2
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
eval {
do {
$rhs->{'address'}
}
}
pack('N4', (0, 0, 0, $rhs))
Truth table33%1/3
A || B
A= eval {
do {
$rhs->{'address'}
}
}B= pack('N4', (0, 0, 0, $rhs))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 141 | $rhs = [ unpack 'N4', $rhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 141 | ▶ | ($lhs, $rhs) = ($rhs, $lhs) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 141 | my @l = @$lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 141 | my @r = @$rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 141 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 141 | for my $hextet (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 564 | $rv[$hextet] = $l[$hextet] & $r[$hextet]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 141 | return Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | sub _bor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 141 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bor: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 141 | my ($rhs, $swapped) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 141 | ▶ | ($self, $rhs) = ($rhs, $self) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 141 | my $lhs = $self->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 141 | $lhs = [ unpack 'N4', $lhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 141 | ▶ | $rhs = eval { $rhs->{ address } } || pack('N4', (0, 0, 0, $rhs)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
MC/DC0%0/2
eval {
do {
$rhs->{'address'}
}
} || pack('N4', (0, 0, 0, $rhs))
eval {
do {
$rhs->{'address'}
}
}
pack('N4', (0, 0, 0, $rhs))
Truth table33%1/3
A || B
A= eval {
do {
$rhs->{'address'}
}
}B= pack('N4', (0, 0, 0, $rhs))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 141 | $rhs = [ unpack 'N4', $rhs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 141 | ▶ | ($lhs, $rhs) = ($rhs, $lhs) if $swapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 141 | my @l = @$lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 141 | my @r = @$rhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 141 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 141 | for my $hextet (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 564 | $rv[$hextet] = $l[$hextet] | $r[$hextet]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 141 | return Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | sub _neg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 141 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_neg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 141 | my @n = unpack('C16', $self->{ address }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 141 | my @rv = map { 255 - $_ } @n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 141 | return Net::IPAddress::Util->new(\@rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub _pow_mask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pow_mask: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 24 | my $pow = 128; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 24 | my $mask = pack('N4', 0, 0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 24 | ▶ | if ($self->is_ipv4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 24 | $pow = 32; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 24 | $mask = pack('C16', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0xff, 0xff, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0, 0, 0, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 24 | return ($pow, $mask); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | sub _mask_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mask_out: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 24 | my ($pow, $mask, @rv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 24 | my @and = (0, 0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 24 | map { $and[ 4 - $_ ] = 0xffffffff } grep { $pow / $_ >= 32 } (1 .. 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 24 | my @or = unpack('N4', $mask); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 24 | ▶ | @rv = pairwise { $a & $b } @rv, @and; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 24 | ▶ | @rv = pairwise { $a | $b } @rv, @or; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 24 | return @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | sub ipv4_mask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 87 | ▶ | return implode_ip(('0' x 64) . ('1' x 16) . ('0' x 16) . ('1' x 32)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipv4_mask: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | sub ipv4_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | return implode_ip(('0' x 64) . ('1' x 16) . ('0' x 48)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipv4_flag: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | sub common_prefix (\@\@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 87 | ▶ | my ($x, $y) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
common_prefix: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 87 | ▶ | return ERROR("Something isn't right there") unless @$x == @$y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 87 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 87 | for my $i (0 .. $#$x) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 10856 | ▶ | if($x->[$i] eq $y->[$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 10775 | push @rv, $x->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 81 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 87 | return @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | sub prefix_mask (\@\@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 87 | ▶ | my ($x, $y) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix_mask: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 87 | ▶ | return ERROR("Something isn't right there") unless @$x == @$y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 87 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 87 | for my $i (0 .. $#$x) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 10856 | ▶ | if($x->[$i] == $y->[$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 10775 | push @rv, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 81 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 87 | return @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | sub ip_pad_prefix (\@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 174 | ▶ | my @array = @{$_[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ip_pad_prefix: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 174 | for my $i (scalar(@array) .. 127) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 722 | push @array, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 174 | return @array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | sub explode_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 174 | ▶ | my $ip = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
explode_ip: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 174 | return map { ~~$_ } split //, unpack 'B128', $ip->{ address }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | sub implode_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 314 | ▶ | return Net::IPAddress::Util->new([ unpack 'C16', pack 'B128', join '', map { ~~$_ } map { split // } @_ ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
implode_ip: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | sub n32_to_ipv4 { local $PROMOTE_N32 = 1; return IP(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
n32_to_ipv4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | sub ERROR { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | my $msg = @_ ? shift() : 'An error has occured'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ERROR: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if ($DIE_ON_ERROR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | confess($msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | cluck($msg) if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | sub radix_sort (\@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # In theory, a radix sort is O(N), which beats Perl's O(N log N) by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # a fair margin. However, it _does_ discard duplicates, so ymmv. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | shift if $_[0] eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
radix_sort: not called CC=5 SCAR=34.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $array = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $from = [ map { [ unpack 'C16', $_->{ address } ] } @$array ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | for (my $i = 15; $i >= 0; $i--) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $to = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | for my $card (@$from) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | push @{$to->[ $card->[ $i ] ]}, $card; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $from = [ map { @{$_ // []} } @$to ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ // []
MC/DC0%0/1
$_ // []
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my @rv = map { IP(pack 'C16', @$_) } @$from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | sub ip2num { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | carp('Compatibility function ip2num() is deprecated') if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ip2num: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $ip = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $self = IP($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $self &= ((2 ** 32) - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return $self->as_n32(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | sub num2ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | carp('Compatibility function num2ip() is deprecated') if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
num2ip: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $num = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $self = n32_to_ipv4($num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return $self->str(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | sub validaddr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | carp('Compatibility function validaddr() is deprecated') if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validaddr: not called CC=7 SCAR=40.3
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $ip = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my @octets = split(/\./, $ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | return unless scalar @octets == 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | for (@octets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | return unless defined $_ && $_ >= 0 && $_ <= 255; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_ and $_ >= 0 and $_ <= 255
defined $_ and $_ >= 0
MC/DC0%0/3
defined $_ and $_ >= 0 and $_ <= 255
defined $_
$_ >= 0
$_ <= 255
Truth table0%0/4
A and B and C
A= defined $_B= $_ >= 0C= $_ <= 255
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | sub mask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | carp('Compatibility function mask() is deprecated') if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mask: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my ($ip, $mask) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $self = IP($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $nm = IP($mask); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return $self & $nm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | sub fqdn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | carp('Compatibility function fqdn() is deprecated') if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fqdn: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $dn = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return split /\./, $dn, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||