summaryrefslogtreecommitdiff
path: root/package/network/config/firewall/files/firewall.init
blob: 1147b833357208cf2f3597c30f59ee4bc668237c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh /etc/rc.common

START=19
USE_PROCD=1
QUIET=""

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")'
	
	return $?
}

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'
	
	return $?
}

service_triggers() {
	procd_add_reload_trigger firewall	

	procd_open_validate
	validate_firewall_redirect
	validate_firewall_rule
	procd_close_validate
}

restart() {
	fw3 restart
}

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=1
	start
}