]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
geoip: put IPv4 geoip data into its own map
authorJan Engelhardt <jengelh@medozas.de>
Sat, 18 Dec 2010 23:30:10 +0000 (00:30 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Sat, 18 Dec 2010 23:48:42 +0000 (00:48 +0100)
extensions/libxt_geoip.c
geoip/xt_geoip_build

index c99d7ea2aff986986a3532c794a4d4a471f5be50..df281850423ca4cada58c892cf2093af562e3bcb 100644 (file)
@@ -58,9 +58,9 @@ static struct geoip_subnet *geoip_get_subnets(const char *code, uint32_t *count)
 
        /* 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) {
index 4ba5404ea41696eb0af568b5d91da60539851e5b..5016ff35d3bdf2d9f29f3a954d22c2fbb96f2f2e 100755 (executable)
@@ -33,9 +33,12 @@ foreach (qw(LE BE)) {
 
 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";
@@ -47,21 +50,21 @@ print STDERR "\r\e[2K$. entries total\n";
 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]);
        }