X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fpppsetup.cgi;h=4bd8d6b97a6981a94d2b6e4208ef6e55e25fb45d;hp=62c3e5dee8c85090fe0077fe3b9a928566bf56bf;hb=ac1cfefab236b73ed52909e14f43eaffc8d6914e;hpb=7ac38dc92777a4a9f3b0d6151befe8f446e2a031 diff --git a/html/cgi-bin/pppsetup.cgi b/html/cgi-bin/pppsetup.cgi index 62c3e5dee8..4bd8d6b97a 100644 --- a/html/cgi-bin/pppsetup.cgi +++ b/html/cgi-bin/pppsetup.cgi @@ -1,1205 +1,1205 @@ -#!/usr/bin/perl -# -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# -# Copyright (C) 03-Apr-2002 Guy Ellis -# - ISDN DOV support -# - ibod now an option -# - PCI ADSL support added -# -# $Id: pppsetup.cgi,v 1.17.2.49 2005/12/01 16:20:35 franck78 Exp $ - -use strict; - -# enable only the following on debugging purpose -#use warnings; -#use CGI::Carp 'fatalsToBrowser'; - -require 'CONFIG_ROOT/general-functions.pl'; -require "${General::swroot}/lang.pl"; -require "${General::swroot}/header.pl"; - -our %pppsettings=(); -my %temppppsettings=(); -our %modemsettings=(); -our %isdnsettings=(); -our %netsettings=(); -my %selected=(); -my %checked=(); -my @profilenames=(); -my $errormessage = ''; -my $maxprofiles = 5; -my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`; - -&Header::showhttpheaders(); - -$pppsettings{'ACTION'} = ''; -&initprofile(); -&Header::getcgihash(\%pppsettings); - -if ($pppsettings{'ACTION'} ne '' && - (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active")) -{ - $errormessage = $Lang::tr{'unable to alter profiles while red is active'}; - # read in the current vars - %pppsettings = (); - $pppsettings{'VALID'} = ''; - &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); -} -elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'}) -{ - unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - my $type = $pppsettings{'TYPE'}; - &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); - $pppsettings{'TYPE'} = $type; -} -elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'}) -{ - if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|usb\/ttyACM0|usb\/ttyACM1|usb\/ttyACM2|usb\/ttyACM3|isdn1|isdn2)$/) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400)$/) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; - } - - if ($pppsettings{'PROFILENAME'} eq '') { - $errormessage = $Lang::tr{'profile name not given'}; - $pppsettings{'PROFILENAME'} = ''; - goto ERROR; } - if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) { - if ($pppsettings{'TELEPHONE'} eq '') { - $errormessage = $Lang::tr{'telephone not set'}; - goto ERROR; } - if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) { - $errormessage = $Lang::tr{'bad characters in the telephone number field'}; - goto ERROR; } - } - unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) { - if ($pppsettings{'USERNAME'} eq '') { - $errormessage = $Lang::tr{'username not set'}; - goto ERROR; } - if ($pppsettings{'PASSWORD'} eq '') { - $errormessage = $Lang::tr{'password not set'}; - goto ERROR; } - } - - if ($pppsettings{'TIMEOUT'} eq '') { - $errormessage = $Lang::tr{'idle timeout not set'}; - goto ERROR; } - if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) { - $errormessage = $Lang::tr{'only digits allowed in the idle timeout'}; - goto ERROR; } - - if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) { - $errormessage = $Lang::tr{'bad characters in script field'}; - goto ERROR; } - - if ($pppsettings{'DNS1'}) - { - if (!(&General::validip($pppsettings{'DNS1'}))) { - $errormessage = $Lang::tr{'invalid primary dns'}; - goto ERROR; } - } - if ($pppsettings{'DNS2'}) - { - if (!(&General::validip($pppsettings{'DNS2'}))) { - $errormessage = $Lang::tr{'invalid secondary dns'}; - goto ERROR; } - } - - if ($pppsettings{'MAXRETRIES'} eq '') { - $errormessage = $Lang::tr{'max retries not set'}; - goto ERROR; } - if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) { - $errormessage = $Lang::tr{'only digits allowed in max retries field'}; - goto ERROR; } - - if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) { - $errormessage = $Lang::tr{'only digits allowed in holdoff field'}; - goto ERROR; } - - my $drivererror = 0; - if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) { - my $modem = ''; - my $speedtouch = &Header::speedtouchversion; - if ($speedtouch >=0 && $speedtouch <=4) { - if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; } - $pppsettings{'MODEM'} = $modem; - } else { - $modem='v0123'; - $errormessage ="$Lang::tr{'unknown'} Rev $speedtouch"; - goto ERROR; - } - if (! -e "${General::swroot}/alcatelusb/firmware.$modem.bin") { - $errormessage = $Lang::tr{'no alcatelusb firmware'}; - $drivererror = 1; - goto ERROR; - } - } - - if($pppsettings{'TYPE'} eq 'eciadsl' && (!(-e "${General::swroot}/eciadsl/synch.bin"))) { - $errormessage = $Lang::tr{'no eciadsl synch.bin file'}; - $drivererror = 1; - goto ERROR; } - - if($pppsettings{'TYPE'} eq 'fritzdsl' && (!(-e "/lib/modules/$kernel/misc/fcdslusb.o.gz"))) { - $errormessage = $Lang::tr{'no fritzdsl driver'}; - $drivererror = 1; - goto ERROR; } - - if( $pppsettings{'USEIBOD'} eq 'on' && $pppsettings{'COMPORT'} eq 'isdn1') { - $errormessage = $Lang::tr{'ibod for dual isdn only'}; - goto ERROR; } - - if ($pppsettings{'TYPE'} eq 'pptp') { - $errormessage = ''; - if ($pppsettings{'METHOD'} eq 'STATIC') { - if (! &General::validip($pppsettings{'ROUTERIP'})) { - $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'}; - } - } else { - if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) { - $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'}; - } - } - if ($errormessage ne '') {goto ERROR; } - } - - if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) { - if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) { - $errormessage = $Lang::tr{'invalid vpi vpci'}; - goto ERROR; } - if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) { - $errormessage = $Lang::tr{'invalid vpi vpci'}; - goto ERROR; } - if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) { - $errormessage = $Lang::tr{'invalid vpi vpci'}; - goto ERROR; } - if ( $pppsettings{'PROTOCOL'} eq '' ) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - } - - if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \ - ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - - if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) { - if ($pppsettings{'DHCP_HOSTNAME'} ne '') { - if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) { - $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; } - } - } - - if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) { - $errormessage = ''; - if (! &General::validip($pppsettings{'IP'})) { - $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; } - if (! &General::validip($pppsettings{'GATEWAY'})) { - $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; } - if (! &General::validmask($pppsettings{'NETMASK'})) { - $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; } - if ($pppsettings{'BROADCAST'} ne '') { - if (! &General::validip($pppsettings{'BROADCAST'})) { - $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; } - } - if( $pppsettings{'DNS'} eq 'Automatic') { - $errormessage = $Lang::tr{'invalid input'}; } - if ($errormessage ne '') {goto ERROR; } - } - - if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \ - $pppsettings{'RECONNECTION'} eq 'dialondemand' ) { - $errormessage = $Lang::tr{'invalid input'}; - goto ERROR; } - - if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) { - $errormessage = $Lang::tr{'dod not compatible with ddns'}; - goto ERROR; } - - if ( ($pppsettings{'TYPE'} =~ /^(bewanadsl)$/) && $pppsettings{'MODEM'} eq '') { - $errormessage = $Lang::tr{'no modem selected'}; - goto ERROR; } - - if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { - $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; } - if( $pppsettings{'PROTOCOL'} eq 'RFC2364') { - $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; } - delete $pppsettings{'ENCAP_RFC1483'}; - delete $pppsettings{'ENCAP_RFC2364'}; - -ERROR: - if ($errormessage) { - $pppsettings{'VALID'} = 'no'; } - else { - $pppsettings{'VALID'} = 'yes'; } - - # write cgi vars to the file. - &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - \%pppsettings); - - # make link and write secret file. - &updatesettings(); - &writesecrets(); - - &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}"); - if ($drivererror) { - my $refresh = ""; - my $title = $Lang::tr{'upload'}; - &Header::openpage($title, 0, $refresh); - } -} -elsif ($pppsettings{'ACTION'} eq $Lang::tr{'select'}) -{ - my $profile = $pppsettings{'PROFILE'}; - %temppppsettings = (); - $temppppsettings{'PROFILE'} = ''; - &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - \%temppppsettings); - - # make link. - &updatesettings(); - - # read in the new params "early" so we can write secrets. - %pppsettings = (); - &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); - $pppsettings{'PROFILE'} = $profile; - &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - \%pppsettings); - - &writesecrets(); - - &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}"); -} -elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'}) -{ - &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}"); - - my $profile = $pppsettings{'PROFILE'}; - truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0); - - %temppppsettings = (); - $temppppsettings{'PROFILE'} = ''; - &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - \%temppppsettings); - - # make link. - &updatesettings(); - - # read in the new params "early" so we can write secrets. - %pppsettings = (); - &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); - $pppsettings{'PROFILE'} = $profile; - &initprofile; - &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - \%pppsettings); -} -else -{ - # read in the current vars - %pppsettings = (); - $pppsettings{'VALID'} = ''; - &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); -} - -# read in the profile names into @profilenames. -my $c=0; -for ($c = 1; $c <= $maxprofiles; $c++) -{ - %temppppsettings = (); - $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty'}; - &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); - $profilenames[$c] = $temppppsettings{'PROFILENAME'}; -} - -if ($pppsettings{'VALID'} eq '') -{ - if ($pppsettings{'PROFILE'} eq '') { - $pppsettings{'PROFILE'} = '1'; - &initprofile(); - } -} -for ($c = 1; $c <= $maxprofiles; $c++) { - $selected{'PROFILE'}{$c} = ''; } -$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; -for ($c = 1; $c <= $maxprofiles; $c++) { - $selected{'BACKUPPROFILE'}{$c} = ''; } -$selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'"; - -$selected{'TYPE'}{'modem'} = ''; -$selected{'TYPE'}{'serial'} = ''; -$selected{'TYPE'}{'isdn'} = ''; -$selected{'TYPE'}{'pppoe'} = ''; -$selected{'TYPE'}{'pptp'} = ''; -$selected{'TYPE'}{'alcatelusb'} = ''; -$selected{'TYPE'}{'alcatelusbk'} = ''; -$selected{'TYPE'}{'pulsardsl'} = ''; -$selected{'TYPE'}{'eciadsl'} = ''; -$selected{'TYPE'}{'fritzdsl'} = ''; -$selected{'TYPE'}{'bewanadsl'} = ''; -$selected{'TYPE'}{'eagleusbadsl'} = ''; -$selected{'TYPE'}{'conexantusbadsl'} = ''; -$selected{'TYPE'}{'conexantpciadsl'} = ''; -$selected{'TYPE'}{'amedynusbadsl'} = ''; -$selected{'TYPE'}{'3cp4218usbadsl'} = ''; -$selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'"; - -$checked{'DEBUG'}{'off'} = ''; -$checked{'DEBUG'}{'on'} = ''; -$checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'"; - -$selected{'COMPORT'}{'ttyS0'} = ''; -$selected{'COMPORT'}{'ttyS1'} = ''; -$selected{'COMPORT'}{'ttyS2'} = ''; -$selected{'COMPORT'}{'ttyS3'} = ''; -$selected{'COMPORT'}{'ttyS4'} = ''; -$selected{'COMPORT'}{'usb/ttyACM0'} = ''; -$selected{'COMPORT'}{'usb/ttyACM1'} = ''; -$selected{'COMPORT'}{'usb/ttyACM2'} = ''; -$selected{'COMPORT'}{'usb/ttyACM3'} = ''; -$selected{'COMPORT'}{'isdn1'} = ''; -$selected{'COMPORT'}{'isdn2'} = ''; -$selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'"; - -$selected{'DTERATE'}{'9600'} = ''; -$selected{'DTERATE'}{'19200'} = ''; -$selected{'DTERATE'}{'38400'} = ''; -$selected{'DTERATE'}{'57600'} = ''; -$selected{'DTERATE'}{'115200'} = ''; -$selected{'DTERATE'}{'230400'} = ''; -$selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'"; - -$checked{'SPEAKER'}{'off'} = ''; -$checked{'SPEAKER'}{'on'} = ''; -$checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'"; - -$selected{'DIALMODE'}{'T'} = ''; -$selected{'DIALMODE'}{'P'} = ''; -$selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'"; - -$checked{'RECONNECTION'}{'manual'} = ''; -$checked{'RECONNECTION'}{'persistent'} = ''; -$checked{'RECONNECTION'}{'dialondemand'} = ''; -$checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'"; - -$checked{'DIALONDEMANDDNS'}{'off'} = ''; -$checked{'DIALONDEMANDDNS'}{'on'} = ''; -$checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'"; - -$checked{'AUTOCONNECT'}{'off'} = ''; -$checked{'AUTOCONNECT'}{'on'} = ''; -$checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'"; - -$checked{'SENDCR'}{'off'} = ''; -$checked{'SENDCR'}{'on'} = ''; -$checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'"; -$checked{'USEDOV'}{'off'} = ''; -$checked{'USEDOV'}{'on'} = ''; -$checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'"; -$checked{'USEIBOD'}{'off'} = ''; -$checked{'USEIBOD'}{'on'} = ''; -$checked{'USEIBOD'}{$pppsettings{'USEIBOD'}} = "checked='checked'"; - -$checked{'MODEM'}{'PCIST'} = ''; -$checked{'MODEM'}{'USB'} = ''; -$checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'"; - -$selected{'LINE'}{'WO'} = ''; -$selected{'LINE'}{'ES'} = ''; -$selected{'LINE'}{'ES03'} = ''; -$selected{'LINE'}{'FR'} = ''; -$selected{'LINE'}{'FR04'} = ''; -$selected{'LINE'}{'FR10'} = ''; -$selected{'LINE'}{'IT'} = ''; -$selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'"; - -$checked{'MODULATION'}{'GDMT'} = ''; -$checked{'MODULATION'}{'ANSI'} = ''; -$checked{'MODULATION'}{'GLITE'} = ''; -$checked{'MODULATION'}{'AUTO'} = ''; -$checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'"; - -$checked{'PROTOCOL'}{'RFC1483'} = ''; -$checked{'PROTOCOL'}{'RFC2364'} = ''; -$checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'"; - -$selected{'ENCAP'}{'0'} = ''; -$selected{'ENCAP'}{'1'} = ''; -$selected{'ENCAP'}{'2'} = ''; -$selected{'ENCAP'}{'3'} = ''; -$selected{'ENCAP'}{'4'} = ''; -$selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'"; -$checked{'METHOD'}{'STATIC'} = ''; -$checked{'METHOD'}{'PPPOE'} = ''; -$checked{'METHOD'}{'PPPOE_PLUGIN'} = ''; -$checked{'METHOD'}{'DHCP'} = ''; -$checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'"; - -$selected{'AUTH'}{'pap-or-chap'} = ''; -$selected{'AUTH'}{'pap'} = ''; -$selected{'AUTH'}{'chap'} = ''; -$selected{'AUTH'}{'standard-login-script'} = ''; -$selected{'AUTH'}{'demon-login-script'} = ''; -$selected{'AUTH'}{'other-login-script'} = ''; -$selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'"; - -$checked{'DNS'}{'Automatic'} = ''; -$checked{'DNS'}{'Manual'} = ''; -$checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'"; - -&Header::openpage($Lang::tr{'ppp setup'}, 1, ''); - -&Header::openbigbox('100%', 'left', '', $errormessage); - -if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage\n"; - print " \n"; - &Header::closebox(); -} - - -### -### Box for selecting profile -### -print "
\n"; -&Header::openbox('100%', 'left', $Lang::tr{'profiles'}); -print < - - $Lang::tr{'profile'}: - - - - - - -END -; -&Header::closebox(); -&Header::openbox('100%', 'left', $Lang::tr{'connection'}.':'); -print < - - $Lang::tr{'interface'}: - - - - - - USB: -END -; -if (-f "/proc/bus/usb/devices") { - my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`; - if ($usb eq '') { - print "\t$Lang::tr{'not running'}\n"; - } else { - print "\t$usb\n"; - } -} - -if ($pppsettings{'TYPE'}) { - print ""; - if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/) { - print < - - -END -; - } elsif ($pppsettings{'TYPE'} eq 'isdn') { - print <$Lang::tr{'isdn1'} - - -END -; - } - if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { - print <$Lang::tr{'computer to modem rate'} - - -END -; - } else { - print "\n"; - } - if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/ ) { - print "\n"; - print "\n"; - if ($pppsettings{'TYPE'} eq 'modem' ) { - print "\n"; - print "\n"; - } else { - print "\n"; - } - } - } - if ($pppsettings{'TYPE'} eq 'modem') { - print < - - - - - -END -; -} - -print < - - - - -END -; - if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) { - $pppsettings{'AUTOCONNECT'} = 'on'; - print "\n"; - print "\n"; - } else { - print "\n"; - print "\n"; - } -print <$Lang::tr{'connection debugging'}: - - - - - - - - -END -; -if ($pppsettings{'TYPE'} ne 'isdn') { -print < - - - - -END -; -} -print < - - - - - - - - - - - -END -; - -if ($pppsettings{'TYPE'} eq 'isdn') { - print < -
$Lang::tr{'interface'}:
 
