From: Jo-Philipp Wich Date: Thu, 12 Jan 2012 11:00:31 +0000 (+0000) Subject: [packages] miniupnpd: convert netmask to prefix and write listen address in CIDR... X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=74a8da3e086a1d994528eff2d952df62921ed35d;p=openwrt%2Fsvn-archive%2Farchive.git [packages] miniupnpd: convert netmask to prefix and write listen address in CIDR notation (#10767, #10770) SVN-Revision: 29722 --- diff --git a/net/miniupnpd/Makefile b/net/miniupnpd/Makefile index ca0dfaaf58..8c342dfc0b 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 c29e67254a..9865030a04 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" ] && \