From ae985a5abb9bdce2e2491830bcaf4ffa268a28cb Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 7 Feb 2009 00:11:58 +0000 Subject: [PATCH] (trunk libT) update to the newest versions of miniupnp and libnatpmp --- libtransmission/upnp.c | 4 ++-- third-party/libnatpmp/README | 2 +- third-party/miniupnp/Changelog.txt | 20 +++++++++++++++++++- third-party/miniupnp/README | 2 +- third-party/miniupnp/minisoap.c | 5 +++-- third-party/miniupnp/minissdpc.c | 8 +++++++- third-party/miniupnp/miniupnpc.c | 20 ++++++++++++++------ third-party/miniupnp/miniwget.c | 8 ++++++-- third-party/miniupnp/upnpcommands.c | 14 +++++++++----- third-party/miniupnp/upnpcommands.h | 12 +++++++++--- 10 files changed, 71 insertions(+), 24 deletions(-) diff --git a/libtransmission/upnp.c b/libtransmission/upnp.c index 87773bd4c..dbf950e19 100644 --- a/libtransmission/upnp.c +++ b/libtransmission/upnp.c @@ -133,7 +133,7 @@ tr_upnpPulse( tr_upnp * handle, tr_snprintf( portStr, sizeof( portStr ), "%d", handle->port ); UPNP_DeletePortMapping( handle->urls.controlURL, handle->data.servicetype, - portStr, "TCP" ); + portStr, "TCP", NULL ); tr_ninf( getKey( ), _( "Stopping port forwarding through \"%s\", service \"%s\"" ), @@ -165,7 +165,7 @@ tr_upnpPulse( tr_upnp * handle, err = UPNP_AddPortMapping( handle->urls.controlURL, handle->data.servicetype, portStr, portStr, handle->lanaddr, - desc, "TCP" ); + desc, "TCP", NULL ); handle->isMapped = !err; } tr_ninf( getKey( ), diff --git a/third-party/libnatpmp/README b/third-party/libnatpmp/README index 541b21cb3..4d20797bc 100644 --- a/third-party/libnatpmp/README +++ b/third-party/libnatpmp/README @@ -1,4 +1,4 @@ libnatpmp is written by Thomas Bernard. Its homepage is http://miniupnp.tuxfamily.org/libnatpmp.html -This code is from the libnatpmp-20081006 snapshot +This code is from the libnatpmp-20090129 snapshot diff --git a/third-party/miniupnp/Changelog.txt b/third-party/miniupnp/Changelog.txt index b207d05ba..7c5c9fd79 100644 --- a/third-party/miniupnp/Changelog.txt +++ b/third-party/miniupnp/Changelog.txt @@ -1,6 +1,24 @@ -$Id: Changelog.txt,v 1.72 2008/09/25 18:02:50 nanard Exp $ +$Id: Changelog.txt,v 1.77 2008/12/18 17:47:32 nanard Exp $ miniUPnP client Changelog. +2008/12/18: + cleanup in Makefile (thanks to Paul de Weerd) + minissdpc.c : win32 compatibility + miniupnpc.c : changed xmlns prefix from 'm' to 'u' + Removed NDEBUG (using DEBUG) + +2008/10/14: + Added the ExternalHost argument to DeletePortMapping() + +2008/10/11: + Added the ExternalHost argument to AddPortMapping() + Put a correct User-Agent: header in HTTP requests. + +VERSION 1.2 : + +2008/10/07: + Update docs + 2008/09/25: Integrated sameport patch from Dario Meloni : Added a "sameport" argument to upnpDiscover(). diff --git a/third-party/miniupnp/README b/third-party/miniupnp/README index 4ec58bff2..23c839658 100644 --- a/third-party/miniupnp/README +++ b/third-party/miniupnp/README @@ -1,3 +1,3 @@ MiniUPnP is written by Thomas Bernard. Its homepage is http://miniupnp.free.fr/ -This is from the miniupnpc-1.2 tarball (7 Oct 2008) +This is from miniupnpc-20090129.tar.gz diff --git a/third-party/miniupnp/minisoap.c b/third-party/miniupnp/minisoap.c index 502c6c176..04b1a92b8 100644 --- a/third-party/miniupnp/minisoap.c +++ b/third-party/miniupnp/minisoap.c @@ -1,4 +1,4 @@ -/* $Id: minisoap.c,v 1.15 2008/02/17 17:57:07 nanard Exp $ */ +/* $Id: minisoap.c,v 1.16 2008/10/11 16:39:29 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005 Thomas Bernard @@ -19,6 +19,7 @@ #include #endif #include "minisoap.h" +#include "miniupnpcstrings.h" /* only for malloc */ #include @@ -92,7 +93,7 @@ int soapPostSubmit(int fd, "POST %s HTTP/1.1\r\n" /* "POST %s HTTP/1.0\r\n"*/ "Host: %s%s\r\n" - "User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0\r\n" + "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" "Content-Length: %d\r\n" "Content-Type: text/xml\r\n" "SOAPAction: \"%s\"\r\n" diff --git a/third-party/miniupnp/minissdpc.c b/third-party/miniupnp/minissdpc.c index d37599fe6..59bd6abb1 100644 --- a/third-party/miniupnp/minissdpc.c +++ b/third-party/miniupnp/minissdpc.c @@ -1,4 +1,4 @@ -/* $Id: minissdpc.c,v 1.6 2008/10/06 23:08:39 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.7 2008/12/18 17:45:48 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2005-2008 Thomas Bernard @@ -10,8 +10,14 @@ #include #include #include +#ifdef WIN32 +#include +#include +#include +#else #include #include +#endif #include "minissdpc.h" #include "miniupnpc.h" diff --git a/third-party/miniupnp/miniupnpc.c b/third-party/miniupnp/miniupnpc.c index 6b97d79a5..7ea5b1bbb 100644 --- a/third-party/miniupnp/miniupnpc.c +++ b/third-party/miniupnp/miniupnpc.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.c,v 1.55 2008/09/25 18:02:50 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.57 2008/12/18 17:46:36 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2005-2007 Thomas Bernard @@ -8,13 +8,19 @@ #include #include #ifdef WIN32 +/* Win32 Specific includes and defines */ #include #include #include #define snprintf _snprintf +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#define strncasecmp _memicmp +#else #define strncasecmp memicmp +#endif #define MAXHOSTNAMELEN 64 #else +/* Standard POSIX includes */ #include #include #include @@ -39,6 +45,8 @@ #endif #define SOAPPREFIX "s" +#define SERVICEPREFIX "u" +#define SERVICEPREFIX2 'u' /* root description parsing */ void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) @@ -53,7 +61,7 @@ void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) parser.datafunc = IGDdata; parser.attfunc = 0; parsexml(&parser); -#ifndef NDEBUG +#ifdef DEBUG printIGD(data); #endif } @@ -150,8 +158,8 @@ int simpleUPnPcommand(int s, const char * url, const char * service, "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" "<" SOAPPREFIX ":Body>" - "" - "" + "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">" + "" "" "\r\n", action, service, action); } @@ -166,7 +174,7 @@ int simpleUPnPcommand(int s, const char * url, const char * service, "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" "<" SOAPPREFIX ":Body>" - "", + "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">", action, service); p = soapbody + soapbodylen; while(args->elt) @@ -198,7 +206,7 @@ int simpleUPnPcommand(int s, const char * url, const char * service, } *(p++) = '<'; *(p++) = '/'; - *(p++) = 'm'; + *(p++) = SERVICEPREFIX2; *(p++) = ':'; pe = action; while(*pe) diff --git a/third-party/miniupnp/miniwget.c b/third-party/miniupnp/miniwget.c index d627e92ee..70abe0977 100644 --- a/third-party/miniupnp/miniwget.c +++ b/third-party/miniupnp/miniwget.c @@ -1,4 +1,4 @@ -/* $Id: miniwget.c,v 1.19 2007/11/02 14:16:19 nanard Exp $ */ +/* $Id: miniwget.c,v 1.21 2008/12/18 17:45:18 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005 Thomas Bernard @@ -31,6 +31,8 @@ #include #endif +#include "miniupnpcstrings.h" + /* miniwget2() : * */ static void * @@ -96,6 +98,8 @@ miniwget2(const char * url, const char * host, "GET %s HTTP/1.1\r\n" "Host: %s:%d\r\n" "Connection: Close\r\n" + "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" + "\r\n", path, host, port); /*write(s, buf, strlen(buf));*/ @@ -137,7 +141,7 @@ miniwget2(const char * url, const char * host, } } *size = allreadyread; -#ifndef NDEBUG +#ifdef DEBUG printf("%d bytes read\n", *size); #endif closesocket(s); diff --git a/third-party/miniupnp/upnpcommands.c b/third-party/miniupnp/upnpcommands.c index 87e572218..552772259 100644 --- a/third-party/miniupnp/upnpcommands.c +++ b/third-party/miniupnp/upnpcommands.c @@ -1,7 +1,7 @@ -/* $Id: upnpcommands.c,v 1.19 2008/02/18 13:27:23 nanard Exp $ */ +/* $Id: upnpcommands.c,v 1.22 2008/12/18 17:45:18 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2008 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ @@ -303,7 +303,8 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, const char * inPort, const char * inClient, const char * desc, - const char * proto) + const char * proto, + const char * remoteHost) { struct UPNParg * AddPortMappingArgs; char buffer[4096]; @@ -317,6 +318,7 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, AddPortMappingArgs = calloc(9, sizeof(struct UPNParg)); AddPortMappingArgs[0].elt = "NewRemoteHost"; + AddPortMappingArgs[0].val = remoteHost; AddPortMappingArgs[1].elt = "NewExternalPort"; AddPortMappingArgs[1].val = extPort; AddPortMappingArgs[2].elt = "NewProtocol"; @@ -351,7 +353,8 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto) + const char * extPort, const char * proto, + const char * remoteHost) { /*struct NameValueParserData pdata;*/ struct UPNParg * DeletePortMappingArgs; @@ -366,6 +369,7 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, DeletePortMappingArgs = calloc(4, sizeof(struct UPNParg)); DeletePortMappingArgs[0].elt = "NewRemoteHost"; + DeletePortMappingArgs[0].val = remoteHost; DeletePortMappingArgs[1].elt = "NewExternalPort"; DeletePortMappingArgs[1].val = extPort; DeletePortMappingArgs[2].elt = "NewProtocol"; @@ -484,7 +488,7 @@ int UPNP_GetPortMappingNumberOfEntries(const char * controlURL, const char * ser char* p; int ret = UPNPCOMMAND_UNKNOWN_ERROR; simpleUPnPcommand(-1, controlURL, servicetype, "GetPortMappingNumberOfEntries", 0, buffer, &bufsize); -#ifndef NDEBUG +#ifdef DEBUG DisplayNameValueList(buffer, bufsize); #endif ParseNameValue(buffer, bufsize, &pdata); diff --git a/third-party/miniupnp/upnpcommands.h b/third-party/miniupnp/upnpcommands.h index 96ca6b687..eb6ce8353 100644 --- a/third-party/miniupnp/upnpcommands.h +++ b/third-party/miniupnp/upnpcommands.h @@ -1,4 +1,4 @@ -/* $Id: upnpcommands.h,v 1.14 2008/09/25 18:02:50 nanard Exp $ */ +/* $Id: upnpcommands.h,v 1.16 2008/10/14 18:05:28 nanard Exp $ */ /* Miniupnp project : http://miniupnp.free.fr/ * Author : Thomas Bernard * Copyright (c) 2005-2008 Thomas Bernard @@ -86,6 +86,8 @@ UPNP_GetLinkLayerMaxBitRates(const char* controlURL, unsigned int * bitrateUp); /* UPNP_AddPortMapping() + * if desc is NULL, it will be defaulted to "libminiupnpc" + * remoteHost is usually NULL because IGD don't support it. * * Return values : * 0 : SUCCESS @@ -114,9 +116,12 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, const char * inPort, const char * inClient, const char * desc, - const char * proto); + const char * proto, + const char * remoteHost); /* UPNP_DeletePortMapping() + * Use same argument values as what was used for AddPortMapping(). + * remoteHost is usually NULL because IGD don't support it. * Return Values : * 0 : SUCCESS * NON ZERO : error. Either an UPnP error code or an undefined error. @@ -126,7 +131,8 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, * 714 NoSuchEntryInArray - The specified value does not exist in the array */ LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto); + const char * extPort, const char * proto, + const char * remoteHost); /* UPNP_GetPortMappingNumberOfEntries() * not supported by all routers */