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