summaryrefslogtreecommitdiffstats
path: root/perl-install/network/adsl.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network/adsl.pm')
-rw-r--r--perl-install/network/adsl.pm184
1 files changed, 131 insertions, 53 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index 2089dd229..7b1566b92 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -16,11 +16,11 @@ sub get_wizard {
my $netc = $wiz->{var}{netc};
my %l = (
- 'pppoe' => N("use pppoe"),
- 'pptp' => N("use pptp"),
- 'dhcp' => N("use dhcp"),
+ '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' => 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
);
@@ -34,11 +34,11 @@ sub get_wizard {
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 don't know, choose 'use pppoe'"),
+Some connections use PPTP, a few use DHCP.
+If you don't know, choose 'use PPPoE'"),
data => [
{
- label => N("ADSL connection type :"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
+ label => N("ADSL connection type:"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
],
pre => sub {
$wiz->{var}{adsl}{type} = $l{sagem}; # debug
@@ -67,15 +67,13 @@ If you don't know, choose 'use pppoe'"),
sub adsl_probe_info {
my ($adsl, $netc, $adsl_type, $o_adsl_modem) = @_;
my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf";
- my $pptp_file = "$::prefix/etc/sysconfig/network-scripts/net_cnx_up";
my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type 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/$_";
}
- ($login) = map { if_(/\sname\s+([^ \n]+)/, $1) } cat_($pptp_file) if (! defined $adsl_type || $adsl_type eq 'pptp') && -r $pptp_file;
my $passwd = passwd_by_login($login);
- if (!$netc->{vpi} && !$netc->{vpi} && member($o_adsl_modem, qw(eci speedtouch))) {
+ if (!$netc->{vpi} && !$netc->{vci} && member($o_adsl_modem, qw(eci speedtouch))) {
($netc->{vpi}, $netc->{vci}) =
(map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, map { sprintf("%x", $_) } $1, $2) } cat_("$::prefix/etc/ppp/peers/ppp0"));
}
@@ -95,12 +93,27 @@ sub adsl_detect() {
return $adsl;
}
+sub sagem_set_parameters {
+ my ($netc) = @_;
+ my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
+ foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) {
+ substInFile {
+ s/VCI=.*\n/VCI=$l{vci}\n/;
+ 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};
+ } "$::prefix$cfg_file";
+ }
+}
+
sub adsl_conf_backend {
- my ($in, $adsl, $netc, $adsl_device, $adsl_type, $o_netcnx) = @_;
+ 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 $bewan_module;
$bewan_module = $o_netcnx->{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $adsl_device eq "bewan";
@@ -115,7 +128,9 @@ modprobe $bewan_module
sleep 10
),
stop => qq(modprobe -r $bewan_module),
- pppd_options => "plugin pppoatm.so $netc->{vpi}." . hex($netc->{vci}),
+ plugin => {
+ pppoa => "pppoatm.so $netc->{vpi}." . hex($netc->{vci})
+ },
ppp_options => qq(
lock
ipparam ppp0
@@ -135,12 +150,15 @@ sync
speedtouch =>
{
- start => '/usr/sbin/modem_run -k -n 2 -f /usr/share/speedtouch/mgmt.o',
+ modules => [ qw(speedtch) ],
+ #- won't call pppd since we've just written ONBOOT=no, only runs modem_run
+ start => '/usr/bin/speedtouch-start --boot',
overide_script => 1,
server => {
- pppoa => '"/usr/sbin/pppoa3 -e 1 -c"
-plugin pppoatm.so
-' . join('.', hex($netc->{vpi}), hex($netc->{vci})),
+ pppoa => qq("/usr/sbin/pppoa3 -c")
+ },
+ plugin => {
+ pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci})),
},
ppp_options => qq(
sync
@@ -157,11 +175,12 @@ noaccomp),
},
sagem =>
{
- start => "/usr/sbin/eaglectrl -w",
+ modules => [ qw(eagle-usb) ],
+ start => '/usr/sbin/eaglectrl -d',
stop => "/usr/bin/killall pppoa",
get_intf => "/usr/sbin/eaglectrl -i",
server => {
- pppoa => qq("/usr/sbin/pppoa -I `/usr/sbin/eaglectrl -s; /usr/sbin/eaglectrl -i`"),
+ pppoa => q("/usr/sbin/fctStartAdsl -t 1 -i"),
},
ppp_options => qq(
mru 1492
@@ -172,8 +191,9 @@ noaccomp -am
novjccomp),
aliases => [
['char-major-108', 'ppp_generic'],
- ['tty-ldisc-14', 'ppp_synctty'],
- ['tty-ldisc-13', 'n_hdlc']
+ ['tty-ldisc-3', 'ppp_async'],
+ ['tty-ldisc-13', 'n_hdlc'],
+ ['tty-ldisc-14', 'ppp_synctty']
],
},
eci =>
@@ -196,16 +216,40 @@ lcp-echo-interval 0)
pptp => qq("/usr/sbin/pptp 10.0.0.138 --nolaunchpppd"),
},
},
+ capi_modem =>
+ {
+ ppp_options => qq(
+connect /bin/true
+ipcp-accept-remote
+ipcp-accept-local
+
+sync
+noauth
+lcp-echo-interval 5
+lcp-echo-failure 3
+lcp-max-configure 50
+lcp-max-terminate 2
+
+noccp
+noipx
+mru 1492
+mtu 1492),
+ plugin => {
+ capi => qq(capiplugin.so
+avmadsl)
+ },
+ },
);
- if ($adsl_type =~ /^pp/) {
+ if ($adsl_type =~ /^pp|^capi$/) {
mkdir_p("$::prefix/etc/ppp");
$in->do_pkgs->install('ppp') if !$>;
my %packages = (
pppoa => [ qw(ppp-pppoatm) ],
pppoe => [ qw(ppp-pppoe rp-pppoe) ],
pptp => [ qw(pptp-linux) ],
+ capi => [ qw(isdn4k-utils) ], #- capi4linux service
);
$in->do_pkgs->install(@{$packages{$adsl_type}}) if !$>;
output("$::prefix/etc/ppp/options",
@@ -242,9 +286,12 @@ usepeerdns
defaultroute)
);
+ my $pty_option = $modems{$adsl_device}{server}{$adsl_type} && "pty $modems{$adsl_device}{server}{$adsl_type}";
+ my $plugin = $modems{$adsl_device}{plugin}{$adsl_type} && "plugin $modems{$adsl_device}{plugin}{$adsl_type}";
+ my $noipdefault = 'noipdefault' unless $adsl_type eq 'pptp';
output("$::prefix/etc/ppp/peers/ppp0",
qq(noauth
-noipdefault
+$noipdefault
$modems{$adsl_device}{ppp_options}
kdebug 1
nopcomp
@@ -255,25 +302,39 @@ maxfail 25
persist
usepeerdns
defaultroute
-pty $modems{$adsl_device}{server}{$adsl_type}
+$pty_option
+$plugin
user "$adsl->{login}"
));
write_secret_backend($adsl->{login}, $adsl->{passwd});
-
+
+ if ($netc->{NET_DEVICE} =~ /^eth/) {
+ my $net_device = $netc->{NET_DEVICE};
+ $intf->{$net_device} = {
+ DEVICE => $net_device,
+ BOOTPROTO => 'none',
+ NETMASK => '255.255.255.0',
+ NETWORK => '10.0.0.0',
+ BROADCAST => '10.0.0.255',
+ ONBOOT => 'yes',
+ };
+ }
+
if ($adsl_type eq 'pppoe') {
- substInFile {
- s/ETH=.*\n/ETH=$netc->{NET_DEVICE}\n/;
- s/USER=.*\n/USER=$adsl->{login}\n/;
- s/DNS1=.*\n/DNS1=$netc->{dnsServer2}\n/;
- s/DNS2=.*\n/DNS2=$netc->{dnsServer3}\n/;
- } "$::prefix/etc/ppp/pppoe.conf";
+ if (-f "$::prefix/etc/ppp/pppoe.conf") {
+ my $net_device = $modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $netc->{NET_DEVICE};
+ substInFile {
+ s/ETH=.*\n/ETH=$net_device\n/;
+ s/USER=.*\n/USER=$adsl->{login}\n/;
+ s/DNS1=.*\n/DNS1=$netc->{dnsServer2}\n/;
+ s/DNS2=.*\n/DNS2=$netc->{dnsServer3}\n/;
+ } "$::prefix/etc/ppp/pppoe.conf";
+ } else {
+ log::l("can't find pppoe.conf, make sure the rp-pppoe package is installed");
+ }
}
-# pptp => {
-# connect => "/usr/bin/pptp 10.0.0.138 name $adsl->{login}",
-# disconnect => "/usr/bin/killall pptp pppd\n",
-# },
# pppoe => {
# # we do not call directly pppd, rp-pppoe take care of "plugin rp-pppoe.so" peers option and the like
# connect => "LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /usr/sbin/adsl-start",
@@ -282,37 +343,54 @@ user "$adsl->{login}"
# },
}
-
+
#- FIXME:
#- ppp0 and ippp0 are hardcoded
- #- pptp has to be done within pppd (no more use of /usr/bin/pptp)
my $kind = $adsl_type eq 'pppoe' ? 'xDSL' : 'ADSL';
+ 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=$kind
-));
+METRIC=$metric
+)) unless member($adsl_type, qw(manual dhcp));
- # sagem specific stuff
+ #- 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') {
- my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
- # set vpi and vci parameters for sagem
- foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) {
- substInFile {
- s/VCI=.*\n/VCI=$l{vci}\n/;
- s/VPI=.*\n/VPI=$l{vpi}\n/;
- s/Encapsulation=.*\n/Encapsulation=$l{Encapsulation}\n/;
- } "$::prefix$cfg_file";
- }
+ $netc->{static_ip} = $intf->{sagem}{IPADDR} if $adsl_type eq 'manual';
+ sagem_set_parameters($netc);
}
-
- # set aliases:
+
+ #- 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;
+ }
+ #- remove the "speedtch off" alias that was written by Mandrakelinux 10.0
+ $adsl_device eq 'speedtouch' and $modules_conf->remove_alias('speedtch');
+
+ 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");
+
+ #- install and run drdsl for dsl connections, once capi driver is loaded
+ $in->do_pkgs->ensure_is_installed_if_available("drdsl", "/usr/sbin/drdsl");
+ run_program::rooted($::prefix, "/usr/sbin/drdsl");
}
- $netc->{NET_INTERFACE} = 'ppp0';
- write_cnx_script($netc);
+ #- load modules and run modem-specific start programs
+ #- useful during install, or in case the packages have been installed after the device has been plugged
+ my @modules = (@{$modems{$adsl_device}{modules}}, map { $_->[1] } @{$modems{$adsl_device}{aliases}});
+ @modules or @modules = qw(ppp_synctty ppp_async ppp_generic n_hdlc); #- required for pppoe/pptp connections
+ @modules && eval { modules::load(@modules) }
+ or log::l("failed to load " . join(',', @modules), " modules: $@");
+ $modems{$adsl_device}{start} and run_program::rooted($::prefix, $modems{$adsl_device}{start});
}
1;