From 314fbe82b79b19499507ec5e8043a4b32c9885a8 Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Sat, 26 Oct 2024 03:35:05 +0800
Subject: [PATCH 1/6] luci-app-firewall: add nft-fullcone and bcm-fullcone
 option

Signed-off-by: sbwml <admin@cooluc.com>
---
 .../resources/view/firewall/zones.js          | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
index 41b9834..b41ebae 100644
--- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
+++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
@@ -58,6 +58,27 @@ return view.extend({
 
 		o = s.option(form.Flag, 'drop_invalid', _('Drop invalid packets'));
 
+		/* Netfilter FullCone NAT support */
+
+		if (L.hasSystemFeature('fullcone')) {
+			o = s.option(form.RichListValue, "fullcone_type", _("Full Cone NAT"));
+			o.value('0', _("Disable"));
+			o.value('1', _("Nftables Fullcone nat"), _('Nftables based fullcone nat scheme.'));
+			o.value('2', _("Broadcom Fullcone nat"), _('Broadcom based fullcone nat scheme.'));
+			o.optional = false;
+			o.load = function (section_id) {
+				var fullcone = uci.get('firewall', section_id, 'fullcone');
+				var brcmfullcone = uci.get('firewall', section_id, 'brcmfullcone');
+				return (fullcone === '1')
+					? (brcmfullcone === '1' ? '2' : '1')
+					: '0';
+			};
+			o.write = function(section_id, value) {
+				uci.set('firewall', section_id, 'fullcone', value === '0' ? null : '1');
+				uci.set('firewall', section_id, 'brcmfullcone', value === '2' ? '1' : null);
+			};
+		}
+
 		var p = [
 			s.option(form.ListValue, 'input', _('Input')),
 			s.option(form.ListValue, 'output', _('Output')),
-- 
2.42.0

