webif: Add a GUI for configuring VLAN interfaces

This patch adds a new CGI file which allows users to edit the
VLAN configuration as well as configuring zones as bridges.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Florian Bührle
2019-05-08 11:56:18 +01:00
committed by Michael Tremer
parent a494174979
commit 1dcf513a41
15 changed files with 638 additions and 0 deletions

View File

@@ -402,6 +402,48 @@ sub get_hardware_address($) {
return $ret;
}
sub get_nic_property {
my $nicname = shift;
my $property = shift;
my $result;
open(FILE, "/sys/class/net/$nicname/$property") or die("Could not read property");
$result = <FILE>;
close(FILE);
chomp($result);
return $result;
}
sub valid_mac($) {
my $mac = shift;
return $mac =~ /^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/;
}
sub random_mac {
my $address = "02";
for my $i (0 .. 4) {
$address = sprintf("$address:%02x", int(rand(255)));
}
return $address;
}
sub get_mac_by_name($) {
my $mac = shift;
if ((!&valid_mac($mac)) && ($mac ne "")) {
if (-e "/sys/class/net/$mac/") {
$mac = get_nic_property($mac, "address");
}
}
return $mac;
}
1;
# Remove the next line to enable the testsuite

View File

@@ -3,6 +3,11 @@
'title' => "$Lang::tr{'net config'}",
'enabled' => 0,
};
$subnetwork->{'11.zoneconf'} = {'caption' => "$Lang::tr{'zoneconf title'}",
'uri' => '/cgi-bin/zoneconf.cgi',
'title' => "$Lang::tr{'zoneconf title'}",
'enabled' => 1,
};
$subnetwork->{'20.proxy'} = {'caption' => "$Lang::tr{'web proxy'}",
'uri' => '/cgi-bin/proxy.cgi',
'title' => "$Lang::tr{'web proxy'}",