2008-08-04 19:51:58 +08:00
|
|
|
. /lib/firewall/uci_firewall.sh
|
|
|
|
unset ZONE
|
|
|
|
config_get ifname $INTERFACE ifname
|
2009-01-17 01:39:03 +08:00
|
|
|
[ "$ifname" == "lo" ] && exit 0
|
|
|
|
|
2008-08-04 19:51:58 +08:00
|
|
|
load_zones() {
|
|
|
|
local name
|
|
|
|
local network
|
|
|
|
config_get name $1 name
|
|
|
|
config_get network $1 network
|
2008-08-12 04:51:51 +08:00
|
|
|
[ -z "$network" ] && network=$name
|
2008-08-04 19:51:58 +08:00
|
|
|
for n in $network; do
|
2009-01-17 01:39:03 +08:00
|
|
|
[ "$n" = "$INTERFACE" ] && ZONE="$ZONE $name"
|
2008-08-04 19:51:58 +08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
config_foreach load_zones zone
|
|
|
|
|
2008-08-12 04:46:17 +08:00
|
|
|
[ -z "$ZONE" ] && exit 0
|
2008-08-04 19:51:58 +08:00
|
|
|
|
|
|
|
[ ifup = "$ACTION" ] && {
|
|
|
|
for z in $ZONE; do
|
|
|
|
local loaded
|
|
|
|
config_get loaded core loaded
|
2009-01-17 01:39:03 +08:00
|
|
|
[ -n "$loaded" ] && addif "$INTERFACE" "$ifname" "$z"
|
2008-08-04 19:51:58 +08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
[ ifdown = "$ACTION" ] && {
|
|
|
|
for z in $ZONE; do
|
|
|
|
local up
|
|
|
|
config_get up $z up
|
2009-01-17 01:39:03 +08:00
|
|
|
[ "$up" == "1" ] && delif "$INTERFACE" "$ifname" "$z"
|
2008-08-04 19:51:58 +08:00
|
|
|
done
|
|
|
|
}
|