diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-26 13:12:01 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-01-26 13:12:01 -0800 |
commit | 1941ce858983749d737b609f918410c33fc98e9b (patch) | |
tree | 72d801e479f05d85c9fe291069b39fc214435f99 /lib | |
parent | 4bcfe92678e6a0f4d31ea198936a21638012158f (diff) | |
parent | fb4995b1be4aefb7652b3e6a5834326c8922ac1b (diff) | |
download | vyatta-cfg-1941ce858983749d737b609f918410c33fc98e9b.tar.gz vyatta-cfg-1941ce858983749d737b609f918410c33fc98e9b.zip |
Merge branch 'jenner' of suva.vyatta.com:/git/vyatta-cfg into jenner
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Vyatta/TypeChecker.pm | 44 |
1 files changed, 44 insertions, 0 deletions
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: |