diff options
author | Olivier Blin <oblin@mandriva.org> | 2004-11-09 11:19:33 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2004-11-09 11:19:33 +0000 |
commit | 647602f92a7b4d06a32cc9b9202a2803f41b6b1f (patch) | |
tree | 63c8a76b86eed114b5b5c72518d27c04f3595433 /perl-install | |
parent | 700c4d5ec594cfc0b4da5272621b9aa64e7761f4 (diff) | |
download | drakx-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.pm | 13 |
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 { |