1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#!/usr/local/bin/perl -w
use strict;
use BER;
use SNMP_Session "0.57";
sub usage();
my $host = shift @ARGV || usage();
my $community = shift @ARGV || 'public';
my $pnniRouteAddrProto = [1,3,6,1,4,1,353,5,4,1,1,19,4,1,8];
my $ilmionly = 1;
my $hostonly = 1;
my $session = SNMP_Session->open ($host, $community, 161)
|| die "couldn't open SNMP session";
$session->map_table ([$pnniRouteAddrProto],
sub {
my ($index, $proto) = @_;
grep (defined $_ && ($_=pretty_print $_),
($proto));
## we are only interested in routes whose proto is local(2).
return if $ilmionly && $proto != 2;
my @index = split ('\.',$index);
my $nsap = join (".", grep ($_=sprintf ("%02x",$_),@index[1..19]));
my $prefix_length = $index[20];
return if $hostonly && $prefix_length != 152;
print $nsap;
print "/",$prefix_length unless $hostonly;
print "\n";
});
$session->close;
1;
sub usage () {
die "Usage: $0 host [community]";
}
|