[routing-wg] Looking for a pgm to CIDRize

2014-12-31 Thread Hank Nussbacher

Dear revelers,

I am looking for a program or website that can take a list of sorted, 
overlapping prefixes and can reduce it to the most CIDRized format.


Example:

5.28.128.0/18
5.28.128.0/20
5.28.128.0/21
5.28.128.0/22
5.28.132.0/23
5.28.136.0/21
5.28.136.0/22
5.29.64.0/18
5.29.64.0/20
5.29.80.0/24
5.29.96.0/20
would reduce to just 2 lines:
5.28.128.0/18
5.29.64.0/18

In the long distant past, I seem to remember hearing or seeing of such a 
program.  Any pointers would be appreciated.


Happy New Year,
Hank




Re: [routing-wg] Looking for a pgm to CIDRize

2014-12-31 Thread Job Snijders
On Wed, Dec 31, 2014 at 09:25:44PM +0200, Hank Nussbacher wrote:

 I am looking for a program or website that can take a list of sorted,
 overlapping prefixes and can reduce it to the most CIDRized format.
 
 Example:
 
 snip

For IPv4 On ubuntu/debian: sudo apt-get install aggregate

Just pipe it in on STDIN ( | aggregate -q ) and it will output what you
want. 

 In the long distant past, I seem to remember hearing or seeing of such
 a program.  Any pointers would be appreciated.

For IPv6: sudo pip install aggregate6 (source:
https://github.com/job/aggregate6) 

Kind regards,

Job



Re: [routing-wg] Looking for a pgm to CIDRize

2014-12-31 Thread Michael Hallgren
Hi Hank,

The Net::IP perl module is a nice candidate.

HNY '15

mh

Le 31/12/2014 20:25, Hank Nussbacher a écrit :
 Dear revelers,

 I am looking for a program or website that can take a list of sorted,
 overlapping prefixes and can reduce it to the most CIDRized format.

 Example:

 5.28.128.0/18
 5.28.128.0/20
 5.28.128.0/21
 5.28.128.0/22
 5.28.132.0/23
 5.28.136.0/21
 5.28.136.0/22
 5.29.64.0/18
 5.29.64.0/20
 5.29.80.0/24
 5.29.96.0/20
 would reduce to just 2 lines:
 5.28.128.0/18
 5.29.64.0/18

 In the long distant past, I seem to remember hearing or seeing of such
 a program.  Any pointers would be appreciated.

 Happy New Year,
 Hank







Re: [routing-wg] Looking for a pgm to CIDRize

2014-12-31 Thread Ronald F. Guilmette

In message 5.1.1.6.2.20141231211552.053fe...@efes.iucc.ac.il, 
Hank Nussbacher h...@efes.iucc.ac.il wrote:

I am looking for a program or website that can take a list of sorted, 
overlapping prefixes and can reduce it to the most CIDRized format.

I rolled my own some time ago.  It's appended below.

It takes the input cidrs either on the command line or via stdin, one
per line (with no fluff).

It's quite trivial as you can see, but requires the Net::CIDR::Lite
package (which does all of the real work).



#!/usr/bin/perl -w

use strict;
use Net::CIDR::Lite;

my $cidr = Net::CIDR::Lite-new;

sub
process_arg
{
  my ($arg) = @_;

  unless ($cidr-add($arg)) {
die Error during add of $arg\n;
  }
}

if (scalar @ARGV) {
  foreach my $arg (@ARGV) {
process_arg ($arg);
  }
} else {
  while (my $line = STDIN) {
chop $line;
process_arg ($line);
  }
}

foreach my $c ($cidr-list) {
  print $c\n;
}