summaryrefslogtreecommitdiffstats
path: root/lib/network/tools.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-03-05 21:12:07 +0000
committerOlivier Blin <oblin@mandriva.com>2008-03-05 21:12:07 +0000
commite6673a9b02ed8c7e1d95a675efd13de4c51adca2 (patch)
tree9b54b6302ad0b62f04b49323edd4764ff96857b7 /lib/network/tools.pm
parent5ac00a05812e0e60c5fa0ab89ca798a7593c2331 (diff)
downloaddrakx-net-e6673a9b02ed8c7e1d95a675efd13de4c51adca2.tar
drakx-net-e6673a9b02ed8c7e1d95a675efd13de4c51adca2.tar.gz
drakx-net-e6673a9b02ed8c7e1d95a675efd13de4c51adca2.tar.bz2
drakx-net-e6673a9b02ed8c7e1d95a675efd13de4c51adca2.tar.xz
drakx-net-e6673a9b02ed8c7e1d95a675efd13de4c51adca2.zip
add utility functions for real/vlan/virtual interfaces
Diffstat (limited to 'lib/network/tools.pm')
-rw-r--r--lib/network/tools.pm24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/network/tools.pm b/lib/network/tools.pm
index 0db6b26..b62d876 100644
--- a/lib/network/tools.pm
+++ b/lib/network/tools.pm
@@ -158,9 +158,31 @@ sub get_default_gateway_interface {
(find { get_interface_type($net->{ifcfg}{$_}) eq 'ethernet' && $net->{ifcfg}{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
}
-sub get_interface_status {
+#- remove suffix from virtual interfaces
+sub get_real_interface {
my ($intf) = @_;
$intf =~ s/:\d+$//;
+ $intf;
+}
+
+sub is_virtual_interface {
+ my ($intf) = @_;
+ $intf =~ /:\d+$/;
+}
+
+sub is_vlan_interface {
+ my ($intf) = @_;
+ $intf =~ /\.\d+$/;
+}
+
+sub is_real_interface {
+ my ($intf) = @_;
+ !is_virtual_interface($intf) && !is_vlan_interface($intf);
+}
+
+sub get_interface_status {
+ my ($intf) = @_;
+ $intf = get_real_interface($intf);
my $routes = get_routes();
return $routes->{$intf}{network}, $routes->{$intf}{network} eq '0.0.0.0' && $routes->{$intf}{gateway};
}