diff options
-rw-r--r-- | debian/changelog | 12 | ||||
-rwxr-xr-x | lib/Vyatta/TypeChecker.pm | 44 |
2 files changed, 56 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 92becf8..3761f06 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +vyatta-cfg (0.14.4) unstable; urgency=low + + [ Stephen Hemminger ] + * Fix regression in Vyatta::Misc + * Fix isIPinInterfaces + * update unit tests + + [ Bob Gilligan ] + * Add more IPv6 address and prefix validation functions. + + -- Bob Gilligan <gilligan@vyatta.com> Thu, 22 Jan 2009 13:35:03 -0800 + vyatta-cfg (0.14.3) unstable; urgency=low [ Stephen Hemminger ] diff --git a/lib/Vyatta/TypeChecker.pm b/lib/Vyatta/TypeChecker.pm index 45803ea..37f365d 100755 --- a/lib/Vyatta/TypeChecker.pm +++ b/lib/Vyatta/TypeChecker.pm @@ -64,6 +64,9 @@ my %type_handler = ( 'macaddr' => \&validate_macaddr, 'macaddr_negate' => \&validate_macaddr_negate, 'ipv6' => \&validate_ipv6, + 'ipv6_negate' => \&validate_ipv6_negate, + 'ipv6net' => \&validate_ipv6net, + 'ipv6net_negate' => \&validate_ipv6net_negate, ); sub validate_ipv4 { @@ -184,6 +187,41 @@ sub validate_ipv6 { return 1; } +sub validate_ipv6_negate { + my $value = shift; + if ($value =~ m/^\!(.*)$/) { + $value = $1; + } + return validate_ipv6($value); +} + +sub validate_ipv6net { + my $value = shift; + + if ($value =~ m/^(.*)\/(.*)$/) { + my $ipv6_addr = $1; + my $prefix_length = $2; + if ($prefix_length < 0 || $prefix_length > 128) { + print "Invalid prefix length: $prefix_length\n"; + return 0; + } + return validate_ipv6($ipv6_addr); + + } else { + print "\"$value\" is not a valid IPv6 prefix\n"; + return 0; + } +} + +sub validate_ipv6net_negate { + my $value = shift; + + if ($value =~ m/^\!(.*)$/) { + $value = $1; + } + return validate_ipv6net($value); +} + sub validateType { my ($type, $value, $quiet) = @_; if (!defined($type) || !defined($value)) { @@ -218,3 +256,9 @@ sub findType { } 1; + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# perl-indent-level: 2 +# End: |