]> git.ipfire.org Git - thirdparty/bird.git/blob - misc/cisco2list
Filter: Fix function comparison
[thirdparty/bird.git] / misc / cisco2list
1 #!/usr/bin/perl
2 #
3 # Convert Cisco routing table listing to list of prefixes
4 #
5
6 $loc = ($ARGV[0] eq "-l"); # Print only local prefixes
7
8 while (<STDIN>) {
9 ($loc ? /^[OR]\s/ : /^B\s/) || next;
10 /^[ORB]( E[12])?\s+(\d+\.\d+\.\d+\.\d+)(\s|\/\d+\s)/ || die "Cannot parse $_";
11 $net = $2;
12 $len = $3;
13 if ($len =~ /^\s*$/) {
14 # Magic rule :)
15 $len = ($net =~ /\.0$/) ? 24 : 32;
16 }
17 $len =~ s/^\///;
18 $net =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
19 printf "%02x%02x%02x%02x/%d\n", $1, $2, $3, $4, $len;
20 }