From patchwork Tue Dec 22 20:06:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3746 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4D0nS06jJBz3wgG for ; Tue, 22 Dec 2020 20:07:12 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4D0nRt1wKXz3Bt; Tue, 22 Dec 2020 20:07:06 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4D0nRs6FkYz30F7; Tue, 22 Dec 2020 20:07:05 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4D0nRs1Kytz2xlZ for ; Tue, 22 Dec 2020 20:07:05 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4D0nRq60HDzty for ; Tue, 22 Dec 2020 20:07:03 +0000 (UTC) Received: (qmail 17527 invoked from network); 22 Dec 2020 20:07:03 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 22 Dec 2020 20:07:03 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH 3/4] zoneconf.cgi: Add STP options to GUI Date: Tue, 22 Dec 2020 21:06:45 +0100 Message-Id: <20201222200646.1609-3-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20201222200646.1609-1-hofmann@leo-andres.de> References: <20201222200646.1609-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1608667624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RpGu18N50OmJUtU5cyqha8VAuDOAzs2VYcEsBm1NBCI=; b=mNFmeotWfhsaAgXLsQzmUCpZA9lKwSQjmV20U7R41RYWR8dCMjcDvDKzQ9F7n+QMi4l66t jhCc7gnauoibB5uYU1vHZor+L7TqEMaDmAHAzp+XM3h7pAQ0KjeCLQIsRbYTax+weYFahH YHly+j6EdrucwImhc7j0HWRvM1TSPM6qmQATf5/82wn2p89mr9rxeNa8EpmTqvbA6euI7N VfpzXTOdgo5GU1+qpAWtBfRo50Xc6xmMDqoaKs6EcsrFXckDqhcgMKobGNFhz3SB3cEq7g zb+50EzOhjdd+my/6HURJWLTq+n0MowZ0TZOmE//yEq6DhkKE2+iJJOIcIGxpQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1608667624; a=rsa-sha256; cv=none; b=OhCZeA/GvDhT5K1eRu2kNSxUjdkcKbUPzS5wggMI2PdhGLHttWIHYjdlfDFkdhvMcMtlwk HTmnnhO/cuWq1Xeqzr2Cea/orZVqshfEARbr19wjS3T650LbopuO9Pp+0eS8SmiBA8BMZS 4wTq3zrXr/P9myWO39+J9JMjS+R8AMFjnA8BzcRw4N+6QDLg766uD6M1cN/OzXZV8WvkFG hXw2vYEpq9iBhlbhAI0pLxO8z0U7pTU/Vjv7gS51vcpTd5wGHrWlHqxHOo/ZrTErnozyZ6 5fzE2Hoi4Vcj2CE7z5dFpZnI77oCHfIY3Bj1qCOjO9UNHTFRqEou/ba+Ssd+ew== X-Spamd-Result: default: False [-2.31 / 11.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.00), ip: 185.26.156.147(0.00)]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCPT_COUNT_ONE(0.00)[1]; DMARC_NA(0.00)[leo-andres.de]; R_SPF_ALLOW(-0.20)[+mx]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[99.99%] X-Rspamd-Queue-Id: 4D0nRq60HDzty Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Changes & new features: - Add CSS for STP options, add texts to language files - Read STP settings from ethernet configuration and display inputs - Validate and save STP settings Signed-off-by: Leo-Andres Hofmann Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de> --- html/cgi-bin/zoneconf.cgi | 100 ++++++++++++++++++++++++++++++++++++++ langs/de/cgi-bin/de.pl | 4 ++ langs/en/cgi-bin/en.pl | 4 ++ 3 files changed, 108 insertions(+) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 13543d244..1d30450ed 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -40,6 +40,13 @@ my $extraHead = < td { + padding: 2px 10px; + } + /* section separators */ #zoneconf tr.divider-top { border-top: 2px solid $Header::bordercolour; @@ -75,6 +82,9 @@ my $extraHead = < td:first-child { + background-color: gray; + } /* alternating row background color */ #zoneconf tr { @@ -108,6 +118,9 @@ my $extraHead = <= 1) && ($stp_priority <= 65535)) { # STP bridge priority range: 1..65535 + $VALIDATE_error = $Lang::tr{"zoneconf val stp priority range error"}; + last; + } + $ethsettings{"${uc}_STP"} = "on"; # network-hotplug-bridges expects "on" + $ethsettings{"${uc}_STP_PRIORITY"} = $stp_priority; + } } # validation failed, show error message and exit @@ -481,6 +513,74 @@ END print "\t\n"; } +# STP options +my @stp_html = (); # form fields buffer (two rows) + +foreach (@zones) { # load settings and prepare form elements for each zone + my $uc = uc $_; + + # skip if zone is not activated + next unless is_zone_activated($_); + + # STP is not available if the RED interface is set to PPP, PPPoE, VDSL, ... + if ($uc eq "RED") { + unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) { + push(@stp_html, ["\t\t\n", "\t\t\n"]); # print empty cell + next; + } + } + + # load configuration + my $stp_available = $ethsettings{"${uc}_MODE"} eq "bridge"; # STP is only available in bridge mode + my $stp_enabled = $ethsettings{"${uc}_STP"} eq "on"; + my $stp_priority = $ethsettings{"${uc}_STP_PRIORITY"}; + + # form element modifiers + my $checked = ""; + my $disabled = ""; + $checked = "checked" if ($stp_available && $stp_enabled); + $disabled = "disabled" unless $stp_available; + + # enable checkbox HTML + my $row_1 = < + + +END +; + $disabled = "disabled" unless $stp_enabled; # STP priority can't be entered if STP is disabled + + # priority input box HTML + my $row_2 = < + + +END +; + # add fields to buffer + push(@stp_html, [$row_1, $row_2]); +} + +# print two rows of prepared form elements +print < + $Lang::tr{"zoneconf stp enable"} +END +; +foreach (@stp_html) { + print $_->[0]; # row 1 +} +print < + + $Lang::tr{"zoneconf stp priority"} +END +; +foreach (@stp_html) { + print $_->[1]; # row 2 +} +print "\t\n"; + # footer and submit button print < diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 38c9783f8..f3e4aca7e 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2977,9 +2977,13 @@ 'zoneconf nicmode default' => 'Normal', 'zoneconf nicmode macvtap' => 'MacVTap', 'zoneconf notice reboot' => 'Bitte einen Neustart durchführen, um die Änderungen zu übernehmen.', +'zoneconf stp enable' => 'STP aktivieren', +'zoneconf stp priority' => 'Brücke Priorität', 'zoneconf title' => 'Zonen einrichten', 'zoneconf val native assignment error' => 'Eine Netzwerkkarte kann nicht von mehreren Zonen nativ verwendet werden.', 'zoneconf val ppp assignment error' => 'Die Netzwerkkarte, die von RED im PPP-Modus verwendet wird, kann keiner anderen Zone zugeordnet werden.', +'zoneconf val stp priority range error' => 'STP Brücke Priorität muss im Bereich 1-65535 liegen', +'zoneconf val stp zone mode error' => 'STP kann nur aktiviert werden, wenn sich die Zone im Brückenmodus befindet', 'zoneconf val vlan amount assignment error' => 'Pro Zone kann nur ein VLAN verwendet werden.', 'zoneconf val vlan tag assignment error' => 'Pro Netzwerkkarte kann derselbe VLAN-Tag nur einmal verwendet werden.', 'zoneconf val zoneslave amount error' => 'Wenn eine Zone nicht im Brückenmodus ist, kann ihr nur eine Netzwerkkarte zugewiesen werden.', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 500913240..649139c73 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -3025,9 +3025,13 @@ 'zoneconf nicmode default' => 'Default', 'zoneconf nicmode macvtap' => 'MacVTap', 'zoneconf notice reboot' => 'Please reboot to apply your changes.', +'zoneconf stp enable' => 'STP enable', +'zoneconf stp priority' => 'Bridge Priority', 'zoneconf title' => 'Zone Configuration', 'zoneconf val native assignment error' => 'A NIC cannot be accessed natively by more than one zone.', 'zoneconf val ppp assignment error' => 'The NIC used for RED in PPP mode cannot be accessed by any other zone.', +'zoneconf val stp priority range error' => 'STP bridge priority must be in the range of 1-65535', +'zoneconf val stp zone mode error' => 'STP can only be enabled if the zone is in bridge mode', 'zoneconf val vlan amount assignment error' => 'A zone cannot have more than one VLAN assigned.', 'zoneconf val vlan tag assignment error' => 'You cannot use the same VLAN tag more than once per NIC.', 'zoneconf val zoneslave amount error' => 'A zone that is not in bridge mode can\'t have more than one NIC assigned',