$Lang::tr{'number'}$Lang::tr{'modem speaker on'}
 
$Lang::tr{'dialing mode'}$Lang::tr{'send cr'}
$Lang::tr{'idle timeout'} 
$Lang::tr{'connect on ipcop restart'}
$Lang::tr{'connect on ipcop restart'}


$Lang::tr{'reconnection'}:
- $Lang::tr{'manual'}
- $Lang::tr{'persistent'}$Lang::tr{'backupprofile'}: -
- $Lang::tr{'dod'}$Lang::tr{'dod for dns'}
$Lang::tr{'holdoff'}:$Lang::tr{'maximum retries'}
- - - - - - - - - -END -; -} - -if ($pppsettings{'TYPE'} eq 'pptp') -{ -print < - -


$Lang::tr{'isdn settings'}
$Lang::tr{'use ibod'}$Lang::tr{'use dov'}
- - - - - - - - - - - - - - - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} eq 'pppoe') -{ -print < -


$Lang::tr{'pptp settings'}
$Lang::tr{'phonebook entry'}
$Lang::tr{'static ip'}$Lang::tr{'router ip'}
 
$Lang::tr{'dhcp mode'}$Lang::tr{'hostname'}: *
- - - -END -; -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) -{ - -print < -


$Lang::tr{'pppoe settings'}
- - - - - - - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} eq 'bewanadsl') -{ -print < - - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} =~ /^(3cp4218usbadsl|bewanadsl)$/) -{ -print < - - - - - - - - - - -END -; -} - -if ($pppsettings{'TYPE'} eq 'eagleusbadsl') -{ -print < - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} eq 'eciadsl') -{ -print < - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) -{ -print < - - -END -; -} -if ($pppsettings{'TYPE'} eq 'alcatelusb') -{ - print ""; -} - -if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/) -{ -print <$Lang::tr{'encapsulation'}: - - -END -; -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) -{ -print < - - - - - - -END -; -} -if ($pppsettings{'TYPE'} eq 'alcatelusb') -{ - print ""; -} - -if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/) -{ - if ($pppsettings{'TYPE'} ne 'fritzdsl') - { -print <$Lang::tr{'encapsulation'}: - - - - - - -END -; - } else { -print <PPPoE - -END -; - } -} -if ($pppsettings{'TYPE'} =~ /^(pppoe|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/) -{ -print < - - - - - - - - - - - - - - -END -; -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/) -{ -print < - - - - - - - - - - - - - - - - - - - - - - - - - - - - -END -; - if ($pppsettings{'TYPE'} =~ /^(eciadsl|eagleusbadsl)$/) - { -print < - - - - - - - - - - -END -; - } -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|eciadsl|fritzdsl)$/) { - print ""; -} -if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) { - my $speedtouch = &Header::speedtouchversion; - if (($speedtouch >= 0) && ($speedtouch <=4)) { - my $modem; - if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; } - print ""; - if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") { - print "\n"; - } else { - print "\n"; - } - } else { - print ""; - } -} elsif ($pppsettings{'TYPE'} eq 'eciadsl') { - print ""; - if (-e "${General::swroot}/eciadsl/synch.bin") { - print "\n"; - } else { - print "\n"; } -} elsif ($pppsettings{'TYPE'} eq 'fritzdsl') { - print ""; - if (-e "/lib/modules/$kernel/misc/fcdslusb.o.gz") { - print "\n"; - } else { - print "\n"; } -} -print < -


$Lang::tr{'adsl settings'}:
$Lang::tr{'vpi number'}$Lang::tr{'vci number'}
 
$Lang::tr{'modem'}: - Bewan ADSL PCI stBewan ADSL USB st
 
$Lang::tr{'modulation'}:$Lang::tr{'automatic'}ANSI T1.483G.DMTG.Lite
 
$Lang::tr{'country'}: -
 
$Lang::tr{'modem'}: -
 
$Lang::tr{'protocol'}: - RFC2364 PPPoA 
- -
 
  - RFC 1483 / 2684 
- -
 
  PPPoE plugin$Lang::tr{'service name'} *
  $Lang::tr{'pppoe'}$Lang::tr{'concentrator name'} *
 
  $Lang::tr{'static ip'}$Lang::tr{'static ip'}:
  $Lang::tr{'gateway ip'}:
  $Lang::tr{'netmask'}:
  $Lang::tr{'broadcast'}: *
 
  $Lang::tr{'dhcp mode'}$Lang::tr{'hostname'}: *
 
$Lang::tr{'firmware'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
$Lang::tr{'unknown'} Rev $speedtouch
$Lang::tr{'driver'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
$Lang::tr{'driver'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
- - - - - - - - - - - - - - - -


$Lang::tr{'authentication'}
$Lang::tr{'username'}$Lang::tr{'password'}
$Lang::tr{'method'}$Lang::tr{'script name'} *
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


DNS:
$Lang::tr{'automatic'}
$Lang::tr{'manual'}$Lang::tr{'primary dns'}$Lang::tr{'secondary dns'}


 $Lang::tr{'profile name'}


$Lang::tr{'legend'}:* $Lang::tr{'this field may be blank'}
-END -; -&Header::closebox(); -} - -print "\n"; - -&Header::closebigbox(); - -&Header::closepage(); - -sub updatesettings -{ - # make a link from the selected profile to the "default" one. - unlink("${General::swroot}/ppp/settings"); - link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", - "${General::swroot}/ppp/settings"); - system ("/bin/touch", "${General::swroot}/ppp/updatesettings"); - if ($pppsettings{'TYPE'} eq 'eagleusbadsl') { - # eagle-usb.conf is in backup but link DSPcode.bin can't, so the link is created in rc.eagleusbadsl - open(FILE, ">/${General::swroot}/eagle-usb/eagle-usb.conf") or die "Unable to write eagle-usb.conf file"; - flock(FILE, 2); - # decimal to hexa - $modemsettings{'VPI'} = uc(sprintf('%X', $pppsettings{'VPI'})); - $modemsettings{'VCI'} = uc(sprintf('%X', $pppsettings{'VCI'})); - if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { - $modemsettings{'Encapsulation'} =1+$pppsettings{'ENCAP'} - } elsif ( $pppsettings{'PROTOCOL'} eq 'RFC2364') { - $modemsettings{'Encapsulation'} =6-$pppsettings{'ENCAP'} - } - print FILE "\n"; - print FILE "VPI=$modemsettings{'VPI'}\n"; - print FILE "VCI=$modemsettings{'VCI'}\n"; - print FILE "Encapsulation=$modemsettings{'Encapsulation'}\n"; - print FILE "Linetype=0A\n"; - print FILE "RatePollFreq=00000009\n"; - print FILE "\n"; - close FILE; - } -} - -sub writesecrets -{ - # write secrets file. - open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; - flock(FILE, 2); - my $username = $pppsettings{'USERNAME'}; - my $password = $pppsettings{'PASSWORD'}; - print FILE "'$username' * '$password'\n"; - chmod 0600, "${General::swroot}/ppp/secrets"; - close FILE; -} - -sub initprofile -{ - $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'}; - $pppsettings{'COMPORT'} = 'ttyS0'; - $pppsettings{'DTERATE'} = 115200; - $pppsettings{'SPEAKER'} = 'off'; - $pppsettings{'RECONNECTION'} = 'manual'; - $pppsettings{'DIALONDEMANDDNS'} = 'off'; - $pppsettings{'AUTOCONNECT'} = 'off'; - $pppsettings{'SENDCR'} = 'off'; - $pppsettings{'USEIBOD'} = 'off'; - $pppsettings{'USEDOV'} = 'off'; - $pppsettings{'MODEM'} = 'PCIST'; - $pppsettings{'LINE'} = 'WO'; - $pppsettings{'ENCAP'} = '0'; - $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1'; - $pppsettings{'PROTOCOL'} = 'RFC2364'; - $pppsettings{'METHOD'} = 'PPPOE_PLUGIN'; - $pppsettings{'DIALMODE'} = 'T'; - $pppsettings{'MAXRETRIES'} = 5; - $pppsettings{'HOLDOFF'} = 30; - $pppsettings{'TIMEOUT'} = 15; - $pppsettings{'MODULATION'} = 'AUTO'; - $pppsettings{'AUTH'} = 'pap-or-chap'; - $pppsettings{'DNS'} = 'Automatic'; - $pppsettings{'DEBUG'} = 'off'; - $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'}; - - # Get ISDN settings so we can see if ISDN is enabled or not. - $isdnsettings{'ENABLED'} = 'off'; - &General::readhash("${General::swroot}/isdn/settings", \%isdnsettings); - - # Get PPPoE settings so we can see if PPPoE is enabled or not. - &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); - - # empty profile partial pre-initialization - if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/) { - $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'}); - } elsif ($isdnsettings{'ENABLED'} eq 'on') { - $pppsettings{'TYPE'}='isdn'; - } else { - $pppsettings{'TYPE'}='modem'; - } -} - +#!/usr/bin/perl +# +# SmoothWall CGIs +# +# This code is distributed under the terms of the GPL +# +# (c) The SmoothWall Team +# +# Copyright (C) 03-Apr-2002 Guy Ellis +# - ISDN DOV support +# - ibod now an option +# - PCI ADSL support added +# +# $Id: pppsetup.cgi,v 1.17.2.49 2005/12/01 16:20:35 franck78 Exp $ + +use strict; + +# enable only the following on debugging purpose +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; + +require 'CONFIG_ROOT/general-functions.pl'; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; + +our %pppsettings=(); +my %temppppsettings=(); +our %modemsettings=(); +our %isdnsettings=(); +our %netsettings=(); +my %selected=(); +my %checked=(); +my @profilenames=(); +my $errormessage = ''; +my $maxprofiles = 5; +my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`; + +&Header::showhttpheaders(); + +$pppsettings{'ACTION'} = ''; +&initprofile(); +&Header::getcgihash(\%pppsettings); + +if ($pppsettings{'ACTION'} ne '' && + (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active")) +{ + $errormessage = $Lang::tr{'unable to alter profiles while red is active'}; + # read in the current vars + %pppsettings = (); + $pppsettings{'VALID'} = ''; + &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); +} +elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'}) +{ + unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + my $type = $pppsettings{'TYPE'}; + &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); + $pppsettings{'TYPE'} = $type; +} +elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'}) +{ + if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|usb\/ttyACM0|usb\/ttyACM1|usb\/ttyACM2|usb\/ttyACM3|isdn1|isdn2)$/) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400)$/) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; + } + + if ($pppsettings{'PROFILENAME'} eq '') { + $errormessage = $Lang::tr{'profile name not given'}; + $pppsettings{'PROFILENAME'} = ''; + goto ERROR; } + if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) { + if ($pppsettings{'TELEPHONE'} eq '') { + $errormessage = $Lang::tr{'telephone not set'}; + goto ERROR; } + if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) { + $errormessage = $Lang::tr{'bad characters in the telephone number field'}; + goto ERROR; } + } + unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) { + if ($pppsettings{'USERNAME'} eq '') { + $errormessage = $Lang::tr{'username not set'}; + goto ERROR; } + if ($pppsettings{'PASSWORD'} eq '') { + $errormessage = $Lang::tr{'password not set'}; + goto ERROR; } + } + + if ($pppsettings{'TIMEOUT'} eq '') { + $errormessage = $Lang::tr{'idle timeout not set'}; + goto ERROR; } + if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) { + $errormessage = $Lang::tr{'only digits allowed in the idle timeout'}; + goto ERROR; } + + if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) { + $errormessage = $Lang::tr{'bad characters in script field'}; + goto ERROR; } + + if ($pppsettings{'DNS1'}) + { + if (!(&General::validip($pppsettings{'DNS1'}))) { + $errormessage = $Lang::tr{'invalid primary dns'}; + goto ERROR; } + } + if ($pppsettings{'DNS2'}) + { + if (!(&General::validip($pppsettings{'DNS2'}))) { + $errormessage = $Lang::tr{'invalid secondary dns'}; + goto ERROR; } + } + + if ($pppsettings{'MAXRETRIES'} eq '') { + $errormessage = $Lang::tr{'max retries not set'}; + goto ERROR; } + if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) { + $errormessage = $Lang::tr{'only digits allowed in max retries field'}; + goto ERROR; } + + if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) { + $errormessage = $Lang::tr{'only digits allowed in holdoff field'}; + goto ERROR; } + + my $drivererror = 0; + if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) { + my $modem = ''; + my $speedtouch = &Header::speedtouchversion; + if ($speedtouch >=0 && $speedtouch <=4) { + if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; } + $pppsettings{'MODEM'} = $modem; + } else { + $modem='v0123'; + $errormessage ="$Lang::tr{'unknown'} Rev $speedtouch"; + goto ERROR; + } + if (! -e "${General::swroot}/alcatelusb/firmware.$modem.bin") { + $errormessage = $Lang::tr{'no alcatelusb firmware'}; + $drivererror = 1; + goto ERROR; + } + } + + if($pppsettings{'TYPE'} eq 'eciadsl' && (!(-e "${General::swroot}/eciadsl/synch.bin"))) { + $errormessage = $Lang::tr{'no eciadsl synch.bin file'}; + $drivererror = 1; + goto ERROR; } + + if($pppsettings{'TYPE'} eq 'fritzdsl' && (!(-e "/lib/modules/$kernel/misc/fcdslusb.o.gz"))) { + $errormessage = $Lang::tr{'no fritzdsl driver'}; + $drivererror = 1; + goto ERROR; } + + if( $pppsettings{'USEIBOD'} eq 'on' && $pppsettings{'COMPORT'} eq 'isdn1') { + $errormessage = $Lang::tr{'ibod for dual isdn only'}; + goto ERROR; } + + if ($pppsettings{'TYPE'} eq 'pptp') { + $errormessage = ''; + if ($pppsettings{'METHOD'} eq 'STATIC') { + if (! &General::validip($pppsettings{'ROUTERIP'})) { + $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'}; + } + } else { + if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) { + $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'}; + } + } + if ($errormessage ne '') {goto ERROR; } + } + + if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) { + if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) { + $errormessage = $Lang::tr{'invalid vpi vpci'}; + goto ERROR; } + if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) { + $errormessage = $Lang::tr{'invalid vpi vpci'}; + goto ERROR; } + if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) { + $errormessage = $Lang::tr{'invalid vpi vpci'}; + goto ERROR; } + if ( $pppsettings{'PROTOCOL'} eq '' ) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + } + + if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \ + ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + + if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) { + if ($pppsettings{'DHCP_HOSTNAME'} ne '') { + if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) { + $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; } + } + } + + if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) { + $errormessage = ''; + if (! &General::validip($pppsettings{'IP'})) { + $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; } + if (! &General::validip($pppsettings{'GATEWAY'})) { + $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; } + if (! &General::validmask($pppsettings{'NETMASK'})) { + $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; } + if ($pppsettings{'BROADCAST'} ne '') { + if (! &General::validip($pppsettings{'BROADCAST'})) { + $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; } + } + if( $pppsettings{'DNS'} eq 'Automatic') { + $errormessage = $Lang::tr{'invalid input'}; } + if ($errormessage ne '') {goto ERROR; } + } + + if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \ + $pppsettings{'RECONNECTION'} eq 'dialondemand' ) { + $errormessage = $Lang::tr{'invalid input'}; + goto ERROR; } + + if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) { + $errormessage = $Lang::tr{'dod not compatible with ddns'}; + goto ERROR; } + + if ( ($pppsettings{'TYPE'} =~ /^(bewanadsl)$/) && $pppsettings{'MODEM'} eq '') { + $errormessage = $Lang::tr{'no modem selected'}; + goto ERROR; } + + if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { + $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; } + if( $pppsettings{'PROTOCOL'} eq 'RFC2364') { + $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; } + delete $pppsettings{'ENCAP_RFC1483'}; + delete $pppsettings{'ENCAP_RFC2364'}; + +ERROR: + if ($errormessage) { + $pppsettings{'VALID'} = 'no'; } + else { + $pppsettings{'VALID'} = 'yes'; } + + # write cgi vars to the file. + &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + \%pppsettings); + + # make link and write secret file. + &updatesettings(); + &writesecrets(); + + &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}"); + if ($drivererror) { + my $refresh = ""; + my $title = $Lang::tr{'upload'}; + &Header::openpage($title, 0, $refresh); + } +} +elsif ($pppsettings{'ACTION'} eq $Lang::tr{'select'}) +{ + my $profile = $pppsettings{'PROFILE'}; + %temppppsettings = (); + $temppppsettings{'PROFILE'} = ''; + &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + \%temppppsettings); + + # make link. + &updatesettings(); + + # read in the new params "early" so we can write secrets. + %pppsettings = (); + &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); + $pppsettings{'PROFILE'} = $profile; + &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + \%pppsettings); + + &writesecrets(); + + &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}"); +} +elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'}) +{ + &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}"); + + my $profile = $pppsettings{'PROFILE'}; + truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0); + + %temppppsettings = (); + $temppppsettings{'PROFILE'} = ''; + &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + \%temppppsettings); + + # make link. + &updatesettings(); + + # read in the new params "early" so we can write secrets. + %pppsettings = (); + &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); + $pppsettings{'PROFILE'} = $profile; + &initprofile; + &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + \%pppsettings); +} +else +{ + # read in the current vars + %pppsettings = (); + $pppsettings{'VALID'} = ''; + &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); +} + +# read in the profile names into @profilenames. +my $c=0; +for ($c = 1; $c <= $maxprofiles; $c++) +{ + %temppppsettings = (); + $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty'}; + &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); + $profilenames[$c] = $temppppsettings{'PROFILENAME'}; +} + +if ($pppsettings{'VALID'} eq '') +{ + if ($pppsettings{'PROFILE'} eq '') { + $pppsettings{'PROFILE'} = '1'; + &initprofile(); + } +} +for ($c = 1; $c <= $maxprofiles; $c++) { + $selected{'PROFILE'}{$c} = ''; } +$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; +for ($c = 1; $c <= $maxprofiles; $c++) { + $selected{'BACKUPPROFILE'}{$c} = ''; } +$selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'"; + +$selected{'TYPE'}{'modem'} = ''; +$selected{'TYPE'}{'serial'} = ''; +$selected{'TYPE'}{'isdn'} = ''; +$selected{'TYPE'}{'pppoe'} = ''; +$selected{'TYPE'}{'pptp'} = ''; +$selected{'TYPE'}{'alcatelusb'} = ''; +$selected{'TYPE'}{'alcatelusbk'} = ''; +$selected{'TYPE'}{'pulsardsl'} = ''; +$selected{'TYPE'}{'eciadsl'} = ''; +$selected{'TYPE'}{'fritzdsl'} = ''; +$selected{'TYPE'}{'bewanadsl'} = ''; +$selected{'TYPE'}{'eagleusbadsl'} = ''; +$selected{'TYPE'}{'conexantusbadsl'} = ''; +$selected{'TYPE'}{'conexantpciadsl'} = ''; +$selected{'TYPE'}{'amedynusbadsl'} = ''; +$selected{'TYPE'}{'3cp4218usbadsl'} = ''; +$selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'"; + +$checked{'DEBUG'}{'off'} = ''; +$checked{'DEBUG'}{'on'} = ''; +$checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'"; + +$selected{'COMPORT'}{'ttyS0'} = ''; +$selected{'COMPORT'}{'ttyS1'} = ''; +$selected{'COMPORT'}{'ttyS2'} = ''; +$selected{'COMPORT'}{'ttyS3'} = ''; +$selected{'COMPORT'}{'ttyS4'} = ''; +$selected{'COMPORT'}{'usb/ttyACM0'} = ''; +$selected{'COMPORT'}{'usb/ttyACM1'} = ''; +$selected{'COMPORT'}{'usb/ttyACM2'} = ''; +$selected{'COMPORT'}{'usb/ttyACM3'} = ''; +$selected{'COMPORT'}{'isdn1'} = ''; +$selected{'COMPORT'}{'isdn2'} = ''; +$selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'"; + +$selected{'DTERATE'}{'9600'} = ''; +$selected{'DTERATE'}{'19200'} = ''; +$selected{'DTERATE'}{'38400'} = ''; +$selected{'DTERATE'}{'57600'} = ''; +$selected{'DTERATE'}{'115200'} = ''; +$selected{'DTERATE'}{'230400'} = ''; +$selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'"; + +$checked{'SPEAKER'}{'off'} = ''; +$checked{'SPEAKER'}{'on'} = ''; +$checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'"; + +$selected{'DIALMODE'}{'T'} = ''; +$selected{'DIALMODE'}{'P'} = ''; +$selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'"; + +$checked{'RECONNECTION'}{'manual'} = ''; +$checked{'RECONNECTION'}{'persistent'} = ''; +$checked{'RECONNECTION'}{'dialondemand'} = ''; +$checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'"; + +$checked{'DIALONDEMANDDNS'}{'off'} = ''; +$checked{'DIALONDEMANDDNS'}{'on'} = ''; +$checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'"; + +$checked{'AUTOCONNECT'}{'off'} = ''; +$checked{'AUTOCONNECT'}{'on'} = ''; +$checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'"; + +$checked{'SENDCR'}{'off'} = ''; +$checked{'SENDCR'}{'on'} = ''; +$checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'"; +$checked{'USEDOV'}{'off'} = ''; +$checked{'USEDOV'}{'on'} = ''; +$checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'"; +$checked{'USEIBOD'}{'off'} = ''; +$checked{'USEIBOD'}{'on'} = ''; +$checked{'USEIBOD'}{$pppsettings{'USEIBOD'}} = "checked='checked'"; + +$checked{'MODEM'}{'PCIST'} = ''; +$checked{'MODEM'}{'USB'} = ''; +$checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'"; + +$selected{'LINE'}{'WO'} = ''; +$selected{'LINE'}{'ES'} = ''; +$selected{'LINE'}{'ES03'} = ''; +$selected{'LINE'}{'FR'} = ''; +$selected{'LINE'}{'FR04'} = ''; +$selected{'LINE'}{'FR10'} = ''; +$selected{'LINE'}{'IT'} = ''; +$selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'"; + +$checked{'MODULATION'}{'GDMT'} = ''; +$checked{'MODULATION'}{'ANSI'} = ''; +$checked{'MODULATION'}{'GLITE'} = ''; +$checked{'MODULATION'}{'AUTO'} = ''; +$checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'"; + +$checked{'PROTOCOL'}{'RFC1483'} = ''; +$checked{'PROTOCOL'}{'RFC2364'} = ''; +$checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'"; + +$selected{'ENCAP'}{'0'} = ''; +$selected{'ENCAP'}{'1'} = ''; +$selected{'ENCAP'}{'2'} = ''; +$selected{'ENCAP'}{'3'} = ''; +$selected{'ENCAP'}{'4'} = ''; +$selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'"; +$checked{'METHOD'}{'STATIC'} = ''; +$checked{'METHOD'}{'PPPOE'} = ''; +$checked{'METHOD'}{'PPPOE_PLUGIN'} = ''; +$checked{'METHOD'}{'DHCP'} = ''; +$checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'"; + +$selected{'AUTH'}{'pap-or-chap'} = ''; +$selected{'AUTH'}{'pap'} = ''; +$selected{'AUTH'}{'chap'} = ''; +$selected{'AUTH'}{'standard-login-script'} = ''; +$selected{'AUTH'}{'demon-login-script'} = ''; +$selected{'AUTH'}{'other-login-script'} = ''; +$selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'"; + +$checked{'DNS'}{'Automatic'} = ''; +$checked{'DNS'}{'Manual'} = ''; +$checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'"; + +&Header::openpage($Lang::tr{'ppp setup'}, 1, ''); + +&Header::openbigbox('100%', 'left', '', $errormessage); + +if ($errormessage) { + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage\n"; + print " \n"; + &Header::closebox(); +} + + +### +### Box for selecting profile +### +print "
\n"; +&Header::openbox('100%', 'left', $Lang::tr{'profiles'}); +print < + + $Lang::tr{'profile'}: + + + + + + +END +; +&Header::closebox(); +&Header::openbox('100%', 'left', $Lang::tr{'connection'}.':'); +print < + + $Lang::tr{'interface'}: + + + + + + USB: +END +; +if (-f "/proc/bus/usb/devices") { + my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`; + if ($usb eq '') { + print "\t$Lang::tr{'not running'}\n"; + } else { + print "\t$usb\n"; + } +} + +if ($pppsettings{'TYPE'}) { + print ""; + if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/) { + print < + + +END +; + } elsif ($pppsettings{'TYPE'} eq 'isdn') { + print <$Lang::tr{'isdn1'} + + +END +; + } + if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { + print <$Lang::tr{'computer to modem rate'} + + +END +; + } else { + print "\n"; + } + if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/ ) { + print "\n"; + print "\n"; + if ($pppsettings{'TYPE'} eq 'modem' ) { + print "\n"; + print "\n"; + } else { + print "\n"; + } + } + } + if ($pppsettings{'TYPE'} eq 'modem') { + print < + + + + + +END +; +} + +print < + + + + +END +; + if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) { + $pppsettings{'AUTOCONNECT'} = 'on'; + print "\n"; + print "\n"; + } else { + print "\n"; + print "\n"; + } +print <$Lang::tr{'connection debugging'}: + + + + + + + + +END +; +if ($pppsettings{'TYPE'} ne 'isdn') { +print < + + + + +END +; +} +print < + + + + + + + + + + + +END +; + +if ($pppsettings{'TYPE'} eq 'isdn') { + print < +
$Lang::tr{'interface'}:
 
$Lang::tr{'number'}$Lang::tr{'modem speaker on'}
 
$Lang::tr{'dialing mode'}$Lang::tr{'send cr'}
$Lang::tr{'idle timeout'} 
$Lang::tr{'connect on ipcop restart'}
$Lang::tr{'connect on ipcop restart'}


$Lang::tr{'reconnection'}:
+ $Lang::tr{'manual'}
+ $Lang::tr{'persistent'}$Lang::tr{'backupprofile'}: +
+ $Lang::tr{'dod'}$Lang::tr{'dod for dns'}
$Lang::tr{'holdoff'}:$Lang::tr{'maximum retries'}
+ + + + + + + + + +END +; +} + +if ($pppsettings{'TYPE'} eq 'pptp') +{ +print < + +


$Lang::tr{'isdn settings'}
$Lang::tr{'use ibod'}$Lang::tr{'use dov'}
+ + + + + + + + + + + + + + + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} eq 'pppoe') +{ +print < +


$Lang::tr{'pptp settings'}
$Lang::tr{'phonebook entry'}
$Lang::tr{'static ip'}$Lang::tr{'router ip'}
 
$Lang::tr{'dhcp mode'}$Lang::tr{'hostname'}: *
+ + + +END +; +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) +{ + +print < +


$Lang::tr{'pppoe settings'}
+ + + + + + + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} eq 'bewanadsl') +{ +print < + + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} =~ /^(3cp4218usbadsl|bewanadsl)$/) +{ +print < + + + + + + + + + + +END +; +} + +if ($pppsettings{'TYPE'} eq 'eagleusbadsl') +{ +print < + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} eq 'eciadsl') +{ +print < + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) +{ +print < + + +END +; +} +if ($pppsettings{'TYPE'} eq 'alcatelusb') +{ + print ""; +} + +if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/) +{ +print <$Lang::tr{'encapsulation'}: + + +END +; +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) +{ +print < + + + + + + +END +; +} +if ($pppsettings{'TYPE'} eq 'alcatelusb') +{ + print ""; +} + +if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/) +{ + if ($pppsettings{'TYPE'} ne 'fritzdsl') + { +print <$Lang::tr{'encapsulation'}: + + + + + + +END +; + } else { +print <PPPoE + +END +; + } +} +if ($pppsettings{'TYPE'} =~ /^(pppoe|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/) +{ +print < + + + + + + + + + + + + + + +END +; +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/) +{ +print < + + + + + + + + + + + + + + + + + + + + + + + + + + + + +END +; + if ($pppsettings{'TYPE'} =~ /^(eciadsl|eagleusbadsl)$/) + { +print < + + + + + + + + + + +END +; + } +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|eciadsl|fritzdsl)$/) { + print ""; +} +if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) { + my $speedtouch = &Header::speedtouchversion; + if (($speedtouch >= 0) && ($speedtouch <=4)) { + my $modem; + if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; } + print ""; + if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") { + print "\n"; + } else { + print "\n"; + } + } else { + print ""; + } +} elsif ($pppsettings{'TYPE'} eq 'eciadsl') { + print ""; + if (-e "${General::swroot}/eciadsl/synch.bin") { + print "\n"; + } else { + print "\n"; } +} elsif ($pppsettings{'TYPE'} eq 'fritzdsl') { + print ""; + if (-e "/lib/modules/$kernel/misc/fcdslusb.o.gz") { + print "\n"; + } else { + print "\n"; } +} +print < +


$Lang::tr{'adsl settings'}:
$Lang::tr{'vpi number'}$Lang::tr{'vci number'}
 
$Lang::tr{'modem'}: + Bewan ADSL PCI stBewan ADSL USB st
 
$Lang::tr{'modulation'}:$Lang::tr{'automatic'}ANSI T1.483G.DMTG.Lite
 
$Lang::tr{'country'}: +
 
$Lang::tr{'modem'}: +
 
$Lang::tr{'protocol'}: + RFC2364 PPPoA 
+ +
 
  + RFC 1483 / 2684 
+ +
 
  PPPoE plugin$Lang::tr{'service name'} *
  $Lang::tr{'pppoe'}$Lang::tr{'concentrator name'} *
 
  $Lang::tr{'static ip'}$Lang::tr{'static ip'}:
  $Lang::tr{'gateway ip'}:
  $Lang::tr{'netmask'}:
  $Lang::tr{'broadcast'}: *
 
  $Lang::tr{'dhcp mode'}$Lang::tr{'hostname'}: *
 
$Lang::tr{'firmware'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
$Lang::tr{'unknown'} Rev $speedtouch
$Lang::tr{'driver'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
$Lang::tr{'driver'}:$Lang::tr{'present'} 
$Lang::tr{'not present'} 
+ + + + + + + + + + + + + + + +


$Lang::tr{'authentication'}
$Lang::tr{'username'}$Lang::tr{'password'}
$Lang::tr{'method'}$Lang::tr{'script name'} *
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +


DNS:
$Lang::tr{'automatic'}
$Lang::tr{'manual'}$Lang::tr{'primary dns'}$Lang::tr{'secondary dns'}


 $Lang::tr{'profile name'}


$Lang::tr{'legend'}:* $Lang::tr{'this field may be blank'}
+END +; +&Header::closebox(); +} + +print "\n"; + +&Header::closebigbox(); + +&Header::closepage(); + +sub updatesettings +{ + # make a link from the selected profile to the "default" one. + unlink("${General::swroot}/ppp/settings"); + link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", + "${General::swroot}/ppp/settings"); + system ("/bin/touch", "${General::swroot}/ppp/updatesettings"); + if ($pppsettings{'TYPE'} eq 'eagleusbadsl') { + # eagle-usb.conf is in backup but link DSPcode.bin can't, so the link is created in rc.eagleusbadsl + open(FILE, ">/${General::swroot}/eagle-usb/eagle-usb.conf") or die "Unable to write eagle-usb.conf file"; + flock(FILE, 2); + # decimal to hexa + $modemsettings{'VPI'} = uc(sprintf('%X', $pppsettings{'VPI'})); + $modemsettings{'VCI'} = uc(sprintf('%X', $pppsettings{'VCI'})); + if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { + $modemsettings{'Encapsulation'} =1+$pppsettings{'ENCAP'} + } elsif ( $pppsettings{'PROTOCOL'} eq 'RFC2364') { + $modemsettings{'Encapsulation'} =6-$pppsettings{'ENCAP'} + } + print FILE "\n"; + print FILE "VPI=$modemsettings{'VPI'}\n"; + print FILE "VCI=$modemsettings{'VCI'}\n"; + print FILE "Encapsulation=$modemsettings{'Encapsulation'}\n"; + print FILE "Linetype=0A\n"; + print FILE "RatePollFreq=00000009\n"; + print FILE "\n"; + close FILE; + } +} + +sub writesecrets +{ + # write secrets file. + open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; + flock(FILE, 2); + my $username = $pppsettings{'USERNAME'}; + my $password = $pppsettings{'PASSWORD'}; + print FILE "'$username' * '$password'\n"; + chmod 0600, "${General::swroot}/ppp/secrets"; + close FILE; +} + +sub initprofile +{ + $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'}; + $pppsettings{'COMPORT'} = 'ttyS0'; + $pppsettings{'DTERATE'} = 115200; + $pppsettings{'SPEAKER'} = 'off'; + $pppsettings{'RECONNECTION'} = 'manual'; + $pppsettings{'DIALONDEMANDDNS'} = 'off'; + $pppsettings{'AUTOCONNECT'} = 'off'; + $pppsettings{'SENDCR'} = 'off'; + $pppsettings{'USEIBOD'} = 'off'; + $pppsettings{'USEDOV'} = 'off'; + $pppsettings{'MODEM'} = 'PCIST'; + $pppsettings{'LINE'} = 'WO'; + $pppsettings{'ENCAP'} = '0'; + $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1'; + $pppsettings{'PROTOCOL'} = 'RFC2364'; + $pppsettings{'METHOD'} = 'PPPOE_PLUGIN'; + $pppsettings{'DIALMODE'} = 'T'; + $pppsettings{'MAXRETRIES'} = 5; + $pppsettings{'HOLDOFF'} = 30; + $pppsettings{'TIMEOUT'} = 15; + $pppsettings{'MODULATION'} = 'AUTO'; + $pppsettings{'AUTH'} = 'pap-or-chap'; + $pppsettings{'DNS'} = 'Automatic'; + $pppsettings{'DEBUG'} = 'off'; + $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'}; + + # Get ISDN settings so we can see if ISDN is enabled or not. + $isdnsettings{'ENABLED'} = 'off'; + &General::readhash("${General::swroot}/isdn/settings", \%isdnsettings); + + # Get PPPoE settings so we can see if PPPoE is enabled or not. + &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); + + # empty profile partial pre-initialization + if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/) { + $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'}); + } elsif ($isdnsettings{'ENABLED'} eq 'on') { + $pppsettings{'TYPE'}='isdn'; + } else { + $pppsettings{'TYPE'}='modem'; + } +} +