93098add92c34598d71cbbfd9a99b776ee3164d9
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / pppsetup.cgi
1 #!/usr/bin/perl
2 #
3 # SmoothWall CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The SmoothWall Team
8 #
9 # Copyright (C) 03-Apr-2002 Guy Ellis <guy@traverse.com.au>
10 # - ISDN DOV support
11 # - ibod now an option
12 # - PCI ADSL support added
13 #
14 # $Id: pppsetup.cgi,v 1.17.2.49 2005/12/01 16:20:35 franck78 Exp $
15
16 use strict;
17
18 # enable only the following on debugging purpose
19 #use warnings;
20 #use CGI::Carp 'fatalsToBrowser';
21
22 require '/var/ipfire/general-functions.pl';
23 require "${General::swroot}/lang.pl";
24 require "${General::swroot}/header.pl";
25
26 our %pppsettings=();
27 my %temppppsettings=();
28 our %modemsettings=();
29 our %isdnsettings=();
30 our %netsettings=();
31 my %selected=();
32 my %checked=();
33 my @profilenames=();
34 my $errormessage = '';
35 my $maxprofiles = 5;
36 my $kernel=`/bin/uname -r | /usr/bin/tr -d '\012'`;
37
38 &Header::showhttpheaders();
39
40 $pppsettings{'ACTION'} = '';
41 &initprofile();
42 &Header::getcgihash(\%pppsettings);
43
44 if ($pppsettings{'ACTION'} ne '' &&
45 (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active"))
46 {
47 $errormessage = $Lang::tr{'unable to alter profiles while red is active'};
48 # read in the current vars
49 %pppsettings = ();
50 $pppsettings{'VALID'} = '';
51 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
52 }
53 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'refresh'})
54 {
55 unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) {
56 $errormessage = $Lang::tr{'invalid input'};
57 goto ERROR; }
58 my $type = $pppsettings{'TYPE'};
59 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
60 $pppsettings{'TYPE'} = $type;
61 }
62 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'})
63 {
64 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|usb\/ttyACM0|usb\/ttyACM1|usb\/ttyACM2|usb\/ttyACM3|isdn1|isdn2)$/) {
65 $errormessage = $Lang::tr{'invalid input'};
66 goto ERROR; }
67 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800)$/) {
68 $errormessage = $Lang::tr{'invalid input'};
69 goto ERROR; }
70 if ($pppsettings{'TYPE'} eq 'modem' && $pppsettings{'DIALMODE'} !~ /^(T|P)$/) {
71 $errormessage = $Lang::tr{'invalid input'};
72 goto ERROR; }
73 if ($pppsettings{'AUTH'} !~ /^(pap-or-chap|pap|chap|standard-login-script|demon-login-script|other-login-script)$/) {
74 $errormessage = $Lang::tr{'invalid input'};
75 goto ERROR;
76 }
77
78 if ($pppsettings{'PROFILENAME'} eq '') {
79 $errormessage = $Lang::tr{'profile name not given'};
80 $pppsettings{'PROFILENAME'} = '';
81 goto ERROR; }
82 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/) {
83 if ($pppsettings{'TELEPHONE'} eq '') {
84 $errormessage = $Lang::tr{'telephone not set'};
85 goto ERROR; }
86 if (!($pppsettings{'TELEPHONE'} =~ /^[\d\*\#\,]+$/)) {
87 $errormessage = $Lang::tr{'bad characters in the telephone number field'};
88 goto ERROR; }
89 }
90 unless (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} =~ /^(STATIC|DHCP)$/)) {
91 if ($pppsettings{'USERNAME'} eq '') {
92 $errormessage = $Lang::tr{'username not set'};
93 goto ERROR; }
94 if ($pppsettings{'PASSWORD'} eq '') {
95 $errormessage = $Lang::tr{'password not set'};
96 goto ERROR; }
97 }
98
99 if ($pppsettings{'TIMEOUT'} eq '') {
100 $errormessage = $Lang::tr{'idle timeout not set'};
101 goto ERROR; }
102 if (!($pppsettings{'TIMEOUT'} =~ /^\d+$/)) {
103 $errormessage = $Lang::tr{'only digits allowed in the idle timeout'};
104 goto ERROR; }
105
106 if ($pppsettings{'LOGINSCRIPT'} =~ /[.\/ ]/ ) {
107 $errormessage = $Lang::tr{'bad characters in script field'};
108 goto ERROR; }
109
110 if ($pppsettings{'DNS1'})
111 {
112 if (!(&General::validip($pppsettings{'DNS1'}))) {
113 $errormessage = $Lang::tr{'invalid primary dns'};
114 goto ERROR; }
115 }
116 if ($pppsettings{'DNS2'})
117 {
118 if (!(&General::validip($pppsettings{'DNS2'}))) {
119 $errormessage = $Lang::tr{'invalid secondary dns'};
120 goto ERROR; }
121 }
122
123 if ($pppsettings{'MAXRETRIES'} eq '') {
124 $errormessage = $Lang::tr{'max retries not set'};
125 goto ERROR; }
126 if (!($pppsettings{'MAXRETRIES'} =~ /^\d+$/)) {
127 $errormessage = $Lang::tr{'only digits allowed in max retries field'};
128 goto ERROR; }
129
130 if (!($pppsettings{'HOLDOFF'} =~ /^\d+$/)) {
131 $errormessage = $Lang::tr{'only digits allowed in holdoff field'};
132 goto ERROR; }
133
134 my $drivererror = 0;
135 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) {
136 my $modem = '';
137 my $speedtouch = &Header::speedtouchversion;
138 if ($speedtouch >=0 && $speedtouch <=4) {
139 if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; }
140 $pppsettings{'MODEM'} = $modem;
141 } else {
142 $modem='v0123';
143 $errormessage ="$Lang::tr{'unknown'} Rev $speedtouch";
144 goto ERROR;
145 }
146 if (! -e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
147 $errormessage = $Lang::tr{'no alcatelusb firmware'};
148 $drivererror = 1;
149 goto ERROR;
150 }
151 }
152
153 if($pppsettings{'TYPE'} eq 'eciadsl' && (!(-e "${General::swroot}/eciadsl/synch.bin"))) {
154 $errormessage = $Lang::tr{'no eciadsl synch.bin file'};
155 $drivererror = 1;
156 goto ERROR; }
157
158 if($pppsettings{'TYPE'} eq 'fritzdsl' && (!(-e "/lib/modules/$kernel/misc/fcdslusb.o.gz"))) {
159 $errormessage = $Lang::tr{'no fritzdsl driver'};
160 $drivererror = 1;
161 goto ERROR; }
162
163 if( $pppsettings{'USEIBOD'} eq 'on' && $pppsettings{'COMPORT'} eq 'isdn1') {
164 $errormessage = $Lang::tr{'ibod for dual isdn only'};
165 goto ERROR; }
166
167 if ($pppsettings{'TYPE'} eq 'pptp') {
168 $errormessage = '';
169 if ($pppsettings{'METHOD'} eq 'STATIC') {
170 if (! &General::validip($pppsettings{'ROUTERIP'})) {
171 $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'};
172 }
173 } else {
174 if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) {
175 $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'};
176 }
177 }
178 if ($errormessage ne '') {goto ERROR; }
179 }
180
181 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/) {
182 if ( ($pppsettings{'VPI'} eq '') || ($pppsettings{'VCI'} eq '') ) {
183 $errormessage = $Lang::tr{'invalid vpi vpci'};
184 goto ERROR; }
185 if ( (!($pppsettings{'VPI'} =~ /^\d+$/)) || (!($pppsettings{'VCI'} =~ /^\d+$/)) ) {
186 $errormessage = $Lang::tr{'invalid vpi vpci'};
187 goto ERROR; }
188 if (($pppsettings{'VPI'} eq '0') && ($pppsettings{'VCI'} eq '0')) {
189 $errormessage = $Lang::tr{'invalid vpi vpci'};
190 goto ERROR; }
191 if ( $pppsettings{'PROTOCOL'} eq '' ) {
192 $errormessage = $Lang::tr{'invalid input'};
193 goto ERROR; }
194 }
195
196 if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \
197 ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) {
198 $errormessage = $Lang::tr{'invalid input'};
199 goto ERROR; }
200
201 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) {
202 if ($pppsettings{'DHCP_HOSTNAME'} ne '') {
203 if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) {
204 $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; }
205 }
206 }
207
208 if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) {
209 $errormessage = '';
210 if (! &General::validip($pppsettings{'IP'})) {
211 $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; }
212 if (! &General::validip($pppsettings{'GATEWAY'})) {
213 $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; }
214 if (! &General::validmask($pppsettings{'NETMASK'})) {
215 $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; }
216 if ($pppsettings{'BROADCAST'} ne '') {
217 if (! &General::validip($pppsettings{'BROADCAST'})) {
218 $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; }
219 }
220 if( $pppsettings{'DNS'} eq 'Automatic') {
221 $errormessage = $Lang::tr{'invalid input'}; }
222 if ($errormessage ne '') {goto ERROR; }
223 }
224
225 if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \
226 $pppsettings{'RECONNECTION'} eq 'dialondemand' ) {
227 $errormessage = $Lang::tr{'invalid input'};
228 goto ERROR; }
229
230 if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) {
231 $errormessage = $Lang::tr{'dod not compatible with ddns'};
232 goto ERROR; }
233
234 if ( ($pppsettings{'TYPE'} =~ /^(bewanadsl)$/) && $pppsettings{'MODEM'} eq '') {
235 $errormessage = $Lang::tr{'no modem selected'};
236 goto ERROR; }
237
238 if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
239 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; }
240 if( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
241 $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; }
242 delete $pppsettings{'ENCAP_RFC1483'};
243 delete $pppsettings{'ENCAP_RFC2364'};
244
245 ERROR:
246 if ($errormessage) {
247 $pppsettings{'VALID'} = 'no'; }
248 else {
249 $pppsettings{'VALID'} = 'yes'; }
250
251 # write cgi vars to the file.
252 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
253 \%pppsettings);
254
255 # make link and write secret file.
256 &updatesettings();
257 &writesecrets();
258
259 &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}");
260 if ($drivererror) {
261 my $refresh = "<META HTTP-EQUIV='refresh' CONTENT='1; URL=/cgi-bin/upload.cgi'>";
262 my $title = $Lang::tr{'upload'};
263 &Header::openpage($title, 0, $refresh);
264 }
265 }
266 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'select'})
267 {
268 my $profile = $pppsettings{'PROFILE'};
269 %temppppsettings = ();
270 $temppppsettings{'PROFILE'} = '';
271 &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
272 \%temppppsettings);
273
274 # make link.
275 &updatesettings();
276
277 # read in the new params "early" so we can write secrets.
278 %pppsettings = ();
279 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
280 $pppsettings{'PROFILE'} = $profile;
281 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
282 \%pppsettings);
283
284 &writesecrets();
285
286 &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}");
287 }
288 elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'})
289 {
290 &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}");
291
292 my $profile = $pppsettings{'PROFILE'};
293 truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0);
294
295 %temppppsettings = ();
296 $temppppsettings{'PROFILE'} = '';
297 &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
298 \%temppppsettings);
299
300 # make link.
301 &updatesettings();
302
303 # read in the new params "early" so we can write secrets.
304 %pppsettings = ();
305 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
306 $pppsettings{'PROFILE'} = $profile;
307 &initprofile;
308 &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
309 \%pppsettings);
310 }
311 else
312 {
313 # read in the current vars
314 %pppsettings = ();
315 $pppsettings{'VALID'} = '';
316 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
317 }
318
319 # read in the profile names into @profilenames.
320 my $c=0;
321 for ($c = 1; $c <= $maxprofiles; $c++)
322 {
323 %temppppsettings = ();
324 $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty profile'};
325 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
326 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
327 }
328
329 if ($pppsettings{'VALID'} eq '')
330 {
331 if ($pppsettings{'PROFILE'} eq '') {
332 $pppsettings{'PROFILE'} = '1';
333 &initprofile();
334 }
335 }
336 for ($c = 1; $c <= $maxprofiles; $c++) {
337 $selected{'PROFILE'}{$c} = ''; }
338 $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
339 for ($c = 1; $c <= $maxprofiles; $c++) {
340 $selected{'BACKUPPROFILE'}{$c} = ''; }
341 $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'";
342
343 $selected{'TYPE'}{'modem'} = '';
344 $selected{'TYPE'}{'serial'} = '';
345 $selected{'TYPE'}{'isdn'} = '';
346 $selected{'TYPE'}{'pppoe'} = '';
347 $selected{'TYPE'}{'pptp'} = '';
348 $selected{'TYPE'}{'alcatelusb'} = '';
349 $selected{'TYPE'}{'alcatelusbk'} = '';
350 $selected{'TYPE'}{'pulsardsl'} = '';
351 $selected{'TYPE'}{'eciadsl'} = '';
352 $selected{'TYPE'}{'fritzdsl'} = '';
353 $selected{'TYPE'}{'bewanadsl'} = '';
354 $selected{'TYPE'}{'eagleusbadsl'} = '';
355 $selected{'TYPE'}{'conexantusbadsl'} = '';
356 $selected{'TYPE'}{'conexantpciadsl'} = '';
357 $selected{'TYPE'}{'amedynusbadsl'} = '';
358 $selected{'TYPE'}{'3cp4218usbadsl'} = '';
359 $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'";
360
361 $checked{'DEBUG'}{'off'} = '';
362 $checked{'DEBUG'}{'on'} = '';
363 $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'";
364
365 $selected{'COMPORT'}{'ttyS0'} = '';
366 $selected{'COMPORT'}{'ttyS1'} = '';
367 $selected{'COMPORT'}{'ttyS2'} = '';
368 $selected{'COMPORT'}{'ttyS3'} = '';
369 $selected{'COMPORT'}{'ttyS4'} = '';
370 $selected{'COMPORT'}{'usb/ttyACM0'} = '';
371 $selected{'COMPORT'}{'usb/ttyACM1'} = '';
372 $selected{'COMPORT'}{'usb/ttyACM2'} = '';
373 $selected{'COMPORT'}{'usb/ttyACM3'} = '';
374 $selected{'COMPORT'}{'isdn1'} = '';
375 $selected{'COMPORT'}{'isdn2'} = '';
376 $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'";
377
378 $selected{'DTERATE'}{'9600'} = '';
379 $selected{'DTERATE'}{'19200'} = '';
380 $selected{'DTERATE'}{'38400'} = '';
381 $selected{'DTERATE'}{'57600'} = '';
382 $selected{'DTERATE'}{'115200'} = '';
383 $selected{'DTERATE'}{'230400'} = '';
384 $selected{'DTERATE'}{'460800'} = '';
385 $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'";
386
387 $checked{'SPEAKER'}{'off'} = '';
388 $checked{'SPEAKER'}{'on'} = '';
389 $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'";
390
391 $selected{'DIALMODE'}{'T'} = '';
392 $selected{'DIALMODE'}{'P'} = '';
393 $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'";
394
395 $checked{'RECONNECTION'}{'manual'} = '';
396 $checked{'RECONNECTION'}{'persistent'} = '';
397 $checked{'RECONNECTION'}{'dialondemand'} = '';
398 $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'";
399
400 $checked{'DIALONDEMANDDNS'}{'off'} = '';
401 $checked{'DIALONDEMANDDNS'}{'on'} = '';
402 $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'";
403
404 $checked{'AUTOCONNECT'}{'off'} = '';
405 $checked{'AUTOCONNECT'}{'on'} = '';
406 $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'";
407
408 $checked{'SENDCR'}{'off'} = '';
409 $checked{'SENDCR'}{'on'} = '';
410 $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'";
411 $checked{'USEDOV'}{'off'} = '';
412 $checked{'USEDOV'}{'on'} = '';
413 $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'";
414 $checked{'USEIBOD'}{'off'} = '';
415 $checked{'USEIBOD'}{'on'} = '';
416 $checked{'USEIBOD'}{$pppsettings{'USEIBOD'}} = "checked='checked'";
417
418 $checked{'MODEM'}{'PCIST'} = '';
419 $checked{'MODEM'}{'USB'} = '';
420 $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'";
421
422 $selected{'LINE'}{'WO'} = '';
423 $selected{'LINE'}{'ES'} = '';
424 $selected{'LINE'}{'ES03'} = '';
425 $selected{'LINE'}{'FR'} = '';
426 $selected{'LINE'}{'FR04'} = '';
427 $selected{'LINE'}{'FR10'} = '';
428 $selected{'LINE'}{'IT'} = '';
429 $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'";
430
431 $checked{'MODULATION'}{'GDMT'} = '';
432 $checked{'MODULATION'}{'ANSI'} = '';
433 $checked{'MODULATION'}{'GLITE'} = '';
434 $checked{'MODULATION'}{'AUTO'} = '';
435 $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'";
436
437 $checked{'PROTOCOL'}{'RFC1483'} = '';
438 $checked{'PROTOCOL'}{'RFC2364'} = '';
439 $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'";
440
441 $selected{'ENCAP'}{'0'} = '';
442 $selected{'ENCAP'}{'1'} = '';
443 $selected{'ENCAP'}{'2'} = '';
444 $selected{'ENCAP'}{'3'} = '';
445 $selected{'ENCAP'}{'4'} = '';
446 $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'";
447 $checked{'METHOD'}{'STATIC'} = '';
448 $checked{'METHOD'}{'PPPOE'} = '';
449 $checked{'METHOD'}{'PPPOE_PLUGIN'} = '';
450 $checked{'METHOD'}{'DHCP'} = '';
451 $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'";
452
453 $selected{'AUTH'}{'pap-or-chap'} = '';
454 $selected{'AUTH'}{'pap'} = '';
455 $selected{'AUTH'}{'chap'} = '';
456 $selected{'AUTH'}{'standard-login-script'} = '';
457 $selected{'AUTH'}{'demon-login-script'} = '';
458 $selected{'AUTH'}{'other-login-script'} = '';
459 $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'";
460
461 $checked{'DNS'}{'Automatic'} = '';
462 $checked{'DNS'}{'Manual'} = '';
463 $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'";
464
465 &Header::openpage($Lang::tr{'ppp setup'}, 1, '');
466
467 &Header::openbigbox('100%', 'left', '', $errormessage);
468
469 if ($errormessage) {
470 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
471 print "<CLASS name='base'>$errormessage\n";
472 print "&nbsp;</CLASS>\n";
473 &Header::closebox();
474 }
475
476
477 ###
478 ### Box for selecting profile
479 ###
480 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
481 &Header::openbox('100%', 'left', $Lang::tr{'profiles'});
482 print <<END
483 <table width='100%'>
484 <tr>
485 <td align='right'>$Lang::tr{'profile'}:</td>
486 <td>
487 <select name='PROFILE'>
488 END
489 ;
490 for ($c = 1; $c <= $maxprofiles; $c++)
491 {
492 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
493 }
494 print <<END
495 </select></td>
496 <td><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td>
497 <td><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
498 <td width='30%'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td>
499 </tr>
500 </table>
501 END
502 ;
503 &Header::closebox();
504 &Header::openbox('100%', 'left', $Lang::tr{'connection'}.':');
505 print <<END
506 <table width='100%'>
507 <tr>
508 <td align='right'>$Lang::tr{'interface'}:</td>
509 <td>
510 <select name='TYPE'>
511 <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option>
512 <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option>
513 END
514 ;
515 if ($isdnsettings{'ENABLED'} eq 'on') {
516 print "\t<option value='isdn' $selected{'TYPE'}{'isdn'}>$Lang::tr{'isdn'}</option>\n";
517 }
518 if ($netsettings{'RED_TYPE'} eq 'PPPOE') {
519 print "\t<option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>\n";
520 }
521 if ($netsettings{'RED_TYPE'} eq 'PPTP') {
522 print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n";
523 }
524 if (-f "/proc/bus/usb/devices") {
525 print <<END
526 <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option>
527 <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option>
528 <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option>
529 <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option>
530 <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option>
531 <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option>
532 <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option>
533 END
534 ;
535 }
536 print <<END
537 <option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>
538 <option value='pulsardsl' $selected{'TYPE'}{'pulsardsl'}>Pulsar ADSL</option>
539 <option value='bewanadsl' $selected{'TYPE'}{'bewanadsl'}>Bewan ADSL PCI st/USB st</option>
540 <option value='conexantpciadsl' $selected{'TYPE'}{'conexantpciadsl'}>Conexant PCI ADSL</option>
541 </select></td>
542 <td width='50%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td>
543 </tr>
544 <tr>
545 <td align='right'>USB:</td>
546 END
547 ;
548 if (-f "/proc/bus/usb/devices") {
549 my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`;
550 if ($usb eq '') {
551 print "\t<td>$Lang::tr{'not running'}</td></tr>\n";
552 } else {
553 print "\t<td>$usb</td></tr>\n";
554 }
555 }
556
557 if ($pppsettings{'TYPE'}) {
558 print "</table><table width='100%'>";
559 if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/) {
560 print <<END
561 <tr>
562 <td align='right'>$Lang::tr{'interface'}:</td>
563 <td><select name='COMPORT'>
564 END
565 ;
566 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
567 print <<END
568 <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>$Lang::tr{'modem on com1'}</option>
569 <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>$Lang::tr{'modem on com2'}</option>
570 <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>$Lang::tr{'modem on com3'}</option>
571 <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>$Lang::tr{'modem on com4'}</option>
572 <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>$Lang::tr{'modem on com5'}</option>
573 <option value='usb/ttyACM0' $selected{'COMPORT'}{'usb/ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option>
574 <option value='usb/ttyACM1' $selected{'COMPORT'}{'usb/ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option>
575 <option value='usb/ttyACM2' $selected{'COMPORT'}{'usb/ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option>
576 <option value='usb/ttyACM3' $selected{'COMPORT'}{'usb/ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option>
577 </select></td>
578 END
579 ;
580 } elsif ($pppsettings{'TYPE'} eq 'isdn') {
581 print <<END
582 <option value='isdn1' $selected{'COMPORT'}{'isdn1'}>$Lang::tr{'isdn1'}</option>
583 <option value='isdn2' $selected{'COMPORT'}{'isdn2'}>$Lang::tr{'isdn2'}</option>
584 </select></td>
585 END
586 ;
587 }
588 if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) {
589 print <<END
590 <td align='right'>$Lang::tr{'computer to modem rate'}</td>
591 <td><select name='DTERATE'>
592 <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option>
593 <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option>
594 <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option>
595 <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option>
596 <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option>
597 <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option>
598 <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option>
599 </select></td>
600 </tr>
601 END
602 ;
603 } else {
604 print "<td colspan='2'>&nbsp;</td></tr>\n";
605 }
606 if ($pppsettings{'TYPE'} =~ /^(modem|isdn)$/ ) {
607 print "<tr><td align='right'>$Lang::tr{'number'}</td>\n";
608 print "<td><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}' /></td>\n";
609 if ($pppsettings{'TYPE'} eq 'modem' ) {
610 print "<td align='right'>$Lang::tr{'modem speaker on'}</td>\n";
611 print "<td><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n";
612 } else {
613 print "<td colspan='2'>&nbsp;</td></tr>\n";
614 }
615 }
616 }
617 if ($pppsettings{'TYPE'} eq 'modem') {
618 print <<END
619 <tr>
620 <td align='right'>$Lang::tr{'dialing mode'}</td>
621 <td><select name='DIALMODE'>
622 <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option>
623 <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option>
624 </select></td>
625 <td align='right'>$Lang::tr{'send cr'}</td>
626 <td><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td>
627 </tr>
628 END
629 ;
630 }
631
632 print <<END
633 <tr>
634 <td align='right'>$Lang::tr{'idle timeout'}</td>
635 <td><input type='text' size='5' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
636 <td colspan='2'>&nbsp;</td>
637 </tr>
638 END
639 ;
640 if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) {
641 $pppsettings{'AUTOCONNECT'} = 'on';
642 print "<tr><td align='right'>$Lang::tr{'connect on ipfire restart'}</td>\n";
643 print "<td><input type='checkbox' disabled='disabled' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'} /></td>\n";
644 } else {
645 print "<tr><td align='right'>$Lang::tr{'connect on ipfire restart'}</td>\n";
646 print "<td><input type='checkbox' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'} /></td>\n";
647 }
648 print <<END
649 <td align='right'>$Lang::tr{'connection debugging'}:</td>
650 <td><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td>
651 </tr>
652 <tr>
653 <td colspan='5'><br /><hr /><b>$Lang::tr{'reconnection'}:</b></td>
654 </tr>
655 <tr>
656 <td colspan='4'>
657 <input type='radio' name='RECONNECTION' value='manual' $checked{'RECONNECTION'}{'manual'} />$Lang::tr{'manual'}</td>
658 </tr>
659 END
660 ;
661 if ($pppsettings{'TYPE'} ne 'isdn') {
662 print <<END
663 <tr>
664 <td>
665 <input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'} />$Lang::tr{'persistent'}</td>
666 <td colspan='2' align='right'>$Lang::tr{'backupprofile'}:</td>
667 <td>
668 <select name='BACKUPPROFILE'>
669 END
670 ;
671 for ($c = 1; $c <= $maxprofiles; $c++) {
672 print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
673 }
674 print <<END
675 </select></td>
676 </tr>
677 END
678 ;
679 }
680 print <<END
681 <tr>
682 <td>
683 <input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'} />$Lang::tr{'dod'}</td>
684 <td colspan='2' align='right'>$Lang::tr{'dod for dns'}</td>
685 <td><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td>
686
687 </tr>
688 <tr>
689 <td align='right'>$Lang::tr{'holdoff'}:</td>
690 <td><input type='text' size='5' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td>
691 <td align='right'>$Lang::tr{'maximum retries'}</td>
692 <td><input type='text' size='5' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td>
693 </tr>
694 END
695 ;
696
697 if ($pppsettings{'TYPE'} eq 'isdn') {
698 print <<END
699 </table>
700 <table width='100%'>
701 <tr>
702 <td colspan='5'><br /><hr /><b>$Lang::tr{'isdn settings'}</b></td>
703 </tr>
704 <tr>
705 <td align='right'>$Lang::tr{'use ibod'}</td>
706 <td><input type='checkbox' name='USEIBOD' $checked{'USEIBOD'}{'on'} /></td>
707 <td align='right'>$Lang::tr{'use dov'}</td>
708 <td><input type='checkbox' name='USEDOV' $checked{'USEDOV'}{'on'} /></td>
709 </tr>
710 END
711 ;
712 }
713
714 if ($pppsettings{'TYPE'} eq 'pptp')
715 {
716 print <<END
717 </table>
718
719 <table width='100%'>
720 <tr>
721 <td colspan='5'><br /><hr /><b>$Lang::tr{'pptp settings'}</b></td>
722 </tr>
723 <tr>
724 <td colspan='2' align='right'>$Lang::tr{'phonebook entry'}</td>
725 <td><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td>
726 </tr>
727 <tr>
728 <td><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
729 <td align='right'>$Lang::tr{'router ip'}</td>
730 <td><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td>
731 </tr>
732 <tr>
733 <td>&nbsp;</td>
734 <td colspan='3'><hr /></td>
735 </tr>
736 <tr>
737 <td><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
738 <td align='right'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
739 <td><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
740 </tr>
741 END
742 ;
743 }
744 if ($pppsettings{'TYPE'} eq 'pppoe')
745 {
746 print <<END
747 </table>
748 <table width='100%'>
749 <tr>
750 <td colspan='5'><br /><hr /><b>$Lang::tr{'pppoe settings'}</b></td>
751 </tr>
752 END
753 ;
754 }
755 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
756 {
757
758 print <<END
759 </table>
760 <table width='100%'>
761 <tr>
762 <td colspan='5'><br /><hr /><b>$Lang::tr{'adsl settings'}:</b></td>
763 </tr>
764 <tr>
765 <td nowrap='nowrap' align='right'>$Lang::tr{'vpi number'}</td>
766 <td><input type='text' size='5' name='VPI' value='$pppsettings{'VPI'}' /></td>
767 <td align='right'>$Lang::tr{'vci number'}</td>
768 <td colspan='2'><input type='text' size='5' name='VCI' value='$pppsettings{'VCI'}' /></td>
769 </tr>
770 <tr>
771 <td>&nbsp;</td>
772 <td colspan='4'><hr /></td>
773 </tr>
774 END
775 ;
776 }
777 if ($pppsettings{'TYPE'} eq 'bewanadsl')
778 {
779 print <<END
780 <tr>
781 <td align='right'>$Lang::tr{'modem'}:</td>
782 <td colspan='2' nowrap='nowrap'>
783 <input type='radio' name='MODEM' value='PCIST' $checked{'MODEM'}{'PCIST'} />Bewan ADSL PCI st</td>
784 <td colspan='2'><input type='radio' name='MODEM' value='USB' $checked{'MODEM'}{'USB'} />Bewan ADSL USB st</td>
785 </tr>
786 <tr>
787 <td>&nbsp;</td>
788 <td colspan='4'><hr /></td>
789 </tr>
790 END
791 ;
792 }
793 if ($pppsettings{'TYPE'} =~ /^(3cp4218usbadsl|bewanadsl)$/)
794 {
795 print <<END
796 <tr>
797 <td align='right'>$Lang::tr{'modulation'}:</td>
798 <td><input type='radio' name='MODULATION' value='AUTO' $checked{'MODULATION'}{'AUTO'} />$Lang::tr{'automatic'}</td>
799 <td><input type='radio' name='MODULATION' value='ANSI' $checked{'MODULATION'}{'ANSI'} />ANSI T1.483</td>
800 <td><input type='radio' name='MODULATION' value='GDMT' $checked{'MODULATION'}{'GDMT'} />G.DMT</td>
801 <td><input type='radio' name='MODULATION' value='GLITE' $checked{'MODULATION'}{'GLITE'} />G.Lite</td>
802 </tr>
803 <tr>
804 <td>&nbsp;</td>
805 <td colspan='4'><hr /></td>
806 </tr>
807 END
808 ;
809 }
810
811 if ($pppsettings{'TYPE'} eq 'eagleusbadsl')
812 {
813 print <<END
814 <tr>
815 <td align='right'>$Lang::tr{'country'}:</td>
816 <td>
817 <select name='LINE'>
818 <option value='WO' $selected{'LINE'}{'WO'}>$Lang::tr{'other countries'}</option>
819 <option value='ES' $selected{'LINE'}{'ES'}>ESPANA</option>
820 <option value='ES03' $selected{'LINE'}{'ES03'}>ESPANA03</option>
821 <option value='FR' $selected{'LINE'}{'FR'}>FRANCE</option>
822 <option value='FR04' $selected{'LINE'}{'FR04'}>FRANCE04</option>
823 <option value='FR10' $selected{'LINE'}{'FR04'}>FRANCE10</option>
824 <option value='IT' $selected{'LINE'}{'IT'}>ITALIA</option>
825 </select></td>
826 </tr>
827 <tr>
828 <td>&nbsp;</td>
829 <td colspan='4'><hr /></td>
830 </tr>
831 END
832 ;
833 }
834 if ($pppsettings{'TYPE'} eq 'eciadsl')
835 {
836 print <<END
837 <tr>
838 <td align='right'>$Lang::tr{'modem'}:</td>
839 <td colspan='5'>
840 <select name='MODEM'>
841 END
842 ;
843 open (MODEMS, "/etc/eciadsl/modems.db") or die 'Unable to open modems database.';
844 while (my $line = <MODEMS>) {
845 $line =~ /^([\S\ ]+).*$/;
846 my $modem = $1;
847 $modem =~ s/^\s*(.*?)\s*$/$1/;
848 print "<option value='$modem'";
849 if ($pppsettings{'MODEM'} =~ /$modem/) { print " selected";}
850 print ">$modem</option>\n";
851 }
852 close (MODEMS);
853
854 print <<END
855 </select>
856 </td>
857 </tr>
858 <tr>
859 <td>&nbsp;</td>
860 <td colspan='4'><hr /></td>
861 </tr>
862 END
863 ;
864 }
865 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
866 {
867 print <<END
868 <tr>
869 <td valign='top' align='right'>$Lang::tr{'protocol'}:</td>
870 <td nowrap='nowrap'>
871 <input type='radio' name='PROTOCOL' value='RFC2364' $checked{'PROTOCOL'}{'RFC2364'} />RFC2364 PPPoA</td>
872 END
873 ;
874 }
875 if ($pppsettings{'TYPE'} eq 'alcatelusb')
876 {
877 print "<td colspan=3>&nbsp;</td></tr>";
878 }
879
880 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/)
881 {
882 print <<END
883 <td align='right'>$Lang::tr{'encapsulation'}:</td>
884 <td colspan='2' width='30%'>
885 <select name='ENCAP_RFC2364'>
886 <option value='0' $selected{'ENCAP'}{'0'}>VCmux</option>
887 <option value='1' $selected{'ENCAP'}{'1'}>LLC</option>
888 </select>
889 </td>
890 </tr>
891 END
892 ;
893 }
894 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|fritzdsl|bewanadsl|eagleusbadsl)$/)
895 {
896 print <<END
897 <tr>
898 <td>&nbsp;</td>
899 <td colspan='4'><hr /></td>
900 </tr>
901 <tr>
902 <td>&nbsp;</td>
903 <td valign='top'>
904 <input type='radio' name='PROTOCOL' value='RFC1483' $checked{'PROTOCOL'}{'RFC1483'} />RFC 1483 / 2684</td>
905 END
906 ;
907 }
908 if ($pppsettings{'TYPE'} eq 'alcatelusb')
909 {
910 print "<td colspan='3'>&nbsp;</td></tr>";
911 }
912
913 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl|fritzdsl)$/)
914 {
915 if ($pppsettings{'TYPE'} ne 'fritzdsl')
916 {
917 print <<END
918 <td align='right'>$Lang::tr{'encapsulation'}:</td>
919 <td colspan='2'>
920 <select name='ENCAP_RFC1483'>
921 <option value='0' $selected{'ENCAP'}{'0'}>BRIDGED_ETH_LLC</option>
922 <option value='1' $selected{'ENCAP'}{'1'}>BRIDGED_ETH_VC</option>
923 <option value='2' $selected{'ENCAP'}{'2'}>ROUTED_IP_LLC</option>
924 <option value='3' $selected{'ENCAP'}{'3'}>ROUTED_IP_VC</option>
925 </select>
926 </td>
927 </tr>
928 <tr>
929 <td colspan='2'>&nbsp;</td>
930 <td colspan='3'><hr /></td>
931 </tr>
932 END
933 ;
934 } else {
935 print <<END
936 <td colspan='4'>PPPoE</td>
937 </tr>
938 END
939 ;
940 }
941 }
942 if ($pppsettings{'TYPE'} =~ /^(pppoe|alcatelusb|alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/)
943 {
944 print <<END
945 <tr>
946 <td>&nbsp;</td>
947 <td>&nbsp;</td>
948 <td><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td>
949 <td align='right'>$Lang::tr{'service name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
950 <td><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td>
951 </tr>
952 <tr>
953 <td>&nbsp;</td>
954 <td>&nbsp;</td>
955 <td><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td>
956 <td align='right'>$Lang::tr{'concentrator name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
957 <td><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td>
958 </tr>
959
960 END
961 ;
962 }
963 if ($pppsettings{'TYPE'} =~ /^(alcatelusbk|amedynusbadsl|conexantusbadsl|conexantpciadsl|3cp4218usbadsl|pulsardsl|eciadsl|bewanadsl|eagleusbadsl)$/)
964 {
965 print <<END
966 <tr>
967 <td colspan='2'>&nbsp;</td>
968 <td colspan='3'><hr /></td>
969 </tr>
970 <tr>
971 <td>&nbsp;</td>
972 <td>&nbsp;</td>
973 <td rowspan='4'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td>
974 <td align='right'>$Lang::tr{'static ip'}:</td>
975 <td><input type='text' size='16' name='IP' value='$pppsettings{'IP'}' /></td>
976 </tr>
977 <tr>
978 <td>&nbsp;</td>
979 <td>&nbsp;</td>
980 <td align='right'>$Lang::tr{'gateway ip'}:</td>
981 <td><input type='text' size='16' name='GATEWAY' value='$pppsettings{'GATEWAY'}' /></td>
982 </tr>
983 <tr>
984 <td>&nbsp;</td>
985 <td>&nbsp;</td>
986 <td align='right'>$Lang::tr{'netmask'}:</td>
987 <td><input type='text' size='16' name='NETMASK' value='$pppsettings{'NETMASK'}' /></td>
988 </tr>
989 <tr>
990 <td>&nbsp;</td>
991 <td>&nbsp;</td>
992 <td align='right' nowrap='nowrap'>$Lang::tr{'broadcast'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
993 <td><input type='text' size='16' name='BROADCAST' value='$pppsettings{'BROADCAST'}' /></td>
994 </tr>
995 END
996 ;
997 if ($pppsettings{'TYPE'} =~ /^(eciadsl|eagleusbadsl)$/)
998 {
999 print <<END
1000 <tr>
1001 <td colspan='2'>&nbsp;</td>
1002 <td colspan='3'><hr /></td>
1003 </tr>
1004 <tr>
1005 <td>&nbsp;</td>
1006 <td>&nbsp;</td>
1007 <td><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td>
1008 <td align='right'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1009 <td><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td>
1010 </tr>
1011 END
1012 ;
1013 }
1014 }
1015 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk|eciadsl|fritzdsl)$/) {
1016 print "<tr><td>&nbsp;</td><td colspan='4'><hr /></td></tr>";
1017 }
1018 if ($pppsettings{'TYPE'} =~ /^(alcatelusb|alcatelusbk)$/) {
1019 my $speedtouch = &Header::speedtouchversion;
1020 if (($speedtouch >= 0) && ($speedtouch <=4)) {
1021 my $modem;
1022 if ($speedtouch ==4) { $modem='v4_b'; } else { $modem='v0123'; }
1023 print "<tr><td align='right'>$Lang::tr{'firmware'}:</td>";
1024 if (-e "${General::swroot}/alcatelusb/firmware.$modem.bin") {
1025 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1026 } else {
1027 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1028 }
1029 } else {
1030 print "<tr><td colspan='5'>$Lang::tr{'unknown'} Rev $speedtouch</td></tr>";
1031 }
1032 } elsif ($pppsettings{'TYPE'} eq 'eciadsl') {
1033 print "<tr><td align='right'>$Lang::tr{'driver'}:</td>";
1034 if (-e "${General::swroot}/eciadsl/synch.bin") {
1035 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1036 } else {
1037 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n"; }
1038 } elsif ($pppsettings{'TYPE'} eq 'fritzdsl') {
1039 print "<tr><td align='right'>$Lang::tr{'driver'}:</td>";
1040 if (-e "/lib/modules/$kernel/misc/fcdslusb.o.gz") {
1041 print "<td>$Lang::tr{'present'}</td><td colspan='3'>&nbsp;</td></tr>\n";
1042 } else {
1043 print "<td>$Lang::tr{'not present'}</td><td colspan='3'>&nbsp;</td></tr>\n"; }
1044 }
1045 print <<END
1046 </table>
1047 <table width='100%'>
1048 <tr>
1049 <td colspan='5'><br /><hr /><b>$Lang::tr{'authentication'}</b></td>
1050 </tr>
1051 <tr>
1052 <td align='right'>$Lang::tr{'username'}</td>
1053 <td><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
1054 <td align='right'>$Lang::tr{'password'}</td>
1055 <td><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td>
1056 </tr>
1057 <tr>
1058 <td align='right'>$Lang::tr{'method'}</td>
1059 <td><select name='AUTH'>
1060 <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option>
1061 <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option>
1062 <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option>
1063 END
1064 ;
1065 if ($pppsettings{'TYPE'} eq 'modem') {
1066 print <<END
1067 <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option>
1068 <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option>
1069 <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option>
1070 END
1071 ;
1072 }
1073 print <<END
1074 </select></td>
1075 <td align='right'>$Lang::tr{'script name'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1076 <td nowrap='nowrap'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td>
1077 </tr>
1078 </table>
1079 <table width='100%'>
1080 <tr>
1081 <td colspan='5'><br /><hr /><b>DNS:</b></td>
1082 </tr>
1083 <tr>
1084 <td colspan='5'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td>
1085 </tr>
1086 <tr>
1087 <td><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td>
1088 <td align='right'>$Lang::tr{'primary dns'}</td>
1089 <td><input type='text' size='16' name='DNS1' value='$pppsettings{'DNS1'}' /></td>
1090 <td align='right'>$Lang::tr{'secondary dns'}</td>
1091 <td><input type='text' size='16' name='DNS2' value='$pppsettings{'DNS2'}' /></td>
1092 </tr>
1093 <tr>
1094 <td colspan='5'><br /><hr /></td>
1095 </tr>
1096 <tr>
1097 <td>&nbsp;</td>
1098 <td align='right'>$Lang::tr{'profile name'}</td>
1099 <td><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}' /></td>
1100 <td><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
1101 </tr>
1102 <tr>
1103 <td colspan='5'><br /><hr /></td>
1104 </tr>
1105 <tr>
1106 <td align='right'>$Lang::tr{'legend'}:</td>
1107 <td><img src='/blob.gif' alt='*' />&nbsp;$Lang::tr{'this field may be blank'}</td>
1108 </tr>
1109 </table>
1110 END
1111 ;
1112 &Header::closebox();
1113 }
1114
1115 print "</form>\n";
1116
1117 &Header::closebigbox();
1118
1119 &Header::closepage();
1120
1121 sub updatesettings
1122 {
1123 # make a link from the selected profile to the "default" one.
1124 unlink("${General::swroot}/ppp/settings");
1125 link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}",
1126 "${General::swroot}/ppp/settings");
1127 system ("/bin/touch", "${General::swroot}/ppp/updatesettings");
1128 if ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
1129 # eagle-usb.conf is in backup but link DSPcode.bin can't, so the link is created in rc.eagleusbadsl
1130 open(FILE, ">/${General::swroot}/eagle-usb/eagle-usb.conf") or die "Unable to write eagle-usb.conf file";
1131 flock(FILE, 2);
1132 # decimal to hexa
1133 $modemsettings{'VPI'} = uc(sprintf('%X', $pppsettings{'VPI'}));
1134 $modemsettings{'VCI'} = uc(sprintf('%X', $pppsettings{'VCI'}));
1135 if( $pppsettings{'PROTOCOL'} eq 'RFC1483') {
1136 $modemsettings{'Encapsulation'} =1+$pppsettings{'ENCAP'}
1137 } elsif ( $pppsettings{'PROTOCOL'} eq 'RFC2364') {
1138 $modemsettings{'Encapsulation'} =6-$pppsettings{'ENCAP'}
1139 }
1140 print FILE "<eaglectrl>\n";
1141 print FILE "VPI=$modemsettings{'VPI'}\n";
1142 print FILE "VCI=$modemsettings{'VCI'}\n";
1143 print FILE "Encapsulation=$modemsettings{'Encapsulation'}\n";
1144 print FILE "Linetype=0A\n";
1145 print FILE "RatePollFreq=00000009\n";
1146 print FILE "</eaglectrl>\n";
1147 close FILE;
1148 }
1149 }
1150
1151 sub writesecrets
1152 {
1153 # write secrets file.
1154 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
1155 flock(FILE, 2);
1156 my $username = $pppsettings{'USERNAME'};
1157 my $password = $pppsettings{'PASSWORD'};
1158 print FILE "'$username' * '$password'\n";
1159 chmod 0600, "${General::swroot}/ppp/secrets";
1160 close FILE;
1161 }
1162
1163 sub initprofile
1164 {
1165 $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'};
1166 $pppsettings{'COMPORT'} = 'ttyS0';
1167 $pppsettings{'DTERATE'} = 115200;
1168 $pppsettings{'SPEAKER'} = 'off';
1169 $pppsettings{'RECONNECTION'} = 'manual';
1170 $pppsettings{'DIALONDEMANDDNS'} = 'off';
1171 $pppsettings{'AUTOCONNECT'} = 'off';
1172 $pppsettings{'SENDCR'} = 'off';
1173 $pppsettings{'USEIBOD'} = 'off';
1174 $pppsettings{'USEDOV'} = 'off';
1175 $pppsettings{'MODEM'} = 'PCIST';
1176 $pppsettings{'LINE'} = 'WO';
1177 $pppsettings{'ENCAP'} = '0';
1178 $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1';
1179 $pppsettings{'PROTOCOL'} = 'RFC2364';
1180 $pppsettings{'METHOD'} = 'PPPOE_PLUGIN';
1181 $pppsettings{'DIALMODE'} = 'T';
1182 $pppsettings{'MAXRETRIES'} = 5;
1183 $pppsettings{'HOLDOFF'} = 30;
1184 $pppsettings{'TIMEOUT'} = 15;
1185 $pppsettings{'MODULATION'} = 'AUTO';
1186 $pppsettings{'AUTH'} = 'pap-or-chap';
1187 $pppsettings{'DNS'} = 'Automatic';
1188 $pppsettings{'DEBUG'} = 'off';
1189 $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'};
1190
1191 # Get ISDN settings so we can see if ISDN is enabled or not.
1192 $isdnsettings{'ENABLED'} = 'off';
1193 &General::readhash("${General::swroot}/isdn/settings", \%isdnsettings);
1194
1195 # Get PPPoE settings so we can see if PPPoE is enabled or not.
1196 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
1197
1198 # empty profile partial pre-initialization
1199 if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/) {
1200 $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'});
1201 } elsif ($isdnsettings{'ENABLED'} eq 'on') {
1202 $pppsettings{'TYPE'}='isdn';
1203 } else {
1204 $pppsettings{'TYPE'}='modem';
1205 }
1206 }
1207