From 435c46d654f735af8d310162b26e1437d59afb37 Mon Sep 17 00:00:00 2001 From: Fedor Date: Wed, 9 Mar 2011 14:05:48 -0500 Subject: [PATCH] Miniupnpd ver 1.5 (20110309) --- release/src/router/miniupnpd/Changelog.txt | 11 +- release/src/router/miniupnpd/Makefile.linux | 19 ++- release/src/router/miniupnpd/Makefile.openwrt | 95 ----------- release/src/router/miniupnpd/README.openwrt | 76 --------- release/src/router/miniupnpd/config.h.openwrt | 29 ---- release/src/router/miniupnpd/genconfig.sh | 13 +- release/src/router/miniupnpd/miniupnpdpath.h | 9 +- release/src/router/miniupnpd/netfilter/iptcrdr.c | 6 +- release/src/router/miniupnpd/upnpdescgen.c | 192 ++++++++++++++++++----- release/src/router/miniupnpd/upnpglobalvars.h | 6 +- 10 files changed, 198 insertions(+), 258 deletions(-) delete mode 100644 release/src/router/miniupnpd/Makefile.openwrt delete mode 100644 release/src/router/miniupnpd/README.openwrt delete mode 100644 release/src/router/miniupnpd/config.h.openwrt diff --git a/release/src/router/miniupnpd/Changelog.txt b/release/src/router/miniupnpd/Changelog.txt index 35b276cb4c..cd5f41da25 100644 --- a/release/src/router/miniupnpd/Changelog.txt +++ b/release/src/router/miniupnpd/Changelog.txt @@ -1,4 +1,13 @@ -$Id: Changelog.txt,v 1.208 2011/03/02 16:04:22 nanard Exp $ +$Id: Changelog.txt,v 1.211 2011/03/09 15:27:41 nanard Exp $ + +2011/03/09: + Some modifications thanks to Daniel Dickinson to improve OpenWRT + build. + Fixed some warnings. + +2011/03/03: + Added code to generate devices/services descriptions for IGD v2 + (to be continued) 2011/03/02: improved netfilter/delete_redirect_and_filter_rules() in order diff --git a/release/src/router/miniupnpd/Makefile.linux b/release/src/router/miniupnpd/Makefile.linux index dfd0546110..ce6e842379 100644 --- a/release/src/router/miniupnpd/Makefile.linux +++ b/release/src/router/miniupnpd/Makefile.linux @@ -1,4 +1,4 @@ -# $Id: Makefile.linux,v 1.52 2010/08/07 21:04:48 nanard Exp $ +# $Id: Makefile.linux,v 1.53 2011/03/09 15:22:46 nanard Exp $ # MiniUPnP project # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ # Author : Thomas Bernard @@ -17,11 +17,12 @@ # $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux # #CFLAGS = -Wall -O -D_GNU_SOURCE -g -DDEBUG -CFLAGS = -Wall -Os -D_GNU_SOURCE -CC = gcc +CFLAGS ?= -Wall -Os -D_GNU_SOURCE +CC ?= gcc RM = rm -f INSTALL = install -STRIP = strip +STRIP ?= strip +CP = cp INSTALLPREFIX ?= $(PREFIX)/usr SBININSTALLDIR = $(INSTALLPREFIX)/sbin @@ -38,16 +39,17 @@ NETFILTEROBJS = netfilter/iptcrdr.o ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) -LIBS = -liptc +LIBS ?= -liptc # the following is better, at least on gentoo with iptables 1.4.6 # see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1618 #LIBS = -lip4tc -ARCH := $(shell uname -m | grep -q "x86_64" && echo 64) +ARCH ?= $(shell uname -m | grep -q "x86_64" && echo 64) ifdef IPTABLESPATH CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/ LDFLAGS := $(LDFLAFGS) -L$(IPTABLESPATH)/libiptc/ # get iptables version and set IPTABLES_143 macro if needed +ifeq ($(TARGET_OPENWRT),) IPTABLESVERSION := $(shell grep "\#define VERSION" $(IPTABLESPATH)/config.h | tr -d \" |cut -d" " -f3 ) IPTABLESVERSION1 := $(shell echo $(IPTABLESVERSION) | cut -d. -f1 ) IPTABLESVERSION2 := $(shell echo $(IPTABLESVERSION) | cut -d. -f2 ) @@ -74,6 +76,7 @@ LIBS = -liptc /usr/lib$(ARCH)/libiptc.a endif endif endif +endif TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o @@ -105,7 +108,11 @@ install: miniupnpd genuuid # genuuid is using the uuidgen CLI tool which is part of libuuid # from the e2fsprogs genuuid: +ifeq ($(TARGET_OPENWRT),) sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen) 2>/dev/null`/" miniupnpd.conf +else + sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen) 2>/dev/null`/" miniupnpd.conf +endif miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(LIBS) diff --git a/release/src/router/miniupnpd/Makefile.openwrt b/release/src/router/miniupnpd/Makefile.openwrt deleted file mode 100644 index 33bfb7a7c7..0000000000 --- a/release/src/router/miniupnpd/Makefile.openwrt +++ /dev/null @@ -1,95 +0,0 @@ -# $Id: Makefile.openwrt,v 1.12 2008/05/01 23:11:18 nanard Exp $ -# http://miniupnp.free.fr/ -# Author : Thomas Bernard -# for use with GNU Make -# This Makefile would probably need some modifications depending on -# your openwrt SDK/etc... -# http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=713 - -#include $(TOPDIR)/rules.mk -#CFLAGS = -Wall -O -D_GNU_SOURCE -g -#CFLAGS = -Wall -Os -D_GNU_SOURCE -#CC = mipsel-linux-gcc -CC = $(TARGET_CC) -CFLAGS = $(TARGET_CFLAGS) -CFLAGS += -D_GNU_SOURCE -CP = cp -RM = rm -f -INSTALL = install -IPTABLESINC=$(STAGING_DIR)/usr/include -#IPTABLESINC=$(BUILD_DIR)/iptables-1.3.3/include -#IPTABLESINC=$(TOPDIR)/../iptables-1.3.3/include - -BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ - upnpreplyparse.o minixml.o \ - upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \ - options.o upnppermissions.o minissdp.o natpmp.o - -LNXOBJS = linux/getifstats.o -NETFILTEROBJS = netfilter/iptcrdr.o -ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) - -#LIBS = $(BUILD_DIR)/iptables-1.3.3/libiptc/libiptc.a -#LIBS = $(TOPDIR)/../iptables-1.3.3/libiptc/libiptc.a - -TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o - -EXECUTABLES = miniupnpd testupnpdescgen - -.PHONY: all clean install depend - -all: $(EXECUTABLES) - -clean: - $(RM) $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(EXECUTABLES) \ - testupnpdescgen.o - -install: miniupnpd - @echo no install for now... - -miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(LIBS) - -testupnpdescgen: $(TESTUPNPDESCGENOBJS) - -netfilter/iptcrdr.o: netfilter/iptcrdr.c - $(CC) $(CFLAGS) -I$(IPTABLESINC) -c -o $@ $< - -depend: config.h - makedepend -f$(MAKEFILE_LIST) -Y \ - $(ALLOBJS:.o=.c) $(TESTUPNPDESCGENOBJS:.o=.c) \ - 2>/dev/null - -config.h: config.h.openwrt - $(CP) $< $@ - -# DO NOT DELETE - -miniupnpd.o: config.h upnpglobalvars.h upnppermissions.h miniupnpdtypes.h -miniupnpd.o: upnphttp.h upnpdescgen.h miniupnpdpath.h getifaddr.h daemonize.h -miniupnpd.o: upnpsoap.h options.h minissdp.h upnpredirect.h natpmp.h -upnphttp.o: upnphttp.h config.h upnpdescgen.h miniupnpdpath.h upnpsoap.h -upnpdescgen.o: upnpdescgen.h miniupnpdpath.h upnpglobalvars.h -upnpdescgen.o: upnppermissions.h config.h miniupnpdtypes.h upnpdescstrings.h -upnpsoap.o: upnpglobalvars.h upnppermissions.h config.h miniupnpdtypes.h -upnpsoap.o: upnphttp.h upnpsoap.h upnpreplyparse.h upnpredirect.h getifaddr.h -upnpsoap.o: getifstats.h -upnpreplyparse.o: upnpreplyparse.h minixml.h -minixml.o: minixml.h -upnpredirect.o: config.h upnpredirect.h upnpglobalvars.h upnppermissions.h -upnpredirect.o: miniupnpdtypes.h netfilter/iptcrdr.h commonrdr.h -getifaddr.o: getifaddr.h -daemonize.o: daemonize.h -upnpglobalvars.o: upnpglobalvars.h upnppermissions.h config.h -upnpglobalvars.o: miniupnpdtypes.h -options.o: options.h upnppermissions.h config.h upnpglobalvars.h -options.o: miniupnpdtypes.h -upnppermissions.o: config.h upnppermissions.h -minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h -minissdp.o: upnpglobalvars.h upnppermissions.h miniupnpdtypes.h minissdp.h -natpmp.o: config.h natpmp.h upnpglobalvars.h upnppermissions.h -natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h -linux/getifstats.o: getifstats.h config.h -netfilter/iptcrdr.o: netfilter/iptcrdr.h commonrdr.h config.h -testupnpdescgen.o: upnpdescgen.h -upnpdescgen.o: upnpdescgen.h miniupnpdpath.h upnpglobalvars.h -upnpdescgen.o: upnppermissions.h config.h miniupnpdtypes.h upnpdescstrings.h diff --git a/release/src/router/miniupnpd/README.openwrt b/release/src/router/miniupnpd/README.openwrt deleted file mode 100644 index adcd34a402..0000000000 --- a/release/src/router/miniupnpd/README.openwrt +++ /dev/null @@ -1,76 +0,0 @@ -MiniUPnP Daemon -(c) 2006 Thomas Bernard -This software is subject to the conditions detailed in -the LICENCE file provided within the distribution. - -How to build and run miniupnpd for your router running openwrt. -These instructions apply to the OpenWRT WHITE RUSSIAN (RC6) version. -My device is a Linksys WRT54G v1, used in pppoe mode. -More information about OpenWRT on http://openwrt.org/ - -First make sure that openwrt white russian RC6 is up and running on your -router device. - -NOTES : Makefile.openwrt has been updated, following informations could - be inacurate. - The X-Wrt team made an ipk package out of miniupnpd, - check the webpage : http://www.x-wrt.org/ - -* A. COMPILATION * - -To Build, use your PC. I have been using the SDK but you might need -to compile the cross compiler yourself. - -1. Get the SDK from http://downloads.openwrt.org/whiterussian/rc6/ - I used http://downloads.openwrt.org/whiterussian/rc6/OpenWrt-SDK-Linux-ppc-1.tar.bz2 - unpack somewhere and add the bin directory to your PATH environement : - > tar xvjf OpenWrt-SDK-Linux-i686-1.tar.bz2 - > PATH=`pwd`/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin:$PATH - > mipsel-linux-gcc --version -mipsel-linux-gcc (GCC) 3.4.4 (OpenWrt-1.0) -[...] - -2. Get iptables 1.3.3 sources from http://downloads.openwrt.org/sources/iptables-1.3.3.tar.bz2 - unpack and compile libiptc.a - > tar xvjf iptables-1.3.3.tar.bz2 - > cd iptables-1.3.3/libiptc/ - > make CC=mipsel-linux-gcc - -3. Go to miniupnpd directory and edit the Makefile.openwrt to make - IPTABLESINC and LIBS variables point to the correct directory. - > make -f Makefile.openwrt - > mipsel-linux-strip miniupnpd - -That's it ! - - -* B. INSTALLATION - USAGE * - -1. copy miniupnpd and scripts to the device : - > scp miniupnpd root@192.168.1.1:. - > cd linux - > scp iptables_init.sh iptables_flush.sh root@192.168.1.1:. - > scp iptables_display.sh iptables_removall.sh root@192.168.1.1:. - -2. log onto your router and edit the scripts in order to adapt to your - configuration : EXTIF variable shoud be set to your external network - interface. In my case it is ppp0 - -3. init tables : - > ./iptables_init.sh - -4. run the daemon : - ./miniupnpd -i ppp0 -a 192.168.1.1 -p 5000 -U -d - -d option is a debug option to prevent the program from going to - background. It is usefull to see the debug messages and check if everything - is ok. - -5. Once you checked that everything is ok, - you can set up a script in /etc/init.d etc... - - If you can build an ipkg package for miniupnpd, I'll be glad ! - -Thomas -contact me by email : miniupnp@free.fr - - diff --git a/release/src/router/miniupnpd/config.h.openwrt b/release/src/router/miniupnpd/config.h.openwrt deleted file mode 100644 index e01b43705b..0000000000 --- a/release/src/router/miniupnpd/config.h.openwrt +++ /dev/null @@ -1,29 +0,0 @@ -/* $Id: config.h.openwrt,v 1.4 2011/02/28 17:30:24 nanard Exp $ */ -/* MiniUPnP Project - * http:///miniupnp.free.fr - * (c) 2006-2011 Thomas Bernard - */ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#define MINIUPNPD_VERSION "1.5" - -#define UPNP_VERSION "20070228" -#define USE_NETFILTER 1 -#define OS_NAME "OpenWRT" -/* OS/version */ -#define OS_VERSION "OpenWRT/kamikaze" -#define OS_URL "http://openwrt.org/" - -#define LOG_MINIUPNPD LOG_DAEMON - -/* Comment the following line to disable NAT-PMP operations */ -#define ENABLE_NATPMP - -/* Comment the following line to use home made daemonize() func instead - * of BSD daemon() */ -#define USE_DAEMON - -#define ENABLE_L3F_SERVICE - -#endif diff --git a/release/src/router/miniupnpd/genconfig.sh b/release/src/router/miniupnpd/genconfig.sh index c786e4a768..d35009e995 100755 --- a/release/src/router/miniupnpd/genconfig.sh +++ b/release/src/router/miniupnpd/genconfig.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Id: genconfig.sh,v 1.40 2011/01/04 11:55:18 nanard Exp $ +# $Id: genconfig.sh,v 1.41 2011/03/09 15:09:07 nanard Exp $ # miniupnp daemon # http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/ # (c) 2006-2011 Thomas Bernard @@ -28,6 +28,12 @@ if [ -f /etc/platform ]; then fi fi +# OpenWRT special case +if [ -f ./os.openwrt ]; then + OS_NAME=OpenWRT + OS_VERSION=$(cat ./os.openwrt) +fi + ${RM} ${CONFIGFILE} echo "/* MiniUPnP Project" >> ${CONFIGFILE} @@ -176,6 +182,11 @@ case $OS_NAME in echo "#define USE_NETFILTER 1" >> ${CONFIGFILE} FW=netfilter ;; + OpenWRT) + OS_URL=http://www.openwrt.org/ + echo "#define USE_NETFILTER 1" >> ${CONFIGFILE} + FW=netfilter + ;; Darwin) echo "#define USE_IPFW 1" >> ${CONFIGFILE} FW=ipfw diff --git a/release/src/router/miniupnpd/miniupnpdpath.h b/release/src/router/miniupnpd/miniupnpdpath.h index 339ff8f76d..506bba7de1 100644 --- a/release/src/router/miniupnpd/miniupnpdpath.h +++ b/release/src/router/miniupnpd/miniupnpdpath.h @@ -1,7 +1,7 @@ -/* $Id: miniupnpdpath.h,v 1.5 2008/02/21 12:54:18 nanard Exp $ */ +/* $Id: miniupnpdpath.h,v 1.6 2011/03/03 17:27:18 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2008 Thomas Bernard + * (c) 2006-2011 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -32,5 +32,10 @@ #define L3F_EVENTURL "/evt/L3F" #endif +/* For DeviceProtection introduced in IGD v2 */ +#define DP_PATH "/DP.xml" +#define DP_CONTROLURL "/ctl/DP" +#define DP_EVENTURL "/evt/DP" + #endif diff --git a/release/src/router/miniupnpd/netfilter/iptcrdr.c b/release/src/router/miniupnpd/netfilter/iptcrdr.c index 8d061443ef..a2d22e0d01 100644 --- a/release/src/router/miniupnpd/netfilter/iptcrdr.c +++ b/release/src/router/miniupnpd/netfilter/iptcrdr.c @@ -1,4 +1,4 @@ -/* $Id: iptcrdr.c,v 1.38 2011/03/02 16:04:22 nanard Exp $ */ +/* $Id: iptcrdr.c,v 1.39 2011/03/09 15:27:42 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2011 Thomas Bernard @@ -399,8 +399,8 @@ delete_redirect_and_filter_rules(unsigned short eport, int proto) const struct ipt_entry_target * target; const struct ip_nat_multi_range * mr; const struct ipt_entry_match *match; - unsigned short iport; - uint32_t iaddr; + unsigned short iport = 0; + uint32_t iaddr = 0; h = iptc_init("nat"); if(!h) diff --git a/release/src/router/miniupnpd/upnpdescgen.c b/release/src/router/miniupnpd/upnpdescgen.c index 60d53e9ddd..9e88efa864 100644 --- a/release/src/router/miniupnpd/upnpdescgen.c +++ b/release/src/router/miniupnpd/upnpdescgen.c @@ -1,4 +1,4 @@ -/* $Id: upnpdescgen.c,v 1.52 2011/01/02 09:25:50 nanard Exp $ */ +/* $Id: upnpdescgen.c,v 1.53 2011/03/03 17:27:18 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2011 Thomas Bernard @@ -19,6 +19,21 @@ #include "upnpglobalvars.h" #include "upnpdescstrings.h" +#ifdef IGD_V2 +/* IGD v2 */ +#define DEVICE_TYPE_IGD "urn:schemas-upnp-org:device:InternetGatewayDevice:2" +#define DEVICE_TYPE_WAN "urn:schemas-upnp-org:device:WANDevice:2" +#define DEVICE_TYPE_WANC "urn:schemas-upnp-org:device:WANConnectionDevice:2" +#define SERVICE_TYPE_WANIPC "urn:schemas-upnp-org:service:WANIPConnection:2" +#define ENABLE_DP_SERVICE +#else +/* IGD v1 */ +#define DEVICE_TYPE_IGD "urn:schemas-upnp-org:device:InternetGatewayDevice:1" +#define DEVICE_TYPE_WAN "urn:schemas-upnp-org:device:WANDevice:1" +#define DEVICE_TYPE_WANC "urn:schemas-upnp-org:device:WANConnectionDevice:1" +#define SERVICE_TYPE_WANIPC "urn:schemas-upnp-org:service:WANIPConnection:1" +#endif + static const char * const upnptypes[] = { "string", @@ -61,6 +76,16 @@ static const char * const upnpallowedvalues[] = "Disconnected", 0, "ERROR_NONE", /* 25 */ +/* Optionals values : + * ERROR_COMMAND_ABORTED + * ERROR_NOT_ENABLED_FOR_INTERNET + * ERROR_USER_DISCONNECT + * ERROR_ISP_DISCONNECT + * ERROR_IDLE_DISCONNECT + * ERROR_FORCED_DISCONNECT + * ERROR_NO_CARRIER + * ERROR_IP_CONFIGURATION + * ERROR_UNKNOWN */ 0, "", /* 27 */ 0 @@ -83,7 +108,7 @@ static const struct XMLElt rootDesc[] = /* 0 */ {root_device, INITHELPER(1,2)}, {"specVersion", INITHELPER(3,2)}, -#if defined(ENABLE_L3F_SERVICE) || defined(HAS_DUMMY_SERVICE) +#if defined(ENABLE_L3F_SERVICE) || defined(HAS_DUMMY_SERVICE) || defined(ENABLE_DP_SERVICE) {"device", INITHELPER(5,13)}, #else {"device", INITHELPER(5,12)}, @@ -91,8 +116,8 @@ static const struct XMLElt rootDesc[] = {"/major", "1"}, {"/minor", "0"}, /* 5 */ - {"/deviceType", "urn:schemas-upnp-org:device:InternetGatewayDevice:1"}, - /* urn:schemas-upnp-org:device:InternetGatewayDevice:2 for v2 */ + {"/deviceType", DEVICE_TYPE_IGD}, + /* urn:schemas-upnp-org:device:InternetGatewayDevice:1 or 2 */ {"/friendlyName", ROOTDEV_FRIENDLYNAME}, /* required */ {"/manufacturer", ROOTDEV_MANUFACTURER}, /* required */ /* 8 */ @@ -103,8 +128,13 @@ static const struct XMLElt rootDesc[] = {"/modelURL", ROOTDEV_MODELURL}, {"/serialNumber", serialnumber}, {"/UDN", uuidvalue}, /* required */ -#if defined(ENABLE_L3F_SERVICE) || defined(HAS_DUMMY_SERVICE) + /* see if /UPC is needed. */ +#if defined(ENABLE_L3F_SERVICE) || defined(HAS_DUMMY_SERVICE) || defined(ENABLE_DP_SERVICE) +#ifdef ENABLE_DP_SERVICE + {"serviceList", INITHELPER(57,2)}, +#else {"serviceList", INITHELPER(57,1)}, +#endif {"deviceList", INITHELPER(18,1)}, {"/presentationURL", presentationurl}, /* recommended */ #else @@ -115,8 +145,8 @@ static const struct XMLElt rootDesc[] = /* 18 */ {"device", INITHELPER(19,13)}, /* 19 */ - {"/deviceType", "urn:schemas-upnp-org:device:WANDevice:1"}, /* required */ - /* urn:schemas-upnp-org:device:WANDevice:2 for v2 */ + {"/deviceType", DEVICE_TYPE_WAN}, /* required */ + /* urn:schemas-upnp-org:device:WANDevice:1 or 2 */ {"/friendlyName", WANDEV_FRIENDLYNAME}, {"/manufacturer", WANDEV_MANUFACTURER}, {"/manufacturerURL", WANDEV_MANUFACTURERURL}, @@ -143,8 +173,8 @@ static const struct XMLElt rootDesc[] = /* 38 */ {"device", INITHELPER(39,12)}, /* 39 */ - {"/deviceType", "urn:schemas-upnp-org:device:WANConnectionDevice:1"}, - /* urn:schemas-upnp-org:device:WANConnectionDevice:2 for v2 */ + {"/deviceType", DEVICE_TYPE_WANC}, + /* urn:schemas-upnp-org:device:WANConnectionDevice:1 or 2 */ {"/friendlyName", WANCDEV_FRIENDLYNAME}, {"/manufacturer", WANCDEV_MANUFACTURER}, {"/manufacturerURL", WANCDEV_MANUFACTURERURL}, @@ -159,17 +189,17 @@ static const struct XMLElt rootDesc[] = /* 51 */ {"service", INITHELPER(52,5)}, /* 52 */ - {"/serviceType", "urn:schemas-upnp-org:service:WANIPConnection:1"}, - /* urn:schemas-upnp-org:service:WANIPConnection:2 for v2 */ - /* {"/serviceId", "urn:upnp-org:serviceId:WANIPConnection"}, */ + {"/serviceType", SERVICE_TYPE_WANIPC}, + /* urn:schemas-upnp-org:service:WANIPConnection:2 for v2 */ {"/serviceId", "urn:upnp-org:serviceId:WANIPConn1"}, {"/controlURL", WANIPC_CONTROLURL}, {"/eventSubURL", WANIPC_EVENTURL}, {"/SCPDURL", WANIPC_PATH}, /* 57 */ #ifdef HAS_DUMMY_SERVICE - {"service", INITHELPER(58,5)}, -/* 58 */ + {"service", INITHELPER(59,5)}, + {"service", INITHELPER(64,5)}, +/* 59 */ {"/serviceType", "urn:schemas-dummy-com:service:Dummy:1"}, {"/serviceId", "urn:dummy-com:serviceId:dummy1"}, {"/controlURL", "/dummy"}, @@ -177,18 +207,28 @@ static const struct XMLElt rootDesc[] = {"/SCPDURL", DUMMY_PATH}, #endif #ifdef ENABLE_L3F_SERVICE - {"service", INITHELPER(58,5)}, -/* 58 */ + {"service", INITHELPER(59,5)}, + {"service", INITHELPER(64,5)}, +/* 59 */ {"/serviceType", "urn:schemas-upnp-org:service:Layer3Forwarding:1"}, {"/serviceId", "urn:upnp-org:serviceId:Layer3Forwarding1"}, {"/controlURL", L3F_CONTROLURL}, /* The Layer3Forwarding service is only */ {"/eventSubURL", L3F_EVENTURL}, /* recommended, not mandatory */ {"/SCPDURL", L3F_PATH}, #endif -/* TODO : add for InternetDatewayDevice v2 : -serviceType : urn:schemas-upnp-org:service:DeviceProtection:1 -serviceId : urn:upnp-org:serviceId:DeviceProtection1 -*/ +#ifdef ENABLE_DP_SERVICE +/* InternetGatewayDevice v2 : + * it is RECOMMEDED that DeviceProtection service is implemented and applied. + * If DeviceProtection is not implemented and applied, it is RECOMMENDED + * that control points are able to access only actions and parameters defined + * as Public role. */ +/* 64 */ + {"/serviceType", "urn:schemas-upnp-org:service:DeviceProtection:1"}, + {"/serviceId", "urn:upnp-org:serviceId:DeviceProtection1"}, + {"/controlURL", DP_CONTROLURL}, + {"/eventSubURL", DP_EVENTURL}, + {"/SCPDURL", DP_PATH}, +#endif {0, 0} }; @@ -202,17 +242,53 @@ static struct XMLElt scpdWANIPCn[] = */ static const struct argument AddPortMappingArgs[] = { - {1, 11}, - {1, 12}, - {1, 14}, - {1, 13}, - {1, 15}, - {1, 9}, - {1, 16}, - {1, 10}, + {1, 11}, /* RemoteHost */ + {1, 12}, /* ExternalPort */ + {1, 14}, /* PortMappingProtocol */ + {1, 13}, /* InternalPort */ + {1, 15}, /* InternalClient */ + {1, 9}, /* PortMappingEnabled */ + {1, 16}, /* PortMappingDescription */ + {1, 10}, /* PortMappingLeaseDuration */ + {0, 0} +}; + +#ifdef IGD_V2 +static const struct argument AddAnyPortMappingArgs[] = +{ + {1, 11}, /* RemoteHost */ + {1, 12}, /* ExternalPort */ + {1, 14}, /* PortMappingProtocol */ + {1, 13}, /* InternalPort */ + {1, 15}, /* InternalClient */ + {1, 9}, /* PortMappingEnabled */ + {1, 16}, /* PortMappingDescription */ + {1, 10}, /* PortMappingLeaseDuration */ + {2, 12}, /* NewReservedPort / ExternalPort */ {0, 0} }; +static const struct argument DeletePortMappingRangeArgs[] = +{ + {1, 12}, /* NewStartPort / ExternalPort */ + {1, 12}, /* NewEndPort / ExternalPort */ + {1, 14}, /* NewProtocol / PortMappingProtocol */ + {1, 18}, /* NewManage / A_ARG_TYPE_Manage */ + {0, 0} +}; + +static const struct argument GetListOfPortMappingsArgs[] = +{ + {1, 12}, /* NewStartPort / ExternalPort */ + {1, 12}, /* NewEndPort / ExternalPort */ + {1, 14}, /* NewProtocol / PortMappingProtocol */ + {1, 18}, /* NewManage / A_ARG_TYPE_Manage */ + {1, 8}, /* NewNumberOfPorts / PortMappingNumberOfEntries */ + {2, 19}, /* NewPortListing / A_ARG_TYPE_PortListing */ + {0, 0} +}; +#endif + static const struct argument GetExternalIPAddressArgs[] = { {2, 7}, @@ -296,12 +372,11 @@ static const struct action WANIPCnActions[] = {"GetGenericPortMappingEntry", GetGenericPortMappingEntryArgs}, /* R */ {"GetSpecificPortMappingEntry", GetSpecificPortMappingEntryArgs}, /* R */ /* added in v2 UPnP-gw-WANIPConnection-v2-Service.pdf */ -/* -SetConnectionType -AddAnyPortMapping -DeletePortMappingRange -GetListOfPortMappings -*/ +#ifdef IGD_V2 + {"AddAnyPortMapping", AddAnyPortMappingArgs}, + {"DeletePortMappingRange", DeletePortMappingRangeArgs}, + {"GetListOfPortMappings", GetListOfPortMappingsArgs}, +#endif {0, 0} }; /* R=Required, O=Optional */ @@ -333,19 +408,31 @@ static const struct stateVar WANIPCnVars[] = {"ExternalIPAddress", 0|0x80, 0, 0, 254}, /* required. Default : empty string */ {"PortMappingNumberOfEntries", 2|0x80, 0, 0, 253}, /* required >= 0 */ {"PortMappingEnabled", 1, 0}, /* Required */ +/* 10 */ {"PortMappingLeaseDuration", 3, 0}, /* required */ + /* TODO : for IGD v2 : + * + * PortMappingLeaseDuration + * ui4 + * Vendor-defined + * + * 0 + * 604800 + * + * */ {"RemoteHost", 0, 0}, /* required. Default : empty string */ {"ExternalPort", 2, 0}, /* required */ {"InternalPort", 2, 0}, /* required */ + /* TODO : add for IGD v2 */ {"PortMappingProtocol", 0, 0, 11}, /* required allowedValues: TCP/UDP */ {"InternalClient", 0, 0}, /* required */ {"PortMappingDescription", 0, 0}, /* required default: empty string */ /* added in v2 UPnP-gw-WANIPConnection-v2-Service.pdf */ -/* -SystemUpdateID -A_ARG_TYPE_Manage -A_ARG_TYPE_PortListing -*/ +#ifdef IGD_V2 + {"SystemUpdateID", 3, 0}, + {"A_ARG_TYPE_Manage", 1, 0}, + {"A_ARG_TYPE_PortListing", 0, 0}, +#endif {0, 0} }; @@ -640,10 +727,31 @@ genServiceDesc(int * len, const struct serviceDesc * s) p = vars[args[j].relatedVar].name; if(0 == memcmp(p, "PortMapping", 11) && 0 != memcmp(p + 11, "Description", 11)) { - if(0 == memcmp(p + 11, "NumberOfEntries", 15)) + if(0 == memcmp(p + 11, "NumberOfEntries", 15)) { + /* PortMappingNumberOfEntries */ +#ifdef IGD_V2 + if(0 == memcmp(acts[i].name, "GetListOfPortMappings", 22)) { + str = strcat_str(str, len, &tmplen, "NumberOfPorts"); + } else { + str = strcat_str(str, len, &tmplen, "PortMappingIndex"); + } +#else str = strcat_str(str, len, &tmplen, "PortMappingIndex"); - else +#endif + } else { + /* PortMappingEnabled + * PortMappingLeaseDuration + * PortMappingProtocol */ str = strcat_str(str, len, &tmplen, p + 11); + } +#ifdef IGD_V2 + } else if(0 == memcmp(p, "A_ARG_TYPE_", 11)) { + str = strcat_str(str, len, &tmplen, p + 11); + } else if(0 == memcmp(p, "ExternalPort", 13) + && args[j].dir == 2 + && 0 == memcmp(acts[i].name, "AddAnyPortMapping", 18)) { + str = strcat_str(str, len, &tmplen, "ReservedPort"); +#endif } else { str = strcat_str(str, len, &tmplen, p); } @@ -804,7 +912,7 @@ getVarsWANIPCn(int * l) { return genEventVars(l, &scpdWANIPCn, - "urn:schemas-upnp-org:service:WANIPConnection:1"); + SERVICE_TYPE_WANIPC); } char * diff --git a/release/src/router/miniupnpd/upnpglobalvars.h b/release/src/router/miniupnpd/upnpglobalvars.h index 14c5d0a712..30b5a20a3e 100644 --- a/release/src/router/miniupnpd/upnpglobalvars.h +++ b/release/src/router/miniupnpd/upnpglobalvars.h @@ -1,7 +1,7 @@ -/* $Id: upnpglobalvars.h,v 1.22 2010/09/21 15:31:01 nanard Exp $ */ +/* $Id: upnpglobalvars.h,v 1.23 2011/03/09 15:27:41 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2010 Thomas Bernard + * (c) 2006-2011 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -49,7 +49,7 @@ extern int runtime_flags; #endif #define SETFLAG(mask) runtime_flags |= mask -#define GETFLAG(mask) runtime_flags & mask +#define GETFLAG(mask) (runtime_flags & mask) #define CLEARFLAG(mask) runtime_flags &= ~mask extern const char * pidfilename; -- 2.11.4.GIT