summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-02-04 14:37:21 -0800
committerBob Gilligan <gilligan@vyatta.com>2009-02-04 14:37:21 -0800
commitbeae8c6231ead94e2ea704ccce6ee39d4e22f594 (patch)
tree2f9e1b69260aa30dff03c30631a8590cb6833b0d /lib
parent76949e545bac7372642bb79cba3c1c3ea8fef871 (diff)
downloadvyatta-cfg-beae8c6231ead94e2ea704ccce6ee39d4e22f594.tar.gz
vyatta-cfg-beae8c6231ead94e2ea704ccce6ee39d4e22f594.zip
Add type checking functions for 16- and 32-bit hexadecimal values.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/TypeChecker.pm16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Vyatta/TypeChecker.pm b/lib/Vyatta/TypeChecker.pm
index 37f365d..89b8932 100755
--- a/lib/Vyatta/TypeChecker.pm
+++ b/lib/Vyatta/TypeChecker.pm
@@ -67,6 +67,8 @@ my %type_handler = (
'ipv6_negate' => \&validate_ipv6_negate,
'ipv6net' => \&validate_ipv6net,
'ipv6net_negate' => \&validate_ipv6net_negate,
+ 'hex16' => \&validate_hex_16_bits,
+ 'hex32' => \&validate_hex_32_bits,
);
sub validate_ipv4 {
@@ -222,6 +224,20 @@ sub validate_ipv6net_negate {
return validate_ipv6net($value);
}
+# Validate a 16-bit hex value, no leading "0x"
+sub validate_hex_16_bits {
+ my $value = shift;
+ $value = lc $value;
+ return 1 if ($value =~ /^[0-9a-f]{4}$/)
+}
+
+# Validate a 32-bit hex value, no leading "0x"
+sub validate_hex_32_bits {
+ my $value = shift;
+ $value = lc $value;
+ return 1 if ($value =~ /^[0-9a-f]{8}$/)
+}
+
sub validateType {
my ($type, $value, $quiet) = @_;
if (!defined($type) || !defined($value)) {