blib/lib/Geo/IP2Proxy.pm

filter: Statementstmt 47.4% 378 / 796 Branchbran 21.5% 74 / 344 Conditioncond 30.6% 46 / 150 MC/DCmcdc 3.1% 3 / 95 Subroutinesub 67.1% 49 / 73 Podpod 50.0% 21 / 42 totaltotal 38.0% 571 / 1500 CC 227 SCAR 72.8
CC
227
Cov
39%
getIPv6Record
2806.7
getIPv4Record
2566.3
open
13.1
CRAP 1451.0
↑ Summary
1 #MIT License
2 #
3 #Copyright (c) 2026 IP2Location.com
4 #
5 #Permission is hereby granted, free of charge, to any person obtaining a copy
6 #of this software and associated documentation files (the "Software"), to deal
7 #in the Software without restriction, including without limitation the rights
8 #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 #copies of the Software, and to permit persons to whom the Software is
10 #furnished to do so, subject to the following conditions:
11 #
12 #The above copyright notice and this permission notice shall be included in all
13 #copies or substantial portions of the Software.
14 #
15 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 #SOFTWARE.
22  
23 package Geo::IP2Proxy;
24  
25 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 3 ▶use vars qw(@ISA $VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use Math::BigInt;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 3 $VERSION = '3.61';
30  
31 3 require Exporter;
32 3 @ISA = qw(Exporter);
33  
34 3 ▶use constant UNKNOWN => "UNKNOWN IP ADDRESS";
Subroutine BEGIN: called CC=1 SCAR=0.0
35 3 ▶use constant IPV6_ADDRESS_IN_IPV4_BIN => "IPV6 ADDRESS MISSING IN IPV4 BIN";
Subroutine BEGIN: called CC=1 SCAR=0.0
36 3 ▶use constant NO_IP => "MISSING IP ADDRESS";
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use constant INVALID_IPV6_ADDRESS => "INVALID IPV6 ADDRESS";
Subroutine BEGIN: called CC=1 SCAR=0.0
38 3 ▶use constant INVALID_IPV4_ADDRESS => "INVALID IPV4 ADDRESS";
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use constant INVALID_IP_ADDRESS => "INVALID IP ADDRESS";
Subroutine BEGIN: called CC=1 SCAR=0.0
40 3 ▶use constant INVALID_BIN_DATABASE => "Incorrect IP2Proxy BIN file format. Please make sure that you are using the latest IP2Proxy BIN file.";
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 ▶use constant NOT_SUPPORTED => "NOT SUPPORTED";
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use constant MAX_IPV4_RANGE => 4294967295;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 3 ▶use constant MAX_IPV6_RANGE => 340282366920938463463374607431768211455;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 3 ▶use constant COUNTRYSHORT => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 3 ▶use constant COUNTRYLONG => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 3 ▶use constant REGION => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 ▶use constant CITY => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 3 ▶use constant ISP => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 3 ▶use constant PROXYTYPE => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 3 ▶use constant ISPROXY => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 3 ▶use constant DOMAIN => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 3 ▶use constant USAGETYPE => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 3 ▶use constant ASN => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 3 ▶use constant AS => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 ▶use constant LASTSEEN => 12;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 3 ▶use constant THREAT => 13;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 3 ▶use constant PROVIDER => 14;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 3 ▶use constant FRAUDSCORE => 15;
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 3 ▶use constant ALL => 100;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 3 ▶use constant IPV4 => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 3 ▶use constant IPV6 => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 3 my @IPV4_COUNTRY_POSITION = (0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3);
66 3 my @IPV4_REGION_POSITION = (0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4);
67 3 my @IPV4_CITY_POSITION = (0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5);
68 3 my @IPV4_ISP_POSITION = (0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6);
69 3 my @IPV4_PROXYTYPE_POSITION = (0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
70 3 my @IPV4_DOMAIN_POSITION = (0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7);
71 3 my @IPV4_USAGETYPE_POSITION = (0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8);
72 3 my @IPV4_ASN_POSITION = (0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9);
73 3 my @IPV4_AS_POSITION = (0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10);
74 3 my @IPV4_LASTSEEN_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11);
75 3 my @IPV4_THREAT_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12);
76 3 my @IPV4_PROVIDER_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13);
77 3 my @IPV4_FRAUDSCORE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14);
78  
79 3 my @IPV6_COUNTRY_POSITION = (0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3);
80 3 my @IPV6_REGION_POSITION = (0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4);
81 3 my @IPV6_CITY_POSITION = (0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5);
82 3 my @IPV6_ISP_POSITION = (0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6);
83 3 my @IPV6_PROXYTYPE_POSITION = (0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
84 3 my @IPV6_DOMAIN_POSITION = (0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7);
85 3 my @IPV6_USAGETYPE_POSITION = (0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8);
86 3 my @IPV6_ASN_POSITION = (0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9);
87 3 my @IPV6_AS_POSITION = (0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10);
88 3 my @IPV6_LASTSEEN_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11);
89 3 my @IPV6_THREAT_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12);
90 3 my @IPV6_PROVIDER_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13);
91 3 my @IPV6_FRAUDSCORE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14);
92  
93 3 my $IPv6_re = qr/:(?::[0-9a-fA-F]{1,4}){0,5}(?:(?::[0-9a-fA-F]{1,4}){1,2}|:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})))|[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}|:)|(?::(?:[0-9a-fA-F]{1,4})?|(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))))|:(?:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})?|))|(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|:[0-9a-fA-F]{1,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){0,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,2}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,3}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))/;
94 3 my $IPv4_re = qr/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
95  
96 3 my $getLastErrorMessage = "";
97  
98 2 ▶sub open {
Subroutine open: called CC=7 SCAR=25.7
Pod documented
99 2 ▶ unless( (@_ > 1) && ($_[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ > 1 and $_[1]) 0 2 2
Condition33%1/3
@_ > 1 and $_[1]
!ll&&!rl&&r
002
MC/DC0%0/2
@_ > 1 and $_[1]
@_ > 1 $_[1]
Truth table33%1/3
A and B
A= @_ > 1B= $_[1]
ABresult
0X0
100
111
100 0 $getLastErrorMessage = "Geo::IP2Proxy::open() requires a database path name.";
101 0 die "Geo::IP2Proxy::open() requires a database path name";
102 }
103 2 my ($class, $db_file) = @_;
104 2 my $handle;
105 my $obj;
106 2 ▶ unless (CORE::open $handle, "$db_file") {
Branch: 1 branch
BranchTrueFalseTotal
unless (CORE::open $handle, "$db_file") 0 2 2
107 0 $getLastErrorMessage = "Geo::IP2Proxy::open() error in opening $db_file" . ".";
108 0 die "Geo::IP2Proxy::open() error in opening $db_file";
109 }
110 2 binmode($handle);
111 2 $obj = bless {filehandle => $handle}, $class;
112 2 $obj->initialize();
113 2 ▶ if ($obj->{"productcode"} == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{'productcode'} == 2) { } 0 2 2
114 } else {
115 2 ▶ if (($obj->{"databaseyear"} <= 20) && ($obj->{"productcode"} == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->{'databaseyear'} <= 20 and $obj->{'productcode'} == 0) { } 2 0 2
Condition33%1/3
$obj->{"databaseyear"} <= 20 and $obj->{"productcode"} == 0
!ll&&!rl&&r
002
MC/DC0%0/2
$obj->{"databaseyear"} <= 20 and $obj->{"productcode"} == 0
$obj->{"databaseyear"} <= 20 $obj->{"productcode"} == 0
Truth table33%1/3
A and B
A= $obj->{"databaseyear"} <= 20B= $obj->{"productcode"} == 0
ABresult
0X0
100
111
116 } else {
117 0 $obj->close();
118 0 undef $obj;
119 0 $getLastErrorMessage = INVALID_BIN_DATABASE;
120 0 die INVALID_BIN_DATABASE;
121 }
122 }
123 2 return $obj;
124 }
125  
126 0 ▶sub close {
Subroutine close: not called CC=2 SCAR=17.9
Pod undocumented
127 0 my ($class) = @_;
128 0 ▶ if (CORE::close($class->{filehandle})) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::close $class->{'filehandle'}) { } 0 0 0
129 0 return 0;
130 } else {
131 0 return 1;
132 }
133 }
134  
135 2 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod undocumented
136 2 my ($obj) = @_;
137 2 my @header = $obj->read512($obj->{filehandle}, 1);
138 2 $obj->{"databasetype"} = unpack("C", $header[0]);
139 2 $obj->{"databasecolumn"} = unpack("C", $header[1]);
140 2 $obj->{"databaseyear"} = unpack("C", $header[2]);
141 2 $obj->{"databasemonth"} = unpack("C", $header[3]);
142 2 $obj->{"databaseday"} = unpack("C", $header[4]);
143 2 $obj->{"ipv4databasecount"} = unpack("V", join('', @header[5..8]));
144 2 $obj->{"ipv4databaseaddr"} = unpack("V", join('', @header[9..12]));
145 2 $obj->{"ipv6databasecount"} = unpack("V", join('', @header[13..16]));
146 2 $obj->{"ipv6databaseaddr"} = unpack("V", join('', @header[17..20]));
147 2 $obj->{"ipv4indexbaseaddr"} = unpack("V", join('', @header[21..24]));
148 2 $obj->{"ipv6indexbaseaddr"} = unpack("V", join('', @header[25..28]));
149 2 $obj->{"productcode"} = unpack("C", $header[29]);
150 2 $obj->{"licensecode"} = unpack("C", $header[30]);
151 2 $obj->{"databasesize"} = unpack("V", join('', @header[31..34]));
152 2 return $obj;
153 }
154  
155 0 ▶sub get_last_error_message {
Subroutine get_last_error_message: not called CC=1 SCAR=6.9
Pod documented
156 0 my $class = shift(@_);
157 0 return ($getLastErrorMessage);
158 }
159  
160 0 ▶sub getModuleVersion {
Subroutine getModuleVersion: not called CC=1 SCAR=6.9
Pod documented
161 0 my $obj = shift(@_);
162 0 return $VERSION;
163 }
164  
165 0 ▶sub getPackageVersion {
Subroutine getPackageVersion: not called CC=1 SCAR=6.9
Pod documented
166 0 my $obj = shift(@_);
167 0 return $obj->{"databasetype"};
168 }
169  
170 0 ▶sub getDatabaseVersion {
Subroutine getDatabaseVersion: not called CC=1 SCAR=6.9
Pod documented
171 0 my $obj = shift(@_);
172 0 my $databaseyear = 2000 + $obj->{"databaseyear"};
173 0 return $databaseyear . "." . $obj->{"databasemonth"} . "." . $obj->{"databaseday"};
174 }
175  
176 6 ▶sub getCountryShort {
Subroutine getCountryShort: called CC=3 SCAR=11.1
Pod documented
177 6 my $obj = shift(@_);
178 6 my $ipaddr = shift(@_);
179 6 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
180 6 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 3 3 6
181 3 return $obj->getIPv4Record($ipnum, COUNTRYSHORT);
182 } else {
183 3 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 3 0 3
184 3 return $obj->getIPv6Record($ipnum, COUNTRYSHORT);
185 } else {
186 0 return INVALID_IP_ADDRESS;
187 }
188 }
189 }
190  
191 0 ▶sub getCountryLong {
Subroutine getCountryLong: not called CC=3 SCAR=24.8
Pod documented
192 0 my $obj = shift(@_);
193 0 my $ipaddr = shift(@_);
194 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
195 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
196 0 return $obj->getIPv4Record($ipnum, COUNTRYLONG);
197 } else {
198 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
199 0 return $obj->getIPv6Record($ipnum, COUNTRYLONG);
200 } else {
201 0 return INVALID_IP_ADDRESS;
202 }
203 }
204 }
205  
206 0 ▶sub getRegion {
Subroutine getRegion: not called CC=3 SCAR=24.8
Pod documented
207 0 my $obj = shift(@_);
208 0 my $ipaddr = shift(@_);
209 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
210 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
211 0 return $obj->getIPv4Record($ipnum, REGION);
212 } else {
213 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
214 0 return $obj->getIPv6Record($ipnum, REGION);
215 } else {
216 0 return INVALID_IP_ADDRESS;
217 }
218 }
219 }
220  
221 0 ▶sub getCity {
Subroutine getCity: not called CC=3 SCAR=24.8
Pod documented
222 0 my $obj = shift(@_);
223 0 my $ipaddr = shift(@_);
224 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
225 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
226 0 return $obj->getIPv4Record($ipnum, CITY);
227 } else {
228 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
229 0 return $obj->getIPv6Record($ipnum, CITY);
230 } else {
231 0 return INVALID_IP_ADDRESS;
232 }
233 }
234 }
235  
236 0 ▶sub getISP {
Subroutine getISP: not called CC=3 SCAR=24.8
Pod documented
237 0 my $obj = shift(@_);
238 0 my $ipaddr = shift(@_);
239 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
240 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
241 0 return $obj->getIPv4Record($ipnum, ISP);
242 } else {
243 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
244 0 return $obj->getIPv6Record($ipnum, ISP);
245 } else {
246 0 return INVALID_IP_ADDRESS;
247 }
248 }
249 }
250  
251 0 ▶sub getProxyType {
Subroutine getProxyType: not called CC=3 SCAR=24.8
Pod documented
252 0 my $obj = shift(@_);
253 0 my $ipaddr = shift(@_);
254 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
255 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
256 0 return $obj->getIPv4Record($ipnum, PROXYTYPE);
257 } else {
258 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
259 0 return $obj->getIPv6Record($ipnum, PROXYTYPE);
260 } else {
261 0 return INVALID_IP_ADDRESS;
262 }
263 }
264 }
265  
266 0 ▶sub isProxy {
Subroutine isProxy: not called CC=3 SCAR=24.8
Pod documented
267 0 my $obj = shift(@_);
268 0 my $ipaddr = shift(@_);
269 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
270 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
271 0 return $obj->getIPv4Record($ipnum, ISPROXY);
272 } else {
273 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
274 0 return $obj->getIPv6Record($ipnum, ISPROXY);
275 } else {
276 0 return -1;
277 }
278 }
279 }
280  
281 0 ▶sub getDomain {
Subroutine getDomain: not called CC=3 SCAR=24.8
Pod documented
282 0 my $obj = shift(@_);
283 0 my $ipaddr = shift(@_);
284 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
285 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
286 0 return $obj->getIPv4Record($ipnum, DOMAIN);
287 } else {
288 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
289 0 return $obj->getIPv6Record($ipnum, DOMAIN);
290 } else {
291 0 return INVALID_IP_ADDRESS;
292 }
293 }
294 }
295  
296 0 ▶sub getUsageType {
Subroutine getUsageType: not called CC=3 SCAR=24.8
Pod documented
297 0 my $obj = shift(@_);
298 0 my $ipaddr = shift(@_);
299 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
300 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
301 0 return $obj->getIPv4Record($ipnum, USAGETYPE);
302 } else {
303 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
304 0 return $obj->getIPv6Record($ipnum, USAGETYPE);
305 } else {
306 0 return INVALID_IP_ADDRESS;
307 }
308 }
309 }
310  
311 0 ▶sub getASN {
Subroutine getASN: not called CC=3 SCAR=24.8
Pod documented
312 0 my $obj = shift(@_);
313 0 my $ipaddr = shift(@_);
314 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
315 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
316 0 return $obj->getIPv4Record($ipnum, ASN);
317 } else {
318 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
319 0 return $obj->getIPv6Record($ipnum, ASN);
320 } else {
321 0 return INVALID_IP_ADDRESS;
322 }
323 }
324 }
325  
326 0 ▶sub getAS {
Subroutine getAS: not called CC=3 SCAR=24.8
Pod documented
327 0 my $obj = shift(@_);
328 0 my $ipaddr = shift(@_);
329 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
330 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
331 0 return $obj->getIPv4Record($ipnum, AS);
332 } else {
333 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
334 0 return $obj->getIPv6Record($ipnum, AS);
335 } else {
336 0 return INVALID_IP_ADDRESS;
337 }
338 }
339 }
340  
341 0 ▶sub getLastSeen {
Subroutine getLastSeen: not called CC=3 SCAR=24.8
Pod documented
342 0 my $obj = shift(@_);
343 0 my $ipaddr = shift(@_);
344 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
345 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
346 0 return $obj->getIPv4Record($ipnum, LASTSEEN);
347 } else {
348 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
349 0 return $obj->getIPv6Record($ipnum, LASTSEEN);
350 } else {
351 0 return INVALID_IP_ADDRESS;
352 }
353 }
354 }
355  
356 0 ▶sub getThreat {
Subroutine getThreat: not called CC=3 SCAR=24.8
Pod documented
357 0 my $obj = shift(@_);
358 0 my $ipaddr = shift(@_);
359 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
360 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
361 0 return $obj->getIPv4Record($ipnum, THREAT);
362 } else {
363 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
364 0 return $obj->getIPv6Record($ipnum, THREAT);
365 } else {
366 0 return INVALID_IP_ADDRESS;
367 }
368 }
369 }
370  
371 0 ▶sub getProvider {
Subroutine getProvider: not called CC=3 SCAR=24.8
Pod documented
372 0 my $obj = shift(@_);
373 0 my $ipaddr = shift(@_);
374 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
375 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
376 0 return $obj->getIPv4Record($ipnum, PROVIDER);
377 } else {
378 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
379 0 return $obj->getIPv6Record($ipnum, PROVIDER);
380 } else {
381 0 return INVALID_IP_ADDRESS;
382 }
383 }
384 }
385  
386 0 ▶sub getFraudScore {
Subroutine getFraudScore: not called CC=3 SCAR=24.8
Pod documented
387 0 my $obj = shift(@_);
388 0 my $ipaddr = shift(@_);
389 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
390 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
391 0 return $obj->getIPv4Record($ipnum, FRAUDSCORE);
392 } else {
393 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
394 0 return $obj->getIPv6Record($ipnum, FRAUDSCORE);
395 } else {
396 0 return INVALID_IP_ADDRESS;
397 }
398 }
399 }
400  
401 0 ▶sub getAll {
Subroutine getAll: not called CC=3 SCAR=24.8
Pod documented
402 0 my $obj = shift(@_);
403 0 my $ipaddr = shift(@_);
404 0 my ($ipv, $ipnum) = $obj->validateIP($ipaddr);
405 0 ▶ if ($ipv == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 4) { } 0 0 0
406 0 return $obj->getIPv4Record($ipnum, ALL);
407 } else {
408 0 ▶ if ($ipv == 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipv == 6) { } 0 0 0
409 0 return $obj->getIPv6Record($ipnum, ALL);
410 } else {
411 0 return (-1, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS, INVALID_IP_ADDRESS);
412 }
413 }
414 }
415  
416 3 ▶sub getIPv6Record {
Subroutine getIPv6Record: called CC=82 SCAR=79.4
Pod undocumented
417 3 my $obj = shift(@_);
418 3 my $ipnum = shift(@_);
419 3 my $mode = shift(@_);
420 3 my $dbtype = $obj->{"databasetype"};
421  
422 3 ▶ if ($ipnum eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipnum eq "") 0 3 3
423 0 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) { } 0 0 0
424 0 return (-1, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP);
425 } else {
426 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) { } 0 0 0
427 0 return -1;
428 } else {
429 0 return NO_IP;
430 }
431 }
432 }
433  
434 3 ▶ if (($mode == COUNTRYSHORT) && ($IPV6_COUNTRY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 1 and $IPV6_COUNTRY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 1 and $IPV6_COUNTRY_POSITION[$dbtype] == 0
!ll&&!rl&&r
030
MC/DC0%0/2
$mode == 1 and $IPV6_COUNTRY_POSITION[$dbtype] == 0
$mode == 1 $IPV6_COUNTRY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 1B= $IPV6_COUNTRY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
435 0 return NOT_SUPPORTED;
436 }
437 3 ▶ if (($mode == COUNTRYLONG) && ($IPV6_COUNTRY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 2 and $IPV6_COUNTRY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 2 and $IPV6_COUNTRY_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 2 and $IPV6_COUNTRY_POSITION[$dbtype] == 0
$mode == 2 $IPV6_COUNTRY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 2B= $IPV6_COUNTRY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
438 0 return NOT_SUPPORTED;
439 }
440 3 ▶ if (($mode == REGION) && ($IPV6_REGION_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 3 and $IPV6_REGION_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 3 and $IPV6_REGION_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 3 and $IPV6_REGION_POSITION[$dbtype] == 0
$mode == 3 $IPV6_REGION_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 3B= $IPV6_REGION_POSITION[$dbtype] == 0
ABresult
0X0
100
111
441 0 return NOT_SUPPORTED;
442 }
443 3 ▶ if (($mode == CITY) && ($IPV6_CITY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 4 and $IPV6_CITY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 4 and $IPV6_CITY_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 4 and $IPV6_CITY_POSITION[$dbtype] == 0
$mode == 4 $IPV6_CITY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 4B= $IPV6_CITY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
444 0 return NOT_SUPPORTED;
445 }
446 3 ▶ if (($mode == ISP) && ($IPV6_ISP_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 5 and $IPV6_ISP_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 5 and $IPV6_ISP_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 5 and $IPV6_ISP_POSITION[$dbtype] == 0
$mode == 5 $IPV6_ISP_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 5B= $IPV6_ISP_POSITION[$dbtype] == 0
ABresult
0X0
100
111
447 0 return NOT_SUPPORTED;
448 }
449 3 ▶ if (($mode == PROXYTYPE) && ($IPV6_PROXYTYPE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 6 and $IPV6_PROXYTYPE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 6 and $IPV6_PROXYTYPE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 6 and $IPV6_PROXYTYPE_POSITION[$dbtype] == 0
$mode == 6 $IPV6_PROXYTYPE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 6B= $IPV6_PROXYTYPE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
450 0 return NOT_SUPPORTED;
451 }
452 3 ▶ if (($mode == DOMAIN) && ($IPV6_DOMAIN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 8 and $IPV6_DOMAIN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 8 and $IPV6_DOMAIN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 8 and $IPV6_DOMAIN_POSITION[$dbtype] == 0
$mode == 8 $IPV6_DOMAIN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 8B= $IPV6_DOMAIN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
453 0 return NOT_SUPPORTED;
454 }
455 3 ▶ if (($mode == USAGETYPE) && ($IPV6_USAGETYPE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 9 and $IPV6_USAGETYPE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 9 and $IPV6_USAGETYPE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 9 and $IPV6_USAGETYPE_POSITION[$dbtype] == 0
$mode == 9 $IPV6_USAGETYPE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 9B= $IPV6_USAGETYPE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
456 0 return NOT_SUPPORTED;
457 }
458 3 ▶ if (($mode == ASN) && ($IPV6_ASN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 10 and $IPV6_ASN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 10 and $IPV6_ASN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 10 and $IPV6_ASN_POSITION[$dbtype] == 0
$mode == 10 $IPV6_ASN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 10B= $IPV6_ASN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
459 0 return NOT_SUPPORTED;
460 }
461 3 ▶ if (($mode == AS) && ($IPV6_AS_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 11 and $IPV6_AS_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 11 and $IPV6_AS_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 11 and $IPV6_AS_POSITION[$dbtype] == 0
$mode == 11 $IPV6_AS_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 11B= $IPV6_AS_POSITION[$dbtype] == 0
ABresult
0X0
100
111
462 0 return NOT_SUPPORTED;
463 }
464 3 ▶ if (($mode == LASTSEEN) && ($IPV6_LASTSEEN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 12 and $IPV6_LASTSEEN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 12 and $IPV6_LASTSEEN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 12 and $IPV6_LASTSEEN_POSITION[$dbtype] == 0
$mode == 12 $IPV6_LASTSEEN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 12B= $IPV6_LASTSEEN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
465 0 return NOT_SUPPORTED;
466 }
467 3 ▶ if (($mode == THREAT) && ($IPV6_THREAT_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 13 and $IPV6_THREAT_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 13 and $IPV6_THREAT_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 13 and $IPV6_THREAT_POSITION[$dbtype] == 0
$mode == 13 $IPV6_THREAT_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 13B= $IPV6_THREAT_POSITION[$dbtype] == 0
ABresult
0X0
100
111
468 0 return NOT_SUPPORTED;
469 }
470 3 ▶ if (($mode == PROVIDER) && ($IPV6_PROVIDER_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 14 and $IPV6_PROVIDER_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 14 and $IPV6_PROVIDER_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 14 and $IPV6_PROVIDER_POSITION[$dbtype] == 0
$mode == 14 $IPV6_PROVIDER_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 14B= $IPV6_PROVIDER_POSITION[$dbtype] == 0
ABresult
0X0
100
111
471 0 return NOT_SUPPORTED;
472 }
473 3 ▶ if (($mode == FRAUDSCORE) && ($IPV6_FRAUDSCORE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 15 and $IPV6_FRAUDSCORE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 15 and $IPV6_FRAUDSCORE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 15 and $IPV6_FRAUDSCORE_POSITION[$dbtype] == 0
$mode == 15 $IPV6_FRAUDSCORE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 15B= $IPV6_FRAUDSCORE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
474 0 return NOT_SUPPORTED;
475 }
476
477 3 my $realipno = Math::BigInt->new($ipnum);
478 3 my $handle = $obj->{"filehandle"};
479 3 my $baseaddr = $obj->{"ipv6databaseaddr"};
480 3 my $dbcount = $obj->{"ipv6databasecount"};
481 3 my $dbcolumn = $obj->{"databasecolumn"};
482 3 my $indexbaseaddr = $obj->{"ipv6indexbaseaddr"};
483  
484 3 ▶ if ($dbcount == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbcount == 0) 0 3 3
485 0 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) { } 0 0 0
486 0 return (IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN, IPV6_ADDRESS_IN_IPV4_BIN);
487 } else {
488 0 return IPV6_ADDRESS_IN_IPV4_BIN;
489 }
490 }
491  
492 3 my $ipnum1_2 = new Math::BigInt($ipnum);
493 3 my $remainder = 0;
494 3 ($ipnum1_2, $remainder) = $ipnum1_2->bdiv(2**112);
495 3 my $indexaddr = $indexbaseaddr + ($ipnum1_2 << 3);
496  
497 3 my $low = 0;
498 3 my $high = $dbcount;
499 3 ▶ if ($indexbaseaddr > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($indexbaseaddr > 0) 3 0 3
500 3 ($low, $high) = $obj->read32x2($handle, $indexaddr);
501 }
502  
503 3 my $mid = 0;
504 3 my $ipfrom = 0;
505 3 my $ipto = 0;
506 3 my $ipno = 0;
507  
508 3 $ipno = $realipno;
509 3 ▶ if ($realipno == "340282366920938463463374607431768211455") {
Branch: 1 branch
BranchTrueFalseTotal
if ($realipno == "340282366920938463463374607431768211455") 0 3 3
510 0 $ipno = $ipno->bsub(1);
511 }
512
513 3 my $raw_positions_row;
514  
515 3 ▶ while ($low <= $high) {
Branch: 1 branch
BranchTrueFalseTotal
if ($low <= $high) 4 0 4
516 4 $mid = int(($low + $high)/2);
517 4 ($ipfrom, $ipto, $raw_positions_row) = $obj->readRow128($handle, $baseaddr + $mid * (($dbcolumn * 4) + 12), $dbcolumn);
518  
519 4 ▶ if (($ipno >= $ipfrom) && ($ipno < $ipto)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipno >= $ipfrom and $ipno < $ipto) { } 3 1 4
Condition66%2/3
$ipno >= $ipfrom and $ipno < $ipto
!ll&&!rl&&r
103
MC/DC50%1/2
$ipno >= $ipfrom and $ipno < $ipto
$ipno >= $ipfrom $ipno < $ipto
Truth table66%2/3
A and B
A= $ipno >= $ipfromB= $ipno < $ipto
ABresult
0X0
100
111
520 3 my $row_pointer = $baseaddr + $mid * (($dbcolumn * 4) + 12);
521  
522 3 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) 0 3 3
523 0 my $countryshort = NOT_SUPPORTED;
524 0 my $countrylong = NOT_SUPPORTED;
525 0 my $region = NOT_SUPPORTED;
526 0 my $city = NOT_SUPPORTED;
527 0 my $isp = NOT_SUPPORTED;
528 0 my $proxytype = NOT_SUPPORTED;
529 0 my $domain = NOT_SUPPORTED;
530 0 my $usagetype = NOT_SUPPORTED;
531 0 my $asn = NOT_SUPPORTED;
532 0 my $as = NOT_SUPPORTED;
533 0 my $lastseen = NOT_SUPPORTED;
534 0 my $threat = NOT_SUPPORTED;
535 0 my $provider = NOT_SUPPORTED;
536 0 my $fraudscore = NOT_SUPPORTED;
537 0 my $isproxy = -1;
538
539 0 ▶ if ($IPV6_COUNTRY_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_COUNTRY_POSITION[$dbtype] != 0) 0 0 0
540 0 $countryshort = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_COUNTRY_POSITION[$dbtype]), 4)));
541 0 $countrylong = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_COUNTRY_POSITION[$dbtype]), 4)) + 3);
542 }
543 0 ▶ if ($IPV6_REGION_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_REGION_POSITION[$dbtype] != 0) 0 0 0
544 0 $region = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_REGION_POSITION[$dbtype]), 4)));
545 }
546 0 ▶ if ($IPV6_CITY_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_CITY_POSITION[$dbtype] != 0) 0 0 0
547 0 $city = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_CITY_POSITION[$dbtype]), 4)));
548 }
549 0 ▶ if ($IPV6_ISP_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_ISP_POSITION[$dbtype] != 0) 0 0 0
550 0 $isp = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_ISP_POSITION[$dbtype]), 4)));
551 }
552 0 ▶ if ($IPV6_PROXYTYPE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_PROXYTYPE_POSITION[$dbtype] != 0) 0 0 0
553 0 $proxytype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_PROXYTYPE_POSITION[$dbtype]), 4)));
554 }
555 0 ▶ if ($IPV6_DOMAIN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_DOMAIN_POSITION[$dbtype] != 0) 0 0 0
556 0 $domain = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_DOMAIN_POSITION[$dbtype]), 4)));
557 }
558 0 ▶ if ($IPV6_USAGETYPE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_USAGETYPE_POSITION[$dbtype] != 0) 0 0 0
559 0 $usagetype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_USAGETYPE_POSITION[$dbtype]), 4)));
560 }
561 0 ▶ if ($IPV6_ASN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_ASN_POSITION[$dbtype] != 0) 0 0 0
562 0 $asn = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_ASN_POSITION[$dbtype]), 4)));
563 }
564 0 ▶ if ($IPV6_AS_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_AS_POSITION[$dbtype] != 0) 0 0 0
565 0 $as = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_AS_POSITION[$dbtype]), 4)));
566 }
567 0 ▶ if ($IPV6_LASTSEEN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_LASTSEEN_POSITION[$dbtype] != 0) 0 0 0
568 0 $lastseen = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_LASTSEEN_POSITION[$dbtype]), 4)));
569 }
570 0 ▶ if ($IPV6_THREAT_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_THREAT_POSITION[$dbtype] != 0) 0 0 0
571 0 $threat = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_THREAT_POSITION[$dbtype]), 4)));
572 }
573 0 ▶ if ($IPV6_PROVIDER_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_PROVIDER_POSITION[$dbtype] != 0) 0 0 0
574 0 $provider = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_PROVIDER_POSITION[$dbtype]), 4)));
575 }
576 0 ▶ if ($IPV6_FRAUDSCORE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_FRAUDSCORE_POSITION[$dbtype] != 0) 0 0 0
577 0 $fraudscore = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_FRAUDSCORE_POSITION[$dbtype]), 4)));
578 }
579  
580 0 ▶ if (($countryshort eq "-") || ($proxytype eq "-")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($countryshort eq '-' or $proxytype eq '-') { } 0 0 0
Condition0%0/3
$countryshort eq "-" or $proxytype eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/2
$countryshort eq "-" or $proxytype eq "-"
$countryshort eq "-" $proxytype eq "-"
Truth table0%0/3
A or B
A= $countryshort eq "-"B= $proxytype eq "-"
ABresult
1X1
011
000
581 0 $isproxy = 0;
582 } else {
583 0 ▶ if (($proxytype eq "DCH") || ($proxytype eq "SES") || ($proxytype eq "AIC")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proxytype eq 'DCH' or $proxytype eq 'SES' or $proxytype eq 'AIC') { } 0 0 0
Condition0%0/6
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
l!l&&r!l&&!r
000
$proxytype eq "DCH" or $proxytype eq "SES"
l!l&&r!l&&!r
000
MC/DC0%0/3
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
$proxytype eq "DCH" $proxytype eq "SES" $proxytype eq "AIC"
Truth table0%0/4
A or B or C
A= $proxytype eq "DCH"B= $proxytype eq "SES"C= $proxytype eq "AIC"
ABCresult
1XX1
01X1
0011
0000
584 0 $isproxy = 2;
585 } else {
586 0 $isproxy = 1;
587 }
588 }
589 0 return ($isproxy, $proxytype, $countryshort, $countrylong, $region, $city, $isp, $domain, $usagetype, $asn, $as, $lastseen, $threat, $provider, $fraudscore);
590 }
591 3 ▶ if ($mode == COUNTRYSHORT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 1) 3 0 3
592 3 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_COUNTRY_POSITION[$dbtype]), 4)));
593 }
594 0 ▶ if ($mode == COUNTRYLONG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 2) 0 0 0
595 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_COUNTRY_POSITION[$dbtype]), 4)) + 3);
596 }
597 0 ▶ if ($mode == REGION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 3) 0 0 0
598 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_REGION_POSITION[$dbtype]), 4)));
599 }
600 0 ▶ if ($mode == CITY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 4) 0 0 0
601 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_CITY_POSITION[$dbtype]), 4)));
602 }
603 0 ▶ if ($mode == ISP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 5) 0 0 0
604 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_ISP_POSITION[$dbtype]), 4)));
605 }
606 0 ▶ if ($mode == PROXYTYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 6) 0 0 0
607 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_PROXYTYPE_POSITION[$dbtype]), 4)));
608 }
609 0 ▶ if ($mode == DOMAIN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 8) 0 0 0
610 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_DOMAIN_POSITION[$dbtype]), 4)));
611 }
612 0 ▶ if ($mode == USAGETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 9) 0 0 0
613 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_USAGETYPE_POSITION[$dbtype]), 4)));
614 }
615 0 ▶ if ($mode == ASN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 10) 0 0 0
616 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_ASN_POSITION[$dbtype]), 4)));
617 }
618 0 ▶ if ($mode == AS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 11) 0 0 0
619 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_AS_POSITION[$dbtype]), 4)));
620 }
621 0 ▶ if ($mode == LASTSEEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 12) 0 0 0
622 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_LASTSEEN_POSITION[$dbtype]), 4)));
623 }
624 0 ▶ if ($mode == THREAT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 13) 0 0 0
625 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_THREAT_POSITION[$dbtype]), 4)));
626 }
627 0 ▶ if ($mode == PROVIDER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 14) 0 0 0
628 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_PROVIDER_POSITION[$dbtype]), 4)));
629 }
630 0 ▶ if ($mode == FRAUDSCORE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 15) 0 0 0
631 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_FRAUDSCORE_POSITION[$dbtype]), 4)));
632 }
633  
634 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) 0 0 0
635 0 my $countryshort = NOT_SUPPORTED;
636 0 my $proxytype = NOT_SUPPORTED;
637 0 my $isproxy = NOT_SUPPORTED;
638 0 ▶ if ($IPV6_PROXYTYPE_POSITION[$dbtype] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV6_PROXYTYPE_POSITION[$dbtype] == 0) { } 0 0 0
639 # PX1, use country as detection
640 0 $countryshort = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_COUNTRY_POSITION[$dbtype]), 4)));
641 } else {
642 0 $proxytype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 8 + 4 * ($IPV6_PROXYTYPE_POSITION[$dbtype]), 4)));
643 }
644 0 ▶ if (($countryshort eq "-") || ($proxytype eq "-")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($countryshort eq '-' or $proxytype eq '-') { } 0 0 0
Condition0%0/3
$countryshort eq "-" or $proxytype eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/2
$countryshort eq "-" or $proxytype eq "-"
$countryshort eq "-" $proxytype eq "-"
Truth table0%0/3
A or B
A= $countryshort eq "-"B= $proxytype eq "-"
ABresult
1X1
011
000
645 0 $isproxy = 0;
646 } else {
647 0 ▶ if (($proxytype eq "DCH") || ($proxytype eq "SES") || ($proxytype eq "AIC")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proxytype eq 'DCH' or $proxytype eq 'SES' or $proxytype eq 'AIC') { } 0 0 0
Condition0%0/6
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
l!l&&r!l&&!r
000
$proxytype eq "DCH" or $proxytype eq "SES"
l!l&&r!l&&!r
000
MC/DC0%0/3
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
$proxytype eq "DCH" $proxytype eq "SES" $proxytype eq "AIC"
Truth table0%0/4
A or B or C
A= $proxytype eq "DCH"B= $proxytype eq "SES"C= $proxytype eq "AIC"
ABCresult
1XX1
01X1
0011
0000
648 0 $isproxy = 2;
649 } else {
650 0 $isproxy = 1;
651 }
652 }
653 0 return $isproxy;
654 }
655 } else {
656 1 ▶ if ($ipno < $ipfrom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipno < $ipfrom) { } 1 0 1
657 1 $high = $mid - 1;
658 } else {
659 0 $low = $mid + 1;
660 }
661 }
662 }
663 0 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) { } 0 0 0
664 0 return (-1, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN);
665 } else {
666 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) { } 0 0 0
667 0 return -1;
668 } else {
669 0 return UNKNOWN;
670 }
671 }
672 }
673  
674 3 ▶sub getIPv4Record {
Subroutine getIPv4Record: called CC=79 SCAR=78.5
Pod undocumented
675 3 my $obj = shift(@_);
676 3 my $ipnum = shift(@_);
677 3 my $mode = shift(@_);
678 3 my $dbtype= $obj->{"databasetype"};
679  
680 3 ▶ if ($ipnum eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipnum eq "") 0 3 3
681 0 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) { } 0 0 0
682 0 return (-1, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP, NO_IP);
683 } else {
684 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) { } 0 0 0
685 0 return -1;
686 } else {
687 0 return NO_IP;
688 }
689 }
690 }
691
692 3 ▶ if (($mode == COUNTRYSHORT) && ($IPV4_COUNTRY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 1 and $IPV4_COUNTRY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 1 and $IPV4_COUNTRY_POSITION[$dbtype] == 0
!ll&&!rl&&r
030
MC/DC0%0/2
$mode == 1 and $IPV4_COUNTRY_POSITION[$dbtype] == 0
$mode == 1 $IPV4_COUNTRY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 1B= $IPV4_COUNTRY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
693 0 return NOT_SUPPORTED;
694 }
695 3 ▶ if (($mode == COUNTRYLONG) && ($IPV4_COUNTRY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 2 and $IPV4_COUNTRY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 2 and $IPV4_COUNTRY_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 2 and $IPV4_COUNTRY_POSITION[$dbtype] == 0
$mode == 2 $IPV4_COUNTRY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 2B= $IPV4_COUNTRY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
696 0 return NOT_SUPPORTED;
697 }
698 3 ▶ if (($mode == REGION) && ($IPV4_REGION_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 3 and $IPV4_REGION_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 3 and $IPV4_REGION_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 3 and $IPV4_REGION_POSITION[$dbtype] == 0
$mode == 3 $IPV4_REGION_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 3B= $IPV4_REGION_POSITION[$dbtype] == 0
ABresult
0X0
100
111
699 0 return NOT_SUPPORTED;
700 }
701 3 ▶ if (($mode == CITY) && ($IPV4_CITY_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 4 and $IPV4_CITY_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 4 and $IPV4_CITY_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 4 and $IPV4_CITY_POSITION[$dbtype] == 0
$mode == 4 $IPV4_CITY_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 4B= $IPV4_CITY_POSITION[$dbtype] == 0
ABresult
0X0
100
111
702 0 return NOT_SUPPORTED;
703 }
704 3 ▶ if (($mode == ISP) && ($IPV4_ISP_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 5 and $IPV4_ISP_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 5 and $IPV4_ISP_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 5 and $IPV4_ISP_POSITION[$dbtype] == 0
$mode == 5 $IPV4_ISP_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 5B= $IPV4_ISP_POSITION[$dbtype] == 0
ABresult
0X0
100
111
705 0 return NOT_SUPPORTED;
706 }
707 3 ▶ if (($mode == PROXYTYPE) && ($IPV4_PROXYTYPE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 6 and $IPV4_PROXYTYPE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 6 and $IPV4_PROXYTYPE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 6 and $IPV4_PROXYTYPE_POSITION[$dbtype] == 0
$mode == 6 $IPV4_PROXYTYPE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 6B= $IPV4_PROXYTYPE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
708 0 return NOT_SUPPORTED;
709 }
710 3 ▶ if (($mode == DOMAIN) && ($IPV4_DOMAIN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 8 and $IPV4_DOMAIN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 8 and $IPV4_DOMAIN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 8 and $IPV4_DOMAIN_POSITION[$dbtype] == 0
$mode == 8 $IPV4_DOMAIN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 8B= $IPV4_DOMAIN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
711 0 return NOT_SUPPORTED;
712 }
713 3 ▶ if (($mode == USAGETYPE) && ($IPV4_USAGETYPE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 9 and $IPV4_USAGETYPE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 9 and $IPV4_USAGETYPE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 9 and $IPV4_USAGETYPE_POSITION[$dbtype] == 0
$mode == 9 $IPV4_USAGETYPE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 9B= $IPV4_USAGETYPE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
714 0 return NOT_SUPPORTED;
715 }
716 3 ▶ if (($mode == ASN) && ($IPV4_ASN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 10 and $IPV4_ASN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 10 and $IPV4_ASN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 10 and $IPV4_ASN_POSITION[$dbtype] == 0
$mode == 10 $IPV4_ASN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 10B= $IPV4_ASN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
717 0 return NOT_SUPPORTED;
718 }
719 3 ▶ if (($mode == AS) && ($IPV4_AS_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 11 and $IPV4_AS_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 11 and $IPV4_AS_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 11 and $IPV4_AS_POSITION[$dbtype] == 0
$mode == 11 $IPV4_AS_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 11B= $IPV4_AS_POSITION[$dbtype] == 0
ABresult
0X0
100
111
720 0 return NOT_SUPPORTED;
721 }
722 3 ▶ if (($mode == LASTSEEN) && ($IPV4_LASTSEEN_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 12 and $IPV4_LASTSEEN_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 12 and $IPV4_LASTSEEN_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 12 and $IPV4_LASTSEEN_POSITION[$dbtype] == 0
$mode == 12 $IPV4_LASTSEEN_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 12B= $IPV4_LASTSEEN_POSITION[$dbtype] == 0
ABresult
0X0
100
111
723 0 return NOT_SUPPORTED;
724 }
725 3 ▶ if (($mode == THREAT) && ($IPV4_THREAT_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 13 and $IPV4_THREAT_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 13 and $IPV4_THREAT_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 13 and $IPV4_THREAT_POSITION[$dbtype] == 0
$mode == 13 $IPV4_THREAT_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 13B= $IPV4_THREAT_POSITION[$dbtype] == 0
ABresult
0X0
100
111
726 0 return NOT_SUPPORTED;
727 }
728 3 ▶ if (($mode == PROVIDER) && ($IPV4_PROVIDER_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 14 and $IPV4_PROVIDER_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 14 and $IPV4_PROVIDER_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 14 and $IPV4_PROVIDER_POSITION[$dbtype] == 0
$mode == 14 $IPV4_PROVIDER_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 14B= $IPV4_PROVIDER_POSITION[$dbtype] == 0
ABresult
0X0
100
111
729 0 return NOT_SUPPORTED;
730 }
731 3 ▶ if (($mode == FRAUDSCORE) && ($IPV4_FRAUDSCORE_POSITION[$dbtype] == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 15 and $IPV4_FRAUDSCORE_POSITION[$dbtype] == 0) 0 3 3
Condition33%1/3
$mode == 15 and $IPV4_FRAUDSCORE_POSITION[$dbtype] == 0
!ll&&!rl&&r
300
MC/DC0%0/2
$mode == 15 and $IPV4_FRAUDSCORE_POSITION[$dbtype] == 0
$mode == 15 $IPV4_FRAUDSCORE_POSITION[$dbtype] == 0
Truth table33%1/3
A and B
A= $mode == 15B= $IPV4_FRAUDSCORE_POSITION[$dbtype] == 0
ABresult
0X0
100
111
732 0 return NOT_SUPPORTED;
733 }
734  
735 3 my $realipno = $ipnum;
736 3 my $handle = $obj->{"filehandle"};
737 3 my $baseaddr = $obj->{"ipv4databaseaddr"};
738 3 my $dbcount = $obj->{"ipv4databasecount"};
739 3 my $dbcolumn = $obj->{"databasecolumn"};
740 3 my $indexbaseaddr = $obj->{"ipv4indexbaseaddr"};
741  
742 3 my $ipnum1_2 = int($ipnum >> 16);
743 3 my $indexaddr = $indexbaseaddr + ($ipnum1_2 << 3);
744  
745 3 my $low = 0;
746 3 my $high = $dbcount;
747 3 ▶ if ($indexbaseaddr > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($indexbaseaddr > 0) 3 0 3
748 3 ($low, $high) = $obj->read32x2($handle, $indexaddr);
749 }
750 3 my $mid = 0;
751 3 my $ipfrom = 0;
752 3 my $ipto = 0;
753 3 my $ipno = 0;
754  
755 3 ▶ if ($realipno == MAX_IPV4_RANGE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($realipno == 4294967295) { } 0 3 3
756 0 $ipno = $realipno - 1;
757 } else {
758 3 $ipno = $realipno;
759 }
760
761 3 my $raw_positions_row;
762  
763 3 ▶ while ($low <= $high) {
Branch: 1 branch
BranchTrueFalseTotal
if ($low <= $high) 15 0 15
764 15 $mid = int(($low + $high) >> 1);
765 15 ($ipfrom, $ipto, $raw_positions_row) = $obj->readRow32($handle, $baseaddr + $mid * $dbcolumn * 4, $dbcolumn);
766
767 15 ▶ if (($ipno >= $ipfrom) && ($ipno < $ipto)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipno >= $ipfrom and $ipno < $ipto) { } 3 12 15
Condition100%3/3
$ipno >= $ipfrom and $ipno < $ipto
!ll&&!rl&&r
933
MC/DC100%2/2
$ipno >= $ipfrom and $ipno < $ipto
$ipno >= $ipfrom $ipno < $ipto
Truth table100%3/3
A and B
A= $ipno >= $ipfromB= $ipno < $ipto
ABresult
0X0
100
111
768 3 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) 0 3 3
769 0 my $countryshort = NOT_SUPPORTED;
770 0 my $countrylong = NOT_SUPPORTED;
771 0 my $region = NOT_SUPPORTED;
772 0 my $city = NOT_SUPPORTED;
773 0 my $isp = NOT_SUPPORTED;
774 0 my $proxytype = NOT_SUPPORTED;
775 0 my $domain = NOT_SUPPORTED;
776 0 my $usagetype = NOT_SUPPORTED;
777 0 my $asn = NOT_SUPPORTED;
778 0 my $as = NOT_SUPPORTED;
779 0 my $lastseen = NOT_SUPPORTED;
780 0 my $threat = NOT_SUPPORTED;
781 0 my $provider = NOT_SUPPORTED;
782 0 my $fraudscore = NOT_SUPPORTED;
783 0 my $isproxy = -1;
784  
785 0 ▶ if ($IPV4_COUNTRY_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_COUNTRY_POSITION[$dbtype] != 0) 0 0 0
786 0 my $pos = unpack("V", substr($raw_positions_row, 4 * ($IPV4_COUNTRY_POSITION[$dbtype]-1), 4));
787 0 $countryshort = $obj->readStr($handle, $pos);
788 0 $countrylong = $obj->readStr($handle, $pos + 3);
789 }
790 0 ▶ if ($IPV4_REGION_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_REGION_POSITION[$dbtype] != 0) 0 0 0
791 0 $region = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_REGION_POSITION[$dbtype]-1), 4)));
792 }
793 0 ▶ if ($IPV4_CITY_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_CITY_POSITION[$dbtype] != 0) 0 0 0
794 0 $city = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_CITY_POSITION[$dbtype]-1), 4)));
795 }
796 0 ▶ if ($IPV4_ISP_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_ISP_POSITION[$dbtype] != 0) 0 0 0
797 0 $isp = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_ISP_POSITION[$dbtype]-1), 4)));
798 }
799 0 ▶ if ($IPV4_PROXYTYPE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_PROXYTYPE_POSITION[$dbtype] != 0) 0 0 0
800 0 $proxytype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_PROXYTYPE_POSITION[$dbtype]-1), 4)));
801 }
802 0 ▶ if ($IPV4_DOMAIN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_DOMAIN_POSITION[$dbtype] != 0) 0 0 0
803 0 $domain = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_DOMAIN_POSITION[$dbtype]-1), 4)));
804 }
805 0 ▶ if ($IPV4_USAGETYPE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_USAGETYPE_POSITION[$dbtype] != 0) 0 0 0
806 0 $usagetype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_USAGETYPE_POSITION[$dbtype]-1), 4)));
807 }
808 0 ▶ if ($IPV4_ASN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_ASN_POSITION[$dbtype] != 0) 0 0 0
809 0 $asn = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_ASN_POSITION[$dbtype]-1), 4)));
810 }
811 0 ▶ if ($IPV4_AS_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_AS_POSITION[$dbtype] != 0) 0 0 0
812 0 $as = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_AS_POSITION[$dbtype]-1), 4)));
813 }
814 0 ▶ if ($IPV4_LASTSEEN_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_LASTSEEN_POSITION[$dbtype] != 0) 0 0 0
815 0 $lastseen = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_LASTSEEN_POSITION[$dbtype]-1), 4)));
816 }
817 0 ▶ if ($IPV4_THREAT_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_THREAT_POSITION[$dbtype] != 0) 0 0 0
818 0 $threat = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_THREAT_POSITION[$dbtype]-1), 4)));
819 }
820 0 ▶ if ($IPV4_PROVIDER_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_PROVIDER_POSITION[$dbtype] != 0) 0 0 0
821 0 $provider = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_PROVIDER_POSITION[$dbtype]-1), 4)));
822 }
823 0 ▶ if ($IPV4_FRAUDSCORE_POSITION[$dbtype] != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_FRAUDSCORE_POSITION[$dbtype] != 0) 0 0 0
824 0 $fraudscore = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_FRAUDSCORE_POSITION[$dbtype]-1), 4)));
825 }
826  
827 0 ▶ if ($countryshort eq "-") {
Branch: 1 branch
BranchTrueFalseTotal
if ($countryshort eq '-') { } 0 0 0
828 0 $isproxy = 0;
829 } else {
830 0 ▶ if (($proxytype eq "DCH") || ($proxytype eq "SES") || ($proxytype eq "AIC")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proxytype eq 'DCH' or $proxytype eq 'SES' or $proxytype eq 'AIC') { } 0 0 0
Condition0%0/6
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
l!l&&r!l&&!r
000
$proxytype eq "DCH" or $proxytype eq "SES"
l!l&&r!l&&!r
000
MC/DC0%0/3
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
$proxytype eq "DCH" $proxytype eq "SES" $proxytype eq "AIC"
Truth table0%0/4
A or B or C
A= $proxytype eq "DCH"B= $proxytype eq "SES"C= $proxytype eq "AIC"
ABCresult
1XX1
01X1
0011
0000
831 0 $isproxy = 2;
832 } else {
833 0 $isproxy = 1;
834 }
835 }
836 0 return ($isproxy, $proxytype, $countryshort, $countrylong, $region, $city, $isp, $domain, $usagetype, $asn, $as, $lastseen, $threat, $provider, $fraudscore);
837 }
838 3 ▶ if ($mode == COUNTRYSHORT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 1) 3 0 3
839 3 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_COUNTRY_POSITION[$dbtype]-1), 4)));
840 }
841 0 ▶ if ($mode == COUNTRYLONG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 2) 0 0 0
842 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_COUNTRY_POSITION[$dbtype]-1), 4))+3);
843 }
844 0 ▶ if ($mode == REGION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 3) 0 0 0
845 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_REGION_POSITION[$dbtype]-1), 4)));
846 }
847 0 ▶ if ($mode == CITY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 4) 0 0 0
848 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_CITY_POSITION[$dbtype]-1), 4)));
849 }
850 0 ▶ if ($mode == ISP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 5) 0 0 0
851 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_ISP_POSITION[$dbtype]-1), 4)));
852 }
853 0 ▶ if ($mode == PROXYTYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 6) 0 0 0
854 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_PROXYTYPE_POSITION[$dbtype]-1), 4)));
855 }
856 0 ▶ if ($mode == DOMAIN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 8) 0 0 0
857 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_DOMAIN_POSITION[$dbtype]-1), 4)));
858 }
859 0 ▶ if ($mode == USAGETYPE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 9) 0 0 0
860 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_USAGETYPE_POSITION[$dbtype]-1), 4)));
861 }
862 0 ▶ if ($mode == ASN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 10) 0 0 0
863 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_ASN_POSITION[$dbtype]-1), 4)));
864 }
865 0 ▶ if ($mode == AS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 11) 0 0 0
866 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_AS_POSITION[$dbtype]-1), 4)));
867 }
868 0 ▶ if ($mode == LASTSEEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 12) 0 0 0
869 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_LASTSEEN_POSITION[$dbtype]-1), 4)));
870 }
871 0 ▶ if ($mode == THREAT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 13) 0 0 0
872 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_THREAT_POSITION[$dbtype]-1), 4)));
873 }
874 0 ▶ if ($mode == PROVIDER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 14) 0 0 0
875 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_PROVIDER_POSITION[$dbtype]-1), 4)));
876 }
877 0 ▶ if ($mode == FRAUDSCORE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 15) 0 0 0
878 0 return $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_FRAUDSCORE_POSITION[$dbtype]-1), 4)));
879 }
880 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) 0 0 0
881 0 my $countryshort = NOT_SUPPORTED;
882 0 my $proxytype = NOT_SUPPORTED;
883 0 my $isproxy = NOT_SUPPORTED;
884 0 ▶ if ($IPV4_PROXYTYPE_POSITION[$dbtype] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IPV4_PROXYTYPE_POSITION[$dbtype] == 0) { } 0 0 0
885 # PX1, use country as detection
886 0 $countryshort = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_COUNTRY_POSITION[$dbtype]-1), 4)));
887 } else {
888 0 $proxytype = $obj->readStr($handle, unpack("V", substr($raw_positions_row, 4 * ($IPV4_PROXYTYPE_POSITION[$dbtype]-1), 4)));
889 }
890 0 ▶ if (($countryshort eq "-") || ($proxytype eq "-")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($countryshort eq '-' or $proxytype eq '-') { } 0 0 0
Condition0%0/3
$countryshort eq "-" or $proxytype eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/2
$countryshort eq "-" or $proxytype eq "-"
$countryshort eq "-" $proxytype eq "-"
Truth table0%0/3
A or B
A= $countryshort eq "-"B= $proxytype eq "-"
ABresult
1X1
011
000
891 0 $isproxy = 0;
892 } else {
893 0 ▶ if (($proxytype eq "DCH") || ($proxytype eq "SES") || ($proxytype eq "AIC")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proxytype eq 'DCH' or $proxytype eq 'SES' or $proxytype eq 'AIC') { } 0 0 0
Condition0%0/6
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
l!l&&r!l&&!r
000
$proxytype eq "DCH" or $proxytype eq "SES"
l!l&&r!l&&!r
000
MC/DC0%0/3
$proxytype eq "DCH" or $proxytype eq "SES" or $proxytype eq "AIC"
$proxytype eq "DCH" $proxytype eq "SES" $proxytype eq "AIC"
Truth table0%0/4
A or B or C
A= $proxytype eq "DCH"B= $proxytype eq "SES"C= $proxytype eq "AIC"
ABCresult
1XX1
01X1
0011
0000
894 0 $isproxy = 2;
895 } else {
896 0 $isproxy = 1;
897 }
898 }
899 0 return $isproxy;
900 }
901 } else {
902 12 ▶ if ($ipno < $ipfrom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipno < $ipfrom) { } 9 3 12
903 9 $high = $mid - 1;
904 } else {
905 3 $low = $mid + 1;
906 }
907 }
908 }
909 0 ▶ if ($mode == ALL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 100) { } 0 0 0
910 0 return (-1, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN);
911 } else {
912 0 ▶ if ($mode == ISPROXY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 7) { } 0 0 0
913 0 return -1;
914 } else {
915 0 return UNKNOWN;
916 }
917 }
918 }
919  
920 15 ▶sub readRow32 {
Subroutine readRow32: called CC=1 SCAR=0.0
Pod undocumented
921 15 my ($obj, $handle, $position, $column) = @_;
922 15 my $data = "";
923 15 my $data_length = $column * 4 + 4;
924 15 seek($handle, $position-1, 0);
925 15 read($handle, $data, $data_length);
926 15 my $ipfrom = substr($data, 0, 4);
927 15 my $ipfrom_next = substr($data, $data_length - 4, 4);
928 15 my $result_row = substr($data, 0, $data_length - 4);
929 15 return (unpack("V", $ipfrom), unpack("V", $ipfrom_next), $result_row);
930 }
931  
932 4 ▶sub readRow128 {
Subroutine readRow128: called CC=1 SCAR=0.0
Pod undocumented
933 4 my ($obj, $handle, $position, $column) = @_;
934 4 my $data = "";
935 4 my $data_length = $column * 4 + 12 + 16;
936 4 seek($handle, $position-1, 0);
937 4 read($handle, $data, $data_length);
938 4 my $ipfrom = substr($data, 0, 16);
939 4 my $ipfrom_next = substr($data, $data_length - 16, 16);
940 4 my $result_row = substr($data, 0, $data_length - 16);
941 4 return (&bytesInt($ipfrom), &bytesInt($ipfrom_next), $result_row);
942 }
943  
944 2 ▶sub read512 {
Subroutine read512: called CC=2 SCAR=7.1
Pod undocumented
945 2 my ($obj, $handle, $position) = @_;
946 2 my $data = "";
947 2 seek($handle, $position-1, 0);
948 2 read($handle, $data, 64);
949 2 my @data_array = split('', $data);
950 2 ▶ while ($#data_array < 63) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#data_array < 63) 0 2 2
951 0 $data_array[$#data_array+1] = 0x00;
952 }
953 2 return @data_array;
954 }
955  
956 6 ▶sub read32x2 {
Subroutine read32x2: called CC=1 SCAR=0.0
Pod undocumented
957 6 my ($obj, $handle, $position) = @_;
958 6 my $data = "";
959 6 seek($handle, $position-1, 0);
960 6 read($handle, $data, 8);
961 6 my $data_1 = substr($data, 0, 4);
962 6 my $data_2 = substr($data, 4, 4);
963 6 return (unpack("V", $data_1), unpack("V", $data_2));
964 }
965  
966 0 ▶sub read128 {
Subroutine read128: not called CC=1 SCAR=6.9
Pod undocumented
967 0 my ($obj, $handle, $position) = @_;
968 0 my $data = "";
969 0 seek($handle, $position-1, 0);
970 0 read($handle, $data, 16);
971 0 return &bytesInt($data);
972 }
973  
974 0 ▶sub read32 {
Subroutine read32: not called CC=1 SCAR=6.9
Pod undocumented
975 0 my ($obj, $handle, $position) = @_;
976 0 my $data = "";
977 0 seek($handle, $position-1, 0);
978 0 read($handle, $data, 4);
979 0 return unpack("V", $data);
980 }
981  
982 0 ▶sub read8 {
Subroutine read8: not called CC=1 SCAR=6.9
Pod undocumented
983 0 my ($obj, $handle, $position) = @_;
984 0 my $data = "";
985 0 seek($handle, $position-1, 0);
986 0 read($handle, $data, 1);
987 0 return unpack("C", $data);
988 }
989  
990 6 ▶sub readStr {
Subroutine readStr: called CC=1 SCAR=0.0
Pod undocumented
991 6 my ($obj, $handle, $position) = @_;
992 6 my $data = "";
993 6 my $string = "";
994 6 seek($handle, $position, 0);
995 6 read($handle, $data, 1);
996 6 read($handle, $string, unpack("C", $data));
997 6 return $string;
998 }
999  
1000 0 ▶sub readFloat {
Subroutine readFloat: not called CC=2 SCAR=17.9
Pod undocumented
1001 0 my ($obj, $handle, $position) = @_;
1002 0 my $data = "";
1003 0 seek($handle, $position-1, 0);
1004 0 read($handle, $data, 4);
1005  
1006 0 my $is_little_endian = unpack("h*", pack("s", 1));
1007 0 ▶ if ($is_little_endian =~ m/^1/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_little_endian =~ /^1/) { } 0 0 0
1008 # "LITTLE ENDIAN - x86\n";
1009 0 return unpack("f", $data);
1010 } else {
1011 # "BIG ENDIAN - MAC\n";
1012 0 return unpack("f", reverse($data));
1013 }
1014 }
1015  
1016 8 ▶sub bytesInt {
Subroutine bytesInt: called CC=2 SCAR=6.9
Pod undocumented
1017 8 my $binip = shift(@_);
1018 8 my @array = split(//, $binip);
1019 8 ▶ return 0 if ($#array != 15);
Branch: 1 branch
BranchTrueFalseTotal
if $#array != 15 0 8 8
1020 8 my $ip96_127 = unpack("V", $array[0] . $array[1] . $array[2] . $array[3]);
1021 8 my $ip64_95 = unpack("V", $array[4] . $array[5] . $array[6] . $array[7]);
1022 8 my $ip32_63 = unpack("V", $array[8] . $array[9] . $array[10] . $array[11]);
1023 8 my $ip1_31 = unpack("V", $array[12] . $array[13] . $array[14] . $array[15]);
1024  
1025 8 my $big1 = Math::BigInt->new("$ip96_127");
1026 8 my $big2 = Math::BigInt->new("$ip64_95")->blsft(32);
1027 8 my $big3 = Math::BigInt->new("$ip32_63")->blsft(64);
1028 8 my $big4 = Math::BigInt->new("$ip1_31")->blsft(96);
1029 8 $big1 = $big1->badd($big2)->badd($big3)->badd($big4);
1030
1031 8 return $big1->bstr();
1032 }
1033  
1034 6 ▶sub validateIP {
Subroutine validateIP: called CC=9 SCAR=25.6
Pod undocumented
1035 6 my $obj = shift(@_);
1036 6 my $ip = shift(@_);
1037 6 my $ipv = -1;
1038 6 my $ipnum = -1;
1039
1040 #name server lookup if domain name
1041 6 $ip = $obj->nameIP($ip);
1042
1043 6 ▶ if ($obj->isIPv4($ip)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->isIPv4($ip)) { } 3 3 6
1044 #ipv4 address
1045 3 $ipv = 4;
1046 3 $ipnum = $obj->ipNo($ip);
1047 } else {
1048 #expand ipv6 address
1049 3 $ip = $obj->expandIPv6Address($ip);
1050 3 ▶ if ($obj->isIPv6($ip)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->isIPv6($ip)) { } 3 0 3
1051 #ipv6 address
1052 3 $ipv = 6;
1053 3 $ipnum = $obj->hexInt($ip);
1054
1055 #reformat ipv4 address in ipv6
1056 3 ▶ if (($ipnum >= 281470681743360) && ($ipnum <= 281474976710655)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipnum >= '281470681743360' and $ipnum <= '281474976710655') 0 3 3
Condition66%2/3
$ipnum >= '281470681743360' and $ipnum <= '281474976710655'
!ll&&!rl&&r
120
MC/DC0%0/2
$ipnum >= '281470681743360' and $ipnum <= '281474976710655'
$ipnum >= '281470681743360' $ipnum <= '281474976710655'
Truth table66%2/3
A and B
A= $ipnum >= '281470681743360'B= $ipnum <= '281474976710655'
ABresult
0X0
100
111
1057 0 $ipv = 4;
1058 0 $ipnum = $ipnum - 281470681743360;
1059 }
1060 #reformat 6to4 address to ipv4 address 2002:: to 2002:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
1061 3 ▶ if (($ipnum >= 42545680458834377588178886921629466624) && ($ipnum <= 42550872755692912415807417417958686719)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipnum >= "4.25456804588344e+37" and $ipnum <= "4.25508727556929e+37") 0 3 3
Condition66%2/3
$ipnum >= "4.25456804588344e+37" and $ipnum <= "4.25508727556929e+37"
!ll&&!rl&&r
120
MC/DC0%0/2
$ipnum >= "4.25456804588344e+37" and $ipnum <= "4.25508727556929e+37"
$ipnum >= "4.25456804588344e+37" $ipnum <= "4.25508727556929e+37"
Truth table66%2/3
A and B
A= $ipnum >= "4.25456804588344e+37"B= $ipnum <= "4.25508727556929e+37"
ABresult
0X0
100
111
1062 0 $ipv = 4;
1063 #bitshift right 80 bits
1064 0 $ipnum->brsft(80);
1065 #bitwise modulus to get the last 32 bit
1066 0 $ipnum->bmod(4294967296);
1067 }
1068 #reformat Teredo address to ipv4 address 2001:0000:: to 2001:0000:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:
1069 3 ▶ if (($ipnum >= 42540488161975842760550356425300246528) && ($ipnum <= 42540488241204005274814694018844196863)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipnum >= "4.25404881619758e+37" and $ipnum <= "4.2540488241204e+37") 0 3 3
Condition66%2/3
$ipnum >= "4.25404881619758e+37" and $ipnum <= "4.2540488241204e+37"
!ll&&!rl&&r
120
MC/DC0%0/2
$ipnum >= "4.25404881619758e+37" and $ipnum <= "4.2540488241204e+37"
$ipnum >= "4.25404881619758e+37" $ipnum <= "4.2540488241204e+37"
Truth table66%2/3
A and B
A= $ipnum >= "4.25404881619758e+37"B= $ipnum <= "4.2540488241204e+37"
ABresult
0X0
100
111
1070 0 $ipv = 4;
1071 0 $ipnum = Math::BigInt->new($ipnum);
1072 #bitwise not to invert binary
1073 0 $ipnum->bnot();
1074 #bitwise modulus to get the last 32 bit
1075 0 $ipnum->bmod(4294967296);
1076 }
1077 } else {
1078 #not IPv4 and IPv6
1079 }
1080 }
1081 6 return ($ipv, $ipnum);
1082 }
1083  
1084 3 ▶sub expandIPv6Address {
Subroutine expandIPv6Address: called CC=6 SCAR=22.7
Pod undocumented
1085 3 my $obj = shift(@_);
1086 3 my $ip = shift(@_);
1087 3 $ip =~ s/\:\:/\:Z\:/;
1088 3 my @ip = split(/\:/, $ip);
1089 3 my $num = scalar(@ip);
1090  
1091 3 my $l = 8;
1092 3 ▶ if ($ip[$#ip] =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip[$#ip] =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) 0 3 3
1093 0 my $a = sprintf("%x", ($1*256 + $2));
1094 0 my $b = sprintf("%x", ($3*256 + $4));
1095 0 $ip[$#ip] = $a;
1096 0 $ip[$#ip+1] = $b;
1097 0 $l--;
1098 }
1099  
1100 3 ▶ if ($#ip == 8) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#ip == 8) 0 3 3
1101 0 shift(@ip);
1102 0 $l++;
1103 }
1104  
1105 3 foreach (0..(scalar(@ip)-1)) {
1106 24 $ip[$_] = ('0'x(4-length ($ip[$_]))).$ip[$_];
1107 }
1108  
1109 3 foreach (0..(scalar(@ip)-1)) {
1110 24 ▶ next unless ($ip[$_] eq '000Z');
Branch: 1 branch
BranchTrueFalseTotal
unless $ip[$_] eq "000Z" 24 0 24
1111 0 my @empty = map { $_ = '0'x4 } (0..7);
1112 0 $ip[$_] = join(':', @empty[0..$l-$num]);
1113 0 last;
1114 }
1115  
1116 3 return (uc(join ':', @ip));
1117 }
1118  
1119 3 ▶sub hexInt {
Subroutine hexInt: called CC=4 SCAR=13.9
Pod undocumented
1120 3 my $obj = shift(@_);
1121 3 my $hexip = shift(@_);
1122  
1123 3 $hexip =~ s/\://g;
1124  
1125 3 ▶ unless (length($hexip) == 32) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $hexip == 32) 0 3 3
1126 0 return 0;
1127 };
1128  
1129 3 my $binip = unpack('B128', pack('H32', $hexip));
1130 3 my ($n, $dec) = (Math::BigInt->new(1), Math::BigInt->new(0));
1131  
1132 3 foreach (reverse (split('', $binip))) {
1133 384 ▶ $_ && ($dec += $n);
Branch: 1 branch
BranchTrueFalseTotal
$_ and $dec += $n 20 364 384
1134 384 $n *= 2;
1135 }
1136  
1137 3 $dec =~ s/^\+//;
1138 3 return $dec;
1139 }
1140  
1141 3 ▶sub ipNo {
Subroutine ipNo: called CC=1 SCAR=0.0
Pod undocumented
1142 3 my $obj = shift(@_);
1143 3 my $ip = shift(@_);
1144 3 my @block = split(/\./, $ip);
1145 3 my $no = 0;
1146 3 $no = $block[3];
1147 3 $no = $no + $block[2] * 256;
1148 3 $no = $no + $block[1] * 256 * 256;
1149 3 $no = $no + $block[0] * 256 * 256 * 256;
1150 3 return $no;
1151 }
1152  
1153 6 ▶sub nameIP {
Subroutine nameIP: called CC=4 SCAR=15.2
Pod undocumented
1154 6 my $obj = shift(@_);
1155 6 my $host = shift(@_);
1156 6 my $ip_address = "";
1157 6 ▶ if (($host =~ m/^$IPv4_re$/) || ($host =~ m/^$IPv6_re$/) || ($host =~ m/^\:\:$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($host =~ /^$IPv4_re$/ or $host =~ /^$IPv6_re$/ or $host =~ /^\:\:$/) { } 6 0 6
Condition50%3/6
$host =~ /^$IPv4_re$/ or $host =~ /^$IPv6_re$/ or $host =~ /^\:\:$/
l!l&&r!l&&!r
600
$host =~ /^$IPv4_re$/ or $host =~ /^$IPv6_re$/
l!l&&r!l&&!r
330
MC/DC0%0/3
$host =~ /^$IPv4_re$/ or $host =~ /^$IPv6_re$/ or $host =~ /^\:\:$/
$host =~ /^$IPv4_re$/ $host =~ /^$IPv6_re$/ $host =~ /^\:\:$/
Truth table50%2/4
A or B or C
A= $host =~ /^$IPv4_re$/B= $host =~ /^$IPv6_re$/C= $host =~ /^\:\:$/
ABCresult
1XX1
01X1
0011
0000
1158 6 $ip_address = $host;
1159 } else {
1160 # TO_DO: Can we return IPv6 address too?
1161 0 $ip_address = join('.', unpack('C4',(gethostbyname($host))[4]));
1162 }
1163 6 return $ip_address;
1164 }
1165  
1166 6 ▶sub isIPv4 {
Subroutine isIPv4: called CC=5 SCAR=16.5
Pod undocumented
1167 6 my $obj = shift(@_);
1168 6 my $ip = shift(@_);
1169 6 ▶ if ($ip =~ m/^$IPv4_re$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^$IPv4_re$/) { } 3 3 6
1170 3 my @octet = split(/\./, $ip);
1171 3 foreach my $i (0 .. $#octet) {
1172 12 ▶ return 0 if (($octet[$i] > 255) || ($octet[$i] < 0));
Branch: 1 branch
BranchTrueFalseTotal
if $octet[$i] > 255 or $octet[$i] < 0 0 12 12
Condition33%1/3
$octet[$i] > 255 or $octet[$i] < 0
l!l&&r!l&&!r
0012
MC/DC0%0/2
$octet[$i] > 255 or $octet[$i] < 0
$octet[$i] > 255 $octet[$i] < 0
Truth table33%1/3
A or B
A= $octet[$i] > 255B= $octet[$i] < 0
ABresult
1X1
011
000
1173 }
1174 3 return 1;
1175 } else {
1176 3 return 0;
1177 }
1178 }
1179  
1180 3 ▶sub isIPv6 {
Subroutine isIPv6: called CC=3 SCAR=12.7
Pod undocumented
1181 3 my $obj = shift(@_);
1182 3 my $ip = shift(@_);
1183 3 ▶ if (($ip =~ m/^$IPv6_re$/) || ($ip =~ m/^$IPv4_re$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^$IPv6_re$/ or $ip =~ /^$IPv4_re$/) { } 3 0 3
Condition33%1/3
$ip =~ /^$IPv6_re$/ or $ip =~ /^$IPv4_re$/
l!l&&r!l&&!r
300
MC/DC0%0/2
$ip =~ /^$IPv6_re$/ or $ip =~ /^$IPv4_re$/
$ip =~ /^$IPv6_re$/ $ip =~ /^$IPv4_re$/
Truth table33%1/3
A or B
A= $ip =~ /^$IPv6_re$/B= $ip =~ /^$IPv4_re$/
ABresult
1X1
011
000
1184 3 return 1;
1185 } else {
1186 0 return 0;
1187 }
1188 }
1189  
1190 3 1;
1191 __END__
↑ Summary