3 miniupnpd_add_rules
() {
10 logger
-t miniupnpd
"adding firewall rules for $iface to zone $zone"
12 iptables
-t nat
-N MINIUPNPD
2>/dev
/null
13 iptables
-t nat
-I zone_
${zone}_prerouting
-i $iface -j MINIUPNPD
14 iptables
-t filter
-N MINIUPNPD
2>/dev
/null
15 iptables
-t filter
-I zone_
${zone}_forward
-i $iface ! -o $iface -j MINIUPNPD
17 uci_set_state upnpd state
"" state
18 uci_set_state upnpd state zone
"$zone"
19 uci_set_state upnpd state ifname
"$iface"
20 uci_set_state upnpd state network
"$network"
23 miniupnpd_remove_rules
() {
24 local zone
="$(uci_get_state upnpd state zone)"
25 local iface
="$(uci_get_state upnpd state ifname)"
27 [ -n "$zone" ] && [ -n "$iface" ] && {
28 logger
-t miniupnpd
"removing firewall rules for $iface from zone $zone"
30 while iptables
-t nat
-D zone_
${zone}_prerouting \
31 -i $iface -j MINIUPNPD
2>/dev
/null
; do :; done
33 while iptables
-t filter
-D zone_
${zone}_forward \
34 -i $iface ! -o $iface -j MINIUPNPD
2>/dev
/null
; do :; done
37 uci_revert_state upnpd
40 /etc
/init.d
/miniupnpd enabled
&& [ -n "`pidof miniupnpd`" ] && {
42 local extif
="$(uci_get upnpd config external_iface)"
43 local curif
="$(uci_get_state upnpd state network)"
45 if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "$extif" ]; then
46 miniupnpd_add_rules
"$ZONE" "$INTERFACE" "$DEVICE"
47 elif [ "$ACTION" = "remove" ] && [ "$INTERFACE" = "$curif" ]; then
48 miniupnpd_remove_rules