summaryrefslogtreecommitdiffstats
path: root/make_ip_del_recovered.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 15:45:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 15:45:37 +0000
commite0801e6bd6cc1241afafea33ba8ef701fec2e5c5 (patch)
treeb5cf84f45181b3dbc14d58833d88683fb7f3465e /make_ip_del_recovered.pl
parentInitial commit. (diff)
downloadwhois-e0801e6bd6cc1241afafea33ba8ef701fec2e5c5.tar.xz
whois-e0801e6bd6cc1241afafea33ba8ef701fec2e5c5.zip
Adding upstream version 5.5.17.upstream/5.5.17upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'make_ip_del_recovered.pl')
-rwxr-xr-xmake_ip_del_recovered.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/make_ip_del_recovered.pl b/make_ip_del_recovered.pl
new file mode 100755
index 0000000..65e9112
--- /dev/null
+++ b/make_ip_del_recovered.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+# https://www.iana.org/assignments/ipv4-recovered-address-space/ipv4-recovered-address-space-2.csv
+
+use warnings;
+use strict;
+use autodie;
+
+use Text::CSV;
+use Net::CIDR;
+use Net::IP;
+
+my $csv = Text::CSV->new;
+
+open(my $in, '<', 'ipv4-recovered-address-space-2.csv');
+open(my $out, '>', 'ip_del_recovered.h');
+
+while (my $row = $csv->getline($in)) {
+ next if $row->[0] eq 'Start address';
+ next if $row->[5] ne 'ALLOCATED';
+
+ print $out '/* ' . $row->[0] . ' - ' . $row->[1] . " */\n";
+ my @networks =
+ map { Net::IP->new($_) }
+ Net::CIDR::range2cidr($row->[0] . '-' . $row->[1]);
+ print $out sprintf(qq|{ %sUL, %sUL, "%s" },\n|,
+ $_->intip,
+ ((~(0xffffffff >> $_->prefixlen)) & 0xffffffff),
+ $row->[4]
+ ) foreach @networks;
+}
+
+close($in);
+close($out);
+