From 040267fc1f8f13d0fda0f79c0af329cd0df7acf4 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 26 Jan 2004 21:47:41 +0000 Subject: (get_eth_cards) - split it out of conf_network_card_backend() (which still call it for compatibility for now but sincefunctions whose behavior is totally altered by arguments are insane should just be splited, caller will be fixed then this compatibily call removed) - add a third string in returned tuples (physical net device description) --- perl-install/network/ethernet.pm | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'perl-install') diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 05dbcfc94..b1b768652 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -48,6 +48,25 @@ sub mapIntfToDevice { } +# return list of [ intf_name, module, device_description ] tuples such as: +# [ "eth0", "3c59x", "3Com Corporation|3c905C-TX [Fast Etherlink]" ] +sub get_eth_cards() { + my @all_cards = detect_devices::getNet(); + + my @devs = detect_devices::pcmcia_probe(); + modules::mergein_conf("$::prefix/etc/modules.conf"); + my $saved_driver; + return map { + my $interface = $_; + my $a = c::getNetDriver($interface) || modules::get_alias($interface); + my $b = find { $_->{device} eq $interface } @devs; + $a ||= $b->{driver}; + $a and $saved_driver = $a; # handle multiple cards managed by the same driver + [ $interface, $saved_driver, (mapIntfToDevice($interface))[0]->{description} ] + } @all_cards; +} + + #- conf_network_card_backend : configure the network cards and return the list of them, or configure one specified interface : WARNING, you have to setup the ethernet cards, by calling load_category($in, 'network/main|gigabit|usb', !$::expert, 1) or load_category_backend before calling this function. Basically, you call this function in 2 times. #- input #- $prefix @@ -72,21 +91,8 @@ sub mapIntfToDevice { sub conf_network_card_backend { my ($netc, $intf, $o_type, $o_interface, $o_ipadr, $o_netadr) = @_; #-type =static or dhcp - if (!$o_interface) { - my @all_cards = detect_devices::getNet(); - - my @devs = detect_devices::pcmcia_probe(); - modules::mergein_conf("$::prefix/etc/modules.conf"); - my $saved_driver; - return map { - my $interface = $_; - my $a = c::getNetDriver($interface) || modules::get_alias($interface); - my $b = find { $_->{device} eq $interface } @devs; - $a ||= $b->{driver}; - $a and $saved_driver = $a; # handle multiple cards managed by the same driver - [ $interface, $saved_driver ] - } @all_cards; - } + return get_eth_cards() if !$o_interface; + $o_interface =~ /eth[0-9]+/ or die("the interface is not an ethx"); $netc->{NET_DEVICE} = $o_interface; #- one consider that there is only ONE Internet connection device.. -- cgit v1.2.1