1 # Copyright (C) 2009-2010 OpenWrt.org
3 FW_LIBDIR
=${FW_LIBDIR:-/lib/firewall}
14 echo "firewall already loaded" >&2
18 uci_set_state firewall core
"" firewall_state
24 echo "Loading defaults"
25 fw_config_once fw_load_defaults defaults
28 config_foreach fw_load_zone zone
30 echo "Loading forwardings"
31 config_foreach fw_load_forwarding forwarding
33 echo "Loading redirects"
34 config_foreach fw_load_redirect redirect
37 config_foreach fw_load_rule rule
39 echo "Loading includes"
40 config_foreach fw_load_include include
42 [ -z "$FW_NOTRACK_DISABLED" ] && {
43 echo "Optimizing conntrack"
44 config_foreach fw_load_notrack_zone zone
47 echo "Loading interfaces"
48 config_foreach fw_configure_interface interface add
52 uci_set_state firewall core zones
"$FW_ZONES"
53 uci_set_state firewall core loaded
1
62 config_get z core zones
64 config_get n core
"${z}_networks"
66 config_get i core
"${n}_ifname"
67 [ -n "$i" ] && env
-i ACTION
=remove ZONE
="$z" \
68 INTERFACE
="$n" DEVICE
="$i" /sbin
/hotplug-call firewall
76 uci_revert_state firewall
80 for h
in $FW_HOOKS; do unset $h; done
96 local bool
=$
(uci_get_state firewall.core.loaded
)
97 return $
((! ${bool:-0}))
102 echo "Error:" "$@" >&2
110 [ -n "$2" ] && shift || level
=notice
111 [ "$level" != error
] ||
echo "Error: $@" >&2
112 logger
-t firewall
-p user.
$level "$@"
117 [ -z "$FW_INITIALIZED" ] ||
return 0
119 .
$FW_LIBDIR/config.sh
122 fw_config_append firewall
124 local hooks
="core stop defaults zone notrack synflood"
126 for file in $FW_LIBDIR/core_
*.sh
; do
128 hk
=$
(basename $file .sh
)
132 for file in $FW_LIBDIR/*.sh
; do
133 lib
=$
(basename $file .sh
)
134 lib
=${lib##[0-9][0-9]_}
136 core
*|fw|config|uci_firewall
) continue ;;
140 for pp
in pre post
; do
141 type ${lib}_${pp}_${hk}_cb
>/dev
/null
&& {
142 append FW_CB_
${pp}_${hk} ${lib}
143 append FW_HOOKS FW_CB_
${pp}_
${hk}
149 fw_callback post init