summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2004-11-09 11:19:33 +0000
committerOlivier Blin <oblin@mandriva.org>2004-11-09 11:19:33 +0000
commit647602f92a7b4d06a32cc9b9202a2803f41b6b1f (patch)
tree63c8a76b86eed114b5b5c72518d27c04f3595433 /perl-install
parent700c4d5ec594cfc0b4da5272621b9aa64e7761f4 (diff)
downloaddrakx-647602f92a7b4d06a32cc9b9202a2803f41b6b1f.tar
drakx-647602f92a7b4d06a32cc9b9202a2803f41b6b1f.tar.gz
drakx-647602f92a7b4d06a32cc9b9202a2803f41b6b1f.tar.bz2
drakx-647602f92a7b4d06a32cc9b9202a2803f41b6b1f.tar.xz
drakx-647602f92a7b4d06a32cc9b9202a2803f41b6b1f.zip
introduce network::tools::get_interface_status
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/network/tools.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index d573e41d8..8167c9cee 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -261,15 +261,20 @@ sub get_default_gateway_interface {
(find { get_interface_type($intf->{$_}) eq 'ethernet' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
}
+sub get_interface_status {
+ my ($gw_intf) = @_;
+ my @routes = `$::prefix/sbin/ip route show`;
+ my $is_up = to_bool(grep { /\s+dev\s+$gw_intf(?:\s+|$)/ } @routes);
+ my ($gw_address) = join('', @routes) =~ /^default\s+via\s+(\S+).*\s+dev\s+$gw_intf(?:\s+|$)/m;
+ return $is_up, $gw_address;
+}
+
#- returns (gateway_interface, interface is up, gateway address, dns server address)
sub get_internet_connection {
my ($netc, $intf, $o_gw_intf) = @_;
- my @routes = `$::prefix/sbin/ip route show`;
my ($gw_intf, $is_up, $gw_address);
$gw_intf = $o_gw_intf || get_default_gateway_interface($netc, $intf) or return;
- $is_up = to_bool(grep { /\s+dev\s+$gw_intf(?:\s+|$)/ } @routes);
- ($gw_address) = join('', @routes) =~ /^default\s+via\s+(\S+).*\s+dev\s+$gw_intf(?:\s+|$)/m;
- return $gw_intf, $is_up, $gw_address, $netc->{dnsServer};
+ return $gw_intf, get_interface_status($gw_intf), $netc->{dnsServer};
}
sub get_interface_type {