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