Add more license tags with SPDX identifiers
[openwrt-github/.git] / package / network / config / firewall / files / firewall.init
index 64e3a8c12ba864bfd9b9f07e98687df84c41122d..ee3ed1a28356759e71930ebc2bb0158451e0a7d3 100755 (executable)
@@ -1,25 +1,61 @@
 #!/bin/sh /etc/rc.common
 
 START=19
+USE_PROCD=1
+QUIET=""
 
-boot() {
-       # Be silent on boot, firewall might be started by hotplug already,
-       # so don't complain in syslog.
-       fw3 -q start
+validate_firewall_redirect()
+{
+       uci_validate_section firewall redirect "${1}" \
+               'proto:or(uinteger, string)' \
+               'src:string' \
+               'src_ip:cidr' \
+               'src_dport:or(port, portrange)' \
+               'dest:string' \
+               'dest_ip:cidr' \
+               'dest_port:or(port, portrange)' \
+               'target:or("SNAT", "DNAT")'
 }
 
-start() {
-       fw3 start
+validate_firewall_rule()
+{
+       uci_validate_section firewall rule "${1}" \
+               'proto:or(uinteger, string)' \
+               'src:string' \
+               'dest:string' \
+               'src_port:or(port, portrange)' \
+               'dest_port:or(port, portrange)' \
+               'target:string'
 }
 
-stop() {
-       fw3 flush
+service_triggers() {
+       procd_add_reload_trigger firewall       
+
+       procd_open_validate
+       validate_firewall_redirect
+       validate_firewall_rule
+       procd_close_validate
 }
 
 restart() {
        fw3 restart
 }
 
-reload() {
+start_service() {
+       fw3 ${QUIET} start
+}
+
+stop_service() {
+       fw3 flush
+}
+
+reload_service() {
        fw3 reload
 }
+
+boot() {
+       # Be silent on boot, firewall might be started by hotplug already,
+       # so don't complain in syslog.
+       QUIET=-q
+       start
+}