summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-06-03 07:14:48 +0000
committerOlivier Blin <oblin@mandriva.org>2005-06-03 07:14:48 +0000
commit8fc41a1333f01496878ca0561f3ca1ad186b6d64 (patch)
tree2dd030c580d5b8e954bce95508ac7ecacc6127b9 /perl-install/network
parent671adafbfbb78f044970bc4af895ed43dff99757 (diff)
downloaddrakx-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar
drakx-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.gz
drakx-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.bz2
drakx-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.xz
drakx-8fc41a1333f01496878ca0561f3ca1ad186b6d64.zip
- merge network settings in a $net hash (it modifies $o fields too):
o $netc becomes $net->{network} and $net->{resolv} o $intf becomes $net->{ifcfg} - move zeroconf config stuff in write_zeroconf - read_tmdns_conf -> read_zeroconf - read_all_conf -> read_net_conf - configureNetwork2 -> configure_network - configure_network: write ifcfg files for ppp interfaces too - don't install wireless-tools in configure_network, this package is in basesystem - most functions don't need the file path as an argument in network::network - drop network::tools::remove_initscript - don't export too much from network::network - don't export from network::tools - remove adsl_unsupported_eci step in drakconnect - drop passwd2 field in network::adsl - drop $net->{isdn_internal} - network::netconnect : main -> safe_main - use network::netconnect::real_main during install - don't read network config in network::netconnect::real_main - install_steps::upNetwork : resolv.conf is already symlinked by network::network::configure_network when appropriate - try to fix install_any::generate_automatic_stage1_params to use a real interface configuration - put authentication stuff in $net->{auth} - drop network::ethernet::write_ether_conf - drop network::adsl::get_wizard - use 'static' instead of 'manual' as ADSL method - drop first_modem and its workarounds in network::modem - drop deprecated "multiple_internet_cnx" step in drakconnect - don't save /etc/sysconfig/drakconnect anymore - drop MDK::Common::Globals stuff - drop getIP in net_applet (Pixel) - drop $netc->{DHCP} - configure_network(): write resolv.conf even if a dhcp interface is configured
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/adsl.pm136
-rw-r--r--perl-install/network/adsl_consts.pm2
-rw-r--r--perl-install/network/ethernet.pm17
-rw-r--r--perl-install/network/isdn.pm2
-rw-r--r--perl-install/network/modem.pm18
-rw-r--r--perl-install/network/netconnect.pm492
-rw-r--r--perl-install/network/network.pm285
-rw-r--r--perl-install/network/tools.pm54
8 files changed, 374 insertions, 632 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index d12627387..6b6e07fb8 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -10,77 +10,23 @@ use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(adsl_conf_backend);
-
-sub get_wizard {
- my ($wiz) = @_;
- my $netc = $wiz->{var}{netc};
-
- my %l = (
- 'pppoe' => N("use PPPoE"),
- 'pptp' => N("use PPTP"),
- 'dhcp' => N("use DHCP"),
- 'speedtouch' => N("Alcatel Speedtouch USB") . if_($netc->{autodetect}{adsl}{speedtouch}, N(" - detected")),
- 'sagem' => N("Sagem (using PPPoA) USB") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
- 'sagem_dhcp' => N("Sagem (using DHCP) USB") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
- # 'eci' => N("ECI Hi-Focus"), # this one needs eci agreement
- );
-
- $wiz->{var}{adsl} = {
- connection_list => \%l,
- type => "",
- };
- add2hash($wiz->{pages},
- {
- adsl_old => {
- name => N("Connect to the Internet") . "\n\n" .
- N("The most common way to connect with adsl is pppoe.
-Some connections use PPTP, a few use DHCP.
-If you do not know, choose 'use PPPoE'"),
- data => [
- {
- label => N("ADSL connection type:"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
- ],
- pre => sub {
- $wiz->{var}{adsl}{type} = $l{sagem}; # debug
- $wiz->{var}{adsl}{type} ||= find { $netc->{autodetect}{adsl}{$_} } keys %l;
- print qq(\n\ntype is "$wiz->{var}{adsl}{type}"\n\n);
- },
- post => sub {
- $wiz->{var}{adsl}{type} = find { $l{$_} eq $wiz->{var}{adsl}{type} } keys %l;
- my $adsl = $wiz->{var}{adsl}{connection};
- my $type = $wiz->{var}{adsl}{type};
- my $netcnx = $wiz->{var}{netcnx};
- $netcnx->{type} = "adsl_$type";
-
- $netcnx->{"adsl_$type"} = {};
- $netcnx->{"adsl_$type"}{vpivci} = '' if $type =~ /eci|speedtouch/;
- return 'ethernet' if $type eq 'dhcp';
- adsl_probe_info($adsl, $netc, $type);
- # my ($adsl, $netc, $intf, $adsl_type) = @_;
- # ask_info2($adsl, $netc);
- return "hw_account";
- },
- },
- });
-}
-
sub adsl_probe_info {
- my ($adsl, $netc, $adsl_type, $o_adsl_modem) = @_;
+ my ($net) = @_;
my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf";
- my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type eq 'pppoe') && -f $pppoe_file;
+ my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (!exists $net->{adsl}{method} || $net->{adsl}{method} eq 'pppoe') && -f $pppoe_file;
my $login = $pppoe_conf{USER};
foreach (qw(/etc/ppp/peers/ppp0 /etc/ppp/options /etc/ppp/options.adsl)) {
($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$::prefix/$_") if !$login && -r "$::prefix/$_";
}
- my $passwd = passwd_by_login($login);
- if (!$netc->{vpi} && !$netc->{vci} && member($o_adsl_modem, qw(eci speedtouch))) {
- ($netc->{vpi}, $netc->{vci}) =
+ my $passwd = network::tools::passwd_by_login($login);
+ if (!$net->{adsl}{vpi} && !$net->{adsl}{vci}) {
+ ($net->{adsl}{vpi}, $net->{adsl}{vci}) =
(map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, map { sprintf("%x", $_) } $1, $2) } cat_("$::prefix/etc/ppp/peers/ppp0"));
}
$pppoe_conf{DNS1} ||= '';
$pppoe_conf{DNS2} ||= '';
- add2hash($netc, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' });
- add2hash($adsl, { login => $login, passwd => $passwd, passwd2 => '' });
+ add2hash($net->{resolv}, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' });
+ add2hash($net->{adsl}, { login => $login, passwd => $passwd });
}
sub adsl_detect() {
@@ -101,8 +47,10 @@ sub adsl_detect() {
}
sub sagem_set_parameters {
- my ($netc) = @_;
- my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
+ my ($net) = @_;
+ my %l = map { $_ => sprintf("%08s", $net->{adsl}{$_}) } qw(vci vpi Encapsulation);
+
+ my $static_ip = $net->{adsl}{method} eq 'static' && $net->{ifcfg}{sagem}{IPADDR};
foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) {
substInFile {
s/Linetype=.*\n/Linetype=0000000A\n/; #- use CMVs
@@ -110,16 +58,16 @@ sub sagem_set_parameters {
s/VPI=.*\n/VPI=$l{vpi}\n/;
s/Encapsulation=.*\n/Encapsulation=$l{Encapsulation}\n/;
s/STATIC_IP=.*\n//;
- s!</eaglectrl>!STATIC_IP=$netc->{static_ip}\n</eaglectrl>! if $netc->{static_ip};
+ s!</eaglectrl>!STATIC_IP=$static_ip\n</eaglectrl>! if $static_ip;
#- TODO: add ISP info, $netc->{provider_id}
} "$::prefix$cfg_file";
}
#- create CMV symlinks for both POTS and ISDN lines
foreach my $type (qw(p i)) {
my $cmv;
- my ($country) = $netc->{provider_id} =~ /^([a-zA-Z]+)\d+$/;
+ my ($country) = $net->{adsl}{provider_id} =~ /^([a-zA-Z]+)\d+$/;
#- try to find a CMV for this specific ISP
- $cmv = "$::prefix/etc/eagle-usb/CMVe${type}$netc->{provider_id}.txt" if $netc->{provider_id};
+ $cmv = "$::prefix/etc/eagle-usb/CMVe${type}$net->{adsl}{provider_id}.txt" if $net->{adsl}{provider_id};
#- if not found, try to found a CMV for the country
-f $cmv or $cmv = "$::prefix/etc/eagle-usb/CMVe${type}${country}.txt";
#- fallback on the generic CMV if no other matched
@@ -131,14 +79,13 @@ sub sagem_set_parameters {
}
sub adsl_conf_backend {
- my ($in, $modules_conf, $adsl, $netc, $intf, $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";
- $adsl_type eq 'pptp' and $adsl_device = 'pptp_modem';
- $adsl_type eq 'capi' and $adsl_device = 'capi_modem';
+ my ($in, $modules_conf, $net) = @_;
+
my $bewan_module;
- $bewan_module = $o_netcnx->{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $adsl_device eq "bewan";
+ $bewan_module = $net->{adsl}{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $net->{adsl}{device} eq "bewan";
+
+ my $adsl_type = $net->{adsl}{method};
+ my $adsl_device = $net->{adsl}{device};
# all supported modems came with their own pppoa module, so no need for "plugin pppoatm.so"
my %modems =
@@ -154,7 +101,7 @@ sleep 10
),
stop => qq(modprobe -r $bewan_module),
plugin => {
- pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci}))
+ pppoa => "pppoatm.so " . join('.', hex($net->{adsl}{vpi}), hex($net->{adsl}{vci}))
},
ppp_options => qq(
default-asyncmap
@@ -178,7 +125,7 @@ sync
pppoa => qq("/usr/sbin/pppoa3 -c")
},
plugin => {
- pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci})),
+ pppoa => "pppoatm.so " . join('.', hex($net->{adsl}{vpi}), hex($net->{adsl}{vci})),
},
ppp_options => qq(
sync
@@ -222,7 +169,7 @@ novjccomp),
{
start => '/usr/bin/startmodem',
server => {
- pppoe => qq("/usr/bin/pppoeci -v 1 -vpi $netc->{vpi} -vci $netc->{vci}"),
+ pppoe => qq("/usr/bin/pppoeci -v 1 -vpi $net->{adsl}{vpi} -vci $net->{adsl}{vci}"),
},
ppp_options => qq(
noipdefault
@@ -268,7 +215,7 @@ avmadsl)
(
pppoe =>
{
- server => '"pppoe -I ' . ($modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $netc->{NET_DEVICE}) . '"',
+ server => '"pppoe -I ' . ($modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $net->{adsl}{ethernet_device}) . '"',
ppp_options => qq(default-asyncmap
mru 1492
mtu 1492
@@ -320,15 +267,15 @@ holdoff 4
maxfail 25
$pty_option
$plugin
-user "$adsl->{login}"
+user "$net->{adsl}{login}"
));
- write_secret_backend($adsl->{login}, $adsl->{passwd});
+ network::tools::write_secret_backend($net->{adsl}{login}, $net->{adsl}{passwd});
- if ($netc->{NET_DEVICE} =~ /^eth/) {
- my $net_device = $netc->{NET_DEVICE};
- $intf->{$net_device} = {
- DEVICE => $net_device,
+ my $ethernet_device = $net->{adsl}{ethernet_device};
+ if ($ethernet_device =~ /^eth/) {
+ $net->{ifcfg}{$ethernet_device} = {
+ DEVICE => $ethernet_device,
BOOTPROTO => 'none',
NETMASK => '255.255.255.0',
NETWORK => '10.0.0.0',
@@ -340,20 +287,17 @@ user "$adsl->{login}"
#- FIXME: ppp0 and ippp0 are hardcoded
my $metric = network::tools::get_default_metric("adsl"); #- FIXME, do not override if already set
- output_with_perm("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0", 0705, qq(DEVICE=ppp0
-ONBOOT=no
-TYPE=ADSL
-METRIC=$metric
-)) unless member($adsl_type, qw(manual dhcp));
+ put_in_hash($net->{ifcfg}{ppp0}, {
+ DEVICE => 'ppp0',
+ TYPE => 'ADSL',
+ METRIC => $metric,
+ }) unless member($adsl_type, qw(static dhcp));
#- remove file used with sagem for dhcp/static connections
unlink("$::prefix/etc/sysconfig/network-scripts/ifcfg-sagem");
#- set vpi, vci and encapsulation parameters for sagem
- if ($adsl_device eq 'sagem') {
- $netc->{static_ip} = $intf->{sagem}{IPADDR} if $adsl_type eq 'manual';
- sagem_set_parameters($netc);
- }
+ $adsl_device eq 'sagem' and sagem_set_parameters($net);
#- set aliases
if (exists $modems{$adsl_device}{aliases}) {
@@ -365,11 +309,9 @@ METRIC=$metric
if ($adsl_type eq "capi") {
require network::isdn;
- network::isdn::setup_capi_conf($adsl->{capi});
- services::stop("isdn4linux");
- services::do_not_start_service_on_boot("isdn4linux");
- services::start_service_on_boot("capi4linux");
- services::start("capi4linux");
+ network::isdn::setup_capi_conf($net->{adsl}{capi_card});
+ services::set_status('isdn4linux', 0);
+ services::set_status('capi4linux', 1);
#- install and run drdsl for dsl connections, once capi driver is loaded
$in->do_pkgs->ensure_is_installed_if_available("drdsl", "/usr/sbin/drdsl");
diff --git a/perl-install/network/adsl_consts.pm b/perl-install/network/adsl_consts.pm
index 93b6dba33..a360b7887 100644
--- a/perl-install/network/adsl_consts.pm
+++ b/perl-install/network/adsl_consts.pm
@@ -583,7 +583,7 @@ our %adsl_data = (
vpi => 8,
vci => 23,
Encapsulation => 3,
- method => 'manual',
+ method => 'static',
},
N("Italy") . "|Tiscali.it, Alice" =>
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 35e22308b..dcda7b643 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -12,31 +12,16 @@ use network::tools;
our @dhcp_clients = qw(dhclient dhcpcd pump dhcpxd);
sub install_dhcp_client {
- my ($in, $ethntf) = @_;
+ my ($in, $client) = @_;
my %packages = (
"dhclient" => "dhcp-client",
);
- my $client = $ethntf->{DHCP_CLIENT};
#- use default dhcp client if none is provided
$client ||= $dhcp_clients[0];
$client = $packages{$client} if exists $packages{$client};
$in->do_pkgs->install($client);
}
-sub write_ether_conf {
- my ($in, $modules_conf, $netcnx, $netc, $intf) = @_;
- configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
- $netc->{NETWORKING} = "yes";
- if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) {
- $netcnx->{type} = 'lan';
- $netcnx->{NET_DEVICE} = $netc->{NET_DEVICE} = '';
- $netcnx->{NET_INTERFACE} = 'lan'; #$netc->{NET_INTERFACE};
- }
- $::isStandalone and $modules_conf->write;
- 1;
-}
-
-
sub mapIntfToDevice {
my ($interface) = @_;
my $hw_addr = c::getHwIDs($interface);
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index 21e701bb5..5c835c154 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -116,7 +116,7 @@ my $file = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db";
$file = "$::prefix$file" if !-e $file;
sub get_info_providers_backend {
- my ($isdn, $_netc, $name) = @_;
+ my ($isdn, $name) = @_;
$name eq N("Unlisted - edit manually") and return;
foreach (catMaybeCompressed($file)) {
chop;
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index 6359069eb..f600db844 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -8,12 +8,6 @@ use detect_devices;
use mouse;
use network::tools;
-sub first_modem {
- my ($netc) = @_;
- return "/mnt/root" if $::isInstall;
- first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}});
-}
-
sub get_user_home() {
my $home;
if ($ENV{USER} ne "root") {
@@ -25,13 +19,8 @@ sub get_user_home() {
$home;
}
-sub ppp_read_conf {
- my ($netcnx, $netc) = @_;
- my $modem = $netcnx->{$netcnx->{type}} ||= {};
- if (my $detected_modem = first_modem($netc)) {
- $modem->{device} ||= $detected_modem->{device};
- }
- $modem->{device} ||= '/dev/modem';
+sub ppp_read_conf() {
+ my $modem = {};
my %l = getVarsFromSh(get_user_home() . "/.kde/share/config/kppprc");
add2hash(\%l, getVarsFromSh("$::prefix/usr/share/config/kppprc"));
$l{Authentication} = 4 if $l{Authentication} !~ /\d/;
@@ -58,14 +47,13 @@ sub ppp_read_conf {
$modem->{auto_gateway} ||= defined $modem->{Gateway} && $modem->{Gateway} ne '0.0.0.0' ? N("Manual") : N("Automatic");
$modem->{auto_ip} ||= defined $modem->{IPAddr} && $modem->{IPAddr} ne '0.0.0.0' ? N("Manual") : N("Automatic");
$modem->{auto_dns} ||= $modem->{dns1} || $modem->{dns2} ? N("Manual") : N("Automatic");
-
+ $modem->{device} ||= '/dev/modem';
$modem;
}
#-----modem conf
sub ppp_configure {
my ($in, $modem) = @_;
- $modem or return;
$in->do_pkgs->install('ppp') if !$::testing;
$in->do_pkgs->install('kdenetwork-kppp') if !$::testing && $in->do_pkgs->is_installed('kdebase');
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index 1b98ef6c0..1982b0afe 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -5,15 +5,11 @@ use common;
use log;
use detect_devices;
use list_modules;
-use run_program;
use modules;
-use any;
-use fs;
use mouse;
use network::network;
use network::tools;
use network::thirdparty;
-use MDK::Common::Globals "network", qw($in);
sub detect {
my ($modules_conf, $auto_detect, $o_class) = @_;
@@ -39,11 +35,6 @@ sub detect {
return;
}
-sub init_globals {
- my ($in) = @_;
- MDK::Common::Globals::init(in => $in);
-}
-
sub detect_timezone() {
my %tmz2country = (
'Europe/Paris' => N("France"),
@@ -63,31 +54,16 @@ sub detect_timezone() {
\@country;
}
-# load sub category's wizard pages into main wizard data structure
-sub get_subwizard {
- my ($wiz, $type) = @_;
- my %net_conf_callbacks = (adsl => sub { require network::adsl; &network::adsl::get_wizard },
- #cable => sub { require network::ethernet; &network::ethernet::get_wizard },
- #isdn => sub { require network::isdn; &network::isdn::get_wizard },
- #lan => sub { require network::ethernet; &network::ethernet::get_wizard },
- #modem => sub { require network::modem; &network::modem::get_wizard },
- );
- $net_conf_callbacks{$type}->($wiz);
-}
-
-# configuring all network devices
sub real_main {
- my ($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 ||= {};
- my $first_time = $o_first_time || 0;
- my ($network_configured, $cnx_type, $type, @all_cards, %eth_intf, %all_eth_intf);
+ my ($net, $in, $modules_conf) = @_;
+ #- network configuration should have been already read in $net at this point
+ my $mouse = $::o->{mouse} || {};
+ my ($cnx_type, @all_cards, %eth_intf, %all_eth_intf);
my (%connections, @connection_list);
- my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip);
+ my ($modem, $modem_name, $modem_dyn_dns, $modem_dyn_ip);
my $cable_no_auth;
- my ($adsl_type, @adsl_devices, %adsl_cards, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider, $adsl_vpi, $adsl_vci);
- my ($ntf_name, $gateway_ex, $up, $need_restart_network);
+ my (@adsl_devices, %adsl_cards, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider, $adsl_vpi, $adsl_vci);
+ my ($ntf_name, $gateway_ex, $up);
my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods);
my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")");
my (@ndiswrapper_drivers, $ndiswrapper_driver, $ndiswrapper_device);
@@ -98,8 +74,6 @@ sub real_main {
my $ethntf = {};
my $db_path = "/usr/share/apps/kppp/Provider";
my (%countries, @isp, $country, $provider, $old_provider);
- my $config = {};
- eval(cat_("$::prefix/etc/sysconfig/drakconnect"));
my %l10n_lan_protocols = (
static => N("Manual configuration"),
@@ -114,16 +88,10 @@ sub real_main {
3 => N("Protocol for the rest of the world\nNo D-Channel (leased lines)"),
);
- network::tools::remove_initscript();
-
- init_globals($in);
-
- read_net_conf($netcnx, $netc, $intf);
-
- $netc->{autodetect} = {};
+ $net->{autodetect} = {};
my $lan_detect = sub {
- detect($modules_conf, $netc->{autodetect}, 'lan');
+ detect($modules_conf, $net->{autodetect}, 'lan');
require network::ethernet;
modules::interactive::load_category($in, $modules_conf, list_modules::ethernet_categories(), !$::expert, 0);
@all_cards = network::ethernet::get_eth_cards($modules_conf);
@@ -159,7 +127,7 @@ sub real_main {
my %adsl_types = (
dhcp => N("Dynamic Host Configuration Protocol (DHCP)"),
- manual => N("Manual TCP/IP configuration"),
+ static => N("Manual TCP/IP configuration"),
pptp => N("Point to Point Tunneling Protocol (PPTP)"),
pppoe => N("PPP over Ethernet (PPPoE)"),
pppoa => N("PPP over ATM (PPPoA)"),
@@ -191,60 +159,36 @@ sub real_main {
);
my $offer_to_connect = sub {
- return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && !member($adsl_type, qw(manual dhcp));
- return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn isdn_external));
+ if ($net->{type} eq 'adsl' && !member($net->{adsl}{method}, qw(static dhcp)) ||
+ member($net->{type}, qw(modem isdn isdn_external))) {
+ return "ask_connect_now";
+ }
return "end";
};
my $after_lan_intf_selection = sub { $is_wireless ? 'wireless' : 'lan_protocol' };
my $after_start_on_boot_step = sub {
- if ($netc->{internet_cnx_choice} && exists $netc->{internet_cnx}{$netc->{internet_cnx_choice}}) {
- $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
- } else {
- undef $netc->{NET_DEVICE};
- }
- if ($netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)) && member($ntf_name, qw(sagem speedtouch))) {
- #- we may need to write sagem specific parameters and load corresponding modules/programs (sagem/speedtouch)
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx);
- }
- network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
- $network_configured = 1;
- return "restart" if $need_restart_network && !$::isInstall && !$::expert;
+ #- can't be done in adsl_account step because of static/dhcp adsl methods
+ #- we need to write sagem specific parameters and load corresponding modules/programs (sagem/speedtouch)
+ $net->{type} eq 'adsl' and network::adsl::adsl_conf_backend($in, $modules_conf, $net);
+
+ network::network::configure_network($net, $in, $modules_conf);
return $offer_to_connect->();
};
my $goto_start_on_boot_ifneeded = sub {
- return $after_start_on_boot_step->() if $netcnx->{type} eq "lan";
- return "isdn_dial_on_boot" if $netcnx->{type} eq 'isdn';
+ return $after_start_on_boot_step->() if $net->{type} eq "lan";
+ return "isdn_dial_on_boot" if $net->{type} eq 'isdn';
return "network_on_boot";
};
- my $save_cnx = sub {
- if (keys %$config) {
- require Data::Dumper;
- output("$::prefix/etc/sysconfig/drakconnect", Data::Dumper->Dump([ $config ], [ '$p' ]));
- }
- return "allow_user_ctl";
- };
-
- my $handle_multiple_cnx = sub {
- $need_restart_network = member($netcnx->{type}, qw(cable lan)) || $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
- my $nb = keys %{$netc->{internet_cnx}};
- if (1 < $nb) {
- return "multiple_internet_cnx";
- } else {
- $netc->{internet_cnx_choice} = $nb == 1 ? (keys %{$netc->{internet_cnx}})[0] : $netcnx->{type};
- return $save_cnx->();
- }
- };
-
my $delete_gateway_settings = sub {
my ($device) = @_;
#- delete gateway settings if gateway device is invalid or matches the reconfigured device
- if (!$netc->{GATEWAYDEV} || !exists $eth_intf{$netc->{GATEWAYDEV}} || $netc->{GATEWAYDEV} eq $device) {
- delete $netc->{GATEWAY};
- delete $netc->{GATEWAYDEV};
+ if (!$net->{network}{GATEWAYDEV} || !exists $eth_intf{$net->{network}{GATEWAYDEV}} || $net->{network}{GATEWAYDEV} eq $device) {
+ delete $net->{network}{GATEWAY};
+ delete $net->{network}{GATEWAYDEV};
}
};
@@ -258,7 +202,7 @@ sub real_main {
#- redetect interfaces (so that the ndiswrapper module can be detected)
$lan_detect->();
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
1;
};
@@ -297,10 +241,6 @@ sub real_main {
welcome =>
{
pre => sub {
- # keep b/c of translations in case they can be reused somewhere else:
- my @_a = (N("(detected on port %s)", 'toto'),
- #-PO: here, "(detected)" string will be appended to eg "ADSL connection"
- N("(detected %s)", 'toto'), N("(detected)"));
my @connections = (
[ N("LAN connection"), "lan" ],
[ N("Wireless connection"), "lan" ],
@@ -323,35 +263,24 @@ sub real_main {
data => \@connection_list,
post => sub {
$is_wireless = $cnx_type eq N("Wireless connection");
- #- why read again the net_conf here?
- read_net_conf($netcnx, $netc, $intf) if $::isInstall; # :-(
- $type = $netcnx->{type} = $connections{$cnx_type};
- return $type;
+ return $net->{type} = $connections{$cnx_type};
},
},
- prepare_detection =>
- {
- name => N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.",
- translate($type), N("Next")),
- post => $handle_multiple_cnx,
- },
-
-
isdn_account =>
{
pre => sub {
- network::isdn::get_info_providers_backend($isdn, $netc, $provider);
+ network::isdn::get_info_providers_backend($isdn, $provider);
$isdn->{huptimeout} ||= 180;
},
name => N("Connection Configuration") . "\n\n" . N("Please fill or check the field below"),
data => sub {
[
{ label => N("Your personal phone number"), val => \$isdn->{phone_in} },
- { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} },
+ { label => N("Provider name (ex provider.net)"), val => \$net->{resolv}{DOMAINNAME2} },
{ label => N("Provider phone number"), val => \$isdn->{phone_out} },
- { label => N("Provider DNS 1 (optional)"), val => \$netc->{dnsServer2} },
- { label => N("Provider DNS 2 (optional)"), val => \$netc->{dnsServer3} },
+ { label => N("Provider DNS 1 (optional)"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("Provider DNS 2 (optional)"), val => \$net->{resolv}{dnsServer3} },
{ label => N("Dialing mode"), list => ["auto", "manual"], val => \$isdn->{dialing_mode} },
{ label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"], val => \$isdn->{speed} },
{ label => N("Connection timeout (in sec)"), val => \$isdn->{huptimeout} },
@@ -366,42 +295,33 @@ sub real_main {
},
post => sub {
network::isdn::write_config($isdn);
- $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $handle_multiple_cnx->();
+ $net->{net_interface} = 'ippp0';
+ "allow_user_ctl";
},
},
cable =>
{
pre => sub {
- $cable_no_auth = sub { $netc->{bpalogin} eq N("None") };
+ $cable_no_auth = sub { $net->{cable}{bpalogin} eq N("None") };
},
name => N("Cable: account options"),
data => sub {
[
- { label => N("Authentication"), type => "list", val => \$netc->{bpalogin}, list => [ N("None"), N("Use BPALogin (needed for Telstra)") ] },
- { label => N("Account Login (user name)"), val => \$netcnx->{login}, disabled => $cable_no_auth },
- { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1, disabled => $cable_no_auth },
+ { label => N("Authentication"), type => "list", val => \$net->{cable}{bpalogin}, list => [ N("None"), N("Use BPALogin (needed for Telstra)") ] },
+ { label => N("Account Login (user name)"), val => \$net->{cable}{login}, disabled => $cable_no_auth },
+ { label => N("Account Password"), val => \$net->{cable}{passwd}, hidden => 1, disabled => $cable_no_auth },
];
},
post => sub {
- if ($cable_no_auth->()) {
- if (-f "$::prefix/etc/rc.d/init.d/bpalogin") {
- require services;
- services::stop("bpalogin");
- services::do_not_start_service_on_boot("bpalogin");
- }
- } else {
- if ($in->do_pkgs->install("bpalogin")) {
- substInFile {
- s/username\s+.*\n/username $netcnx->{login}\n/;
- s/password\s+.*\n/password $netcnx->{passwd}\n/;
- } "$::prefix/etc/bpalogin.conf";
- require services;
- services::start_service_on_boot("bpalogin");
- services::restart("bpalogin");
- }
- }
+ my $use_bpalogin = !$cable_no_auth->();
+ if ($in->do_pkgs->install("bpalogin")) {
+ substInFile {
+ s/username\s+.*\n/username $net->{cable}{login}\n/;
+ s/password\s+.*\n/password $net->{cable}{passwd}\n/;
+ } "$::prefix/etc/bpalogin.conf";
+ }
+ services::set_status("bpalogin", $use_bpalogin);
$auto_ip = 1;
return "lan";
}
@@ -410,8 +330,8 @@ sub real_main {
isdn =>
{
pre=> sub {
- detect($modules_conf, $netc->{autodetect}, 'isdn');
- %isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}};
+ detect($modules_conf, $net->{autodetect}, 'isdn');
+ %isdn_cards = map { $_->{description} => $_ } @{$net->{autodetect}{isdn}};
},
name => N("Select the network interface to configure:"),
data => sub {
@@ -419,18 +339,15 @@ sub real_main {
list => [ $my_isdn, N("External ISDN modem"), keys %isdn_cards ] } ];
},
post => sub {
- # !intern_pci:
- # data => [ { val => \$isdn_type, type => "list", list => [ , ], } ],
- # post => sub {
if ($isdn_name eq $my_isdn) {
return "isdn_ask";
} elsif ($isdn_name eq N("External ISDN modem")) {
- $netcnx->{type} = 'isdn_external';
+ $net->{type} = 'isdn_external';
return "modem";
}
# FIXME: some of these should be taken from isdn db
- $netcnx->{isdn_internal} = $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) };
+ $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) };
if ($isdn->{id}) {
log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
@@ -489,7 +406,7 @@ If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
},
post => sub {
- $netcnx->{isdn_internal} = $isdn = $isdn_cards{$isdn_name};
+ $isdn = $isdn_cards{$isdn_name};
return "isdn_protocol";
}
},
@@ -549,9 +466,9 @@ Take a look at http://www.linmodems.org"),
{
pre => sub {
require network::modem;
- detect($modules_conf, $netc->{autodetect}, 'modem');
+ detect($modules_conf, $net->{autodetect}, 'modem');
$modem = {};
- if ($netcnx->{type} eq 'isdn_external') {
+ if ($net->{type} eq 'isdn_external') {
#- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i
#- it does not even work with TA 128 modems
#- http://bugs.mandrakelinux.com/query.php?bug=1033
@@ -561,17 +478,17 @@ Take a look at http://www.linmodems.org"),
name => N("Select the modem to configure:"),
data => sub {
[ { label => N("Modem"), type => "list", val => \$modem_name, allow_empty_list => 1,
- list => [ keys %{$netc->{autodetect}{modem}}, N("Manual choice") ], } ];
+ list => [ keys %{$net->{autodetect}{modem}}, N("Manual choice") ], } ];
},
complete => sub {
- my $driver = $netc->{autodetect}{modem}{$modem_name}{driver} or return 0;
+ my $driver = $net->{autodetect}{modem}{$modem_name}{driver} or return 0;
!network::thirdparty::setup_device($in, 'rtc', $driver, $modem, qw(device));
},
post => sub {
return 'choose_serial_port' if $modem_name eq N("Manual choice");
- if (exists $netc->{autodetect}{modem}{$modem_name}{device}) {
+ if (exists $net->{autodetect}{modem}{$modem_name}{device}) {
#- this is a serial probed modem
- $modem->{device} = $netc->{autodetect}{modem}{$modem_name}{device};
+ $modem->{device} = $net->{autodetect}{modem}{$modem_name}{device};
return "ppp_provider";
} else {
#- driver exists but device field hasn't been filled by network::thirdparty::setup_device
@@ -590,7 +507,7 @@ Take a look at http://www.linmodems.org"),
interactive_help_id => 'selectSerialPort',
data => sub {
[ { val => \$modem->{device}, format => \&mouse::serial_port2text, type => "list",
- list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ];
+ list => [ grep { $_ ne $mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ];
},
post => sub {
return 'ppp_provider';
@@ -601,8 +518,7 @@ Take a look at http://www.linmodems.org"),
ppp_provider =>
{
pre => sub {
- network::modem::ppp_read_conf($netcnx, $netc) if !$modem_conf_read;
- $modem_conf_read = 1;
+ add2hash($modem, network::modem::ppp_read_conf());
$in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path);
my $p_db_path = "$::prefix$db_path";
@isp = map {
@@ -703,8 +619,8 @@ Take a look at http://www.linmodems.org"),
},
post => sub {
network::modem::ppp_configure($in, $modem);
- $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $handle_multiple_cnx->();
+ $net->{net_interface} = 'ppp0';
+ "allow_user_ctl";
},
},
@@ -712,22 +628,21 @@ Take a look at http://www.linmodems.org"),
adsl =>
{
pre => sub {
- get_subwizard($wiz, 'adsl');
$lan_detect->();
@adsl_devices = keys %eth_intf;
- detect($modules_conf, $netc->{autodetect}, 'adsl');
+ detect($modules_conf, $net->{autodetect}, 'adsl');
%adsl_cards = ();
- foreach my $modem_type (keys %{$netc->{autodetect}{adsl}}) {
- foreach my $modem (@{$netc->{autodetect}{adsl}{$modem_type}}) {
+ foreach my $modem_type (keys %{$net->{autodetect}{adsl}}) {
+ foreach my $modem (@{$net->{autodetect}{adsl}{$modem_type}}) {
my $name = join(': ', $adsl_descriptions{$modem_type}, $modem->{description});
$adsl_cards{$name} = [ $modem_type, $modem ];
}
}
push @adsl_devices, keys %adsl_cards;
- detect($modules_conf, $netc->{autodetect}, 'isdn');
- if (my @isdn_modems = @{$netc->{autodetect}{isdn}}) {
+ detect($modules_conf, $net->{autodetect}, 'isdn');
+ if (my @isdn_modems = @{$net->{autodetect}{isdn}}) {
require network::isdn;
%isdn_cards = map { $_->{description} => $_ } grep { $_->{driver} =~ /dsl/i } map { network::isdn::get_capi_card($_) } @isdn_modems;
push @adsl_devices, keys %isdn_cards;
@@ -743,12 +658,12 @@ Take a look at http://www.linmodems.org"),
if (exists $adsl_cards{$ntf_name}) {
my $modem;
($ntf_name, $modem) = @{$adsl_cards{$ntf_name}};
- $netcnx->{bus} = $modem->{bus} if $ntf_name eq 'bewan';
+ $net->{adsl}{bus} = $modem->{bus} if $ntf_name eq 'bewan';
}
if (exists($isdn_cards{$ntf_name})) {
require network::isdn;
- $netcnx->{capi} = $isdn_cards{$ntf_name};
- $adsl_type = "capi";
+ $net->{adsl}{capi_card} = $isdn_cards{$ntf_name};
+ $net->{adsl}{method} = "capi";
return 'adsl_account';
}
return 'adsl_provider';
@@ -769,12 +684,12 @@ Take a look at http://www.linmodems.org"),
list => [ sort(N("Unlisted - edit manually"), keys %adsl_data) ], sort => 0 } ];
},
post => sub {
- $adsl_type = 'pppoa' if member($ntf_name, qw(bewan speedtouch));
+ $net->{adsl}{method} = 'pppoa' if member($ntf_name, qw(bewan speedtouch));
if ($adsl_provider ne N("Unlisted - edit manually")) {
$adsl_data = $adsl_data{$adsl_provider};
if ($adsl_provider ne $adsl_old_provider) {
- $netc->{$_} = $adsl_data->{$_} foreach qw(DOMAINNAME2 Encapsulation vpi vci provider_id);
- $adsl_type = $adsl_data->{method};
+ $net->{adsl}{$_} = $adsl_data->{$_} foreach qw(Encapsulation vpi vci provider_id method);
+ $net->{resolv}{$_} = $adsl_data->{$_} foreach qw(DOMAINNAME2);
}
}
return 'adsl_protocol';
@@ -787,12 +702,10 @@ Take a look at http://www.linmodems.org"),
pre => sub {
# preselect right protocol for ethernet though connections:
if (!exists $adsl_descriptions{$ntf_name}) {
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
- $adsl_type ||= $ethntf->{BOOTPROTO} || "dhcp";
- #- FIXME: use static instead of manual as key in %adsl_types
- $adsl_type = "manual" if $adsl_type eq "static";
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
+ $net->{adsl}{method} ||= $ethntf->{BOOTPROTO} || "dhcp";
#- pppoa shouldn't be selected by default for ethernet devices, fallback on pppoe
- $adsl_type = "pppoe" if $adsl_type eq "pppoa";
+ $net->{adsl}{method} = "pppoe" if $net->{adsl}{method} eq "pppoa";
}
},
name => N("Connect to the Internet") . "\n\n" .
@@ -800,38 +713,38 @@ Take a look at http://www.linmodems.org"),
Some connections use PPTP, a few use DHCP.
If you do not know, choose 'use PPPoE'"),
data => [
- { text => N("ADSL connection type:"), val => \$adsl_type, type => "list",
+ { text => N("ADSL connection type:"), val => \$net->{adsl}{method}, type => "list",
list => [ sort { $adsl_types{$a} cmp $adsl_types{$b} } keys %adsl_types ],
format => sub { $adsl_types{$_[0]} },
},
],
post => sub {
my $real_interface = $ntf_name;
- $netcnx->{type} = 'adsl';
+ $net->{type} = 'adsl';
# blacklist bogus driver, enable ifplugd support else:
$find_lan_module->();
$ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->();
- if ($ntf_name eq "sagem" && member($adsl_type, qw(manual dhcp))) {
+ if ($ntf_name eq "sagem" && member($net->{adsl}{method}, qw(static dhcp))) {
#- "fctStartAdsl -i" builds ifcfg-ethX from ifcfg-sagem and echoes ethX
#- it auto-detects dhcp/static modes thanks to encapsulation setting
- $ethntf = $intf->{sagem} ||= {};
+ $ethntf = $net->{ifcfg}{sagem} ||= {};
$ethntf->{DEVICE} = "`/usr/sbin/fctStartAdsl -i`";
$ethntf->{MII_NOT_SUPPORTED} = "yes";
}
- if ($ntf_name eq "speedtouch" && member($adsl_type, qw(manual dhcp))) {
+ if ($ntf_name eq "speedtouch" && member($net->{adsl}{method}, qw(static dhcp))) {
#- use ATMARP with the atm0 interface
$real_interface = "atm0";
- $ethntf = $intf->{$real_interface} ||= {};
+ $ethntf = $net->{ifcfg}{$real_interface} ||= {};
$ethntf->{DEVICE} = $real_interface;
$ethntf->{ATM_ADDR} = undef;
$ethntf->{MII_NOT_SUPPORTED} = "yes";
}
#- delete gateway settings if gateway device is invalid or if reconfiguring the gateway interface
- exists $intf->{$real_interface} and $delete_gateway_settings->($real_interface);
+ exists $net->{ifcfg}{$real_interface} and $delete_gateway_settings->($real_interface);
# process static/dhcp ethernet devices:
- if (exists($intf->{$real_interface}) && member($adsl_type, qw(manual dhcp))) {
+ if (exists($net->{ifcfg}{$real_interface}) && member($net->{adsl}{method}, qw(static dhcp))) {
$ethntf->{TYPE} = "ADSL";
- $auto_ip = $adsl_type eq 'dhcp';
+ $auto_ip = $net->{adsl}{method} eq 'dhcp';
return 'lan_intf';
}
return 'adsl_account';
@@ -842,26 +755,26 @@ If you do not know, choose 'use PPPoE'"),
adsl_account =>
{
pre => sub {
- network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name);
- $netc->{NET_DEVICE} = member($adsl_type, 'pppoe', 'pptp') ? $ntf_name : 'ppp0';
- $netc->{NET_INTERFACE} = 'ppp0';
- ($adsl_vpi, $adsl_vci) = map { hex($_) } @$netc{'vpi', 'vci'};
+ network::adsl::adsl_probe_info($net);
+ member($net->{adsl}{method}, qw(pppoe pptp)) and $net->{adsl}{ethernet_device} = $ntf_name;
+ $net->{net_interface} = 'ppp0';
+ ($adsl_vpi, $adsl_vci) = (hex($net->{adsl}{vpi}), hex($net->{adsl}{vci}));
},
name => N("Connection Configuration") . "\n\n" .
N("Please fill or check the field below"),
data => sub {
[
- if_(0, { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} }),
- { label => N("First DNS Server (optional)"), val => \$netc->{dnsServer2} },
- { label => N("Second DNS Server (optional)"), val => \$netc->{dnsServer3} },
- { label => N("Account Login (user name)"), val => \$netcnx->{login} },
- { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1 },
- if_($adsl_type ne "capi",
+ if_(0, { label => N("Provider name (ex provider.net)"), val => \$net->{resolv}{DOMAINNAME2} }),
+ { label => N("First DNS Server (optional)"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("Second DNS Server (optional)"), val => \$net->{resolv}{dnsServer3} },
+ { label => N("Account Login (user name)"), val => \$net->{adsl}{login} },
+ { label => N("Account Password"), val => \$net->{adsl}{passwd}, hidden => 1 },
+ if_($net->{adsl}{method} ne "capi",
{ label => N("Virtual Path ID (VPI):"), val => \$adsl_vpi, advanced => 1 },
{ label => N("Virtual Circuit ID (VCI):"), val => \$adsl_vci, advanced => 1 }
),
if_($ntf_name eq "sagem",
- { label => N("Encapsulation:"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ],
+ { label => N("Encapsulation:"), val => \$net->{adsl}{Encapsulation}, list => [ keys %encapsulations ],
format => sub { $encapsulations{$_[0]} }, advanced => 1,
},
),
@@ -871,25 +784,18 @@ If you do not know, choose 'use PPPoE'"),
#- update ATM_ADDR for ATMARP connections
exists $ethntf->{ATM_ADDR} and $ethntf->{ATM_ADDR} = join('.', $adsl_vpi, $adsl_vci);
#- convert VPI/VCI back to hex
- @$netc{'vpi', 'vci'} = map { sprintf("%x", $_) } ($adsl_vpi, $adsl_vci);
+ ($net->{adsl}{vpi}, $net->{adsl}{vci}) = map { sprintf("%x", $_) } ($adsl_vpi, $adsl_vci);
- $netc->{internet_cnx_choice} = 'adsl';
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); #FIXME
- $config->{adsl} = { kind => $ntf_name, protocol => $adsl_type };
- $handle_multiple_cnx->();
+ $net->{adsl}{device} =
+ $net->{adsl}{method} eq 'pptp' ? 'pptp_modem' :
+ $net->{adsl}{method} eq 'capi' ? 'capi_modem' :
+ $ntf_name;
+ network::adsl::adsl_conf_backend($in, $modules_conf, $net);
+ "allow_user_ctl";
},
},
- adsl_unsupported_eci =>
- {
- name => N("The ECI Hi-Focus modem cannot be supported due to binary driver distribution problem.
-
-You can find a driver on http://eciadsl.flashtux.org/"),
- end => 1,
- },
-
-
lan =>
{
pre => $lan_detect,
@@ -921,7 +827,7 @@ You can find a driver on http://eciadsl.flashtux.org/"),
} elsif ($ntf_name eq "Use a Windows driver (with ndiswrapper)") {
return $ndiswrapper_next_step->();
}
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
return $after_lan_intf_selection->();
},
},
@@ -951,8 +857,6 @@ You can find a driver on http://eciadsl.flashtux.org/"),
},
- # FIXME: is_install: no return for each card "last step" because of manual popping
- # better construct an hash of { current_netintf => next_step } which next_step = last_card ? next_eth_step : next_card ?
lan_intf =>
{
pre => sub {
@@ -966,7 +870,7 @@ You can find a driver on http://eciadsl.flashtux.org/"),
$ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->();
$hotplug = !text2bool($ethntf->{MII_NOT_SUPPORTED});
$track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop();
- delete $ethntf->{TYPE} if $netcnx->{type} ne 'adsl' || !member($adsl_type, qw(manual dhcp));
+ delete $ethntf->{TYPE} if $net->{type} ne 'adsl' || !member($net->{adsl}{method}, qw(static dhcp));
$ethntf->{DHCP_CLIENT} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd));
},
name => sub { join('',
@@ -989,7 +893,7 @@ notation (for example, 1.2.3.4).")),
{ text => N("Track network card id (useful for laptops)"), val => \$track_network_id, type => "bool" },
if_(!$is_wireless,
{ text => N("Network Hotplugging"), val => \$hotplug, type => "bool" }),
- if_($netcnx->{type} eq "lan",
+ if_($net->{type} eq "lan",
{ text => N("Start at boot"), val => \$onboot, type => "bool" },
),
{ label => N("Metric"), val => \$ethntf->{METRIC}, advanced => 1 },
@@ -1005,7 +909,6 @@ notation (for example, 1.2.3.4).")),
},
complete => sub {
$ethntf->{BOOTPROTO} = $auto_ip ? "dhcp" : "static";
- $netc->{DHCP} = $auto_ip;
return 0 if $auto_ip;
if (!is_ip($ethntf->{IPADDR})) {
$in->ask_warn(N("Error"), N("IP address should be in format 1.2.3.4"));
@@ -1020,7 +923,7 @@ notation (for example, 1.2.3.4).")),
return 1, 0;
}
#- test if IP address is already used (do not test for sagem DSL devices since it may use many ifcfg files)
- if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %$intf) {
+ if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %{$net->{ifcfg}}) {
$in->ask_warn(N("Error"), N("%s already in use\n", $ethntf->{IPADDR}));
return 1, 0;
}
@@ -1038,7 +941,7 @@ notation (for example, 1.2.3.4).")),
$ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR};
#- FIXME: special case for sagem where $ethntf->{DEVICE} is the result of a command
#- we can't always use $ntf_name because of some USB DSL modems
- $netc->{$_} = $ntf_name eq "sagem" ? "sagem" : $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE);
+ $net->{net_interface} = $ntf_name eq "sagem" ? "sagem" : $ethntf->{DEVICE};
if ($auto_ip) {
#- delete gateway settings if gateway device is invalid or if reconfiguring the gateway interface to dhcp
$delete_gateway_settings->($ntf_name);
@@ -1082,8 +985,6 @@ notation (for example, 1.2.3.4).")),
{
pre => sub {
require network::wireless;
- $ethntf->{wireless_eth} = 1;
- $netc->{wireless_eth} = 1;
$ethntf->{WIRELESS_MODE} ||= "Managed";
$ethntf->{WIRELESS_ESSID} ||= "any";
($wireless_enc_key, my $restricted) = network::wireless::get_wep_key_from_iwconfig($ethntf->{WIRELESS_ENC_KEY});
@@ -1207,7 +1108,7 @@ set TxRate=0);
dvb_adapter =>
{
pre => sub {
- my $previous_ethntf = find { $is_dvb_interface->($_) } values %$intf;
+ my $previous_ethntf = find { $is_dvb_interface->($_) } values %{$net->{ifcfg}};
$dvb_ad = $previous_ethntf->{DVB_ADAPTER_ID};
$dvb_net = $previous_ethntf->{DVB_NETWORK_DEMUX};
$dvb_pid = $previous_ethntf->{DVB_NETWORK_PID};
@@ -1225,7 +1126,7 @@ set TxRate=0);
},
post => sub {
$ntf_name = 'dvb' . $dvb_ad . '_' . $dvb_net;
- $ethntf = $intf->{$ntf_name} ||= {};
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= {};
$ethntf->{DEVICE} = $ntf_name;
$ethntf->{DVB_ADAPTER_ID} = qq("$dvb_ad");
$ethntf->{DVB_NETWORK_DEMUX} = qq("$dvb_net");
@@ -1238,13 +1139,13 @@ set TxRate=0);
{
pre => sub {
if ($ethntf->{IPADDR}) {
- $netc->{dnsServer} ||= dns($ethntf->{IPADDR});
+ $net->{resolv}{dnsServer} ||= dns($ethntf->{IPADDR});
$gateway_ex = gateway($ethntf->{IPADDR});
- # $netc->{GATEWAY} ||= gateway($ethntf->{IPADDR});
+ # $net->{network}{GATEWAY} ||= gateway($ethntf->{IPADDR});
if ($ntf_name eq "sagem") {
my @sagem_ip = split(/\./, $ethntf->{IPADDR});
$sagem_ip[3] = 254;
- $netc->{GATEWAY} = join(".", @sagem_ip);
+ $net->{network}{GATEWAY} = join(".", @sagem_ip);
}
}
},
@@ -1255,16 +1156,16 @@ You may also enter the IP address of the gateway if you have one.") .
" " . # better looking text (to be merged into texts since some languages (eg: ja) doesn't need it
N("Last but not least you can also type in your DNS server IP addresses."),
data => sub {
- [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$netc->{HOSTNAME} },
+ [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$net->{network}{HOSTNAME} },
if_(!$auto_ip,
- { label => N("DNS server 1"), val => \$netc->{dnsServer} },
- { label => N("DNS server 2"), val => \$netc->{dnsServer2} },
- { label => N("DNS server 3"), val => \$netc->{dnsServer3} },
- { label => N("Search domain"), val => \$netc->{DOMAINNAME},
+ { label => N("DNS server 1"), val => \$net->{resolv}{dnsServer} },
+ { label => N("DNS server 2"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("DNS server 3"), val => \$net->{resolv}{dnsServer3} },
+ { label => N("Search domain"), val => \$net->{resolv}{DOMAINNAME},
help => N("By default search domain will be set from the fully-qualified host name") },
- { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} },
+ { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$net->{network}{GATEWAY} },
if_(@all_cards > 1,
- { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ N_("None"), sort keys %all_eth_intf ],
+ { label => N("Gateway device"), val => \$net->{network}{GATEWAYDEV}, list => [ N_("None"), sort keys %all_eth_intf ],
format => sub { $all_eth_intf{$_[0]} || translate($_[0]) } },
),
),
@@ -1272,18 +1173,18 @@ N("Last but not least you can also type in your DNS server IP addresses."),
},
complete => sub {
foreach my $dns (qw(dnsServer dnsServer2 dnsServer3)) {
- if ($netc->{$dns} && !is_ip($netc->{$dns})) {
+ if ($net->{resolv}{$dns} && !is_ip($net->{resolv}{$dns})) {
$in->ask_warn(N("Error"), N("DNS server address should be in format 1.2.3.4"));
return 1;
}
}
- if ($netc->{GATEWAY} && !is_ip($netc->{GATEWAY})) {
+ if ($net->{network}{GATEWAY} && !is_ip($net->{network}{GATEWAY})) {
$in->ask_warn(N("Error"), N("Gateway address should be in format 1.2.3.4"));
return 1;
}
},
post => sub {
- $netc->{GATEWAYDEV} eq "None" and delete $netc->{GATEWAYDEV};
+ $net->{network}{GATEWAYDEV} eq "None" and delete $net->{network}{GATEWAYDEV};
return "zeroconf";
}
},
@@ -1295,32 +1196,14 @@ N("Last but not least you can also type in your DNS server IP addresses."),
This is the name your machine will use to advertise any of
its shared resources that are not managed by the network.
It is not necessary on most networks."),
- data => [ { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} } ],
+ data => [ { label => N("Zeroconf Host name"), val => \$net->{zeroconf}{hostname} } ],
complete => sub {
- if ($netc->{ZEROCONF_HOSTNAME} =~ /\./) {
+ if ($net->{zeroconf}{hostname} =~ /\./) {
$in->ask_warn(N("Error"), N("Zeroconf host name must not contain a ."));
return 1;
}
},
- post => $handle_multiple_cnx,
- },
-
-
- multiple_internet_cnx =>
- {
- name => N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n") . if_(!$::isStandalone, "You may want to configure some profiles after the installation, in the Mandriva Control Center"),
- data => sub {
- [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice},
- list => [ keys %{$netc->{internet_cnx}} ] } ];
- },
- post => $save_cnx,
- },
-
-
- apply_settings =>
- {
- name => N("Configuration is complete, do you want to apply settings?"),
- type => "yesorno",
+ next => "allow_user_ctl",
},
@@ -1328,13 +1211,10 @@ It is not necessary on most networks."),
{
name => N("Do you want to allow users to start the connection?"),
type => "yesorno",
- default => sub { bool2yesno(text2bool($intf->{$netc->{NET_INTERFACE}}{USERCTL})) },
+ default => sub { bool2yesno(text2bool($net->{ifcfg}{$net->{net_interface}}{USERCTL})) },
post => sub {
my ($res) = @_;
- $res = bool2yesno($res);
- $intf->{$netc->{NET_INTERFACE}}{USERCTL} = $res;
- my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
- -f $ifcfg_file and substInFile { s/^USERCTL.*\n//; $_ .= qq(USERCTL=$res\n) if eof } $ifcfg_file;
+ $net->{ifcfg}{$net->{net_interface}}{USERCTL} = bool2yesno($res);
return $goto_start_on_boot_ifneeded->();
},
},
@@ -1342,20 +1222,12 @@ It is not necessary on most networks."),
network_on_boot =>
{
- pre => sub {
- # condition is :
- member($netc->{internet_cnx_choice}, ('adsl', 'isdn')); # and $netc->{at_boot} = $in->ask_yesorno(N("Network Configuration Wizard"), N("Do you want to start the connection at boot?"));
- },
name => N("Do you want to start the connection at boot?"),
type => "yesorno",
- default => sub { ($type eq 'modem' ? 'no' : 'yes') },
+ default => sub { ($net->{type} eq 'modem' ? 'no' : 'yes') },
post => sub {
my ($res) = @_;
- $netc->{at_boot} = $res;
- $res = bool2yesno($res);
- $ethntf->{ONBOOT} = $res if $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
- my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
- -f $ifcfg_file and substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } $ifcfg_file;
+ $net->{ifcfg}{$net->{net_interface}} = bool2yesno($res);
return $after_start_on_boot_step->();
},
},
@@ -1364,7 +1236,7 @@ It is not necessary on most networks."),
isdn_dial_on_boot =>
{
pre => sub {
- $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written
+ $net->{ifcfg}{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written
@isdn_dial_methods = ({ name => N("Automatically at boot"),
ONBOOT => 1, DIAL_ON_IFUP => 1 },
{ name => N("By using Net Applet in the system tray"),
@@ -1372,8 +1244,8 @@ It is not necessary on most networks."),
{ name => N("Manually (the interface would still be activated at boot)"),
ONBOOT => 1, DIAL_ON_IFUP => 0 });
my $method = find {
- $_->{ONBOOT} eq text2bool($intf->{ippp0}{ONBOOT}) &&
- $_->{DIAL_ON_IFUP} eq text2bool($intf->{ippp0}{DIAL_ON_IFUP});
+ $_->{ONBOOT} eq text2bool($net->{ifcfg}{ippp0}{ONBOOT}) &&
+ $_->{DIAL_ON_IFUP} eq text2bool($net->{ifcfg}{ippp0}{DIAL_ON_IFUP});
} @isdn_dial_methods;
#- use net_applet by default
$isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name};
@@ -1384,49 +1256,31 @@ It is not necessary on most networks."),
},
post => sub {
my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods;
- $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
+ $net->{ifcfg}{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
return $after_start_on_boot_step->();
},
},
-
- restart =>
- {
- name => N("The network needs to be restarted. Do you want to restart it?"),
- type => "yesorno",
- post => sub {
- my ($a) = @_;
- 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"),
- N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
- }
- return $offer_to_connect->();
- },
- },
-
-
ask_connect_now =>
{
name => N("Do you want to try to connect to the Internet now?"),
type => "yesorno",
post => sub {
my ($a) = @_;
- my $type = $netc->{internet_cnx_choice};
+ my $type = $net->{type};
$up = 1;
if ($a) {
# local $::isWizard = 0;
my $_w = $in->wait_message('', N("Testing your connection..."), 1);
- disconnect_backend($netc);
+ network::tools::disconnect_backend($net);
sleep 1;
- connect_backend($netc);
+ network::tools::connect_backend($net);
my $s = 30;
$type =~ /modem/ and $s = 50;
$type =~ /adsl/ and $s = 35;
$type =~ /isdn/ and $s = 20;
sleep $s;
- $up = connected();
+ $up = network::tools::connected();
}
$success = $up;
return $a ? "disconnect" : "end";
@@ -1445,7 +1299,7 @@ Try to reconfigure your connection.");
no_back => 1,
end => 1,
post => sub {
- $::isInstall and disconnect_backend($netc);
+ $::isInstall and network::tools::disconnect_backend($net);
return "end";
},
},
@@ -1466,42 +1320,31 @@ Test your connection via net_monitor or mcc. If your connection does not work, y
},
};
- my $use_wizard = 1;
- if ($::isInstall) {
- if ($first_time && $in->{method} =~ /^(ftp|http|nfs)$/) {
- local $::isWizard;
- !$::expert && !$o_noauto || $in->ask_okcancel(N("Network Configuration"),
- N("Because you are doing a network installation, your network is already configured.
+ #- keeping the translations in case someone want to restore these texts
+ if_(0,
+ # keep b/c of translations in case they can be reused somewhere else:
+ N("(detected on port %s)", 'toto'),
+ #-PO: here, "(detected)" string will be appended to eg "ADSL connection"
+ N("(detected %s)", 'toto'), N("(detected)"),
+ N("Network Configuration"),
+ N("Because you are doing a network installation, your network is already configured.
Click on Ok to keep your configuration, or cancel to reconfigure your Internet & Network connection.
-"), 1)
- and do {
- $netcnx->{type} = 'lan';
- $netc->{$_} = 'eth0' foreach qw(NET_DEVICE NET_INTERFACE);
- $use_wizard = 0;
- };
- }
- }
-
- if ($use_wizard) {
- require wizards;
- $wiz->{var} = {
- netc => $netc,
- mouse => $mouse,
- intf => $intf,
- };
- wizards->new->process($wiz, $in);
- }
-
- # install needed packages:
- $network_configured or network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
-
- $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
- $netcnx->{type} =~ /adsl/ or run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null");
+"),
+ N("The network needs to be restarted. Do you want to restart it?"),
+ N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), #- nice one ...
+ N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.", 'a', 'b'),
+ N("Configuration is complete, do you want to apply settings?"),
+ N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n"),
+ N("Internet connection"),
+ );
+
+ require wizards;
+ wizards->new->process($wiz, $in);
}
-sub main {
- my ($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) };
+sub safe_main {
+ my ($net, $in, $modules_conf) = @_;
+ eval { real_main($net, $in, $modules_conf) };
my $err = $@;
if ($err) { # && $in->isa('interactive::gtk')
$err =~ /wizcancel/ and $in->exit(0);
@@ -1513,23 +1356,17 @@ sub main {
}
}
-sub read_net_conf {
- my ($netcnx, $netc, $intf) = @_;
- network::network::read_all_conf($::prefix, $netc, $intf, $netcnx);
-}
-
sub start_internet {
my ($o) = @_;
- init_globals($o);
#- give a chance for module to be loaded using kernel-BOOT modules...
+ #- FIXME, this has nothing to do there
$::isStandalone or modules::load_category($o->{modules_conf}, 'network/*');
- connect_backend($o->{netc});
+ network::tools::connect_backend($o->{net});
}
sub stop_internet {
my ($o) = @_;
- init_globals($o);
- disconnect_backend($o->{netc});
+ network::tools::disconnect_backend($o->{net});
}
1;
@@ -1540,14 +1377,11 @@ sub stop_internet {
use lib qw(/usr/lib/libDrakX);
use network::netconnect;
+use modules;
use Data::Dumper;
-use class_discard;
-
-local $in = class_discard->new;
-
-network::netconnect::init_globals($in);
my %i;
+my $modules_conf = modules::any_conf->read;
network::netconnect::detect($modules_conf, \%i);
print Dumper(\%i),"\n";
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 2bccad7df..ab0130d37 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -15,12 +15,45 @@ use any;
use vars qw(@ISA @EXPORT);
use log;
+my $network_file = "$::prefix/etc/sysconfig/network";
+my $resolv_file = "$::prefix/etc/resolv.conf";
+my $tmdns_file = "$::prefix/etc/tmdns.conf";
+
+
@ISA = qw(Exporter);
-@EXPORT = qw(add2hosts addDefaultRoute configureNetwork2 dns dnsServers findIntf gateway guessHostname is_ip is_ip_forbidden masked_ip netmask read_all_conf read_conf read_interface_conf read_resolv_conf resolv sethostname write_conf write_resolv_conf);
+@EXPORT = qw(addDefaultRoute dns dnsServers gateway guessHostname is_ip is_ip_forbidden masked_ip netmask resolv sethostname);
+
+#- $net hash structure
+#- autodetect
+#- type
+#- net_interface
+#- PROFILE: selected netprofile
+#- network (/etc/sysconfig/network) : GATEWAY GATEWAYDEV HOSTNAME NETWORKING NISDOMAIN
+#- NETWORKING : networking flag : string : "yes" by default
+#- FORWARD_IPV4 : forward IP flag : string : "false" by default
+#- HOSTNAME : hostname : string : "localhost.localdomain" by default
+#- GATEWAY : gateway
+#- GATEWAYDEV : gateway interface
+#- NISDOMAIN : nis domain
+#- resolv (/etc/resolv.conf): dnsServer, dnsServer2, dnsServer3, DOMAINNAME, DOMAINNAME2, DOMAINNAME3
+#- dnsServer : dns server 1
+#- dnsServer2 : dns server 2
+#- dnsServer3 : dns server 3 : note that we uses the dns1 for the LAN, and the 2 others for the internet conx
+#- DOMAINNAME : domainname : string : $netc->{HOSTNAME} =~ /\.(.*)/ by default
+#- DOMAINNAME2 : well it's another domainname : have to look further why we used 2
+#- adsl: bus, Encapsulation, vpi, vci provider_id, method, login, passwd, ethernet_device, capi_card
+#- cable: bpalogin, login, passwd
+#- zeroconf: hostname
+#- auth: LDAPDOMAIN WINDOMAIN
+#- ifcfg (/etc/sysconfig/network-scripts/ifcfg-*):
+#- key : device name
+#- value : hash containing ifcfg file values
+#- DHCP_HOSTNAME : If you have a dhcp and want to set the hostname
+#- IPADDR : IP address
+#- NETMASK : netmask
+#- DEVICE : device name
+#- BOOTPROTO : boot prototype : "bootp" or "dhcp" or "pump" or ...
-#-######################################################################################
-#- Functions
-#-######################################################################################
sub read_conf {
my ($file) = @_;
+{ getVarsFromSh($file) };
@@ -52,38 +85,48 @@ sub read_interface_conf {
\%intf;
}
-sub read_tmdns_conf() {
- my $file = "$::prefix/etc/tmdns.conf";
- cat_($file) =~ /^\s*hostname\s*=\s*(\w+)/m && { ZEROCONF_HOSTNAME => $1 };
+sub read_zeroconf() {
+ cat_($tmdns_file) =~ /^\s*hostname\s*=\s*(\w+)/m && { ZEROCONF_HOSTNAME => $1 };
}
-sub write_conf {
- my ($netc) = @_;
- my $file = "$::prefix/etc/sysconfig/network";
+sub write_network_conf {
+ my ($net) = @_;
- if ($netc->{HOSTNAME} && $netc->{HOSTNAME} =~ /\.(.+)$/) {
- $netc->{DOMAINNAME} = $1;
+ if ($net->{network}{HOSTNAME} && $net->{network}{HOSTNAME} =~ /\.(.+)$/) {
+ $net->{resolv}{DOMAINNAME} = $1;
}
- $netc->{NETWORKING} = 'yes';
+ $net->{network}{NETWORKING} = 'yes';
- setVarsInSh($file, $netc, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN));
+ setVarsInSh($network_file, $net->{network}, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN));
}
sub write_zeroconf {
- my ($file, $zhostname) = @_;
- eval { substInFile { s/^\s*(hostname)\s*=.*/$1 = $zhostname/ } $file };
+ my ($net, $in) = @_;
+ my $zhostname = $net->{zeroconf}{hostname};
+
+ if ($zhostname) {
+ $in->do_pkgs->ensure_binary_is_installed('tmdns', 'tmdns', 'auto') if !$in->do_pkgs->is_installed('bind');
+ $in->do_pkgs->ensure_binary_is_installed('zcip', 'zcip', 'auto');
+ }
+
+ #- write blank hostname even if disabled so that drakconnect does not assume zeroconf is enabled
+ eval { substInFile { s/^\s*(hostname)\s*=.*/$1 = $zhostname/ } $tmdns_file } if $zhostname || -f $tmdns_file;
+
+ require services;
+ services::set_status('tmdns', $net->{zeroconf}{hostname});
}
sub write_resolv_conf {
- my ($file, $netc) = @_;
+ my ($net) = @_;
+ my $resolv = $net->{resolv};
my %new = (
- search => [ grep { $_ } uniq(@$netc{'DOMAINNAME', 'DOMAINNAME2', 'DOMAINNAME3'}) ],
- nameserver => [ grep { $_ } uniq(@$netc{'dnsServer', 'dnsServer2', 'dnsServer3'}) ],
+ search => [ grep { $_ } uniq(@$resolv{'DOMAINNAME', 'DOMAINNAME2', 'DOMAINNAME3'}) ],
+ nameserver => [ grep { $_ } uniq(@$resolv{'dnsServer', 'dnsServer2', 'dnsServer3'}) ],
);
my (%prev, @unknown);
- foreach (cat_($file)) {
+ foreach (cat_($resolv_file)) {
s/\s+$//;
s/^[#\s]*//;
@@ -94,7 +137,7 @@ sub write_resolv_conf {
push @unknown, $_;
}
}
- unlink $file if -l $file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever
+ unlink $resolv_file if -l $resolv_file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever
if (@{$new{search}} || @{$new{nameserver}}) {
$prev{$_} = [ difference2($prev{$_} || [], $new{$_}) ] foreach keys %new;
@@ -109,7 +152,7 @@ sub write_resolv_conf {
my @old = map { "# nameserver $_\n" } @{$prev{nameserver}};
@new, @old;
};
- output_with_perm($file, 0644, @search, @nameserver, (map { "# $_\n" } @unknown), "\n# ppp temp entry\n");
+ output_with_perm($resolv_file, 0644, @search, @nameserver, (map { "# $_\n" } @unknown), "\n# ppp temp entry\n");
#-res_init(); # reinit the resolver so DNS changes take affect
1;
@@ -128,10 +171,16 @@ sub update_broadcast_and_network {
}
sub write_interface_conf {
- my ($file, $intf, $_netc, $_prefix) = @_;
+ my ($net, $name) = @_;
+
+ my $file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$name";
+ #- prefer ifcfg-XXX files
+ unlink("$::prefix/etc/sysconfig/network-scripts/$name");
+
+ my $intf = $net->{ifcfg}{$name};
require network::ethernet;
- my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
+ my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
$intf->{HWADDR} &&= $mac_address; #- set HWADDR to MAC address if required
update_broadcast_and_network($intf);
@@ -147,15 +196,16 @@ sub write_interface_conf {
if_($intf->{DEVICE} =~ /^ippp\d+$/, qw(DIAL_ON_IFUP))
);
substInFile { s/^DEVICE='(`.*`)'/DEVICE=$1/g } $file; #- remove quotes if DEVICE is the result of a command
-
chmod $intf->{WIRELESS_ENC_KEY} ? 0700 : 0755, $file; #- hide WEP key for non-root users
log::explanations("written $intf->{DEVICE} interface configuration in $file");
}
sub add2hosts {
- my ($file, $hostname, @ips) = @_;
+ my ($hostname, @ips) = @_;
my ($sub_hostname) = $hostname =~ /(.*?)\./;
+ my $file = "$::prefix/etc/hosts";
+
my %l;
foreach (cat_($file)) {
my ($ip, $aliases) = /^\s*(\S+)\s+(\S+.*)$/ or next;
@@ -170,35 +220,34 @@ sub add2hosts {
# The interface/gateway needs to be configured before this will work!
sub guessHostname {
- my ($_prefix, $netc, $intf) = @_;
+ my ($net, $intf_name) = @_;
- $intf->{isUp} && dnsServers($netc) or return 0;
- $netc->{HOSTNAME} && $netc->{DOMAINNAME} and return 1;
+ $net->{ifcfg}{$intf_name}{isUp} && dnsServers($net) or return 0;
+ $net->{network}{HOSTNAME} && $net->{resolv}{DOMAINNAME} and return 1;
- write_resolv_conf("$::prefix/etc/resolv.conf", $netc);
+ write_resolv_conf($net);
- my $name = gethostbyaddr(Socket::inet_aton($intf->{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0;
+ my $name = gethostbyaddr(Socket::inet_aton($net->{ifcfg}{$intf_name}{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0;
log::explanations("reverse name lookup worked");
- add2hash($netc, { HOSTNAME => $name });
+ $net->{network}{HOSTNAME} ||= $name;
1;
}
sub addDefaultRoute {
- my ($netc) = @_;
- c::addDefaultRoute($netc->{GATEWAY}) if $netc->{GATEWAY};
+ my ($net) = @_;
+ c::addDefaultRoute($net->{network}{GATEWAY}) if $net->{network}{GATEWAY};
}
sub sethostname {
- my ($netc) = @_;
+ my ($net) = @_;
my $text;
- syscall_("sethostname", $netc->{HOSTNAME}, length $netc->{HOSTNAME}) ? ($text="set sethostname to $netc->{HOSTNAME}") : ($text="sethostname failed: $!");
+ my $hostname = $net->{network}{HOSTNAME};
+ syscall_("sethostname", $hostname, length $hostname) ? ($text="set sethostname to $hostname") : ($text="sethostname failed: $!");
log::explanations($text);
- if (!$::isInstall) {
- run_program::run("/usr/bin/run-parts", "--arg", $netc->{HOSTNAME}, "/etc/sysconfig/network-scripts/hostname.d");
- }
+ run_program::run("/usr/bin/run-parts", "--arg", $hostname, "/etc/sysconfig/network-scripts/hostname.d") unless $::isInstall;
}
sub resolv($) {
@@ -210,15 +259,16 @@ sub resolv($) {
}
sub dnsServers {
- my ($netc) = @_;
- my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3);
+ my ($net) = @_;
+ #- FIXME: that's weird
+ my %used_dns; @used_dns{$net->{network}{dnsServer}, $net->{network}{dnsServer2}, $net->{network}{dnsServer3}} = (1, 2, 3);
sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns;
}
sub findIntf {
- my ($intf, $device) = @_;
- $intf->{$device}{DEVICE} = undef;
- $intf->{$device};
+ my ($net, $device) = @_;
+ $net->{ifcfg}{$device}{DEVICE} = undef;
+ $net->{ifcfg}{$device};
}
my $ip_regexp = qr/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
@@ -293,16 +343,16 @@ sub gateway {
sub netprofile_set {
- my ($netc, $profile) = @_;
- $netc->{PROFILE} = $profile;
- system('/sbin/set-netprofile', $netc->{PROFILE});
- log::explanations(qq(Switching to "$netc->{PROFILE}" profile));
+ my ($net, $profile) = @_;
+ $net->{PROFILE} = $profile;
+ system('/sbin/set-netprofile', $net->{PROFILE});
+ log::explanations(qq(Switching to "$net->{PROFILE}" profile));
}
sub netprofile_save {
- my ($netc) = @_;
- system('/sbin/save-netprofile', $netc->{PROFILE});
- log::explanations(qq(Saving "$netc->{PROFILE}" profile));
+ my ($net) = @_;
+ system('/sbin/save-netprofile', $net->{PROFILE});
+ log::explanations(qq(Saving "$net->{PROFILE}" profile));
}
sub netprofile_delete {
@@ -313,9 +363,9 @@ sub netprofile_delete {
}
sub netprofile_add {
- my ($netc, $profile) = @_;
+ my ($net, $profile) = @_;
return if !$profile || $profile eq "default" || member($profile, netprofile_list());
- system('/sbin/clone-netprofile', $netc->{PROFILE}, $profile);
+ system('/sbin/clone-netprofile', $net->{PROFILE}, $profile);
log::explanations(qq("Creating "$profile" profile));
}
@@ -324,9 +374,9 @@ sub netprofile_list() {
}
sub netprofile_read {
- my ($netc) = @_;
+ my ($net) = @_;
my $config = { getVarsFromSh("$::prefix/etc/netprofile/current") };
- $netc->{PROFILE} = $config->{PROFILE} || 'default';
+ $net->{PROFILE} = $config->{PROFILE} || 'default';
}
@@ -430,46 +480,45 @@ xml:readonly:$defaults_dir
}
}
-sub read_all_conf {
- my ($_prefix, $netc, $intf, $o_netcnx) = @_;
- $netc ||= {}; $intf ||= {};
- my $netcnx = $o_netcnx || {};
- add2hash($netc, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network";
- add2hash($netc, read_resolv_conf());
- add2hash($netc, read_tmdns_conf());
+sub read_net_conf {
+ my ($net) = @_;
+ add2hash($net->{network} ||= {}, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network";
+ add2hash($net->{resolv} ||= {}, read_resolv_conf());
+ add2hash($net->{zeroconf} ||= {}, read_zeroconf());
foreach (all("$::prefix/etc/sysconfig/network-scripts")) {
my ($device) = /^ifcfg-([A-Za-z0-9.:_-]+)$/;
next if $device =~ /.rpmnew$|.rpmsave$/;
if ($device && $device ne 'lo') {
- my $intf = findIntf($intf, $device);
+ my $intf = findIntf($net, $device);
add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") });
$intf->{DEVICE} ||= $device;
}
}
- netprofile_read($netc);
- if (my $default_intf = network::tools::get_default_gateway_interface($netc, $intf)) {
- $netcnx->{type} ||= network::tools::get_interface_type($intf->{$default_intf});
+ netprofile_read($net);
+ if (my $default_intf = network::tools::get_default_gateway_interface($net)) {
+ $net->{net_interface} = $default_intf;
+ $net->{type} = network::tools::get_interface_type($net->{ifcfg}{$default_intf});
}
}
#- FIXME: this is buggy, use network::tools::get_default_gateway_interface
sub probe_netcnx_type {
- my ($_prefix, $_netc, $intf, $netcnx) = @_;
+ my ($net) = @_;
#- try to probe $netcnx->{type} which is used almost everywhere.
- unless ($netcnx->{type}) {
+ unless ($net->{type}) {
#- ugly hack to determine network type (avoid saying not configured in summary).
- -e "$::prefix/etc/ppp/peers/adsl" and $netcnx->{type} ||= 'adsl'; # enough ?
- -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $netcnx->{type} ||= 'isdn'; # enough ?
- $intf->{ppp0} and $netcnx->{type} ||= 'modem';
- $intf->{eth0} and $netcnx->{type} ||= 'lan';
+ -e "$::prefix/etc/ppp/peers/adsl" and $net->{type} ||= 'adsl'; # enough ?
+ -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $net->{type} ||= 'isdn'; # enough ?
+ $net->{ifcfg}{ppp0} and $net->{type} ||= 'modem';
+ $net->{ifcfg}{eth0} and $net->{type} ||= 'lan';
}
}
sub easy_dhcp {
- my ($modules_conf, $netc, $intf) = @_;
+ my ($net, $modules_conf) = @_;
- return if text2bool($netc->{NETWORKING});
+ return if text2bool($net->{network}{NETWORKING});
require modules;
require network::ethernet;
@@ -483,87 +532,45 @@ sub easy_dhcp {
my $dhcp_intf = $ether_dev[0];
log::explanations("easy_dhcp: found $dhcp_intf");
- put_in_hash($netc, {
- NETWORKING => "yes",
- DHCP => "yes",
- NET_DEVICE => $dhcp_intf,
- NET_INTERFACE => $dhcp_intf,
- });
- $intf->{$dhcp_intf} ||= {};
- put_in_hash($intf->{$dhcp_intf}, {
+ put_in_hash($net->{network}, {
+ NETWORKING => "yes",
+ DHCP => "yes",
+ NET_DEVICE => $dhcp_intf,
+ NET_INTERFACE => $dhcp_intf,
+ });
+ $net->{ifcfg}{$dhcp_intf} ||= {};
+ put_in_hash($net->{ifcfg}{$dhcp_intf}, {
DEVICE => $dhcp_intf,
BOOTPROTO => 'dhcp',
NETMASK => '255.255.255.0',
ONBOOT => 'yes'
});
+ $net->{type} = 'lan';
+ $net->{net_interface} = $dhcp_intf;
+
1;
}
-#- configureNetwork2 : configure the network interfaces.
-#- input
-#- $prefix
-#- $netc
-#- $intf
-#- $netc input
-#- NETWORKING : networking flag : string : "yes" by default
-#- FORWARD_IPV4 : forward IP flag : string : "false" by default
-#- HOSTNAME : hostname : string : "localhost.localdomain" by default
-#- DOMAINNAME : domainname : string : $netc->{HOSTNAME} =~ /\.(.*)/ by default
-#- DOMAINNAME2 : well it's another domainname : have to look further why we used 2
-#- The following are facultatives
-#- DHCP_HOSTNAME : If you have a dhcp and want to set the hostname
-#- GATEWAY : gateway
-#- GATEWAYDEV : gateway interface
-#- NISDOMAIN : nis domain
-#- $netc->{dnsServer} : dns server 1
-#- $netc->{dnsServer2} : dns server 2
-#- $netc->{dnsServer3} : dns server 3 : note that we uses the dns1 for the LAN, and the 2 others for the internet conx
-#- $intf input: for each $device (for example ethx)
-#- $intf->{$device}{IPADDR} : IP address
-#- $intf->{$device}{NETMASK} : netmask
-#- $intf->{$device}{DEVICE} : DEVICE = $device
-#- $intf->{$device}{BOOTPROTO} : boot prototype : "bootp" or "dhcp" or "pump" or ...
-sub configureNetwork2 {
- my ($in, $modules_conf, $_prefix, $netc, $intf) = @_;
- my $etc = "$::prefix/etc";
+sub configure_network {
+ my ($net, $in, $modules_conf) = @_;
if (!$::testing) {
require network::ethernet;
network::ethernet::update_iftab();
network::ethernet::configure_eth_aliases($modules_conf);
- $netc->{wireless_eth} and $in->do_pkgs->ensure_binary_is_installed('wireless-tools', 'iwconfig', 'auto');
- write_conf($netc);
- write_resolv_conf("$etc/resolv.conf", $netc) unless $netc->{DHCP};
+ write_network_conf($net);
+ write_resolv_conf($net);
if ($::isInstall && ! -e "/etc/resolv.conf") {
#- symlink resolv.conf in install root too so that updates and suppl media can be added
- symlink "$etc/resolv.conf", "/etc/resolv.conf";
+ symlink "$::prefix/etc/resolv.conf", "/etc/resolv.conf";
}
- foreach (grep { !/^ppp\d+/ } keys %$intf) {
- unlink("$etc/sysconfig/network-scripts/$_");
- write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_", $intf->{$_}, $netc, $::prefix);
- $intf->{$_}{BOOTPROTO} eq "dhcp" and network::ethernet::install_dhcp_client($in, $intf->{$_});
- }
- add2hosts("$etc/hosts", $netc->{HOSTNAME}, "127.0.0.1") if $netc->{HOSTNAME};
- add2hosts("$etc/hosts", "localhost", "127.0.0.1");
-
- if ($netc->{ZEROCONF_HOSTNAME}) {
- $in->do_pkgs->ensure_binary_is_installed('tmdns', 'tmdns', 'auto') if !$in->do_pkgs->is_installed('bind');
- $in->do_pkgs->ensure_binary_is_installed('zcip', 'zcip', 'auto');
- write_zeroconf("$etc/tmdns.conf", $netc->{ZEROCONF_HOSTNAME});
- require services;
- services::start_service_on_boot("tmdns");
- services::restart("tmdns");
- } else {
- #- disable zeroconf
- require services;
- #- write blank hostname so that drakconnect does not assume zeroconf is enabled
- -f "$etc/tmdns.conf" and write_zeroconf("$etc/tmdns.conf", '');
- if (-f "$etc/rc.d/init.d/tmdns") {
- services::stop("tmdns");
- services::do_not_start_service_on_boot("tmdns");
- }
- }
- any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %$intf and $in->do_pkgs->install('pump');
+ write_interface_conf($net, $_) foreach keys %{$net->{ifcfg}};
+ network::ethernet::install_dhcp_client($in, $_->{DHCP_CLIENT}) foreach grep { $_->{BOOTPROTO} eq "dhcp" } values %{$net->{ifcfg}};
+ add2hosts($net->{network}{HOSTNAME}, "127.0.0.1") if $net->{network}{HOSTNAME};
+ add2hosts("localhost", "127.0.0.1");
+ write_zeroconf($net, $in);
+
+ any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %{$net->{ifcfg}} and $in->do_pkgs->install('pump');
}
}
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index ba51572a7..478dca21d 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -4,11 +4,6 @@ use strict;
use common;
use run_program;
use c;
-use vars qw(@ISA @EXPORT @EXPORT_OK);
-use MDK::Common::System qw(getVarsFromSh);
-
-@ISA = qw(Exporter);
-@EXPORT = qw(connect_backend connected connected_bg disconnect_backend is_dynamic_ip passwd_by_login read_secret_backend test_connected remove_initscript write_secret_backend start_interface stop_interface);
sub write_secret_backend {
my ($a, $b) = @_;
@@ -159,48 +154,39 @@ sub check_link_beat() {
});
}
-sub remove_initscript() {
- $::testing and return;
- if (-e "$::prefix/etc/rc.d/init.d/internet") {
- run_program::rooted($::prefix, "/sbin/chkconfig", "--del", "internet");
- rm_rf("$::prefix/etc/rc.d/init.d/internet");
- log::explanations("Removed internet service");
- }
-}
-
sub is_dynamic_ip {
- my ($intf) = @_;
- any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %$intf;
+ my ($net) = @_;
+ any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %{$net->{ifcfg}};
}
sub is_dynamic_host {
- my ($intf) = @_;
- any { defined $_->{DHCP_HOSTNAME} } values %$intf;
+ my ($net) = @_;
+ any { defined $_->{DHCP_HOSTNAME} } values %{$net->{ifcfg}};
}
#- returns interface whose IP address matchs given IP address, according to its network mask
sub find_matching_interface {
- my ($intf, $address) = @_;
+ my ($net, $address) = @_;
my @ip = split '\.', $address;
find {
- my @intf_ip = split '\.', $intf->{$_}{IPADDR} or return;
- my @mask = split '\.', $intf->{$_}{NETMASK} or return;
+ my @intf_ip = split '\.', $net->{ifcfg}{$_}{IPADDR} or return;
+ my @mask = split '\.', $net->{ifcfg}{$_}{NETMASK} or return;
every { $_ } mapn { ($_[0] & $_[2]) == ($_[1] & $_[2]) } \@intf_ip, \@ip, \@mask;
- } sort keys %$intf;
+ } sort keys %{$net->{ifcfg}};
}
#- returns gateway interface if found
sub get_default_gateway_interface {
- my ($netc, $intf) = @_;
- my @intfs = sort keys %$intf;
+ my ($net) = @_;
+ my @intfs = sort keys %{$net->{ifcfg}};
`$::prefix/sbin/ip route show` =~ /^default.*\s+dev\s+(\S+)/m && $1 ||
- $netc->{GATEWAYDEV} ||
- $netc->{GATEWAY} && find_matching_interface($intf, $netc->{GATEWAY}) ||
- (find { get_interface_type($intf->{$_}) eq 'adsl' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'isdn' && text2bool($intf->{$_}{DIAL_ON_IFUP}) } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'modem' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'wifi' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'ethernet' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
+ $net->{network}{GATEWAYDEV} ||
+ $net->{network}{GATEWAY} && find_matching_interface($net, $net->{network}{GATEWAY}) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'adsl' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'isdn' && text2bool($net->{ifcfg}{$_}{DIAL_ON_IFUP}) } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'modem' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'wifi' && $net->{ifcfg}{$_}{BOOTPROTO} eq 'dhcp' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'ethernet' && $net->{ifcfg}{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
}
sub get_interface_status {
@@ -213,9 +199,9 @@ sub get_interface_status {
#- returns (gateway_interface, interface is up, gateway address, dns server address)
sub get_internet_connection {
- my ($netc, $intf, $o_gw_intf) = @_;
- my $gw_intf = $o_gw_intf || get_default_gateway_interface($netc, $intf) or return;
- return $gw_intf, get_interface_status($gw_intf), $netc->{dnsServer};
+ my ($net, $o_gw_intf) = @_;
+ my $gw_intf = $o_gw_intf || get_default_gateway_interface($net) or return;
+ return $gw_intf, get_interface_status($gw_intf), $net->{resolv}{dnsServer};
}
sub get_interface_type {