From b1299db4531805bce37e669cc5ca9b10b43870b4 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Wed, 21 May 2014 16:00:37 +0200 Subject: [PATCH] Use the IANA recovered address space list --- data.h | 1 + ip_del_recovered.h | 18 ++++++++++++++++++ make_ip_del_recovered.pl | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 ip_del_recovered.h create mode 100755 make_ip_del_recovered.pl diff --git a/data.h b/data.h index 012dec8..a653bba 100644 --- a/data.h +++ b/data.h @@ -102,6 +102,7 @@ struct ip_del { }; const struct ip_del ip_assign[] = { +#include "ip_del_recovered.h" #include "ip_del.h" { 0, 0, NULL } }; diff --git a/ip_del_recovered.h b/ip_del_recovered.h new file mode 100644 index 0000000..1f0707d --- /dev/null +++ b/ip_del_recovered.h @@ -0,0 +1,18 @@ +{ 736100352UL, 736624639UL, "whois.apnic.net" }, +{ 736886784UL, 737411071UL, "whois.apnic.net" }, +{ 737476608UL, 738000895UL, "whois.apnic.net" }, +{ 738066432UL, 738197503UL, "whois.apnic.net" }, +{ 757071872UL, 759169023UL, "whois.arin.net" }, +{ 759169024UL, 759238655UL, "whois.apnic.net" }, +{ 763363328UL, 765460479UL, "whois.ripe.net" }, +{ 765460480UL, 767557631UL, "whois.lacnic.net" }, +{ 767557632UL, 769589247UL, "whois.afrinic.net" }, +{ 2523594752UL, 2523660287UL, "whois.apnic.net" }, +{ 2525036544UL, 2525102079UL, "whois.apnic.net" }, +{ 2532442112UL, 2532507647UL, "whois.apnic.net" }, +{ 2584739840UL, 2584805375UL, "whois.afrinic.net" }, +{ 2737767424UL, 2737771263UL, "whois.apnic.net" }, +{ 2737771520UL, 2737772031UL, "whois.apnic.net" }, +{ 2737774592UL, 2737778175UL, "whois.apnic.net" }, +{ 2737778432UL, 2737831935UL, "whois.apnic.net" }, +{ 2738159616UL, 2738225151UL, "whois.apnic.net" }, diff --git a/make_ip_del_recovered.pl b/make_ip_del_recovered.pl new file mode 100755 index 0000000..ff9a4d7 --- /dev/null +++ b/make_ip_del_recovered.pl @@ -0,0 +1,31 @@ +#!/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; + +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'; + + my ($b1, $b2, $b3, $b4) = split(/\./, $row->[0]); + my ($e1, $e2, $e3, $e4) = split(/\./, $row->[1]); + die if not defined $b4 or not defined $e4; + + print $out '{ ' . + (($b1 << 24) + ($b2 << 16) + ($b3 << 8) + $b4) . 'UL, ' . + (($e1 << 24) + ($e2 << 16) + ($e3 << 8) + $e4) . 'UL, ' . + '"' . $row->[4] . qq|" },\n|; +} + +close($in); +close($out); +