natpmp: use network.sh to find device names
authorJo-Philipp Wich <[email protected]>
Tue, 29 May 2012 01:47:57 +0000 (01:47 +0000)
committerJo-Philipp Wich <[email protected]>
Tue, 29 May 2012 01:47:57 +0000 (01:47 +0000)
SVN-Revision: 31976

net/natpmp/Makefile
net/natpmp/files/natpmp.init

index 4bb496ef4812f8e219a674fae81410c85f9f2473..c936359d85251cff02ff2c94457223c7cb51fc5b 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=natpmp
 PKG_VERSION:=0.2.3
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE_URL:=http://download.savannah.nongnu.org/releases/natpmp/
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
index 3b4bba2457fd33108d2d16cb32ea6eeb2520e4cf..374e3648f57253ea4bd53f7ad421d5badcd01589 100644 (file)
@@ -22,8 +22,7 @@ start() {
        config_load natpmp
        config_foreach natpmp_config natpmp
 
-       include /lib/network
-       scan_interfaces
+       . /lib/functions/network.sh
 
        # Flush all the rules in the natpmp chain, or create it, if it doesn't exists.
        $IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null || \
@@ -36,15 +35,16 @@ start() {
        # Iterate through the private interfaces.
        BIND_ARGS=""
        for IF in $PRIVATE_IFS; do
-               config_get IF "$IF" ifname "$IF"
+               local dev
+               network_get_device dev "$IF" || dev="$IF"
 
                # Get the IP address of this interface.
-               ADDR=`$IP addr show dev $IF 2>/dev/null | grep "^ *inet .* $IF\$" | cut -d " " -f 6 | cut -d / -f 1`
+               ADDR=`$IP addr show dev $dev 2>/dev/null | grep "^ *inet .* $dev\$" | cut -d " " -f 6 | cut -d / -f 1`
                if [ -n "$ADDR" ] ; then
                        # Add the IP address to the argument list.
                        BIND_ARGS="$BIND_ARGS -a $ADDR"
                else
-                       echo "Could not get IP address of interface $IF. Skipping." >&2
+                       echo "Could not get IP address of interface $dev. Skipping." >&2
                fi
        done
 
@@ -53,10 +53,11 @@ start() {
                exit 1
        fi
 
-       config_get PUBLIC_IF "$PUBLIC_IF" ifname "$PUBLIC_IF"
+       local pubdev
+       network_get_device pubdev "$PUBLIC_IF" || pubdev="$PUBLIC_IF"
 
        SERVICE_PID_FILE="$PIDFILE"
-       service_start $NATPMP -i "$PUBLIC_IF" $BIND_ARGS -- "$IPTABLES_CHAIN"
+       service_start $NATPMP -i "$pubdev" $BIND_ARGS -- "$IPTABLES_CHAIN"
 }
 
 stop() {