summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-02-18 11:06:43 -0800
committerBob Gilligan <gilligan@vyatta.com>2009-02-18 11:06:43 -0800
commitc45cd828d10fb556eda0fcfdae8219dfcb5d16da (patch)
tree3eee8328d1519c55352fe8dfc4c3da0953a27503 /lib
parent8c912fc15ee831d095d9b28442c03e97bb1f3bdb (diff)
downloadvyatta-cfg-c45cd828d10fb556eda0fcfdae8219dfcb5d16da.tar.gz
vyatta-cfg-c45cd828d10fb556eda0fcfdae8219dfcb5d16da.zip
Add type check function for firewall IPv6 src/dst address parameters
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/TypeChecker.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Vyatta/TypeChecker.pm b/lib/Vyatta/TypeChecker.pm
index 89b8932..a711030 100755
--- a/lib/Vyatta/TypeChecker.pm
+++ b/lib/Vyatta/TypeChecker.pm
@@ -69,6 +69,7 @@ my %type_handler = (
'ipv6net_negate' => \&validate_ipv6net_negate,
'hex16' => \&validate_hex_16_bits,
'hex32' => \&validate_hex_32_bits,
+ 'ipv6_addr_param' => \&validate_ipv6_addr_param,
);
sub validate_ipv4 {
@@ -238,6 +239,36 @@ sub validate_hex_32_bits {
return 1 if ($value =~ /^[0-9a-f]{8}$/)
}
+# Validate the overloaded IPv6 source and destination address parameter in
+# the firewall configuration tree.
+sub validate_ipv6_addr_param {
+ my $value = shift;
+
+ # leading exclamation point is valid in all three formats
+ if ($value =~ m/^\!(.*)$/) {
+ $value = $1;
+ }
+
+ if ($value =~ m/^(.*)-(.*)$/) {
+ # first format: <ipv6addr>-<ipv6-addr>
+ if (validate_ipv6($1)) {
+ return validate_ipv6($2);
+ } else {
+ return 0;
+ }
+ }
+
+ elsif ($value =~ m/^(.*)\/(.*)$/) {
+ # Second format: <ipv6addr>/<prefix-len>
+ return validate_ipv6net($value);
+ }
+
+ else {
+ # third format: <ipv6addr>
+ return validate_ipv6($value)
+ }
+}
+
sub validateType {
my ($type, $value, $quiet) = @_;
if (!defined($type) || !defined($value)) {