summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniil Baturin <daniil.baturin@vyatta.com>2012-03-29 03:01:29 +0700
committerDaniil Baturin <daniil.baturin@vyatta.com>2012-03-29 03:01:29 +0700
commit6746df51d7ac8e2f487dd74ca8b23c74fb4f28c1 (patch)
tree3c6692f7cce7e80fc3c6771053d034155dfeb7af /scripts
parent9f41b8563b7fc261b31d9ad2732a303a8459fccf (diff)
downloadvyatta-cfg-vpn-6746df51d7ac8e2f487dd74ca8b23c74fb4f28c1.tar.gz
vyatta-cfg-vpn-6746df51d7ac8e2f487dd74ca8b23c74fb4f28c1.zip
Add a script for validating single IPv4 or IPv6 address with no prefix
length.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/is_valid_address.pl15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/is_valid_address.pl b/scripts/is_valid_address.pl
new file mode 100755
index 0000000..2860cc2
--- /dev/null
+++ b/scripts/is_valid_address.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+# Check a single IPv4 or IPv6 address
+
+use NetAddr::IP;
+
+$ip = $ARGV[0];
+
+if( !defined($ip) ||
+ $ip =~ "/" || # Ensure it doesn't have prefix length
+ !($addr = new NetAddr::IP $ip)
+ ) {
+ exit 1;
+}
+
+exit 0;