--- /dev/null
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=miniupnpd
+PKG_VERSION:=0.1
+PKG_RELEASE:=2
+PKG_MD5SUM:=4ba2a49c593d0c1088cc5791b8c6a985
+
+PKG_SOURCE_URL:=http://ftp.berlios.de/pub/xwrt/storage/
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/miniupnpd
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=+iptables
+ TITLE:=Lightweight UPnP daemon
+ DESCRIPTION:=\
+ Lightweight UPnP daemon
+ URL:=http://miniupnp.tuxfamily.org/
+endef
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) -f Makefile.openwrt
+endef
+
+define Build/Clean
+ # remove the client dir since the build system doesnt know about it
+ rm -rf $(PKG_BUILD_DIR)/../miniupnpc
+endef
+
+define Package/miniupnpd/install
+ $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/miniupnpd $(1)/usr/bin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/linux/*.sh $(1)/usr/bin/
+ $(INSTALL_BIN) ./files/miniupnpd.init $(1)/etc/init.d/miniupnpd
+ $(STRIP) $(1)/usr/bin/miniupnpd
+endef
+
+$(eval $(call BuildPackage,miniupnpd))
--- /dev/null
+#!/bin/sh
+upnpd_enabled=$(nvram get upnp_enabled)
+if [ "$upnpd_enabled" = "1" ]; then
+ echo "miniupnpd starting ..."
+ iptables_flush.sh 2>&- >&-
+ killall miniupnpd 2>&-
+ iptables_removeall.sh 2>&- >&-
+ iptables_init.sh
+ upnpd_log=$(nvram get upnpd_log_output)
+ if [ "$upnpd_log" = "1" ]; then
+ miniupnpd -i $(nvram get wan_ifname) -a $(nvram get lan_ipaddr) -p 5000 -U -d | logger -t miniupnpd &
+ else
+ miniupnpd -i $(nvram get wan_ifname) -a $(nvram get lan_ipaddr) -p 5000 -U
+ fi
+else
+ echo "miniupnpd service is disabled. Set nvram upnp_enabled to '1' to enable."
+fi
--- /dev/null
+--- miniupnpd.orig/Makefile.openwrt 2006-11-23 06:31:06.000000000 -0600
++++ miniupnpd/Makefile.openwrt 2006-11-26 17:16:20.000000000 -0600
+@@ -2,12 +2,13 @@
+ # http://miniupnp.free.fr/
+ # Author : Thomas Bernard
+ # for use with GNU Make
+-#CFLAGS = -Wall -O -D_GNU_SOURCE -g
+-CFLAGS = -Wall -Os -D_GNU_SOURCE
+-CC = mipsel-linux-gcc
++include $(TOPDIR)/rules.mk
++CC = $(TARGET_CC)
++CFLAGS = $(TARGET_CFLAGS)
++CFLAGS += -D_GNU_SOURCE
+ RM = rm -f
+ INSTALL = install
+-IPTABLESINC=/home/nanard/code/openwrt/iptables-1.3.3/include
++IPTABLESINC=$(STAGING_DIR)/usr/include
+
+ BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
+ ../miniupnpc/upnpreplyparse.o ../miniupnpc/minixml.o \
+@@ -15,7 +16,7 @@
+
+ LNXOBJS = linux/getifstats.o linux/iptcrdr.o
+
+-LIBS = /home/nanard/code/openwrt/iptables-1.3.3/libiptc/libiptc.a
++LIBS = $(STAGING_DIR)/usr/lib/libiptc.a
+
+ TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
+
+@@ -32,6 +33,7 @@
+ @echo no install for now...
+
+ miniupnpd: $(BASEOBJS) $(LNXOBJS) $(LIBS)
++ $(CC) $(CFLAGS) -o $@ $(BASEOBJS) $(LNXOBJS) $(LIBS)
+
+ testupnpdescgen: $(TESTUPNPDESCGENOBJS)
+
--- /dev/null
+diff -urN miniupnpd.orig/linux/iptables_init.sh miniupnpd/linux/iptables_init.sh
+--- miniupnpd.orig/linux/iptables_init.sh 2006-11-23 07:56:34.000000000 -0500
++++ miniupnpd/linux/iptables_init.sh 2006-11-24 18:57:43.000000000 -0500
+@@ -2,8 +2,7 @@
+ # $Id: iptables_init.sh,v 1.3 2006/11/23 12:32:57 nanard Exp $
+ IPTABLES=iptables
+
+-#change this parameters :
+-EXTIF=eth0
++EXTIF=$(nvram get wan_device)
+ EXTIP="`LC_ALL=C /sbin/ifconfig $EXTIF | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
+ echo "External IP = $EXTIP"
+
+diff -urN miniupnpd.orig/linux/iptables_removeall.sh miniupnpd/linux/iptables_removeall.sh
+--- miniupnpd.orig/linux/iptables_removeall.sh 2006-11-23 07:56:34.000000000 -0500
++++ miniupnpd/linux/iptables_removeall.sh 2006-11-24 19:00:47.000000000 -0500
+@@ -2,8 +2,7 @@
+ # $Id: iptables_removeall.sh,v 1.3 2006/11/23 12:32:57 nanard Exp $
+ IPTABLES=iptables
+
+-#change this parameters :
+-EXTIF=eth0
++EXTIF=$(nvram get wan_device)
+ EXTIP="`LC_ALL=C /sbin/ifconfig $EXTIF | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
+
+ #removing the MINIUPNPD chain for nat