From 206873af79606eb170fbff26137634bab475fec0 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Tue, 6 Nov 2007 13:47:45 -0800 Subject: Fix ospf area validation and move error message to template file. --- scripts/vyatta_quagga_utils.pl | 16 ++++++++++------ templates/protocols/ospf/area/node.def | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl index d64be3a9..e2e871f8 100644 --- a/scripts/vyatta_quagga_utils.pl +++ b/scripts/vyatta_quagga_utils.pl @@ -56,17 +56,21 @@ sub check_not_exists() { sub check_ospf_area() { my $area = shift; - + + # + # allow both decimal or dotted decimal + # if ($area =~ m/^\d+$/) { if ($area >= 0 && $area <= 4294967295) { - return 0; + exit 0; } } - - if (isIpAddress($area)) { - return 0; + if ($area =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { + foreach $octet ($1, $2, $3, $4) { + if (($octet < 0) || ($octet > 255)) { exit 1; } + } + exit 0 } - print "invalid ospf area\n"; exit 1; } diff --git a/templates/protocols/ospf/area/node.def b/templates/protocols/ospf/area/node.def index 22cb1ca0..d733005c 100644 --- a/templates/protocols/ospf/area/node.def +++ b/templates/protocols/ospf/area/node.def @@ -1,5 +1,5 @@ tag: type: txt -syntax: exec "/opt/vyatta/sbin/vyatta_quagga_utils.pl --check-ospf-area $(@)" +syntax: exec "/opt/vyatta/sbin/vyatta_quagga_utils.pl --check-ospf-area $(@)"; "Invalid OSFP area \"$(@)\" " help: "Area" -- cgit v1.2.3