]>
git.ipfire.org Git - people/trikolon/ipfire-2.x.git/blob - html/cgi-bin/pppsetup.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
33 my %temppppsettings=();
34 our %modemsettings=();
40 my $errormessage = '';
42 my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
45 my %mainsettings = ();
46 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
47 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
49 &Header
::showhttpheaders
();
51 $pppsettings{'ACTION'} = '';
53 &Header
::getcgihash
(\
%pppsettings);
55 if ($pppsettings{'ACTION'} ne '' &&
56 (-e
'/var/run/ppp-ipcop.pid' || -e
"${General::swroot}/red/active"))
58 $errormessage = $Lang::tr
{'unable to alter profiles while red is active'};
59 # read in the current vars
61 $pppsettings{'VALID'} = '';
62 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
64 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'refresh'})
66 unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|pppoeatm)$/) {
67 $errormessage = $Lang::tr
{'invalid input'};
69 my $type = $pppsettings{'TYPE'};
70 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
71 $pppsettings{'TYPE'} = $type;
73 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'save'})
75 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|ttyACM0|ttyACM1|ttyACM2|ttyACM3|isdn1|isdn2)$/) {
76 $errormessage = $Lang::tr
{'invalid input'};
78 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800|921600)$/) {
79 $errormessage = $Lang::tr
{'invalid input'};
81 if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) {
82 $errormessage = $Lang::tr
{'invalid input'};
84 if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) {
85 $errormessage = $Lang::tr
{'invalid input'};
89 if ($pppsettings{'PROFILENAME'} eq '') {
90 $errormessage = $Lang::tr
{'profile name not given'};
91 $pppsettings{'PROFILENAME'} = '';
93 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) {
94 if ($pppsettings{'TELEPHONE'} eq '') {
95 $errormessage = $Lang::tr
{'telephone not set'};
97 if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) {
98 $errormessage = $Lang::tr
{'bad characters in the telephone number field'};
101 unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) {
102 if ($pppsettings{'USERNAME'} eq '') {
103 $errormessage = $Lang::tr
{'username not set'};
105 if ($pppsettings{'PASSWORD'} eq '') {
106 $errormessage = $Lang::tr
{'password not set'};
110 if ($pppsettings{'TIMEOUT'} eq '') {
111 $errormessage = $Lang::tr
{'idle timeout not set'};
113 if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) {
114 $errormessage = $Lang::tr
{'only digits allowed in the idle timeout'};
117 if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) {
118 $errormessage = $Lang::tr
{'bad characters in script field'};
121 if ($pppsettings{'DNS1'})
123 if (!(&General
::validip
($pppsettings{'DNS1'}))) {
124 $errormessage = $Lang::tr
{'invalid primary dns'};
127 if ($pppsettings{'DNS2'})
129 if (!(&General
::validip
($pppsettings{'DNS2'}))) {
130 $errormessage = $Lang::tr
{'invalid secondary dns'};
134 if ($pppsettings{'MAXRETRIES'} eq '') {
135 $errormessage = $Lang::tr
{'max retries not set'};
137 if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) {
138 $errormessage = $Lang::tr
{'only digits allowed in max retries field'};
141 if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) {
142 $errormessage = $Lang::tr
{'only digits allowed in holdoff field'};
145 if ($pppsettings{'TYPE'} eq 'pptp') {
147 if ($pppsettings{'METHOD'} eq 'STATIC') {
148 if (! &General
::validip
($pppsettings{'ROUTERIP'})) {
149 $errormessage = $Lang::tr
{'router ip'}.' '.$Lang::tr
{'invalid ip'};
152 if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General
::validfqdn
($pppsettings{'DHCP_HOSTNAME'})) ) {
153 $errormessage = $errormessage.' '.$Lang::tr
{'hostname'}.' '.$Lang::tr
{'invalid hostname'};
156 if ($errormessage ne '') {goto ERROR
; }
158 if ($pppsettings{'TYPE'} =~ /^(pppoeatm)$/) {
159 if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) {
160 $errormessage = $Lang::tr
{'invalid vpi vpci'};
162 if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) {
163 $errormessage = $Lang::tr
{'invalid vpi vpci'};
165 if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) {
166 $errormessage = $Lang::tr
{'invalid vpi vpci'};
168 if ( $pppsettings{'PROTOCOL'} eq '' ) {
169 $errormessage = $Lang::tr
{'invalid input'};
173 if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \
174 ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) {
175 $errormessage = $Lang::tr
{'invalid input'};
178 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) {
179 if ($pppsettings{'DHCP_HOSTNAME'} ne '') {
180 if (! &General
::validfqdn
($pppsettings{'DHCP_HOSTNAME'})) {
181 $errormessage = $errormessage.' '.$Lang::tr
{'hostname'}.': '.$Lang::tr
{'invalid hostname'}; }
185 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) {
187 if (! &General
::validip
($pppsettings{'IP'})) {
188 $errormessage = $Lang::tr
{'static ip'}.' '.$Lang::tr
{'invalid ip'}; }
189 if (! &General
::validip
($pppsettings{'GATEWAY'})) {
190 $errormessage = $errormessage.' '.$Lang::tr
{'gateway ip'}.' '.$Lang::tr
{'invalid ip'}; }
191 if (! &General
::validmask
($pppsettings{'NETMASK'})) {
192 $errormessage = $errormessage.' '.$Lang::tr
{'netmask'}.' '.$Lang::tr
{'invalid netmask'}; }
193 if ($pppsettings{'BROADCAST'} ne '') {
194 if (! &General
::validip
($pppsettings{'BROADCAST'})) {
195 $errormessage = $errormessage.' '.$Lang::tr
{'broadcast'}.' '.$Lang::tr
{'invalid broadcast ip'}; }
197 if( $pppsettings{'DNS'} eq 'Automatic') {
198 $errormessage = $Lang::tr
{'invalid input'}; }
199 if ($errormessage ne '') {goto ERROR
; }
202 if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \
203 $pppsettings{'RECONNECTION'} eq 'dialondemand' ) {
204 $errormessage = $Lang::tr
{'invalid input'};
207 if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) {
208 $errormessage = $Lang::tr
{'dod not compatible with ddns'};
211 # if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
212 # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; }
213 # if( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
214 # $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; }
215 delete $pppsettings{'ENCAP_RFC1483'};
216 delete $pppsettings{'ENCAP_RFC2364'};
220 $pppsettings{'VALID'} = 'no'; }
222 $pppsettings{'VALID'} = 'yes'; }
224 # write cgi vars to the file.
225 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
228 # make link and write secret file.
232 &General
::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}");
234 if ($pppsettings{'ACTION'} eq $Lang::tr
{'select'})
236 my $profile = $pppsettings{'PROFILE'};
237 %temppppsettings = ();
238 $temppppsettings{'PROFILE'} = '';
239 &General
::readhash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
245 # read in the new params "early" so we can write secrets.
247 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
248 $pppsettings{'PROFILE'} = $profile;
249 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
254 &General
::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}");
256 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'delete'})
258 &General
::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}");
260 my $profile = $pppsettings{'PROFILE'};
261 truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0);
263 %temppppsettings = ();
264 $temppppsettings{'PROFILE'} = '';
265 &General
::readhash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
271 # read in the new params "early" so we can write secrets.
273 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
274 $pppsettings{'PROFILE'} = $profile;
276 &General
::writehash
("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
279 elsif ($pppsettings{'ACTION'} eq $Lang::tr
{'refresh'})
284 # read in the current vars
286 $pppsettings{'VALID'} = '';
287 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
290 # read in the profile names into @profilenames.
292 for ($c = 1; $c <= $maxprofiles; $c++)
294 %temppppsettings = ();
295 $temppppsettings{'PROFILENAME'} = $Lang::tr
{'empty profile'};
296 &General
::readhash
("${General::swroot}/ppp/settings-$c", \
%temppppsettings);
297 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
300 if ($pppsettings{'VALID'} eq '')
302 if ($pppsettings{'PROFILE'} eq '') {
303 $pppsettings{'PROFILE'} = '1';
307 for ($c = 1; $c <= $maxprofiles; $c++) {
308 $selected{'PROFILE'}{$c} = ''; }
309 $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
310 for ($c = 1; $c <= $maxprofiles; $c++) {
311 $selected{'BACKUPPROFILE'}{$c} = ''; }
312 $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'";
314 $selected{'TYPE'}{'modem'} = '';
315 $selected{'TYPE'}{'serial'} = '';
316 $selected{'TYPE'}{'pppoe'} = '';
317 $selected{'TYPE'}{'pptp'} = '';
318 $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'";
319 $checked{'DEBUG'}{'off'} = '';
320 $checked{'DEBUG'}{'on'} = '';
321 $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'";
323 $selected{'COMPORT'}{'ttyS0'} = '';
324 $selected{'COMPORT'}{'ttyS1'} = '';
325 $selected{'COMPORT'}{'ttyS2'} = '';
326 $selected{'COMPORT'}{'ttyS3'} = '';
327 $selected{'COMPORT'}{'ttyS4'} = '';
328 if ( $pppsettings{'TYPE'} ne '' ){
329 $selected{'COMPORT'}{'ttyACM0'} = '';
330 $selected{'COMPORT'}{'ttyACM1'} = '';
331 $selected{'COMPORT'}{'ttyACM2'} = '';
332 $selected{'COMPORT'}{'ttyACM3'} = '';}
333 $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'";
335 $selected{'DTERATE'}{'9600'} = '';
336 $selected{'DTERATE'}{'19200'} = '';
337 $selected{'DTERATE'}{'38400'} = '';
338 $selected{'DTERATE'}{'57600'} = '';
339 $selected{'DTERATE'}{'115200'} = '';
340 $selected{'DTERATE'}{'230400'} = '';
341 $selected{'DTERATE'}{'460800'} = '';
342 $selected{'DTERATE'}{'921600'} = '';
343 $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'";
345 $checked{'SPEAKER'}{'off'} = '';
346 $checked{'SPEAKER'}{'on'} = '';
347 $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'";
349 $selected{'DIALMODE'}{'T'} = '';
350 $selected{'DIALMODE'}{'P'} = '';
351 $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'";
353 $checked{'RECONNECTION'}{'persistent'} = '';
354 $checked{'RECONNECTION'}{'dialondemand'} = '';
355 $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'";
357 $checked{'DIALONDEMANDDNS'}{'off'} = '';
358 $checked{'DIALONDEMANDDNS'}{'on'} = '';
359 $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'";
361 $checked{'AUTOCONNECT'}{'off'} = '';
362 $checked{'AUTOCONNECT'}{'on'} = '';
363 $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'";
365 $checked{'SENDCR'}{'off'} = '';
366 $checked{'SENDCR'}{'on'} = '';
367 $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'";
368 $checked{'USEDOV'}{'off'} = '';
369 $checked{'USEDOV'}{'on'} = '';
370 $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'";
372 $checked{'MODEM'}{'PCIST'} = '';
373 $checked{'MODEM'}{'USB'} = '';
374 $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'";
376 $selected{'LINE'}{'WO'} = '';
377 $selected{'LINE'}{'ES'} = '';
378 $selected{'LINE'}{'ES03'} = '';
379 $selected{'LINE'}{'FR'} = '';
380 $selected{'LINE'}{'FR04'} = '';
381 $selected{'LINE'}{'FR10'} = '';
382 $selected{'LINE'}{'IT'} = '';
383 $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'";
385 $checked{'MODULATION'}{'GDMT'} = '';
386 $checked{'MODULATION'}{'ANSI'} = '';
387 $checked{'MODULATION'}{'GLITE'} = '';
388 $checked{'MODULATION'}{'AUTO'} = '';
389 $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'";
391 $checked{'PROTOCOL'}{'RFC1483'} = '';
392 $checked{'PROTOCOL'}{'RFC2364'} = '';
393 $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'";
395 $selected{'ENCAP'}{'0'} = '';
396 $selected{'ENCAP'}{'1'} = '';
397 #$selected{'ENCAP'}{'2'} = '';
398 #$selected{'ENCAP'}{'3'} = '';
399 #$selected{'ENCAP'}{'4'} = '';
400 $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'";
402 $checked{'METHOD'}{'STATIC'} = '';
403 $checked{'METHOD'}{'PPPOE'} = '';
404 $checked{'METHOD'}{'PPPOE_PLUGIN'} = '';
405 $checked{'METHOD'}{'DHCP'} = '';
406 $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'";
408 $selected{'AUTH'}{'pap-or-chap'} = '';
409 $selected{'AUTH'}{'pap'} = '';
410 $selected{'AUTH'}{'chap'} = '';
411 $selected{'AUTH'}{'standard-login-script'} = '';
412 $selected{'AUTH'}{'demon-login-script'} = '';
413 $selected{'AUTH'}{'other-login-script'} = '';
414 $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'";
416 $checked{'DNS'}{'Automatic'} = '';
417 $checked{'DNS'}{'Manual'} = '';
418 $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'";
420 &Header
::openpage
($Lang::tr
{'ppp setup'}, 1, '');
421 &Header
::openbigbox
('100%', 'left', '', $errormessage);
423 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
424 $errormessage = $Lang::tr
{'dialup red not ppp'};
425 &Header
::openbox
('100%', 'center', $Lang::tr
{'error messages'});
426 print "<CLASS name='base'>$errormessage\n";
427 print " </CLASS>\n";
429 &Header
::closebigbox
();
431 &Header
::closepage
();
436 &Header
::openbox
('100%', 'center', $Lang::tr
{'error messages'});
437 print "<CLASS name='base'>$errormessage\n";
438 print " </CLASS>\n";
444 ### Box for selecting profile
446 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
447 &Header
::openbox
('100%', 'center', $Lang::tr
{'profile'});
449 <table width='95%' cellspacing='0'>
451 <td align='left'>$Lang::tr{'profile'}</td>
453 <select name='PROFILE' style="width: 165px">
456 for ($c = 1; $c <= $maxprofiles; $c++)
458 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
462 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td>
463 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
464 <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td>
473 &Header
::openbox
('100%', 'center', $Lang::tr
{'connection'});
476 <table width='95%' cellspacing='0'>
478 <td width='25%'>$Lang::tr{'interface'}:</td>
480 <select name='TYPE' style="width: 165px">
483 if ($netsettings{'RED_TYPE'} eq 'PPPOE') {
485 <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option>
486 <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option>
487 <option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>
491 my $atmdev=`cat /proc/net/atm/devices | grep 0`;
495 <option value='pppoeatm' $selected{'TYPE'}{'pppoeatm'}>PPPoE over ATM-BRIDGE</option>
500 #if ($netsettings{'RED_TYPE'} eq 'PPTP') {#
501 # print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n";
506 # <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option>
507 # <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option>
508 # <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option>
509 # <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option>
510 # <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option>
511 # <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option>
512 # <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option>
516 # print "<option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>";
520 <td colspan='1' width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}'></td>
523 if ($pppsettings{'TYPE'} =~ /^(modem)$/) {
525 <td colspan='1' width='25%'><A HREF=modem.cgi>$Lang::tr{'modem configuration'}</A></td>
532 #if (-f "/proc/bus/usb/devices") {
533 # <td colspan='2' width='50%'>USB:</td>
534 # my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`;
536 # print "\t<td colspan='2' width='50%'>$Lang::tr{'not running'}</td></tr>\n";
538 # print "\t<td colspan='2' width='50%'>$usb</td></tr>\n";
542 if ($pppsettings{'TYPE'}) {
543 print "<tr><td colspan='4' width='100%'><br></br></td></tr>";
545 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) {
549 <td colspan='3' width='75%'>$Lang::tr{'interface'}:</td>
550 <td width='25%'><select name='COMPORT' style="width: 165px">
553 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
555 <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>COM1</option>
556 <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>COM2</option>
557 <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>COM3</option>
558 <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>COM4</option>
559 <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>COM5</option>
562 if ($pppsettings{'TYPE'} ne 'serial' ) {
564 <option value='ttyACM0' $selected{'COMPORT'}{'ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option>
565 <option value='ttyACM1' $selected{'COMPORT'}{'ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option>
566 <option value='ttyACM2' $selected{'COMPORT'}{'ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option>
567 <option value='ttyACM3' $selected{'COMPORT'}{'ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option>
571 print "</select></td> "}
572 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
575 <td colspan='3' width='75%'>$Lang::tr{'computer to modem rate'}</td>
576 <td width='25%'><select name='DTERATE' style="width: 165px">
577 <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option>
578 <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option>
579 <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option>
580 <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option>
581 <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option>
582 <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option>
583 <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option>
584 <option value='921600' $selected{'DTERATE'}{'921600'}>921600</option>
590 if ($pppsettings{'TYPE'} =~ /^(modem)$/ ) {
591 print "<tr><td colspan='3' width='75%'>$Lang::tr{'number'}</td>\n";
592 print "<td width='25%'><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}'></td><tr>\n";
593 if ($pppsettings{'TYPE'} eq 'modem' ) {
594 print "<tr><td colspan='3' width='75%'>$Lang::tr{'modem speaker on'}</td>\n";
595 print "<td width='25%'><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n";
599 if ($pppsettings{'TYPE'} eq 'modem') {
602 <td colspan='3' width='75%'>$Lang::tr{'dialing mode'}</td>
603 <td width='25%'><select name='DIALMODE' style="width: 165px">
604 <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option>
605 <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option>
609 <td colspan='3' width='75%'>$Lang::tr{'send cr'}</td>
610 <td width='50%'><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td>
618 <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}</td>
619 <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
622 <td colspan='3' width='75%'>$Lang::tr{'connection debugging'}:</td>
623 <td width='25%'><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td>
626 <td colspan='4' width='100%'><br></br></td></tr>
628 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'reconnection'}:</b></td>
631 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'}>$Lang::tr{'dod'}</td>
635 if ($pppsettings{'TYPE'} ne 'isdn') {
638 <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td>
641 <td colspan='3' width='75%'>$Lang::tr{'backupprofile'}:</td>
642 <td width='25%'><select name='BACKUPPROFILE' style="width: 165px">
645 for ($c = 1; $c <= $maxprofiles; $c++) {
646 print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
656 <td colspan='3' width='75%'>$Lang::tr{'dod for dns'}</td>
657 <td width='25%'><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td>
660 <td colspan='3' width='75%'>$Lang::tr{'holdoff'}:</td>
661 <td width='25%'><input type='text' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td>
664 <td colspan='3' width='75%'>$Lang::tr{'maximum retries'}</td>
665 <td width='25%'><input type='text' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td>
670 if ($pppsettings{'TYPE'} eq 'pptp')
673 <tr><td colspan='4' width='100%'><br></br></td></tr>
675 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pptp settings'}</b></td>
678 <td width='25%'>$Lang::tr{'phonebook entry'}</td>
679 <td colspan='2' width='50%'></td>
680 <td width='25%'><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td>
683 <td width='25%'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
684 <td colspan='2' width='50%'>$Lang::tr{'router ip'}</td>
685 <td width='25%'><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td>
688 <td width='25%'><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
689 <td colspan='2' width='50%'>$Lang::tr{'hostname'}: <img src='/blob.gif' alt='*' /></td>
690 <td width='25%'><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
695 if ($pppsettings{'TYPE'} =~ /^(pppoeatm)$/)
700 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'adsl settings'}:</b></td>
703 <td> $Lang::tr{'encapsulation'}:</td>
704 <td colspan='2' width='30%'>
705 <select name='ENCAP'>
706 <option value='0' $selected{'ENCAP'}{'0'}>LLC</option>
707 <option value='1' $selected{'ENCAP'}{'1'}>VCmux</option>
713 <td nowrap='nowrap'>$Lang::tr{'vpi number'}</td>
714 <td><input type='text' size='5' name='VPI' value='$pppsettings{'VPI'}' /></td>
715 <td align='right'>$Lang::tr{'vci number'}</td>
716 <td colspan='2'><input type='text' size='5' name='VCI' value='$pppsettings{'VCI'}' /></td>
723 if ($pppsettings{'TYPE'} eq 'pppoe' || $pppsettings{'TYPE'} eq 'pppoeatm')
726 <tr><td colspan='4' width='100%'><br></br></td></tr>
728 <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pppoe settings'}</b></td>
731 <td width='25%'><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td>
732 <td colspan='2' width='50%'>$Lang::tr{'service name'} <img src='/blob.gif' alt='*' /></td>
733 <td width='25%'><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td>
736 <td width='25%'><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td>
737 <td colspan='2' width='50%'>$Lang::tr{'concentrator name'} <img src='/blob.gif' alt='*' /></td>
738 <td width='25%'><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td>
741 <td width='25%'>MTU</td>
742 <td colspan='2' width='50%'></td>
743 <td width='25%'><input type='text' name='MTU' value='$pppsettings{'MTU'}' /></td>
750 <tr><td colspan='4' width='100%'><br></br></td></tr>
752 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td>
755 <td width='25%'>$Lang::tr{'username'}</td>
756 <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
757 <td width='25%'>$Lang::tr{'password'}</td>
758 <td width='25%'><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td>
761 <td width='25%'>$Lang::tr{'method'}</td>
762 <td width='25%'><select name='AUTH' style="width: 165px">
763 <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option>
764 <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option>
765 <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option>
768 if ($pppsettings{'TYPE'} eq 'modem') {
770 <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option>
771 <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option>
772 <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option>
778 <td width='25%'>$Lang::tr{'script name'} <img src='/blob.gif' alt='*' /></td>
779 <td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
781 <tr><td colspan='4' width='100%'><br></br></td></tr>
783 <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>DNS:</b></td>
786 <td colspan='4' width='100%'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td>
789 <td colspan='4' width='100%'><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td>
792 <td width='25%'>$Lang::tr{'primary dns'}</td>
793 <td width='25%'><input type='text' name='DNS1' value='$pppsettings{'DNS1'}'></td>
794 <td width='25%'>$Lang::tr{'secondary dns'}</td>
795 <td width='25%'><input type='text' name='DNS2' value='$pppsettings{'DNS2'}'></td>
797 <tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr>
799 <td width='25%'>$Lang::tr{'profile name'}</td>
800 <td width='25%'><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}'>
801 <td colspan='2' width='50%'></td>
804 <td align='center' colspan='4' width='100%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td>
807 <td colspan='2' width='50%'>$Lang::tr{'legend'}:</td>
808 <td colspan='2' width='50%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td>
818 &Header
::closebigbox
();
820 &Header
::closepage
();
824 # make a link from the selected profile to the "default" one.
825 unlink("${General::swroot}/ppp/settings");
826 link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
827 "${General::swroot}/ppp/settings");
828 system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings");
833 # write secrets file.
834 open(FILE
, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
836 my $username = $pppsettings{'USERNAME'};
837 my $password = $pppsettings{'PASSWORD'};
838 print FILE
"'$username' * '$password'\n";
839 chmod 0600, "${General::swroot}/ppp/secrets";
845 $pppsettings{'PROFILENAME'} = $Lang::tr
{'unnamed'};
846 $pppsettings{'COMPORT'} = 'ttyS0';
847 $pppsettings{'DTERATE'} = 115200;
848 $pppsettings{'SPEAKER'} = 'off';
849 $pppsettings{'RECONNECTION'} = 'persistent';
850 $pppsettings{'DIALONDEMANDDNS'} = 'off';
851 $pppsettings{'AUTOCONNECT'} = 'on';
852 $pppsettings{'SENDCR'} = 'off';
853 $pppsettings{'USEIBOD'} = 'off';
854 $pppsettings{'USEDOV'} = 'off';
855 $pppsettings{'MODEM'} = 'PCIST';
856 $pppsettings{'LINE'} = 'WO';
857 $pppsettings{'ENCAP'} = '0';
858 $pppsettings{'VPI'} = '1';
859 $pppsettings{'VCI'} = '32';
860 $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1';
861 $pppsettings{'PROTOCOL'} = 'RFC2364';
862 $pppsettings{'METHOD'} = 'PPPOE_PLUGIN';
863 if ( $pppsettings{'METHOD'} eq 'PPPOE_PLUGIN' ) {
864 $pppsettings{'MTU'} = '1492';
865 $pppsettings{'MRU'} = '1492';
867 $pppsettings{'MTU'} = '1452';
868 $pppsettings{'MRU'} = '1452';
870 $pppsettings{'DIALMODE'} = 'T';
871 $pppsettings{'MAXRETRIES'} = 5;
872 $pppsettings{'HOLDOFF'} = 30;
873 $pppsettings{'TIMEOUT'} = 15;
874 $pppsettings{'MODULATION'} = 'AUTO';
875 $pppsettings{'AUTH'} = 'pap-or-chap';
876 $pppsettings{'DNS'} = 'Automatic';
877 $pppsettings{'DEBUG'} = 'off';
878 $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'};
880 # Get PPPoE settings so we can see if PPPoE is enabled or not.
881 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
883 # empty profile partial pre-initialization
884 if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/) {
885 $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'});
887 $pppsettings{'TYPE'}='modem';