diff --git a/net/miniupnpd/Makefile b/net/miniupnpd/Makefile index ca0dfaaf5..8c342dfc0 100644 --- a/net/miniupnpd/Makefile +++ b/net/miniupnpd/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2011 OpenWrt.org +# Copyright (C) 2006-2012 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=miniupnpd PKG_VERSION:=1.6.20110730 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_URL:=http://miniupnp.free.fr/files PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/net/miniupnpd/files/miniupnpd.init b/net/miniupnpd/files/miniupnpd.init index c29e67254..9865030a0 100644 --- a/net/miniupnpd/files/miniupnpd.init +++ b/net/miniupnpd/files/miniupnpd.init @@ -57,6 +57,23 @@ 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 @@ -109,8 +126,10 @@ start() { local ipaddr netmask config_get ipaddr "$iface" ipaddr config_get netmask "$iface" netmask "255.255.255.0" - [ -n "$ipaddr" ] && \ - echo "listening_ip=$ipaddr/$netmask" >>$tmpconf + [ -n "$ipaddr" ] && { + upnpd_netmask2prefix "$netmask" + echo "listening_ip=$ipaddr/$?" >>$tmpconf + } done [ "$port" != "auto" ] && \