From 2eee57c7c433bc6d48384a299b839520911687be Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 29 May 2012 00:43:39 +0000 Subject: [PATCH] [packages] miniupnpd: use network.sh to find devices and subnets git-svn-id: svn://svn.openwrt.org/openwrt/packages@31963 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/miniupnpd/files/miniupnpd.init | 31 +++++------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/net/miniupnpd/files/miniupnpd.init b/net/miniupnpd/files/miniupnpd.init index 9865030a0..7c38ef0e2 100644 --- a/net/miniupnpd/files/miniupnpd.init +++ b/net/miniupnpd/files/miniupnpd.init @@ -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