miniupnpd: use network.sh to find devices and subnets
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 29 May 2012 00:43:39 +0000 (00:43 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 29 May 2012 00:43:39 +0000 (00:43 +0000)
SVN-Revision: 31963

net/miniupnpd/files/miniupnpd.init

index 9865030a04cf3d5e842901263216c6e2a7a73ce4..7c38ef0e29372ccc704af0b0f3ef62b33357a720 100644 (file)
@@ -57,23 +57,6 @@ upnpd_write_bool() {
        fi
 }
 
-upnpd_netmask2prefix() {
-       local octet
-       local prefix=0
-       local IFS="."
-
-       set -- $1
-
-       for octet in $1 $2 $3 $4; do
-               while [ $octet -gt 0 ]; do
-                       prefix=$(($prefix + ($octet & 1)))
-                       octet=$(($octet >> 1))
-               done
-       done
-
-       return $prefix
-}
-
 start() {
        type miniupnpd_add_rules >/dev/null 2>/dev/null || \
                ACTION=- . /etc/hotplug.d/firewall/50-miniupnpd
@@ -103,11 +86,10 @@ start() {
 
        local args
 
-       include /lib/network
-       scan_interfaces
+       . /lib/functions/network.sh
 
        local ifname
-       config_get ifname ${extiface:-wan} ifname
+       network_get_device ifname ${extiface:-wan}
 
        if [ -n "$conffile" ]; then
                args="-f $conffile"
@@ -123,12 +105,9 @@ start() {
 
                local iface
                for iface in ${intiface:-lan}; do
-                       local ipaddr netmask
-                       config_get ipaddr "$iface" ipaddr
-                       config_get netmask "$iface" netmask "255.255.255.0"
-                       [ -n "$ipaddr" ] && {
-                               upnpd_netmask2prefix "$netmask"
-                               echo "listening_ip=$ipaddr/$?" >>$tmpconf
+                       local ipnet
+                       network_get_subnet ipnet "$iface" && {
+                               echo "listening_ip=$ipnet" >>$tmpconf
                        }
                done