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