diff options
author | Daniil Baturin <daniil@baturin.org> | 2010-11-16 09:26:13 +0600 |
---|---|---|
committer | Gaurav Sinha <gaurav.sinha@vyatta.com> | 2012-08-24 13:35:01 -0700 |
commit | eac365dc5aaf88457d487fcd501164d246d7b548 (patch) | |
tree | 2225176d379aebac51b741ee1065bf4f59a914e8 | |
parent | 41563446646940ded446e480a26554f7b6b2d0b9 (diff) | |
download | vyatta-cfg-quagga-eac365dc5aaf88457d487fcd501164d246d7b548.tar.gz vyatta-cfg-quagga-eac365dc5aaf88457d487fcd501164d246d7b548.zip |
Added OSPFv3 CLI backend that uses Vyatta::Quagga::Config
Signed-off-by: Gaurav Sinha <gaurav.sinha@vyatta.com>
-rwxr-xr-x | scripts/ospfv3/vyatta-ospfv3.pl | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/scripts/ospfv3/vyatta-ospfv3.pl b/scripts/ospfv3/vyatta-ospfv3.pl new file mode 100755 index 00000000..c359d348 --- /dev/null +++ b/scripts/ospfv3/vyatta-ospfv3.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl + +# Author: Daniil Baturin <daniil@baturin.org> +# Date: 2010 +# Description: OSPFv3 CLI backend + +# **** License **** +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# This code was originally developed by Vyatta, Inc. +# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc. +# All Rights Reserved. +# **** End License **** + +use strict; +use warnings; + +use Getopt::Long; +use NetAddr::IP::Lite; + +use lib "/opt/vyatta/share/perl5/"; +use Vyatta::Config; +use Vyatta::Quagga::Config; +use Vyatta::Misc; + +my %quagga_commands = ( + 'protocols' => { + set => undef, + del => undef + }, + 'protocols ospfv3' => { + set => 'router ospf6', + del => 'no router ospf6' + }, + 'protocols ospfv3 parameters' => { + set => undef, + del => undef + }, + 'protocols ospfv3 parameters router-id' => { + set => 'router ospf6 ; router-id #5', + del => undef + }, + 'protocols ospfv3 area' => { + set => undef, + del => undef + }, + 'protocols ospfv3 area var' => { + set => undef, + del => undef + }, + 'protocols ospfv3 area var range' => { + set => undef, + del => undef + }, + 'protocols ospfv3 area var range var' => { + set => 'router ospf6 ; area #4 range #6', + del => 'router ospf6 ; no area #4 range #6' + }, + 'protocols ospfv3 area var range var advertise' => { + set => 'router ospf6 ; area #4 range #6 advertise', + del => 'router ospf6 ; no area #4 range #6' + }, + 'protocols ospfv3 area var range var not-advertise' => { + set => 'router ospf6 ; area #4 range #6 not-advertise', + del => 'router ospf6 ; no area #4 range #6 not-advertise' + }, + 'protocols ospfv3 area var interface' => { + set => 'router ospf6 ; no interface #6 area #4; interface #6 area #4', + del => 'router ospf6 ; no interface #6 area #4', + noerr => 'set' + }, + 'protocols ospfv3 area var import-list' => { + set => 'router ospf6 ; area #4 import-list #6', + del => 'router ospf6 ; no area #4 import-list #6' + }, + 'protocols ospfv3 area var export-list' => { + set => 'router ospf6 ; area #4 export-list #6', + del => 'router ospf6 ; no area #4 export-list #6' + }, + 'protocols ospfv3 area var filter-list' => { + set => 'router ospf6 ; area #4 filter-list prefix #6', + del => 'router ospf6 ; no area #4 filter-list prefix #6' + }, + 'protocols ospfv3 redistribute' => { + set => undef, + del => undef + }, + 'protocols ospfv3 redistribute connected' => { + set => 'router ospf6 ; redistribute connected ?route-map', + del => 'router ospf6 ; no redistribute connected' + }, + 'protocols ospfv3 redistribute kernel' => { + set => 'router ospf6 ; redistribute kernel ?route-map', + del => 'router ospf6 ; no redistribute kernel' + }, + 'protocols ospfv3 redistribute bgp' => { + set => 'router ospf6 ; redistribute bgp ?route-map', + del => 'router ospf6 ; no redistribute bgp' + }, + 'protocols ospfv3 redistribute ripng' => { + set => 'router ospf6 ; redistribute ripng ?route-map', + del => 'router ospf6 ; no redistribute ripng' + }, + 'protocols ospfv3 redistribute static' => { + set => 'router ospf6 ; redistribute static ?route-map', + del => 'router ospf6 ; no redistribute static' + } +); + +my ($main, $check_area, $area); + +GetOptions( + "main" => \$main, + "check-area" => \$check_area, + "area=s" => \$area +); + +main() if ($main); +check_ospfv3_area($area) if ($check_area); + +exit 0; + +sub main { + # Create a Vyatta Quagga Config object initialized by commands mapping + my $quagga_config = new Vyatta::Quagga::Config('protocols', \%quagga_commands); + #$quagga_config->setDebugLevel('3'); + + $quagga_config->deleteConfigTreeRecursive('protocols ospfv3') || die "exiting $?\n"; + + $quagga_config->setConfigTreeRecursive('protocols ospfv3 parameters') || die "exiting $?\n"; # Priority 630 + $quagga_config->setConfigTreeRecursive('protocols ospfv3') || die "exiting $?\n"; # Priority 640 +} + +# Quagga ospf6d doesn't accept numeric area id, but requires dotted decimal. Bug 4172. +sub check_ospfv3_area { + my $area = shift; + + if ( $area =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) { + foreach my $octet ( $1, $2, $3, $4 ) { + if ( ( $octet < 0 ) || ( $octet > 255 ) ) { exit 1; } + } + exit 0; + } + + die "Invalid OSPFv3 area: $area\n"; +} + |