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