--- ------ extra functions ------ --
-
-function ruleCheck() -- determine if rule needs a protocol specified
- local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".src_port"))
- local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".dest_port"))
- if sourcePort ~= "" or destPort ~= "" then -- ports configured
- local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. arg[1] .. ".proto"))
- if protocol == "" or protocol == "all" then -- no or improper protocol
- error_protocol = 1
- end
- end
-end
-
-function ruleWarn() -- display warning message at the top of the page
- if error_protocol == 1 then
- return "<font color=\"ff0000\"><strong>WARNING: this rule is incorrectly configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>"
- else
- return ""
- end
-end
-
-function cbiAddPolicy(field)
- uci.cursor():foreach("mwan3", "policy",
- function (section)
- field:value(section[".name"])
- end
- )
-end
-
-function cbiAddProtocol(field)
- local protocols = ut.trim(sys.exec("cat /etc/protocols | grep ' # ' | awk '{print $1}' | grep -vw -e 'ip' -e 'tcp' -e 'udp' -e 'icmp' -e 'esp' | grep -v 'ipv6' | sort | tr '\n' ' '"))
- for p in string.gmatch(protocols, "%S+") do
- field:value(p)
- end
-end
-
--- ------ rule configuration ------ --
-