[packages] miniupnpd: convert netmask to prefix and write listen address in CIDR...
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 12 Jan 2012 11:00:31 +0000 (11:00 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 12 Jan 2012 11:00:31 +0000 (11:00 +0000)
SVN-Revision: 29722

net/miniupnpd/Makefile
net/miniupnpd/files/miniupnpd.init

index ca0dfaaf589f9e13dfc84354d3cda3b66378dc4f..8c342dfc0b668b90e66cf0881df6675ee2905d2d 100644 (file)
@@ -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
index c29e67254ae700b9eae12597757806116efc2f5a..9865030a04cf3d5e842901263216c6e2a7a73ce4 100644 (file)
@@ -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" ] && \