summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-03-20 11:11:56 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2008-03-20 11:11:56 -0700
commit00030c2e909b33ef0dbf694d82525134bdb5ffdf (patch)
tree5a832eb10dc6a9de9514af0c65c95bcd418d35e5
parent50ee96499609f9bd229e6d06a7ce57a17e9e4c52 (diff)
downloadvyatta-cfg-00030c2e909b33ef0dbf694d82525134bdb5ffdf.tar.gz
vyatta-cfg-00030c2e909b33ef0dbf694d82525134bdb5ffdf.zip
add validation for more types
-rwxr-xr-xscripts/VyattaTypeChecker.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/VyattaTypeChecker.pm b/scripts/VyattaTypeChecker.pm
index 2a7d0c9..f77664f 100755
--- a/scripts/VyattaTypeChecker.pm
+++ b/scripts/VyattaTypeChecker.pm
@@ -52,8 +52,11 @@ use strict;
my %type_handler = (
'ipv4' => \&validate_ipv4,
'ipv4net' => \&validate_ipv4net,
+ 'ipv4range' => \&validate_ipv4range,
'ipv4_negate' => \&validate_ipv4_negate,
'ipv4net_negate' => \&validate_ipv4net_negate,
+ 'ipv4range_negate' => \&validate_ipv4range_negate,
+ 'iptables4_addr' => \&validate_iptables4_addr,
'protocol' => \&validate_protocol,
'protocol_negate' => \&validate_protocol_negate,
'macaddr' => \&validate_macaddr,
@@ -75,6 +78,14 @@ sub validate_ipv4net {
return 1;
}
+sub validate_ipv4range {
+ $_ = shift;
+ return 0 if (!/^([^-]+)-([^-]+)$/);
+ my ($a1, $a2) = ($1, $2);
+ return 0 if (!validate_ipv4($a1) || !validate_ipv4($a2));
+ return 1;
+}
+
sub validate_ipv4_negate {
my $value = shift;
if ($value =~ m/^\!(.*)$/) {
@@ -91,6 +102,22 @@ sub validate_ipv4net_negate {
return validate_ipv4net($value);
}
+sub validate_ipv4range_negate {
+ my $value = shift;
+ if ($value =~ m/^\!(.*)$/) {
+ $value = $1;
+ }
+ return validate_ipv4range($value);
+}
+
+sub validate_iptables4_addr {
+ my $value = shift;
+ return 0 if (!validate_ipv4_negate($value)
+ && !validate_ipv4net_negate($value)
+ && !validate_ipv4range_negate($value));
+ return 1;
+}
+
sub validate_protocol {
my $value = shift;
$value = lc $value;