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