diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2007-12-20 20:35:52 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2007-12-20 20:35:52 -0800 |
commit | 60fddb5cba5a7d2eb33ba5f77901b71c58ad462a (patch) | |
tree | 1696d25329d43d0bf428f206f84257d194205696 /scripts/VyattaMisc.pm | |
parent | 26fc574ed0265750244a23aa5cfeba222f20d56d (diff) | |
download | vyatta-cfg-60fddb5cba5a7d2eb33ba5f77901b71c58ad462a.tar.gz vyatta-cfg-60fddb5cba5a7d2eb33ba5f77901b71c58ad462a.zip |
Fix broken bgp in glendale.
Diffstat (limited to 'scripts/VyattaMisc.pm')
-rwxr-xr-x | scripts/VyattaMisc.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/VyattaMisc.pm b/scripts/VyattaMisc.pm index 48b3aa7..abb5fbb 100755 --- a/scripts/VyattaMisc.pm +++ b/scripts/VyattaMisc.pm @@ -26,6 +26,11 @@ # package VyattaMisc; +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(getNetAddIP isIpAddress); +@EXPORT_OK = qw(getNetAddIP isIpAddress); + use strict; @@ -60,6 +65,28 @@ sub getNetAddrIP { return $naip; } +sub isIpAddress { + my $ip = shift; + + $_ = $ip; + if ( ! /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { + return 0; + } + else { + my @ips = split /\./, $ip; + my $octet = 0; + my $counter = 0; + + foreach $octet (@ips) { + if (($octet < 0) || ($octet > 255)) { return 0; } + if (($counter == 0) && ($octet < 1)) { return 0; } + $counter++; + } + } + + return 1; +} + sub isClusterIP { my ($vc, $ip) = @_; |