[packages] natpmp: use network.sh to find device names

git-svn-id: svn://svn.openwrt.org/openwrt/packages@31976 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2012-05-29 01:47:57 +00:00
parent debb9936a4
commit 635485f819
2 changed files with 9 additions and 8 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=natpmp PKG_NAME:=natpmp
PKG_VERSION:=0.2.3 PKG_VERSION:=0.2.3
PKG_RELEASE:=4 PKG_RELEASE:=5
PKG_SOURCE_URL:=http://download.savannah.nongnu.org/releases/natpmp/ PKG_SOURCE_URL:=http://download.savannah.nongnu.org/releases/natpmp/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View File

@ -22,8 +22,7 @@ start() {
config_load natpmp config_load natpmp
config_foreach natpmp_config natpmp config_foreach natpmp_config natpmp
include /lib/network . /lib/functions/network.sh
scan_interfaces
# Flush all the rules in the natpmp chain, or create it, if it doesn't exists. # 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 || \ $IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null || \
@ -36,15 +35,16 @@ start() {
# Iterate through the private interfaces. # Iterate through the private interfaces.
BIND_ARGS="" BIND_ARGS=""
for IF in $PRIVATE_IFS; do 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. # 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 if [ -n "$ADDR" ] ; then
# Add the IP address to the argument list. # Add the IP address to the argument list.
BIND_ARGS="$BIND_ARGS -a $ADDR" BIND_ARGS="$BIND_ARGS -a $ADDR"
else else
echo "Could not get IP address of interface $IF. Skipping." >&2 echo "Could not get IP address of interface $dev. Skipping." >&2
fi fi
done done
@ -53,10 +53,11 @@ start() {
exit 1 exit 1
fi 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_PID_FILE="$PIDFILE"
service_start $NATPMP -i "$PUBLIC_IF" $BIND_ARGS -- "$IPTABLES_CHAIN" service_start $NATPMP -i "$pubdev" $BIND_ARGS -- "$IPTABLES_CHAIN"
} }
stop() { stop() {