]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/netconfig.cgi
f13d864cbcbe128bf1310e6ae91a56f34d633f75
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / netconfig.cgi
1 #!/usr/bin/perl
2 #
3 # EMBCop CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) Michel Schaaf
8 #
9 # $Id: netconfig.cgi,v 1.11.2.27 2005/10/27 07:40:14 schaaf Exp $
10 #
11
12 use strict;
13
14 # enable only the following on debugging purpose
15 use warnings;
16 use CGI::Carp 'fatalsToBrowser';
17
18 require '/var/ipfire/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
21
22 my %cgiparams=();
23 $cgiparams{'ACTION'} = '';
24 &Header::getcgihash(\%cgiparams);
25
26 my %ethsettings = ();
27 &General::readhash("${General::swroot}/ethernet/settings", \%ethsettings);
28
29 my $key = ();
30
31 my %net_config_type = (0 => "GREEN (RED is modem/ISDN)",
32 1 => "GREEN + ORANGE (RED is modem/ISDN)",
33 2 => "GREEN + RED",
34 3 => "GREEN + ORANGE + RED",
35 4 => "GREEN + BLUE (RED is modem/ISDN)",
36 5 => "GREEN + ORANGE + BLUE (RED is modem/ISDN)",
37 6 => "GREEN + BLUE + RED",
38 7 => "GREEN + ORANGE + BLUE + RED");
39
40 my %landevice = ("eth0", "eth1", "eth2", "eth3");
41 my %types = ("STATIC", "DHCP", "PPPOE", "PPTP");
42
43 my $dev_name = ();
44
45 my %nic = (
46 "100VG-AnyLan Network Adapters, HP J2585B, J2585A, etc" => "hp100" ,
47 "3Com EtherLink III" => "3c509" ,
48 "3Com 3c501" => "3c501" ,
49 "3Com ISA EtherLink XL" => "3c515" ,
50 "3Com 3c503 and 3c503/16" => "3c503" ,
51 "3Com EtherLink MC (3c523)" => "3c523" ,
52 "3Com EtherLink MC/32 (3c527)" => "3c527" ,
53 "3Com EtherLink Plus (3c505)" => "3c505" ,
54 "3Com EtherLink 16" => "3c507" ,
55 "3Com Corkscrew EtherLink PCI III/XL etc." => "3c59x" ,
56 "3Com Typhoon Family (3C990 3CR990 and variants)" => "typhoon" ,
57 "Adaptec Starfire/DuraLAN" => "starfire" ,
58 "Alteon AceNIC/3Com 3C985/Netgear GA620 Gigabit" => "acenic" ,
59 "AMD8111 based 10/100 Ethernet Controller" => "amd8111e" ,
60 "AMD LANCE/PCnetAllied Telesis AT1500, J2405A, etc" => "lance" ,
61 "AMD PCnet32 and AMD PCnetPCI" => "pcnet32" ,
62 "Ansel Communications EISA 3200" => "ac3200" ,
63 "Apricot 680x0 VME, 82596 chipset" => "82596" ,
64 "AT1700/1720" => "at1700" ,
65 "Broadcom 4400" => "b44" ,
66 "Broadcom Tigon3" => "tg3" ,
67 "Cabletron E2100 series ethercards" => "e2100" ,
68 "CATC USB NetMate-based Ethernet" => "catc" ,
69 "CDC USB Ethernet" => "CDCEther" ,
70 "Crystal LAN CS8900/CS8920" => "cs89x0" ,
71 "Compaq Netelligent 10/100 TX PCI UTP, etc" => "tlan" ,
72 "D-Link DL2000-based Gigabit Ethernet" => "dl2k" ,
73 "Digi Intl. RightSwitch SE-X EISA and PCI" => "dgrs" ,
74 "Digital 21x4x Tulip PCI ethernet cards, etc." => "tulip" ,
75 "Digital DEPCA & EtherWORKS,DEPCA, DE100, etc" => "depca" ,
76 "DM9102 PCI Fast Ethernet Adapter" => "dmfe" ,
77 "Dummy Network Card (testing)" => "dummy" ,
78 "EtherWORKS DE425 TP/COAX EISA, DE434 TP PCI, etc." => "de4x5" ,
79 "EtherWORKS 3 (DE203, DE204 and DE205)" => "ewrk3" ,
80 "HP PCLAN/plus" => "hp-plus" ,
81 "HP LAN ethernet" => "hp" ,
82 "IBM LANA" => "ibmlana" ,
83 "ICL EtherTeam 16i/32" ,"eth16i" ,
84 "Intel i82557/i82558 PCI EtherExpressPro" => "e100" ,
85 "Intel EtherExpress Cardbus Ethernet" => "eepro100_cb" ,
86 "Intel i82595 ISA EtherExpressPro10/10+ driver" ,"eepro" ,
87 "Intel EtherExpress 16 (i82586)" => "eexpress" ,
88 "Intel Panther onboard i82596 driver" => "lp486e" ,
89 "Intel PRO/1000 Gigabit Ethernet" => "e1000" ,
90 "KLSI USB KL5USB101-based" => "kaweth" ,
91 "MiCom-Interlan NI5010 ethercard" => "ni5010" ,
92 "Mylex EISA LNE390A/B" => "lne390" ,
93 "Myson MTD-8xx PCI Ethernet" => "fealnx" ,
94 "National Semiconductor DP8381x" => "natsemi" ,
95 "National Semiconductor DP83820" => "ns83820" ,
96 "NE/2 MCA" => "ne2" ,
97 "NE2000 PCI cards, RealTEk RTL-8029, etc" => "ne2k-pci" ,
98 "NE1000 / NE2000 (non-pci)" => "ne" ,
99 "NI50 card (i82586 Ethernet chip)" => "ni52" ,
100 "NI6510, ni6510 EtherBlaster" => "ni65" ,
101 "Novell/Eagle/Microdyne NE3210 EISA" => "ne3210" ,
102 "NVidia Nforce2 Driver" => "forcedeth" ,
103 "Packet Engines Hamachi GNIC-II" => "hamachi" ,
104 "Packet Engines Yellowfin Gigabit-NIC" => "yellowfin" ,
105 "Pegasus/Pegasus-II USB ethernet" => "pegasus" ,
106 "PureData PDUC8028,WD8003 and WD8013 compatibles" => "wd" ,
107 "Racal-Interlan EISA ES3210" => "es3210" ,
108 "RealTek RTL-8139 Fast Ethernet" => "8139too" ,
109 "RealTek RTL-8139C+ series 10/100 PCI Ethernet" => "8139cp" ,
110 "RealTek RTL-8150 USB ethernet" => "rtl8150" ,
111 "RealTek RTL-8169 Gigabit Ethernet" => "r8169" ,
112 "SiS 900 PCI" => "sis900" ,
113 "SKnet MCA" => "sk_mca" ,
114 "SMC 9000 series of ethernet cards" => "smc9194" ,
115 "SMC EtherPower II" => "epic100" ,
116 "SMC Ultra/EtherEZ ISA/PnP Ethernet" => "smc-ultra" ,
117 "SMC Ultra32 EISA Ethernet" => "smc-ultra32" ,
118 "SMC Ultra MCA Ethernet" => "smc-mca" ,
119 "Sundance Alta" => "sundance" ,
120 "SysKonnect SK-98xx" => "sk98lin" ,
121 "Toshiba TC35815 Ethernet" => "tc35815" ,
122 "Tulip chipset Cardbus Ethernet" => "tulip_cb" ,
123 "USB Ethernet" => "usbnet" ,
124 "VIA Rhine PCI Fast Ethernet, etc" => "via-rhine" ,
125 "Winbond W89c840 Ethernet" => "winbond-840" ,
126 "Xircom Cardbus Ethernet" => "xircom_cb" ,
127 "Xircom (tulip-like) Cardbus Ethernet" => "xircom_tulip_cb" );
128
129 if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) {
130 $ethsettings{'CONFIG_TYPE'} = $cgiparams{'CONFIG_TYPE'};
131 $ethsettings{'GREEN_ADDRESS'} = $cgiparams{'GREEN_ADDRESS'};
132 $ethsettings{'GREEN_NETMASK'} = $cgiparams{'GREEN_NETMASK'};
133 $ethsettings{'GREEN_DRIVER'} = $cgiparams{'GREEN_DRIVER'};
134 $ethsettings{'GREEN_DRIVER_OPTIONS'} = $cgiparams{'GREEN_DRIVER_OPTIONS'};
135 $ethsettings{'GREEN_DEV'} = $cgiparams{'GREEN_DEV'};
136 $ethsettings{'GREEN_BROADCAST'} = $cgiparams{'GREEN_BROADCAST'};
137 $ethsettings{'GREEN_NETADDRESS'} = $cgiparams{'GREEN_NETADDRESS'};
138 $ethsettings{'RED_ADDRESS'} = $cgiparams{'RED_ADDRESS'};
139 $ethsettings{'RED_NETMASK'} = $cgiparams{'RED_NETMASK'};
140 $ethsettings{'RED_DRIVER'} = $cgiparams{'RED_DRIVER'};
141 $ethsettings{'RED_DRIVER_OPTIONS'} = $cgiparams{'RED_DRIVER_OPTIONS'};
142 $ethsettings{'RED_DEV'} = $cgiparams{'RED_DEV'};
143 $ethsettings{'RED_BROADCAST'} = $cgiparams{'RED_BROADCAST'};
144 $ethsettings{'RED_TYPE'} = $cgiparams{'RED_TYPE'};
145 $ethsettings{'RED_NETADDRESS'} = $cgiparams{'RED_NETADDRESS'};
146 $ethsettings{'ORANGE_ADDRESS'} = $cgiparams{'ORANGE_ADDRESS'};
147 $ethsettings{'ORANGE_NETMASK'} = $cgiparams{'ORANGE_NETMASK'};
148 $ethsettings{'ORANGE_DRIVER'} = $cgiparams{'ORANGE_DRIVER'};
149 $ethsettings{'ORANGE_DRIVER_OPTIONS'} = $cgiparams{'ORANGE_DRIVER_OPTIONS'};
150 $ethsettings{'ORANGE_DEV'} = $cgiparams{'ORANGE_DEV'};
151 $ethsettings{'ORANGE_BROADCAST'} = $cgiparams{'ORANGE_BROADCAST'};
152 $ethsettings{'ORANGE_NETADDRESS'} = $cgiparams{'ORANGE_NETADDRESS'};
153 $ethsettings{'BLUE_ADDRESS'} = $cgiparams{'BLUE_ADDRESS'};
154 $ethsettings{'BLUE_NETMASK'} = $cgiparams{'BLUE_NETMASK'};
155 $ethsettings{'BLUE_DRIVER'} = $cgiparams{'BLUE_DRIVER'};
156 $ethsettings{'BLUE_DRIVER_OPTIONS'} = $cgiparams{'BLUE_DRIVER_OPTIONS'};
157 $ethsettings{'BLUE_DEV'} = $cgiparams{'BLUE_DEV'};
158 $ethsettings{'BLUE_BROADCAST'} = $cgiparams{'BLUE_BROADCAST'};
159 $ethsettings{'BLUE_NETADDRESS'} = $cgiparams{'BLUE_NETADDRESS'};
160
161 &General::writehash("${General::swroot}/ethernet/settings", \%ethsettings);
162 }
163
164 &Header::showhttpheaders();
165
166 &Header::openpage($Lang::tr{'net config'}, 1, '');
167
168 &Header::openbigbox('100%', 'center');
169
170 &Header::openbox('100%', 'left', $Lang::tr{'net config'});
171
172 print <<END
173 <b>$Lang::tr{'net config type'}</b>
174 <form method="POST" action="netconfig.cgi">
175 <table width=100%>
176 <tr>
177 <td valign=top>
178 <select name="CONFIG_TYPE">
179 END
180 ;
181
182 foreach my $k (sort keys %net_config_type){
183 if ($k eq $ethsettings{'CONFIG_TYPE'}){
184 print "<option value=\"$k\" selected>$net_config_type{$k}</option>";}else{
185 print "<option value=\"$k\">$net_config_type{$k}</option>";}
186 }
187 print <<END
188 </select>
189 </td>
190 <td valign=top>$Lang::tr{'net config type help'}</td>
191 <td valign=top align=right><input type="reset" name="ACTION" value="$Lang::tr{'reset'}"><input type="submit" name="ACTION" value="$Lang::tr{'save'}"></td>
192 </tr>
193 </table>
194 END
195 ;
196
197 print <<END
198 <hr><b>GREEN</b><br />
199 <table width=100%><tr>
200 <td width=12%>$Lang::tr{'ip address'}:</td>
201 <td width=12%><input type=text name="GREEN_ADDRESS" value="$ethsettings{'GREEN_ADDRESS'}" size=15></td>
202 <td width=12%>$Lang::tr{'netmask'}:</td>
203 <td width=12%><input type=text name="GREEN_NETMASK" value="$ethsettings{'GREEN_NETMASK'}" size=15></td>
204 <td>
205 $Lang::tr{'net address'}:
206 </td>
207 <td>
208 <input type=text name="GREEN_NETADDRESS" value="$ethsettings{'GREEN_NETADDRESS'}" size=15/>
209 </td>
210 </tr>
211 <tr>
212 <td>$Lang::tr{'broadcast'}:</td>
213 <td><input type=text name="GREEN_BROADCAST" value="$ethsettings{'GREEN_BROADCAST'}" size=15></td>
214 <td>$Lang::tr{'device'}:</td>
215 <td><select name="GREEN_DEV">
216 END
217 ;
218
219 foreach (sort %landevice){
220 if ($_ eq $ethsettings{'GREEN_DEV'}){
221 print "<option value=\"$_\" selected>$_</option>";}else{
222 print "<option value=\"$_\">$_</option>";}
223 }
224
225 print <<END
226 </select>
227 <td width=12%>$Lang::tr{'driver'}:$ethsettings{'GREEN_DRIVER'}</td>
228 <td width=40%><select name=GREEN_DRIVER>
229 END
230 ;
231
232 foreach (sort keys %nic){
233 if ($nic{$_} eq $ethsettings{'GREEN_DRIVER'}){
234 print "<option value=\"$nic{$_}\" selected>$_</option>";}else{
235 print "<option value=\"$nic{$_}\">$_</option>";}
236 }
237 print <<END
238 </select>
239 </tr>
240 <tr>
241 <td>
242 </td>
243 <td>
244 </td>
245 <td>
246 </td>
247 <td>
248 </td>
249 <td>$Lang::tr{'options'}:</td>
250 <td><input type=text name="GREEN_DRIVER_OPTIONS" value="$ethsettings{'GREEN_DRIVER_OPTIONS'}" size=45></td>
251 </tr>
252 </table>
253 <hr>
254 END
255 ;
256
257 if ($ethsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/){
258 print <<END
259 <hr><b>RED</b><br />
260 <table width=100%><tr>
261 <td width=12%>$Lang::tr{'ip address'}:</td>
262 <td width=12%><input type=text name="RED_ADDRESS" value="$ethsettings{'RED_ADDRESS'}" size=15></td>
263 <td width=12%>$Lang::tr{'netmask'}:</td>
264 <td width=12%><input type=text name="RED_NETMASK" value="$ethsettings{'RED_NETMASK'}" size=15></td>
265 <td>$Lang::tr{'net address'}:</td>
266 <td><input type=text name="RED_NETADDRESS" value="$ethsettings{'RED_NETADDRESS'}" size=15/></td
267 </tr>
268 <tr>
269 <td>$Lang::tr{'device'}:</td>
270 <td><select name="RED_DEV">
271 END
272 ;
273
274 foreach (sort %landevice){
275 if ($_ eq $ethsettings{'RED_DEV'}){
276 print "<option value=\"$_\" selected>$_</option>";}else{
277 print "<option value=\"$_\">$_</option>";}
278 }
279
280 print <<END
281 </select>
282 </td>
283 <td>$Lang::tr{'broadcast'}:</td>
284 <td><input type=text name="RED_BROADCAST" value="$ethsettings{'RED_BROADCAST'}" size=15></td>
285 <td width=12%>$Lang::tr{'driver'}:$ethsettings{'RED_DRIVER'}</td>
286 <td width=40%><select name=RED_DRIVER>
287 END
288 ;
289
290 foreach (sort keys %nic){
291 if ($nic{$_} eq $ethsettings{'RED_DRIVER'}){
292 print "<option value=\"$nic{$_}\" selected>$_</option>";}else{
293 print "<option value=\"$nic{$_}\">$_</option>";}
294 }
295 print <<END
296 </select>
297 </tr><tr><td> $Lang::tr{'type'}:</td><td><select name="RED_TYPE">
298 END
299 ;
300
301 foreach (sort %types){
302 if ($_ eq $ethsettings{'RED_TYPE'}){
303 print "<option value=\"$_\" selected>$_</option>";}else{
304 print "<option value=\"$_\">$_</option>";}
305 }
306
307 print <<END
308 </select>
309 </td>
310 <td></td><td></td>
311 <td>$Lang::tr{'options'}:</td>
312 <td><input type=text name="RED_DRIVER_OPTIONS" value="$ethsettings{'RED_DRIVER_OPTIONS'}" size=45></td>
313 </tr>
314 </table>
315 <hr>
316 END
317 ;
318
319 }
320
321 if ($ethsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/){
322 print <<END
323 <hr><b>ORANGE</b><br />
324 <table width=100%><tr>
325 <td width=12%>$Lang::tr{'ip address'}:</td>
326 <td width=12%><input type=text name="ORANGE_ADDRESS" value="$ethsettings{'ORANGE_ADDRESS'}" size=15></td>
327 <td width=12%>$Lang::tr{'netmask'}:</td>
328 <td width=12%><input type=text name="ORANGE_NETMASK" value="$ethsettings{'ORANGE_NETMASK'}" size=15></td>
329 <td>$Lang::tr{'net address'}:</td>
330 <td><input type=text name="ORANGE_NETADDRESS" value="$ethsettings{'ORANGE_NETADDRESS'}" size=15/></td>
331 </tr>
332 <tr>
333 <td>$Lang::tr{'device'}:</td>
334 <td><select name="ORANGE_DEV">
335 END
336 ;
337
338 foreach (sort %landevice){
339 if ($_ eq $ethsettings{'ORANGE_DEV'}){
340 print "<option value=\"$_\" selected>$_</option>";}else{
341 print "<option value=\"$_\">$_</option>";}
342 }
343
344 print <<END
345 </select>
346 </td>
347 <td>$Lang::tr{'broadcast'}:</td>
348 <td><input type=text name="ORANGE_BROADCAST" value="$ethsettings{'ORANGE_BROADCAST'}" size=15></td>
349 <td width=12%>$Lang::tr{'driver'}:$ethsettings{'ORANGE_DRIVER'}</td>
350 <td width=40%><select name=ORANGE_DRIVER>
351 END
352 ;
353
354 foreach (sort keys %nic){
355 if ($nic{$_} eq $ethsettings{'ORANGE_DRIVER'}){
356 print "<option value=\"$nic{$_}\" selected>$_</option>";}else{
357 print "<option value=\"$nic{$_}\">$_</option>";}
358 }
359 print <<END
360 </select>
361 </tr>
362 <tr>
363 <td></td><td></td>
364 <td></td><td></td>
365 <td>$Lang::tr{'options'}:</td>
366 <td><input type=text name="ORANGE_DRIVER_OPTIONS" value="$ethsettings{'ORANGE_DRIVER_OPTIONS'}" size=45></td>
367 </tr>
368 </table>
369 <hr>
370 END
371 ;
372
373 }
374
375 if ($ethsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/){
376 print <<END
377 <hr><b>BLUE</b><br />
378 <table width=100%><tr>
379 <td width=12%>$Lang::tr{'ip address'}:</td>
380 <td width=12%><input type=text name="BLUE_ADDRESS" value="$ethsettings{'BLUE_ADDRESS'}" size=15></td>
381 <td width=12%>$Lang::tr{'netmask'}:</td>
382 <td width=12%><input type=text name="BLUE_NETMASK" value="$ethsettings{'BLUE_NETMASK'}" size=15></td>
383 <td>$Lang::tr{'net address'}:</td>
384 <td><input type=text name="BLUE_NETADDRESS" value="$ethsettings{'BLUE_NETADDRESS'}" size=15/></td>
385 </tr>
386 <tr>
387 <td>$Lang::tr{'device'}:</td>
388 <td><select name="BLUE_DEV">
389 END
390 ;
391
392 foreach (sort %landevice){
393 if ($_ eq $ethsettings{'BLUE_DEV'}){
394 print "<option value=\"$_\" selected>$_</option>";}else{
395 print "<option value=\"$_\">$_</option>";}
396 }
397
398 print <<END
399 </select>
400 </td>
401 <td>$Lang::tr{'broadcast'}:</td>
402 <td><input type=text name="BLUE_BROADCAST" value="$ethsettings{'BLUE_BROADCAST'}" size=15></td>
403 <td width=12%>$Lang::tr{'driver'}:$ethsettings{'BLUE_DRIVER'}</td>
404 <td width=40%><select name=BLUE_DRIVER>
405 END
406 ;
407
408 foreach (sort keys %nic){
409 if ($nic{$_} eq $ethsettings{'BLUE_DRIVER'}){
410 print "<option value=\"$nic{$_}\" selected>$_</option>";}else{
411 print "<option value=\"$nic{$_}\">$_</option>";}
412 }
413 print <<END
414 </select>
415 </td>
416 </tr>
417 <tr>
418 <td></td><td></td>
419 <td></td><td></td>
420 <td>$Lang::tr{'options'}:</td>
421 <td><input type=text name="BLUE_DRIVER_OPTIONS" value="$ethsettings{'BLUE_DRIVER_OPTIONS'}" size=45></td>
422 </tr>
423 </table>
424 <hr>
425 END
426 ;
427
428 }
429
430 print <<END
431 </form>
432 END
433 ;
434
435 &Header::closebox();
436
437 &Header::closebigbox();
438
439 &Header::closepage();