require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
+###--- HTML HEAD ---###
my $extraHead = <<END
<style>
table#zoneconf {
<script src="/include/zoneconf.js"></script>
END
;
+###--- END HTML HEAD ---###
+### Read configuration ###
my %ethsettings = ();
my %vlansettings = ();
my %cgiparams = ();
&Header::showhttpheaders();
# Define all zones we will check for NIC assignment
-my @zones = ("green", "red", "orange", "blue");
+my @zones = ("red", "green", "orange", "blue");
# Get all physical NICs present
opendir(my $dh, "/sys/class/net/");
}
}
+### Functions ###
+
+# Check if a zone is in IP mode or in PPP, PPPoE, VDSL, ... mode
+sub is_zonetype_ip {
+ my $zone_type = shift;
+ return ($zone_type eq "STATIC" || $zone_type eq "DHCP");
+}
+
+# Check if a zone is activated (device assigned)
+sub is_zone_activated {
+ my $zone = uc shift;
+ return ($ethsettings{"${zone}_DEV"} ne "");
+}
+
+### START PAGE ###
&Header::openpage($Lang::tr{"zoneconf title"}, 1, $extraHead);
&Header::openbigbox('100%', 'center');
}
}
+ # skip NIC/VLAN assignment and additional zone options for RED in PPP mode
next;
}
}
}
+ # validation failed, show error message and exit
if ($VALIDATE_error) {
&Header::openbox('100%', 'left', $Lang::tr{"error"});
exit 0;
}
+ # new settings are valid, write configuration files
&General::writehash("${General::swroot}/ethernet/settings",\%ethsettings);
&General::writehash("${General::swroot}/ethernet/vlans",\%vlansettings);
$restart_notice = $Lang::tr{'zoneconf notice reboot'};
}
-&Header::openbox('100%', 'left', $Lang::tr{"zoneconf nic assignment"});
-
### START OF TABLE ###
+&Header::openbox('100%', 'left', $Lang::tr{"zoneconf nic assignment"});
+
print <<END
<form method='post' enctype='multipart/form-data'>
<table id="zoneconf">
# Fill the table header with all activated zones
foreach (@zones) {
my $uc = uc $_;
- my $dev_name = $ethsettings{"${uc}_DEV"};
- if ($dev_name eq "") { # If the zone is not activated, don't show it
- next;
- }
+ # If the zone is not activated, don't show it
+ next unless is_zone_activated($_);
- # If the zone is in PPP mode, don't show a mode dropdown
+ # If the red zone is in PPP mode, don't show a mode dropdown
if ($uc eq "RED") {
my $red_type = $ethsettings{"RED_TYPE"};
- my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP"));
- if ($red_restricted) {
- print "\t\t<td class='heading $_'>$uc ($red_type)</td>\n";
+ unless (is_zonetype_ip($red_type)) {
+ print "\t\t<td class='heading bold $_'>$uc ($red_type)</td>\n";
next; # We're done here
}
print "\t</tr>\n";
+# NIC assignment matrix
foreach (@nics) {
my $mac = $_->[0];
my $nic = $_->[1];
# Iterate through all zones and check if the current NIC is assigned to it
foreach (@zones) {
my $uc = uc $_;
- my $dev_name = $ethsettings{"${uc}_DEV"};
my $highlight = "";
- if ($dev_name eq "") { # Again, skip the zone if it is not activated
- next;
- }
+ # If the zone is not activated, don't show it
+ next unless is_zone_activated($_);
if ($uc eq "RED") {
- my $red_type = $ethsettings{"RED_TYPE"};
- my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP"));
-
# VLANs/Bridging is not possible if the RED interface is set to PPP, PPPoE, VDSL, ...
- if ($red_restricted) {
+ unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) {
my $checked = "";
if ($mac eq $ethsettings{"${uc}_MACADDR"}) {
print "\t</tr>\n";
}
+# footer and submit button
print <<END
</table>