#!/usr/bin/perl
#
# (c) 2004 by Unilogic Networks B.V.
#             Cliff Albert <cliff@unilogicnetworks.net>
#
#	      This perl script will parse a cisco or foundry configuration
#	      dump file and will generate a Juniper compatible XML file.
#	      This can be used to put inside peering-slut as (c) by Sjeemz
#	      
my $configuration_file = '/etc/netcfg/ams-br01.cfg';

print "<rpc-reply xmlns:junos=\"http://xml.juniper.net/junos/6.2R2/junos\">\n";
print "<bgp-information xmlns=\"http://xml.juniper.net/junos/6.2R2/junos-routing\">\n";
print "  <group-count>0</group-count>\n";
print "  <peer-count>0</peer-count>\n";
print "  <down-peer-count>0</down-peer-count>\n";

open CFG_FILE,$configuration_file;
while (<CFG_FILE>) {
	if ($_ =~ /neighbor (\d+\.\d+\.\d+\.\d+) remote-as (\d+)/) {
		print "<bgp-peer junos:style=\"terse\">\n";
		print "<peer-address>$1</peer-address>\n";
		print "<peer-as>$2</peer-as>\n";
		print "</bgp-peer>\n";
	};
	};

close CFG_FILE;
print "</bgp-information>\n";
print "</rpc-reply>\n";

