summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-07-21 00:16:04 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-07-21 00:16:04 +0000
commit7e8fa9773839843c9d8def81ec2ef1315115825a (patch)
treeb20f63ae9f67b2d9c7e8aa6a2b86d56e0d953743 /perl-install/network
parent54b71cdf438434e4693aa6064596f4fdb4aac59e (diff)
downloaddrakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar
drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.gz
drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.bz2
drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.tar.xz
drakx-7e8fa9773839843c9d8def81ec2ef1315115825a.zip
- %modules::conf is no more a global, so many functions need passing $modules_conf
- $modules_conf is a class choosing modules.conf or modprobe.conf (esp. useful after install) (but not working yet!) - modules::load() doesn't use $modules_conf, use modules::load_and_configure() - modules::load() doesn't allow options, use either modules::load_raw() or modules::load_and_configure() - some functions used to want an array ref for modules options and some a string, now every functions use a string - many functions (like modules::get_alias()) are now methods on $modules_conf - some functions in mouse.pm needed a $in where a $do_pkgs is enough - some perl_checker compliance - small fixes
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/adsl.pm6
-rw-r--r--perl-install/network/ethernet.pm27
-rw-r--r--perl-install/network/isdn.pm5
-rw-r--r--perl-install/network/netconnect.pm50
-rw-r--r--perl-install/network/network.pm6
-rw-r--r--perl-install/network/shorewall.pm5
-rw-r--r--perl-install/network/tools.pm4
7 files changed, 52 insertions, 51 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index 2089dd229..f2b50186b 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -96,7 +96,7 @@ sub adsl_detect() {
}
sub adsl_conf_backend {
- my ($in, $adsl, $netc, $adsl_device, $adsl_type, $o_netcnx) = @_;
+ my ($in, $modules_conf, $adsl, $netc, $adsl_device, $adsl_type, $o_netcnx) = @_;
# FIXME: should not be needed:
defined $o_netcnx and $netc->{adsltype} = $o_netcnx->{type};
$netc->{adsltype} ||= "adsl_$adsl_type";
@@ -307,8 +307,8 @@ TYPE=$kind
# set aliases:
if (exists $modems{$adsl_device}{aliases}) {
- modules::set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}};
- $::isStandalone and modules::write_conf();
+ $modules_conf->set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}};
+ $::isStandalone and $modules_conf->write;
}
$netc->{NET_INTERFACE} = 'ppp0';
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 6f9cc8c85..a93d66c77 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -14,7 +14,7 @@ use vars qw(@ISA @EXPORT);
@EXPORT = qw(conf_network_card_backend);
sub write_ether_conf {
- my ($in, $netcnx, $netc, $intf) = @_;
+ my ($in, $modules_conf, $netcnx, $netc, $intf) = @_;
configureNetwork2($in, $::prefix, $netc, $intf);
$netc->{NETWORKING} = "yes";
if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) {
@@ -30,7 +30,7 @@ qq(
/sbin/ifup lo
), $netcnx->{type});
}
- $::isStandalone and modules::write_conf();
+ $::isStandalone and $modules_conf->write;
1;
}
@@ -46,16 +46,16 @@ 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() {
+sub get_eth_cards {
+ my ($modules_conf) = @_;
my @all_cards = detect_devices::getNet();
my @devs = detect_devices::pcmcia_probe();
- modules::mergein_conf();
my $saved_driver;
return map {
my $interface = $_;
my $description;
- my $a = c::getNetDriver($interface) || modules::get_alias($interface);
+ my $a = c::getNetDriver($interface) || $modules_conf->get_alias($interface);
if (my $b = find { $_->{device} eq $interface } @devs) { # PCMCIA case
$a = $b->{driver};
$description = $b->{description};
@@ -64,18 +64,18 @@ sub get_eth_cards() {
}
if (!$description) {
my $drv = readlink("/sys/class/net/$interface/driver");
- if ($drv and $drv =~ s!.*/!!) {
+ if ($drv && $drv =~ s!.*/!!) {
$a = $drv;
my %l;
my %sysfs_fields = (id => "device", subid => "subsystem_device", vendor => "vendor", subvendor => "subsystem_vendor");
$l{$_} = hex(chomp_(cat_("/sys/class/net/$interface/device/" . $sysfs_fields{$_}))) foreach keys %sysfs_fields;
my @cards = grep { my $dev = $_; every { $dev->{$_} eq $l{$_} } keys %l } detect_devices::probeall();
- $description = $cards[0]{description} if $#cards == 0;
+ $description = $cards[0]{description} if @cards == 1;
}
}
if (!$description) {
my @cards = grep { $_->{driver} eq ($a || $saved_driver) } detect_devices::probeall();
- $description = $cards[0]->{description} if $#cards == 0;
+ $description = $cards[0]{description} if @cards == 1;
}
$a and $saved_driver = $a; # handle multiple cards managed by the same driver
[ $interface, $saved_driver, if_($description, $description) ]
@@ -83,11 +83,11 @@ sub get_eth_cards() {
}
sub get_eth_cards_names {
- my (@all_cards) = @_;
+ my ($modules_conf, @all_cards) = @_;
foreach my $card (@all_cards) {
- modules::remove_alias($card->[1]);
- modules::set_alias($card->[0], $card->[1]);
+ $modules_conf->remove_alias($card->[1]);
+ $modules_conf->set_alias($card->[0], $card->[1]);
}
{ map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards };
@@ -131,10 +131,11 @@ sub conf_network_card_backend {
}
# automatic net aliases configuration
-sub configure_eth_aliases() {
+sub configure_eth_aliases {
+ my ($modules_conf) = @_;
foreach (detect_devices::getNet()) {
my $driver = c::getNetDriver($_) or next;
- modules::set_alias($_, $driver);
+ $modules_conf->set_alias($_, $driver);
}
}
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index e4f0ac49a..e4eea89d8 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -120,7 +120,8 @@ sub get_info_providers_backend {
sub read_providers_backend() { map { /(.*?)=>/ } catMaybeCompressed($file) }
-sub detect_backend() {
+sub detect_backend {
+ my ($modules_conf) = @_;
my @isdn;
require detect_devices;
each_index {
@@ -132,7 +133,7 @@ sub detect_backend() {
$isdn->{description} =~ s/.*\|//;
# $c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax";
if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) {
- modules::set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
+ $modules_conf->set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
}
$c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1;
push @isdn, $isdn;
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index fc0b4aa19..7dde76ea3 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -13,23 +13,23 @@ use network::tools;
use MDK::Common::Globals "network", qw($in);
sub detect {
- my ($auto_detect, $o_class) = @_;
+ my ($modules_conf, $auto_detect, $o_class) = @_;
my %l = (
isdn => sub {
require network::isdn;
- $auto_detect->{isdn} = network::isdn::detect_backend();
+ $auto_detect->{isdn} = network::isdn::detect_backend($modules_conf);
},
lan => sub { # ethernet
- modules::load_category('network/main|gigabit|usb');
+ modules::load_category($modules_conf, 'network/main|gigabit|usb');
require network::ethernet;
- $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards() };
+ $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) };
},
adsl => sub {
require network::adsl;
$auto_detect->{adsl} = network::adsl::adsl_detect();
},
modem => sub {
- $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem() };
+ $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) };
},
);
$l{$_}->() foreach $o_class || keys %l;
@@ -74,7 +74,7 @@ sub get_subwizard {
# configuring all network devices
sub real_main {
- my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
+ my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
my $netc = $o_netc ||= {};
my $mouse = $o_mouse ||= {};
my $intf = $o_intf ||= {};
@@ -120,15 +120,13 @@ sub real_main {
read_net_conf($netcnx, $netc, $intf);
- modules::mergein_conf();
-
$netc->{autodetect} = {};
my $lan_detect = sub {
- detect($netc->{autodetect}, 'lan');
- modules::interactive::load_category($in, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 0);
- @all_cards = network::ethernet::get_eth_cards();
- %eth_intf = network::ethernet::get_eth_cards_names(@all_cards);
+ detect($modules_conf, $netc->{autodetect}, 'lan');
+ modules::interactive::load_category($in, $modules_conf, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 0);
+ @all_cards = network::ethernet::get_eth_cards($modules_conf);
+ %eth_intf = network::ethernet::get_eth_cards_names($modules_conf, @all_cards);
require list_modules;
%eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) }
grep { to_bool($is_wireless) == c::isNetDeviceWirelessAware($_->[0]) } @all_cards;
@@ -332,7 +330,7 @@ sub real_main {
isdn =>
{
pre=> sub {
- detect($netc->{autodetect}, 'isdn');
+ detect($modules_conf, $netc->{autodetect}, 'isdn');
%isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}};
},
name => N("Select the network interface to configure:"),
@@ -347,7 +345,7 @@ sub real_main {
if ($isdn_name eq $my_isdn) {
return "isdn_ask";
} elsif ($isdn_name eq N("External ISDN modem")) {
- detect($netc->{autodetect}, 'modem');
+ detect($modules_conf, $netc->{autodetect}, 'modem');
$netc->{isdntype} = 'isdn_external';
$netcnx->{isdn_external}{device} = network::modem::first_modem($netc);
network::isdn::read_config($netcnx->{isdn_external});
@@ -463,7 +461,7 @@ Take a look at http://www.linmodems.org"),
{
pre => sub {
require network::modem;
- detect($netc->{autodetect}, 'modem');
+ detect($modules_conf, $netc->{autodetect}, 'modem');
},
name => N("Select the modem to configure:"),
data => sub {
@@ -646,7 +644,7 @@ killall pppd
pre => sub {
get_subwizard($wiz, 'adsl');
$lan_detect->();
- detect($netc->{autodetect}, 'adsl');
+ detect($modules_conf, $netc->{autodetect}, 'adsl');
@adsl_devices = keys %eth_intf;
foreach my $modem (keys %adsl_devices) {
push @adsl_devices, $modem if $netc->{autodetect}{adsl}{$modem};
@@ -813,7 +811,7 @@ If you don't know, choose 'use pppoe'"),
},
post => sub {
$netc->{internet_cnx_choice} = 'adsl';
- network::adsl::adsl_conf_backend($in, $netcnx, $netc, $ntf_name, $adsl_type, $netcnx); #FIXME
+ network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $ntf_name, $adsl_type, $netcnx); #FIXME
$config->{adsl} = { kind => $ntf_name, protocol => $adsl_type };
$handle_multiple_cnx->();
},
@@ -840,7 +838,7 @@ You can find a driver on http://eciadsl.flashtux.org/"),
post => sub {
$ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
if ($ntf_name eq "Manually load a driver") {
- modules::interactive::load_category__prompt($in, 'network/main|gigabit|pcmcia|usb|wireless');
+ modules::interactive::load_category__prompt($in, $modules_conf, 'network/main|gigabit|pcmcia|usb|wireless');
return 'lan';
}
$::isInstall && $netc->{NET_DEVICE} eq $ethntf->{DEVICE} ? 'lan_alrd_cfg' : 'lan_protocol';
@@ -1055,8 +1053,8 @@ See iwpriv(8) man page for further information."),
{
pre => sub {
#-type =static or dhcp
- modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1);
- @all_cards = network::ethernet::get_eth_cards() or
+ modules::interactive::load_category($in, $modules_conf, 'network/main|gigabit|usb', !$::expert, 1);
+ @all_cards = network::ethernet::get_eth_cards($modules_conf) or
# FIXME: fix this
$in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system.
I cannot set up this connection type.")), return;
@@ -1069,7 +1067,7 @@ I cannot set up this connection type.")), return;
post => sub {
network::ethernet::write_ether_conf();
- modules::write_conf() if $::isStandalone;
+ $modules_conf->write if $::isStandalone;
my $_device = network::ethernet::conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr);
return "lan";
},
@@ -1182,7 +1180,7 @@ It is not necessary on most networks."),
type => "yesorno",
post => sub {
my ($a) = @_;
- network::ethernet::write_ether_conf($in, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan';
+ network::ethernet::write_ether_conf($in, $modules_conf, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan';
if ($a && !$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) {
$success = 0;
$in->ask_okcancel(N("Network Configuration"),
@@ -1332,8 +1330,8 @@ fi
}
sub main {
- my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
- eval { real_main('', , $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) };
+ my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
+ eval { real_main('', , $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) };
my $err = $@;
if ($err) { # && $in->isa('interactive::gtk')
local $::isEmbedded = 0; # to prevent sub window embedding
@@ -1404,7 +1402,7 @@ sub start_internet {
my ($o) = @_;
init_globals($o);
#- give a chance for module to be loaded using kernel-BOOT modules...
- $::isStandalone or modules::load_category('network/main|gigabit|usb');
+ $::isStandalone or modules::load_category($o->{modules_conf}, 'network/main|gigabit|usb');
run_program::rooted($::prefix, $network::tools::connect_file);
}
@@ -1430,7 +1428,7 @@ local $in = class_discard->new;
network::netconnect::init_globals($in);
my %i;
-&network::netconnect::detect(\%i);
+network::netconnect::detect($modules_conf, \%i);
print Dumper(\%i),"\n";
=cut
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 9f4256770..ae871084e 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -363,14 +363,14 @@ sub probe_netcnx_type {
}
sub easy_dhcp {
- my ($netc, $intf) = @_;
+ my ($modules_conf, $netc, $intf) = @_;
return if text2bool($netc->{NETWORKING});
require modules;
require network::ethernet;
- modules::load_category('network/main|gigabit|usb');
- my @all_cards = network::ethernet::get_eth_cards();
+ modules::load_category($modules_conf, 'network/main|gigabit|usb');
+ my @all_cards = network::ethernet::get_eth_cards($modules_conf);
#- only for a single network card
(any { $_->[0] eq 'eth0' } @all_cards) && (every { $_->[0] ne 'eth1' } @all_cards) or return;
diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm
index f518bd00e..1bd15fead 100644
--- a/perl-install/network/shorewall.pm
+++ b/perl-install/network/shorewall.pm
@@ -69,8 +69,9 @@ sub default_interfaces {
my @l = detect_devices::getNet() or return;
-my @all_cards = network::ethernet::get_eth_cards();
-my %net_devices = network::ethernet::get_eth_cards_names(@all_cards);
+ my $modules_conf = modules::any_conf->read;
+my @all_cards = network::ethernet::get_eth_cards($modules_conf);
+my %net_devices = network::ethernet::get_eth_cards_names($modules_conf, @all_cards);
put_in_hash(\%net_devices, { 'ppp+' => 'ppp+', 'ippp+' => 'ippp+' });
$in->ask_from('',
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index 3e2dbaee7..bf1508a4b 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -190,9 +190,9 @@ sub is_dynamic_host {
}
sub reread_net_conf {
- my ($netcnx, $netc, $intf) = @_;
+ my ($modules_conf, $netcnx, $netc, $intf) = @_;
network::netconnect::read_net_conf($netcnx, $netc, $intf);
- modules::load_category('net');
+ modules::load_category($modules_conf, 'net');
}
sub convert_wep_key_for_iwconfig {