/* Use simple integer vector files */
#if __BYTE_ORDER == _BIG_ENDIAN
- snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv0", code);
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/BE/%s.iv4", code);
#else
- snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv0", code);
+ snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/LE/%s.iv4", code);
#endif
if ((fd = open(buf, O_RDONLY)) < 0) {
while (my $row = $csv->getline(*ARGV)) {
if (!defined($country{$row->[4]})) {
- $country{$row->[4]} = {name => $row->[5], pool => []};
+ $country{$row->[4]} = {
+ name => $row->[5],
+ pool_v4 => [],
+ };
}
- my $c = $country{$row->[4]}{pool};
+ my $c = $country{$row->[4]}{pool_v4};
push(@$c, [$row->[2], $row->[3]]);
if ($. % 4096 == 0) {
print STDERR "\r\e[2K$. entries";
foreach my $iso_code (sort keys %country) {
my($file, $fh_le, $fh_be);
- printf "%5u ranges for %s %s\n",
- scalar(@{$country{$iso_code}{pool}}),
+ printf "%5u IPv4 ranges for %s %s\n",
+ scalar(@{$country{$iso_code}{pool_v4}}),
$iso_code, $country{$iso_code}{name};
- $file = "$target_dir/LE/".uc($iso_code).".iv0";
+ $file = "$target_dir/LE/".uc($iso_code).".iv4";
if (!open($fh_le, "> $file")) {
print STDERR "Error opening $file: $!\n";
exit 1;
}
- $file = "$target_dir/BE/".uc($iso_code).".iv0";
+ $file = "$target_dir/BE/".uc($iso_code).".iv4";
if (!open($fh_be, "> $file")) {
print STDERR "Error opening $file: $!\n";
exit 1;
}
- foreach my $range (@{$country{$iso_code}{pool}}) {
+ foreach my $range (@{$country{$iso_code}{pool_v4}}) {
print $fh_le pack("VV", $range->[0], $range->[1]);
print $fh_be pack("NN", $range->[0], $range->[1]);
}