aboutsummaryrefslogtreecommitdiff
path: root/scripts/ripe-prefixes-to-csv.awk
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2010-04-13 02:35:49 +0000
committerRob Austein <sra@hactrn.net>2010-04-13 02:35:49 +0000
commit04540226feb7a1ca4f185a6345a4b57d8397dd96 (patch)
tree63f7808c260d151c2d64f85e237be4e6d7d0ec80 /scripts/ripe-prefixes-to-csv.awk
parent41c51dee21554e6ff668a399bdc1c72df9173722 (diff)
Move all of the testbed-related scripts to the scripts/ directory
svn path=/myrpki/apnic-to-csv.py; revision=3192
Diffstat (limited to 'scripts/ripe-prefixes-to-csv.awk')
-rw-r--r--scripts/ripe-prefixes-to-csv.awk43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/ripe-prefixes-to-csv.awk b/scripts/ripe-prefixes-to-csv.awk
new file mode 100644
index 00000000..582d5ce7
--- /dev/null
+++ b/scripts/ripe-prefixes-to-csv.awk
@@ -0,0 +1,43 @@
+#!/usr/bin/awk -f
+# $Id$
+
+# ftp -pa ftp://ftp.ripe.net/pub/stats/ripencc/membership/alloclist.txt
+
+BEGIN {
+ translation["ie.google"] = "GoogleIreland";
+}
+
+function done() {
+ if (handle in translation)
+ handle = translation[handle];
+ for (i = 1; i <= n_allocs; i++)
+ print handle "\t" alloc[i];
+ n_allocs = 0;
+}
+
+/^[a-z]/ {
+ done();
+ handle = $0;
+ nr = NR;
+}
+
+NR == nr + 1 {
+ name = $0;
+}
+
+NR > nr + 2 && NF > 1 && $2 !~ /:/ {
+ split($2, a, "/");
+ len = a[2];
+ split(a[1], a, /[.]/);
+ for (i = length(a); i < 4; i++)
+ a[i+1] = 0;
+ alloc[++n_allocs] = sprintf("%d.%d.%d.%d/%d", a[1], a[2], a[3], a[4], len);
+}
+
+NR > nr + 2 && NF > 1 && $2 ~ /:/ {
+ alloc[++n_allocs] = $2;
+}
+
+END {
+ done();
+}