summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2008-08-04 10:47:40 -0700
committerStig Thormodsrud <stig@vyatta.com>2008-08-04 10:47:40 -0700
commitca878cfa9eaa6567dfab5461f9bd1587f8b3e85e (patch)
tree2b598423f16a4ef83868b8525905a7116eea69ed
parentf03fa5d21e5e5f620ea1e52c6403fe23a4284d85 (diff)
downloadvyatta-cfg-ca878cfa9eaa6567dfab5461f9bd1587f8b3e85e.tar.gz
vyatta-cfg-ca878cfa9eaa6567dfab5461f9bd1587f8b3e85e.zip
Move is_ip_v4_or_v6() to VyattaMisc.pm so other scripts can use it.
-rwxr-xr-xscripts/VyattaMisc.pm27
-rw-r--r--scripts/vyatta-interfaces.pl23
2 files changed, 25 insertions, 25 deletions
diff --git a/scripts/VyattaMisc.pm b/scripts/VyattaMisc.pm
index e6bd9ff..d74b55a 100755
--- a/scripts/VyattaMisc.pm
+++ b/scripts/VyattaMisc.pm
@@ -24,8 +24,8 @@
package VyattaMisc;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(getNetAddIP isIpAddress);
-@EXPORT_OK = qw(getNetAddIP isIpAddress);
+@EXPORT = qw(getNetAddIP isIpAddress is_ip_v4_or_v6);
+@EXPORT_OK = qw(getNetAddIP isIpAddress is_ip_v4_or_v6);
use strict;
@@ -61,6 +61,29 @@ sub getNetAddrIP {
return $naip;
}
+sub is_ip_v4_or_v6 {
+ my $addr = shift;
+
+ my $ip = NetAddr::IP->new($addr);
+ if (defined $ip && $ip->version() == 4) {
+ #
+ # the call to IP->new() will accept 1.1 and consider
+ # it to be 1.1.0.0, so add a check to force all
+ # 4 octets to be defined
+ #
+ if ($addr !~ /\d+\.\d+\.\d+\.\d+/) {
+ return undef;
+ }
+ return 4;
+ }
+ $ip = NetAddr::IP->new6($addr);
+ if (defined $ip && $ip->version() == 6) {
+ return 6;
+ }
+
+ return undef;
+}
+
sub isIpAddress {
my $ip = shift;
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 2f59bd3..0c219c1 100644
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -220,29 +220,6 @@ sub dhcp_update_config {
dhcp_write_file($conf_file, $output);
}
-sub is_ip_v4_or_v6 {
- my $addr = shift;
-
- my $ip = NetAddr::IP->new($addr);
- if (defined $ip && $ip->version() == 4) {
- #
- # the call to IP->new() will accept 1.1 and consider
- # it to be 1.1.0.0, so add a check to force all
- # 4 octets to be defined
- #
- if ($addr !~ /\d+\.\d+\.\d+\.\d+/) {
- return undef;
- }
- return 4;
- }
- $ip = NetAddr::IP->new6($addr);
- if (defined $ip && $ip->version() == 6) {
- return 6;
- }
-
- return undef;
-}
-
sub generate_dhclient_intf_files {
my $intf = shift;