]>
Commit | Line | Data |
---|---|---|
ac1cfefa MT |
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 | # | |
ac1cfefa MT |
9 | |
10 | use strict; | |
11 | ||
12 | # enable only the following on debugging purpose | |
13 | #use warnings; | |
14 | #use CGI::Carp 'fatalsToBrowser'; | |
15 | ||
986e08d9 | 16 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
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 | ||
f2fdd0c1 CS |
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 | ||
ac1cfefa MT |
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 | { | |
285c5bbd | 54 | unless ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn|pppoe|pptp)$/) { |
ac1cfefa MT |
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 | { | |
3e615c37 | 63 | if ($pppsettings{'TYPE'} =~ /^(modem|serial|isdn)$/ && $pppsettings{'COMPORT'} !~ /^(ttyS0|ttyS1|ttyS2|ttyS3|ttyS4|ttyACM0|ttyACM1|ttyACM2|ttyACM3|isdn1|isdn2)$/) { |
ac1cfefa MT |
64 | $errormessage = $Lang::tr{'invalid input'}; |
65 | goto ERROR; } | |
6c666a3b | 66 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ && $pppsettings{'DTERATE'} !~ /^(9600|19200|38400|57600|115200|230400|460800)$/) { |
ac1cfefa MT |
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 | ||
ac1cfefa MT |
133 | if ($pppsettings{'TYPE'} eq 'pptp') { |
134 | $errormessage = ''; | |
135 | if ($pppsettings{'METHOD'} eq 'STATIC') { | |
136 | if (! &General::validip($pppsettings{'ROUTERIP'})) { | |
137 | $errormessage = $Lang::tr{'router ip'}.' '.$Lang::tr{'invalid ip'}; | |
138 | } | |
139 | } else { | |
140 | if (($pppsettings{'DHCP_HOSTNAME'} ne '') && (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) ) { | |
141 | $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.' '.$Lang::tr{'invalid hostname'}; | |
142 | } | |
143 | } | |
144 | if ($errormessage ne '') {goto ERROR; } | |
145 | } | |
146 | ||
ac1cfefa MT |
147 | if ( ($pppsettings{'PROTOCOL'} eq 'RFC1483') && ($pppsettings{'METHOD'} eq '') && \ |
148 | ($pppsettings{'TYPE'} !~ /^(alcatelusb|fritzdsl)$/)) { | |
149 | $errormessage = $Lang::tr{'invalid input'}; | |
150 | goto ERROR; } | |
151 | ||
152 | if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'DHCP')) { | |
153 | if ($pppsettings{'DHCP_HOSTNAME'} ne '') { | |
154 | if (! &General::validfqdn($pppsettings{'DHCP_HOSTNAME'})) { | |
155 | $errormessage = $errormessage.' '.$Lang::tr{'hostname'}.': '.$Lang::tr{'invalid hostname'}; } | |
156 | } | |
157 | } | |
158 | ||
159 | if (($pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} eq 'STATIC')) { | |
160 | $errormessage = ''; | |
161 | if (! &General::validip($pppsettings{'IP'})) { | |
162 | $errormessage = $Lang::tr{'static ip'}.' '.$Lang::tr{'invalid ip'}; } | |
163 | if (! &General::validip($pppsettings{'GATEWAY'})) { | |
164 | $errormessage = $errormessage.' '.$Lang::tr{'gateway ip'}.' '.$Lang::tr{'invalid ip'}; } | |
165 | if (! &General::validmask($pppsettings{'NETMASK'})) { | |
166 | $errormessage = $errormessage.' '.$Lang::tr{'netmask'}.' '.$Lang::tr{'invalid netmask'}; } | |
167 | if ($pppsettings{'BROADCAST'} ne '') { | |
168 | if (! &General::validip($pppsettings{'BROADCAST'})) { | |
169 | $errormessage = $errormessage.' '.$Lang::tr{'broadcast'}.' '.$Lang::tr{'invalid broadcast ip'}; } | |
170 | } | |
171 | if( $pppsettings{'DNS'} eq 'Automatic') { | |
172 | $errormessage = $Lang::tr{'invalid input'}; } | |
173 | if ($errormessage ne '') {goto ERROR; } | |
174 | } | |
175 | ||
176 | if( $pppsettings{'PROTOCOL'} eq 'RFC1483' && $pppsettings{'METHOD'} ne 'PPPOE' && \ | |
177 | $pppsettings{'RECONNECTION'} eq 'dialondemand' ) { | |
178 | $errormessage = $Lang::tr{'invalid input'}; | |
179 | goto ERROR; } | |
180 | ||
181 | if( $pppsettings{'RECONNECTION'} eq 'dialondemand' && `/bin/cat ${General::swroot}/ddns/config` =~ /,on$/m ) { | |
182 | $errormessage = $Lang::tr{'dod not compatible with ddns'}; | |
183 | goto ERROR; } | |
184 | ||
ac1cfefa MT |
185 | if( $pppsettings{'PROTOCOL'} eq 'RFC1483') { |
186 | $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC1483'}; } | |
187 | if( $pppsettings{'PROTOCOL'} eq 'RFC2364') { | |
188 | $pppsettings{'ENCAP'} = $pppsettings{'ENCAP_RFC2364'}; } | |
189 | delete $pppsettings{'ENCAP_RFC1483'}; | |
190 | delete $pppsettings{'ENCAP_RFC2364'}; | |
191 | ||
192 | ERROR: | |
193 | if ($errormessage) { | |
194 | $pppsettings{'VALID'} = 'no'; } | |
195 | else { | |
196 | $pppsettings{'VALID'} = 'yes'; } | |
197 | ||
198 | # write cgi vars to the file. | |
199 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
200 | \%pppsettings); | |
201 | ||
202 | # make link and write secret file. | |
203 | &updatesettings(); | |
204 | &writesecrets(); | |
205 | ||
206 | &General::log("$Lang::tr{'profile saved'} $pppsettings{'PROFILENAME'}"); | |
207 | if ($drivererror) { | |
208 | my $refresh = "<META HTTP-EQUIV='refresh' CONTENT='1; URL=/cgi-bin/upload.cgi'>"; | |
209 | my $title = $Lang::tr{'upload'}; | |
210 | &Header::openpage($title, 0, $refresh); | |
211 | } | |
212 | } | |
213 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'select'}) | |
214 | { | |
215 | my $profile = $pppsettings{'PROFILE'}; | |
216 | %temppppsettings = (); | |
217 | $temppppsettings{'PROFILE'} = ''; | |
218 | &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
219 | \%temppppsettings); | |
220 | ||
221 | # make link. | |
222 | &updatesettings(); | |
223 | ||
224 | # read in the new params "early" so we can write secrets. | |
225 | %pppsettings = (); | |
226 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
227 | $pppsettings{'PROFILE'} = $profile; | |
228 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
229 | \%pppsettings); | |
230 | ||
231 | &writesecrets(); | |
232 | ||
233 | &General::log("$Lang::tr{'profile made current'} $pppsettings{'PROFILENAME'}"); | |
234 | } | |
235 | elsif ($pppsettings{'ACTION'} eq $Lang::tr{'delete'}) | |
236 | { | |
237 | &General::log("$Lang::tr{'profile deleted'} $pppsettings{'PROFILENAME'}"); | |
238 | ||
239 | my $profile = $pppsettings{'PROFILE'}; | |
240 | truncate ("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", 0); | |
241 | ||
242 | %temppppsettings = (); | |
243 | $temppppsettings{'PROFILE'} = ''; | |
244 | &General::readhash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
245 | \%temppppsettings); | |
246 | ||
247 | # make link. | |
248 | &updatesettings(); | |
249 | ||
250 | # read in the new params "early" so we can write secrets. | |
251 | %pppsettings = (); | |
252 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
253 | $pppsettings{'PROFILE'} = $profile; | |
254 | &initprofile; | |
255 | &General::writehash("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
256 | \%pppsettings); | |
257 | } | |
258 | else | |
259 | { | |
260 | # read in the current vars | |
261 | %pppsettings = (); | |
262 | $pppsettings{'VALID'} = ''; | |
263 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
264 | } | |
265 | ||
266 | # read in the profile names into @profilenames. | |
267 | my $c=0; | |
268 | for ($c = 1; $c <= $maxprofiles; $c++) | |
269 | { | |
270 | %temppppsettings = (); | |
6c666a3b | 271 | $temppppsettings{'PROFILENAME'} = $Lang::tr{'empty profile'}; |
ac1cfefa MT |
272 | &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); |
273 | $profilenames[$c] = $temppppsettings{'PROFILENAME'}; | |
274 | } | |
275 | ||
276 | if ($pppsettings{'VALID'} eq '') | |
277 | { | |
278 | if ($pppsettings{'PROFILE'} eq '') { | |
279 | $pppsettings{'PROFILE'} = '1'; | |
280 | &initprofile(); | |
281 | } | |
282 | } | |
283 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
284 | $selected{'PROFILE'}{$c} = ''; } | |
285 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; | |
286 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
287 | $selected{'BACKUPPROFILE'}{$c} = ''; } | |
288 | $selected{'BACKUPPROFILE'}{$pppsettings{'BACKUPPROFILE'}} = "selected='selected'"; | |
289 | ||
290 | $selected{'TYPE'}{'modem'} = ''; | |
291 | $selected{'TYPE'}{'serial'} = ''; | |
ac1cfefa MT |
292 | $selected{'TYPE'}{'pppoe'} = ''; |
293 | $selected{'TYPE'}{'pptp'} = ''; | |
ac1cfefa MT |
294 | $selected{'TYPE'}{$pppsettings{'TYPE'}} = "selected='selected'"; |
295 | ||
296 | $checked{'DEBUG'}{'off'} = ''; | |
297 | $checked{'DEBUG'}{'on'} = ''; | |
298 | $checked{'DEBUG'}{$pppsettings{'DEBUG'}} = "checked='checked'"; | |
299 | ||
300 | $selected{'COMPORT'}{'ttyS0'} = ''; | |
301 | $selected{'COMPORT'}{'ttyS1'} = ''; | |
302 | $selected{'COMPORT'}{'ttyS2'} = ''; | |
303 | $selected{'COMPORT'}{'ttyS3'} = ''; | |
304 | $selected{'COMPORT'}{'ttyS4'} = ''; | |
3e615c37 MT |
305 | $selected{'COMPORT'}{'ttyACM0'} = ''; |
306 | $selected{'COMPORT'}{'ttyACM1'} = ''; | |
307 | $selected{'COMPORT'}{'ttyACM2'} = ''; | |
308 | $selected{'COMPORT'}{'ttyACM3'} = ''; | |
ac1cfefa MT |
309 | $selected{'COMPORT'}{'isdn1'} = ''; |
310 | $selected{'COMPORT'}{'isdn2'} = ''; | |
311 | $selected{'COMPORT'}{$pppsettings{'COMPORT'}} = "selected='selected'"; | |
312 | ||
313 | $selected{'DTERATE'}{'9600'} = ''; | |
314 | $selected{'DTERATE'}{'19200'} = ''; | |
315 | $selected{'DTERATE'}{'38400'} = ''; | |
316 | $selected{'DTERATE'}{'57600'} = ''; | |
317 | $selected{'DTERATE'}{'115200'} = ''; | |
318 | $selected{'DTERATE'}{'230400'} = ''; | |
6c666a3b | 319 | $selected{'DTERATE'}{'460800'} = ''; |
ac1cfefa MT |
320 | $selected{'DTERATE'}{$pppsettings{'DTERATE'}} = "selected='selected'"; |
321 | ||
322 | $checked{'SPEAKER'}{'off'} = ''; | |
323 | $checked{'SPEAKER'}{'on'} = ''; | |
324 | $checked{'SPEAKER'}{$pppsettings{'SPEAKER'}} = "checked='checked'"; | |
325 | ||
326 | $selected{'DIALMODE'}{'T'} = ''; | |
327 | $selected{'DIALMODE'}{'P'} = ''; | |
328 | $selected{'DIALMODE'}{$pppsettings{'DIALMODE'}} = "selected='selected'"; | |
329 | ||
330 | $checked{'RECONNECTION'}{'manual'} = ''; | |
331 | $checked{'RECONNECTION'}{'persistent'} = ''; | |
332 | $checked{'RECONNECTION'}{'dialondemand'} = ''; | |
333 | $checked{'RECONNECTION'}{$pppsettings{'RECONNECTION'}} = "checked='checked'"; | |
334 | ||
335 | $checked{'DIALONDEMANDDNS'}{'off'} = ''; | |
336 | $checked{'DIALONDEMANDDNS'}{'on'} = ''; | |
337 | $checked{'DIALONDEMANDDNS'}{$pppsettings{'DIALONDEMANDDNS'}} = "checked='checked'"; | |
338 | ||
339 | $checked{'AUTOCONNECT'}{'off'} = ''; | |
340 | $checked{'AUTOCONNECT'}{'on'} = ''; | |
341 | $checked{'AUTOCONNECT'}{$pppsettings{'AUTOCONNECT'}} = "checked='checked'"; | |
342 | ||
343 | $checked{'SENDCR'}{'off'} = ''; | |
344 | $checked{'SENDCR'}{'on'} = ''; | |
345 | $checked{'SENDCR'}{$pppsettings{'SENDCR'}} = "checked='checked'"; | |
346 | $checked{'USEDOV'}{'off'} = ''; | |
347 | $checked{'USEDOV'}{'on'} = ''; | |
348 | $checked{'USEDOV'}{$pppsettings{'USEDOV'}} = "checked='checked'"; | |
349 | $checked{'USEIBOD'}{'off'} = ''; | |
350 | $checked{'USEIBOD'}{'on'} = ''; | |
351 | $checked{'USEIBOD'}{$pppsettings{'USEIBOD'}} = "checked='checked'"; | |
352 | ||
353 | $checked{'MODEM'}{'PCIST'} = ''; | |
354 | $checked{'MODEM'}{'USB'} = ''; | |
355 | $checked{'MODEM'}{$pppsettings{'MODEM'}} = "checked='checked'"; | |
356 | ||
357 | $selected{'LINE'}{'WO'} = ''; | |
358 | $selected{'LINE'}{'ES'} = ''; | |
359 | $selected{'LINE'}{'ES03'} = ''; | |
360 | $selected{'LINE'}{'FR'} = ''; | |
361 | $selected{'LINE'}{'FR04'} = ''; | |
362 | $selected{'LINE'}{'FR10'} = ''; | |
363 | $selected{'LINE'}{'IT'} = ''; | |
364 | $selected{'LINE'}{$pppsettings{'LINE'}} = "selected='selected'"; | |
365 | ||
366 | $checked{'MODULATION'}{'GDMT'} = ''; | |
367 | $checked{'MODULATION'}{'ANSI'} = ''; | |
368 | $checked{'MODULATION'}{'GLITE'} = ''; | |
369 | $checked{'MODULATION'}{'AUTO'} = ''; | |
370 | $checked{'MODULATION'}{$pppsettings{'MODULATION'}} = "checked='checked'"; | |
371 | ||
372 | $checked{'PROTOCOL'}{'RFC1483'} = ''; | |
373 | $checked{'PROTOCOL'}{'RFC2364'} = ''; | |
374 | $checked{'PROTOCOL'}{$pppsettings{'PROTOCOL'}} = "checked='checked'"; | |
375 | ||
376 | $selected{'ENCAP'}{'0'} = ''; | |
377 | $selected{'ENCAP'}{'1'} = ''; | |
378 | $selected{'ENCAP'}{'2'} = ''; | |
379 | $selected{'ENCAP'}{'3'} = ''; | |
380 | $selected{'ENCAP'}{'4'} = ''; | |
381 | $selected{'ENCAP'}{$pppsettings{'ENCAP'}} = "selected='selected'"; | |
382 | $checked{'METHOD'}{'STATIC'} = ''; | |
383 | $checked{'METHOD'}{'PPPOE'} = ''; | |
384 | $checked{'METHOD'}{'PPPOE_PLUGIN'} = ''; | |
385 | $checked{'METHOD'}{'DHCP'} = ''; | |
386 | $checked{'METHOD'}{$pppsettings{'METHOD'}} = "checked='checked'"; | |
387 | ||
388 | $selected{'AUTH'}{'pap-or-chap'} = ''; | |
389 | $selected{'AUTH'}{'pap'} = ''; | |
390 | $selected{'AUTH'}{'chap'} = ''; | |
391 | $selected{'AUTH'}{'standard-login-script'} = ''; | |
392 | $selected{'AUTH'}{'demon-login-script'} = ''; | |
393 | $selected{'AUTH'}{'other-login-script'} = ''; | |
394 | $selected{'AUTH'}{$pppsettings{'AUTH'}} = "selected='selected'"; | |
395 | ||
396 | $checked{'DNS'}{'Automatic'} = ''; | |
397 | $checked{'DNS'}{'Manual'} = ''; | |
398 | $checked{'DNS'}{$pppsettings{'DNS'}} = "checked='checked'"; | |
399 | ||
400 | &Header::openpage($Lang::tr{'ppp setup'}, 1, ''); | |
ac1cfefa MT |
401 | &Header::openbigbox('100%', 'left', '', $errormessage); |
402 | ||
403 | if ($errormessage) { | |
330345c2 | 404 | &Header::openbox('100%', 'center', $Lang::tr{'error messages'}); |
ac1cfefa MT |
405 | print "<CLASS name='base'>$errormessage\n"; |
406 | print " </CLASS>\n"; | |
407 | &Header::closebox(); | |
408 | } | |
409 | ||
410 | ||
411 | ### | |
412 | ### Box for selecting profile | |
413 | ### | |
414 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
330345c2 | 415 | &Header::openbox('100%', 'center', $Lang::tr{'profile'}); |
ac1cfefa | 416 | print <<END |
330345c2 | 417 | <table width='95%' cellspacing='0'> |
ac1cfefa | 418 | <tr> |
330345c2 MT |
419 | <td align='left'>$Lang::tr{'profile'}</td> |
420 | <td align='left'> | |
421 | <select name='PROFILE' style="width: 165px"> | |
ac1cfefa MT |
422 | END |
423 | ; | |
424 | for ($c = 1; $c <= $maxprofiles; $c++) | |
425 | { | |
426 | print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
427 | } | |
428 | print <<END | |
429 | </select></td> | |
330345c2 MT |
430 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'select'}' /></td> |
431 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td> | |
432 | <td align='left'><input type='submit' name='ACTION' value='$Lang::tr{'restore'}' /></td> | |
ac1cfefa MT |
433 | </tr> |
434 | </table> | |
330345c2 MT |
435 | <br></br> |
436 | <hr></hr> | |
ac1cfefa MT |
437 | END |
438 | ; | |
330345c2 | 439 | |
ac1cfefa | 440 | &Header::closebox(); |
330345c2 MT |
441 | &Header::openbox('100%', 'center', $Lang::tr{'connection'}); |
442 | ||
ac1cfefa | 443 | print <<END |
330345c2 | 444 | <table width='95%' cellspacing='0'> |
ac1cfefa | 445 | <tr> |
330345c2 MT |
446 | <td width='25%'>$Lang::tr{'interface'}:</td> |
447 | <td width='25%'> | |
448 | <select name='TYPE' style="width: 165px"> | |
ac1cfefa MT |
449 | <option value='modem' $selected{'TYPE'}{'modem'}>$Lang::tr{'modem'}</option> |
450 | <option value='serial' $selected{'TYPE'}{'serial'}>$Lang::tr{'serial'}</option> | |
451 | END | |
452 | ; | |
ac1cfefa MT |
453 | if ($netsettings{'RED_TYPE'} eq 'PPPOE') { |
454 | print "\t<option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>\n"; | |
455 | } | |
456 | if ($netsettings{'RED_TYPE'} eq 'PPTP') { | |
457 | print "\t<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>\n"; | |
458 | } | |
459 | if (-f "/proc/bus/usb/devices") { | |
460 | print <<END | |
461 | <option value='eciadsl' $selected{'TYPE'}{'eciadsl'}>ECI USB ADSL</option> | |
462 | <option value='eagleusbadsl' $selected{'TYPE'}{'eagleusbadsl'}>Eagle USB ADSL (Acer Allied-Telesyn Comtrend D-Link Sagem USR)</option> | |
463 | <option value='conexantusbadsl' $selected{'TYPE'}{'conexantusbadsl'}>Conexant USB(Aetra Amigo Draytek Etec Mac Olitec Vitelcom Zoom)</option> | |
464 | <option value='amedynusbadsl' $selected{'TYPE'}{'amedynusbadsl'}>Zyxel 630-11 / Asus AAM6000UG USB ADSL</option> | |
465 | <option value='3cp4218usbadsl' $selected{'TYPE'}{'3cp4218usbadsl'}>3Com USB AccessRunner</option> | |
466 | <option value='alcatelusb' $selected{'TYPE'}{'alcatelusb'}>Speedtouch USB ADSL user mode driver</option> | |
467 | <option value='alcatelusbk' $selected{'TYPE'}{'alcatelusbk'}>Speedtouch USB ADSL kernel mode driver</option> | |
468 | END | |
469 | ; | |
470 | } | |
8cc01c83 CS |
471 | |
472 | # print "<option value='fritzdsl' $selected{'TYPE'}{'fritzdsl'}>Fritz!DSL</option>"; | |
ac1cfefa | 473 | print <<END |
8cc01c83 | 474 | </select></td> |
330345c2 | 475 | <td colspan='2' width='50%'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}'></td> |
ac1cfefa MT |
476 | </tr> |
477 | <tr> | |
330345c2 | 478 | <td colspan='2' width='50%'>USB:</td> |
ac1cfefa MT |
479 | END |
480 | ; | |
481 | if (-f "/proc/bus/usb/devices") { | |
482 | my $usb=`lsmod | cut -d ' ' -f1 | grep -E "hci"`; | |
483 | if ($usb eq '') { | |
330345c2 | 484 | print "\t<td colspan='2' width='50%'>$Lang::tr{'not running'}</td></tr>\n"; |
ac1cfefa | 485 | } else { |
330345c2 | 486 | print "\t<td colspan='2' width='50%'>$usb</td></tr>\n"; |
ac1cfefa MT |
487 | } |
488 | } | |
489 | ||
490 | if ($pppsettings{'TYPE'}) { | |
330345c2 | 491 | print "<tr><td colspan='4' width='100%'><br></br></td></tr>"; |
285c5bbd | 492 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/) { |
ac1cfefa MT |
493 | print <<END |
494 | <tr> | |
330345c2 MT |
495 | <td colspan='3' width='75%'>$Lang::tr{'interface'}:</td> |
496 | <td width='25%'><select name='COMPORT' style="width: 165px"> | |
ac1cfefa MT |
497 | END |
498 | ; | |
499 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { | |
500 | print <<END | |
501 | <option value='ttyS0' $selected{'COMPORT'}{'ttyS0'}>$Lang::tr{'modem on com1'}</option> | |
502 | <option value='ttyS1' $selected{'COMPORT'}{'ttyS1'}>$Lang::tr{'modem on com2'}</option> | |
503 | <option value='ttyS2' $selected{'COMPORT'}{'ttyS2'}>$Lang::tr{'modem on com3'}</option> | |
504 | <option value='ttyS3' $selected{'COMPORT'}{'ttyS3'}>$Lang::tr{'modem on com4'}</option> | |
505 | <option value='ttyS4' $selected{'COMPORT'}{'ttyS4'}>$Lang::tr{'modem on com5'}</option> | |
a29b2d7b MT |
506 | <option value='ttyACM0' $selected{'COMPORT'}{'ttyACM0'}>$Lang::tr{'usb modem on acm0'}</option> |
507 | <option value='ttyACM1' $selected{'COMPORT'}{'ttyACM1'}>$Lang::tr{'usb modem on acm1'}</option> | |
508 | <option value='ttyACM2' $selected{'COMPORT'}{'ttyACM2'}>$Lang::tr{'usb modem on acm2'}</option> | |
509 | <option value='ttyACM3' $selected{'COMPORT'}{'ttyACM3'}>$Lang::tr{'usb modem on acm3'}</option> | |
ac1cfefa MT |
510 | </select></td> |
511 | END | |
ac1cfefa MT |
512 | ; |
513 | } | |
514 | if ($pppsettings{'TYPE'} =~ /^(modem|serial)$/ ) { | |
515 | print <<END | |
330345c2 MT |
516 | <tr> |
517 | <td colspan='3' width='75%'>$Lang::tr{'computer to modem rate'}</td> | |
518 | <td width='25%'><select name='DTERATE' style="width: 165px"> | |
ac1cfefa MT |
519 | <option value='9600' $selected{'DTERATE'}{'9600'}>9600</option> |
520 | <option value='19200' $selected{'DTERATE'}{'19200'}>19200</option> | |
521 | <option value='38400' $selected{'DTERATE'}{'38400'}>38400</option> | |
522 | <option value='57600' $selected{'DTERATE'}{'57600'}>57600</option> | |
523 | <option value='115200' $selected{'DTERATE'}{'115200'}>115200</option> | |
524 | <option value='230400' $selected{'DTERATE'}{'230400'}>230400</option> | |
6c666a3b | 525 | <option value='460800' $selected{'DTERATE'}{'460800'}>460800</option> |
ac1cfefa MT |
526 | </select></td> |
527 | </tr> | |
528 | END | |
529 | ; | |
330345c2 | 530 | } |
285c5bbd | 531 | if ($pppsettings{'TYPE'} =~ /^(modem)$/ ) { |
330345c2 MT |
532 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'number'}</td>\n"; |
533 | print "<td width='25%'><input type='text' name='TELEPHONE' value='$pppsettings{'TELEPHONE'}'></td><tr>\n"; | |
ac1cfefa | 534 | if ($pppsettings{'TYPE'} eq 'modem' ) { |
330345c2 MT |
535 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'modem speaker on'}</td>\n"; |
536 | print "<td width='25%'><input type='checkbox' name='SPEAKER' $checked{'SPEAKER'}{'on'} /></td></tr>\n"; | |
537 | } | |
ac1cfefa MT |
538 | } |
539 | } | |
540 | if ($pppsettings{'TYPE'} eq 'modem') { | |
541 | print <<END | |
542 | <tr> | |
330345c2 MT |
543 | <td colspan='3' width='75%'>$Lang::tr{'dialing mode'}</td> |
544 | <td width='25%'><select name='DIALMODE' style="width: 165px"> | |
ac1cfefa MT |
545 | <option value='T' $selected{'DIALMODE'}{'T'}>$Lang::tr{'tone'}</option> |
546 | <option value='P' $selected{'DIALMODE'}{'P'}>$Lang::tr{'pulse'}</option> | |
547 | </select></td> | |
330345c2 MT |
548 | </tr> |
549 | <tr> | |
550 | <td colspan='3' width='75%'>$Lang::tr{'send cr'}</td> | |
551 | <td width='50%'><input type='checkbox' name='SENDCR' $checked{'SENDCR'}{'on'} /></td> | |
ac1cfefa MT |
552 | </tr> |
553 | END | |
554 | ; | |
555 | } | |
556 | ||
557 | print <<END | |
558 | <tr> | |
330345c2 MT |
559 | <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}</td> |
560 | <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td> | |
ac1cfefa MT |
561 | </tr> |
562 | END | |
563 | ; | |
564 | if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && ( $netsettings{'RED_TYPE'} eq "DHCP" || $netsettings{'RED_TYPE'} eq "STATIC") ) { | |
565 | $pppsettings{'AUTOCONNECT'} = 'on'; | |
330345c2 MT |
566 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'connect on ipfire restart'}</td>\n"; |
567 | print "<td width='25%'><input type='checkbox' disabled='disabled' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'}></td>\n"; | |
ac1cfefa | 568 | } else { |
330345c2 MT |
569 | print "<tr><td colspan='3' width='75%'>$Lang::tr{'connect on ipfire restart'}</td>\n"; |
570 | print "<td width='25%'><input type='checkbox' name='AUTOCONNECT' value='on' $checked{'AUTOCONNECT'}{'on'}></td>\n"; | |
ac1cfefa MT |
571 | } |
572 | print <<END | |
330345c2 MT |
573 | </tr> |
574 | <tr> | |
575 | <td colspan='3' width='75%'>$Lang::tr{'connection debugging'}:</td> | |
576 | <td width='25%'><input type='checkbox' name='DEBUG' $checked{'DEBUG'}{'on'} /></td> | |
577 | </tr> | |
578 | <tr> | |
579 | <td colspan='4' width='100%'><br></br></td></tr> | |
ac1cfefa | 580 | <tr> |
f2fdd0c1 | 581 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'reconnection'}:</b></td> |
ac1cfefa MT |
582 | </tr> |
583 | <tr> | |
330345c2 | 584 | <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='manual' $checked{'RECONNECTION'}{'manual'}>$Lang::tr{'manual'}</td> |
ac1cfefa | 585 | </tr> |
330345c2 MT |
586 | <tr> |
587 | <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='dialondemand' $checked{'RECONNECTION'}{'dialondemand'}>$Lang::tr{'dod'}</td> | |
588 | </tr> | |
ac1cfefa MT |
589 | END |
590 | ; | |
591 | if ($pppsettings{'TYPE'} ne 'isdn') { | |
592 | print <<END | |
330345c2 MT |
593 | <tr> |
594 | <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td> | |
595 | </tr> | |
596 | <tr> | |
597 | <td colspan='3' width='75%'>$Lang::tr{'backupprofile'}:</td> | |
598 | <td width='25%'><select name='BACKUPPROFILE' style="width: 165px"> | |
ac1cfefa MT |
599 | END |
600 | ; | |
601 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
602 | print "\t<option value='$c' $selected{'BACKUPPROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
603 | } | |
604 | print <<END | |
605 | </select></td> | |
606 | </tr> | |
607 | END | |
608 | ; | |
609 | } | |
610 | print <<END | |
330345c2 MT |
611 | <tr> |
612 | <td colspan='3' width='75%'>$Lang::tr{'dod for dns'}</td> | |
613 | <td width='25%'><input type='checkbox' name='DIALONDEMANDDNS' $checked{'DIALONDEMANDDNS'}{'on'} /></td> | |
614 | </tr> | |
ac1cfefa | 615 | <tr> |
330345c2 MT |
616 | <td colspan='3' width='75%'>$Lang::tr{'holdoff'}:</td> |
617 | <td width='25%'><input type='text' name='HOLDOFF' value='$pppsettings{'HOLDOFF'}' /></td> | |
ac1cfefa MT |
618 | </tr> |
619 | <tr> | |
330345c2 MT |
620 | <td colspan='3' width='75%'>$Lang::tr{'maximum retries'}</td> |
621 | <td width='25%'><input type='text' name='MAXRETRIES' value='$pppsettings{'MAXRETRIES'}' /></td> | |
ac1cfefa MT |
622 | </tr> |
623 | END | |
624 | ; | |
625 | ||
ac1cfefa MT |
626 | if ($pppsettings{'TYPE'} eq 'pptp') |
627 | { | |
628 | print <<END | |
330345c2 | 629 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 630 | <tr> |
f2fdd0c1 | 631 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pptp settings'}</b></td> |
ac1cfefa MT |
632 | </tr> |
633 | <tr> | |
330345c2 MT |
634 | <td width='25%'>$Lang::tr{'phonebook entry'}</td> |
635 | <td colspan='2' width='50%'></td> | |
636 | <td width='25%'><input type='text' name='PHONEBOOK' value='$pppsettings{'PHONEBOOK'}' /></td> | |
ac1cfefa MT |
637 | </tr> |
638 | <tr> | |
330345c2 MT |
639 | <td width='25%'><input type='radio' name='METHOD' value='STATIC' $checked{'METHOD'}{'STATIC'} />$Lang::tr{'static ip'}</td> |
640 | <td colspan='2' width='50%'>$Lang::tr{'router ip'}</td> | |
641 | <td width='25%'><input type='text' name='ROUTERIP' value='$pppsettings{'ROUTERIP'}' /></td> | |
ac1cfefa MT |
642 | </tr> |
643 | <tr> | |
330345c2 MT |
644 | <td width='25%'><input type='radio' name='METHOD' value='DHCP' $checked{'METHOD'}{'DHCP'} />$Lang::tr{'dhcp mode'}</td> |
645 | <td colspan='2' width='50%'>$Lang::tr{'hostname'}: <img src='/blob.gif' alt='*' /></td> | |
646 | <td width='25%'><input type='text' name='DHCP_HOSTNAME' value='$pppsettings{'DHCP_HOSTNAME'}' /></td> | |
ac1cfefa MT |
647 | </tr> |
648 | END | |
649 | ; | |
650 | } | |
651 | if ($pppsettings{'TYPE'} eq 'pppoe') | |
652 | { | |
653 | print <<END | |
330345c2 | 654 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 655 | <tr> |
f2fdd0c1 | 656 | <td colspan='4' width='100%' bgcolor='$color{'color20'}'><b>$Lang::tr{'pppoe settings'}</b></td> |
ac1cfefa MT |
657 | </tr> |
658 | <tr> | |
330345c2 MT |
659 | <td width='25%'><input type='radio' name='METHOD' value='PPPOE_PLUGIN' $checked{'METHOD'}{'PPPOE_PLUGIN'} />PPPoE plugin</td> |
660 | <td colspan='2' width='50%'>$Lang::tr{'service name'} <img src='/blob.gif' alt='*' /></td> | |
661 | <td width='25%'><input type='text' name='SERVICENAME' value='$pppsettings{'SERVICENAME'}' /></td> | |
ac1cfefa MT |
662 | </tr> |
663 | <tr> | |
330345c2 MT |
664 | <td width='25%'><input type='radio' name='METHOD' value='PPPOE' $checked{'METHOD'}{'PPPOE'} />$Lang::tr{'pppoe'}</td> |
665 | <td colspan='2' width='50%'>$Lang::tr{'concentrator name'} <img src='/blob.gif' alt='*' /></td> | |
666 | <td width='25%'><input type='text' name='CONCENTRATORNAME' value='$pppsettings{'CONCENTRATORNAME'}' /></td> | |
ac1cfefa | 667 | </tr> |
2ed35f39 CS |
668 | <tr> |
669 | <td width='25%'>MTU</td> | |
670 | <td colspan='2' width='50%'></td> | |
671 | <td width='25%'><input type='text' name='MTU' value='$pppsettings{'MTU'}' /></td> | |
672 | </tr> | |
ac1cfefa MT |
673 | END |
674 | ; | |
675 | } | |
676 | ||
ac1cfefa | 677 | print <<END |
330345c2 | 678 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 679 | <tr> |
f2fdd0c1 | 680 | <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td> |
ac1cfefa MT |
681 | </tr> |
682 | <tr> | |
330345c2 MT |
683 | <td width='25%'>$Lang::tr{'username'}</td> |
684 | <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td> | |
685 | <td width='25%'>$Lang::tr{'password'}</td> | |
686 | <td width='25%'><input type='password' name='PASSWORD' value='$pppsettings{'PASSWORD'}' /></td> | |
ac1cfefa MT |
687 | </tr> |
688 | <tr> | |
330345c2 MT |
689 | <td width='25%'>$Lang::tr{'method'}</td> |
690 | <td width='25%'><select name='AUTH' style="width: 165px"> | |
ac1cfefa MT |
691 | <option value='pap-or-chap' $selected{'AUTH'}{'pap-or-chap'}>$Lang::tr{'pap or chap'}</option> |
692 | <option value='pap' $selected{'AUTH'}{'pap'}>PAP</option> | |
693 | <option value='chap' $selected{'AUTH'}{'chap'}>CHAP</option> | |
694 | END | |
695 | ; | |
696 | if ($pppsettings{'TYPE'} eq 'modem') { | |
697 | print <<END | |
698 | <option value='standard-login-script' $selected{'AUTH'}{'standard-login-script'}>$Lang::tr{'standard login script'}</option> | |
699 | <option value='demon-login-script' $selected{'AUTH'}{'demon-login-script'}>$Lang::tr{'demon login script'}</option> | |
700 | <option value='other-login-script' $selected{'AUTH'}{'other-login-script'}>$Lang::tr{'other login script'}</option> | |
701 | END | |
702 | ; | |
703 | } | |
704 | print <<END | |
705 | </select></td> | |
330345c2 MT |
706 | <td width='25%'>$Lang::tr{'script name'} <img src='/blob.gif' alt='*' /></td> |
707 | <td width='25%'><input type='text' name='LOGINSCRIPT' value='$pppsettings{'LOGINSCRIPT'}' /></td> | |
ac1cfefa | 708 | </tr> |
330345c2 | 709 | <tr><td colspan='4' width='100%'><br></br></td></tr> |
ac1cfefa | 710 | <tr> |
f2fdd0c1 | 711 | <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>DNS:</b></td> |
ac1cfefa MT |
712 | </tr> |
713 | <tr> | |
330345c2 | 714 | <td colspan='4' width='100%'><input type='radio' name='DNS' value='Automatic' $checked{'DNS'}{'Automatic'} />$Lang::tr{'automatic'}</td> |
ac1cfefa MT |
715 | </tr> |
716 | <tr> | |
330345c2 | 717 | <td colspan='4' width='100%'><input type='radio' name='DNS' value='Manual' $checked{'DNS'}{'Manual'} />$Lang::tr{'manual'}</td> |
ac1cfefa MT |
718 | </tr> |
719 | <tr> | |
330345c2 MT |
720 | <td width='25%'>$Lang::tr{'primary dns'}</td> |
721 | <td width='25%'><input type='text' name='DNS1' value='$pppsettings{'DNS1'}'></td> | |
722 | <td width='25%'>$Lang::tr{'secondary dns'}</td> | |
723 | <td width='25%'><input type='text' name='DNS2' value='$pppsettings{'DNS2'}'></td> | |
ac1cfefa | 724 | </tr> |
330345c2 | 725 | <tr><td colspan='4' width='100%'><br></br><hr></hr><br></br></td></tr> |
ac1cfefa | 726 | <tr> |
330345c2 MT |
727 | <td width='25%'>$Lang::tr{'profile name'}</td> |
728 | <td width='25%'><input type='text' name='PROFILENAME' value='$pppsettings{'PROFILENAME'}'> | |
729 | <td colspan='2' width='50%'></td> | |
ac1cfefa MT |
730 | </tr> |
731 | <tr> | |
330345c2 | 732 | <td align='center' colspan='4' width='100%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td> |
ac1cfefa MT |
733 | </tr> |
734 | <tr> | |
330345c2 MT |
735 | <td colspan='2' width='50%'>$Lang::tr{'legend'}:</td> |
736 | <td colspan='2' width='50%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td> | |
ac1cfefa MT |
737 | </tr> |
738 | </table> | |
739 | END | |
740 | ; | |
741 | &Header::closebox(); | |
742 | } | |
743 | ||
744 | print "</form>\n"; | |
745 | ||
746 | &Header::closebigbox(); | |
747 | ||
748 | &Header::closepage(); | |
749 | ||
750 | sub updatesettings | |
751 | { | |
752 | # make a link from the selected profile to the "default" one. | |
753 | unlink("${General::swroot}/ppp/settings"); | |
754 | link("${General::swroot}/ppp/settings-$pppsettings{'PROFILE'}", | |
755 | "${General::swroot}/ppp/settings"); | |
9833e7d8 | 756 | system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings"); |
ac1cfefa MT |
757 | } |
758 | ||
759 | sub writesecrets | |
760 | { | |
761 | # write secrets file. | |
762 | open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; | |
763 | flock(FILE, 2); | |
764 | my $username = $pppsettings{'USERNAME'}; | |
765 | my $password = $pppsettings{'PASSWORD'}; | |
766 | print FILE "'$username' * '$password'\n"; | |
767 | chmod 0600, "${General::swroot}/ppp/secrets"; | |
768 | close FILE; | |
769 | } | |
770 | ||
771 | sub initprofile | |
772 | { | |
773 | $pppsettings{'PROFILENAME'} = $Lang::tr{'unnamed'}; | |
774 | $pppsettings{'COMPORT'} = 'ttyS0'; | |
775 | $pppsettings{'DTERATE'} = 115200; | |
776 | $pppsettings{'SPEAKER'} = 'off'; | |
777 | $pppsettings{'RECONNECTION'} = 'manual'; | |
778 | $pppsettings{'DIALONDEMANDDNS'} = 'off'; | |
779 | $pppsettings{'AUTOCONNECT'} = 'off'; | |
780 | $pppsettings{'SENDCR'} = 'off'; | |
781 | $pppsettings{'USEIBOD'} = 'off'; | |
782 | $pppsettings{'USEDOV'} = 'off'; | |
783 | $pppsettings{'MODEM'} = 'PCIST'; | |
784 | $pppsettings{'LINE'} = 'WO'; | |
785 | $pppsettings{'ENCAP'} = '0'; | |
786 | $pppsettings{'PHONEBOOK'} = 'RELAY_PPP1'; | |
787 | $pppsettings{'PROTOCOL'} = 'RFC2364'; | |
788 | $pppsettings{'METHOD'} = 'PPPOE_PLUGIN'; | |
285c5bbd MT |
789 | if ( $pppsettings{'METHOD'} eq 'PPPOE_PLUGIN' ) { |
790 | $pppsettings{'MTU'} = '1492'; | |
791 | $pppsettings{'MRU'} = '1492'; | |
792 | } else { | |
793 | $pppsettings{'MTU'} = '1452'; | |
794 | $pppsettings{'MRU'} = '1452'; | |
f515baeb | 795 | } |
ac1cfefa MT |
796 | $pppsettings{'DIALMODE'} = 'T'; |
797 | $pppsettings{'MAXRETRIES'} = 5; | |
798 | $pppsettings{'HOLDOFF'} = 30; | |
799 | $pppsettings{'TIMEOUT'} = 15; | |
800 | $pppsettings{'MODULATION'} = 'AUTO'; | |
801 | $pppsettings{'AUTH'} = 'pap-or-chap'; | |
802 | $pppsettings{'DNS'} = 'Automatic'; | |
803 | $pppsettings{'DEBUG'} = 'off'; | |
804 | $pppsettings{'BACKUPPROFILE'} = $pppsettings{'PROFILE'}; | |
ac1cfefa MT |
805 | |
806 | # Get PPPoE settings so we can see if PPPoE is enabled or not. | |
807 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
808 | ||
809 | # empty profile partial pre-initialization | |
810 | if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/) { | |
811 | $pppsettings{'TYPE'}=lc($netsettings{'RED_TYPE'}); | |
ac1cfefa MT |
812 | } else { |
813 | $pppsettings{'TYPE'}='modem'; | |
814 | } | |
815 | } | |
816 |