From: Charles Kerr Date: Sun, 4 May 2008 22:09:33 +0000 (+0000) Subject: update to the miniupnpc-20080427 snapshot X-Git-Tag: 1.20~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5baa32dfea295c62983cfe43b7901a06f029fd11;p=transmission update to the miniupnpc-20080427 snapshot update to the libnatpmp-20080428 snapshot --- diff --git a/third-party/libnatpmp/README b/third-party/libnatpmp/README index f7df69f24..4bf23b005 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-20071213 snapshot +This code is from the libnatpmp-20080428 snapshot diff --git a/third-party/libnatpmp/natpmp.c b/third-party/libnatpmp/natpmp.c index 5e5b528cd..4aa031d89 100644 --- a/third-party/libnatpmp/natpmp.c +++ b/third-party/libnatpmp/natpmp.c @@ -1,6 +1,7 @@ -/* $Id: natpmp.c,v 1.4 2007/12/02 00:12:47 nanard Exp $ */ +/* $Id: natpmp.c,v 1.6 2008/04/28 02:58:34 nanard Exp $ */ /* libnatpmp - * Copyright (c) 2007, Thomas BERNARD + * Copyright (c) 2007-2008, Thomas BERNARD + * http://miniupnp.free.fr/libnatpmp.html * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -13,14 +14,20 @@ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include -#include -#include #include #include +#ifdef WIN32 +#include +#include +#include +#else +#include +#include +#include #include #include +#endif #include "natpmp.h" #include "getgateway.h" @@ -247,3 +254,69 @@ int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response) return n; } +#ifdef ENABLE_STRNATPMPERR +const char * strnatpmperr(int r) +{ + const char * s; + switch(r) { + case NATPMP_ERR_INVALIDARGS: + s = "invalid arguments"; + break; + case NATPMP_ERR_SOCKETERROR: + s = "socket() failed"; + break; + case NATPMP_ERR_CANNOTGETGATEWAY: + s = "cannot get default gateway ip address"; + break; + case NATPMP_ERR_CLOSEERR: + s = "close() failed"; + break; + case NATPMP_ERR_RECVFROM: + s = "recvfrom() failed"; + break; + case NATPMP_ERR_NOPENDINGREQ: + s = "no pending request"; + break; + case NATPMP_ERR_NOGATEWAYSUPPORT: + s = "the gateway does not support nat-pmp"; + break; + case NATPMP_ERR_CONNECTERR: + s = "connect() failed"; + break; + case NATPMP_ERR_WRONGPACKETSOURCE: + s = "packet not received from the default gateway"; + break; + case NATPMP_ERR_SENDERR: + s = "send() failed"; + break; + case NATPMP_ERR_FCNTLERROR: + s = "fcntl() failed"; + break; + case NATPMP_ERR_GETTIMEOFDAYERR: + s = "gettimeofday() failed"; + break; + case NATPMP_ERR_UNSUPPORTEDVERSION: + s = "unsupported nat-pmp version error from server"; + break; + case NATPMP_ERR_UNSUPPORTEDOPCODE: + s = "unsupported nat-pmp opcode error from server"; + break; + case NATPMP_ERR_UNDEFINEDERROR: + s = "undefined nat-pmp server error"; + break; + case NATPMP_ERR_NOTAUTHORIZED: + s = "not authorized"; + break; + case NATPMP_ERR_NETWORKFAILURE: + s = "network failure"; + break; + case NATPMP_ERR_OUTOFRESOURCES: + s = "nat-pmp server out of resources"; + break; + default: + s = "Unknown libnatpmp error"; + } + return s; +} +#endif + diff --git a/third-party/libnatpmp/natpmp.h b/third-party/libnatpmp/natpmp.h index a6647f6d1..da3f437a7 100644 --- a/third-party/libnatpmp/natpmp.h +++ b/third-party/libnatpmp/natpmp.h @@ -1,6 +1,7 @@ -/* $Id: natpmp.h,v 1.6 2007/12/13 14:55:16 nanard Exp $ */ +/* $Id: natpmp.h,v 1.8 2008/04/28 02:58:34 nanard Exp $ */ /* libnatpmp - * Copyright (c) 2007, Thomas BERNARD + * Copyright (c) 2007-2008, Thomas BERNARD + * http://miniupnp.free.fr/libnatpmp.html * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,7 +22,11 @@ #include #include +#ifdef WIN32 +#include +#else #include +#endif typedef struct { int s; /* socket */ @@ -171,4 +176,8 @@ int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout); * NATPMP_ERR_UNDEFINEDERROR */ int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response); +#ifdef ENABLE_STRNATPMPERR +const char * strnatpmperr(int t); +#endif + #endif diff --git a/third-party/miniupnp/README b/third-party/miniupnp/README index e44feef90..0e35a5f53 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 version 1.0 of miniupnpc +This is from the miniupnp-20080428 snapshot diff --git a/third-party/miniupnp/igd_desc_parse.c b/third-party/miniupnp/igd_desc_parse.c index 5b06facee..e839ff4c1 100644 --- a/third-party/miniupnp/igd_desc_parse.c +++ b/third-party/miniupnp/igd_desc_parse.c @@ -1,8 +1,8 @@ -/* $Id: igd_desc_parse.c,v 1.7 2006/11/19 22:32:33 nanard Exp $ */ +/* $Id: igd_desc_parse.c,v 1.8 2008/04/23 11:51:06 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * 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. * */ @@ -10,6 +10,9 @@ #include #include +/* TODO : rewrite this code so it correctly handle descriptions with + * both WANIPConnection and/or WANPPPConnection */ + /* Start element handler : * update nesting level counter and copy element name */ void IGDstartelt(void * d, const char * name, int l) @@ -18,6 +21,12 @@ void IGDstartelt(void * d, const char * name, int l) memcpy( datas->cureltname, name, l); datas->cureltname[l] = '\0'; datas->level++; + if( (l==7) && !memcmp(name, "service", l) ) { + datas->controlurl_tmp[0] = '\0'; + datas->eventsuburl_tmp[0] = '\0'; + datas->scpdurl_tmp[0] = '\0'; + datas->servicetype_tmp[0] = '\0'; + } } /* End element handler : @@ -30,7 +39,6 @@ void IGDendelt(void * d, const char * name, int l) /*printf("endelt %2d %.*s\n", datas->level, l, name);*/ if( (l==7) && !memcmp(name, "service", l) ) { - /*datas->state++; */ /* if( datas->state < 1 && !strcmp(datas->servicetype, @@ -38,15 +46,21 @@ void IGDendelt(void * d, const char * name, int l) "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) datas->state ++; */ - if(0==strcmp(datas->servicetype_CIF, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) - datas->state = 2; - if(0==strcmp(datas->servicetype, - "urn:schemas-upnp-org:service:WANIPConnection:1") ) - datas->state = 3; -/* if(0==strcmp(datas->servicetype, - "urn:schemas-upnp-org:service:WANPPPConnection:1") ) - datas->state = 4; */ + if(0==strcmp(datas->servicetype_tmp, + "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) { + memcpy(datas->controlurl_CIF, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->eventsuburl_CIF, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->scpdurl_CIF, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->servicetype_CIF, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE); + } else if(0==strcmp(datas->servicetype_tmp, + "urn:schemas-upnp-org:service:WANIPConnection:1") + || 0==strcmp(datas->servicetype_tmp, + "urn:schemas-upnp-org:service:WANPPPConnection:1") ) { + memcpy(datas->controlurl, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->eventsuburl, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->scpdurl, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE); + memcpy(datas->servicetype, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE); + } } } @@ -60,32 +74,16 @@ void IGDdata(void * d, const char * data, int l) datas->level, datas->cureltname, l, data); */ if( !strcmp(datas->cureltname, "URLBase") ) dstmember = datas->urlbase; - else if(datas->state<=1) - { - if( !strcmp(datas->cureltname, "serviceType") ) - dstmember = datas->servicetype_CIF; - else if( !strcmp(datas->cureltname, "controlURL") ) - dstmember = datas->controlurl_CIF; - else if( !strcmp(datas->cureltname, "eventSubURL") ) - dstmember = datas->eventsuburl_CIF; - else if( !strcmp(datas->cureltname, "SCPDURL") ) - dstmember = datas->scpdurl_CIF; - else if( !strcmp(datas->cureltname, "deviceType") ) - dstmember = datas->devicetype_CIF; - } - else if(datas->state==2) - { - if( !strcmp(datas->cureltname, "serviceType") ) - dstmember = datas->servicetype; - else if( !strcmp(datas->cureltname, "controlURL") ) - dstmember = datas->controlurl; - else if( !strcmp(datas->cureltname, "eventSubURL") ) - dstmember = datas->eventsuburl; - else if( !strcmp(datas->cureltname, "SCPDURL") ) - dstmember = datas->scpdurl; - else if( !strcmp(datas->cureltname, "deviceType") ) - dstmember = datas->devicetype; - } + else if( !strcmp(datas->cureltname, "serviceType") ) + dstmember = datas->servicetype_tmp; + else if( !strcmp(datas->cureltname, "controlURL") ) + dstmember = datas->controlurl_tmp; + else if( !strcmp(datas->cureltname, "eventSubURL") ) + dstmember = datas->eventsuburl_tmp; + else if( !strcmp(datas->cureltname, "SCPDURL") ) + dstmember = datas->scpdurl_tmp; +/* else if( !strcmp(datas->cureltname, "deviceType") ) + dstmember = datas->devicetype_tmp;*/ if(dstmember) { if(l>=MINIUPNPC_URL_MAXSIZE) @@ -99,13 +97,13 @@ void printIGD(struct IGDdatas * d) { printf("urlbase = %s\n", d->urlbase); printf("WAN Device (Common interface config) :\n"); - printf(" deviceType = %s\n", d->devicetype_CIF); + /*printf(" deviceType = %s\n", d->devicetype_CIF);*/ printf(" serviceType = %s\n", d->servicetype_CIF); printf(" controlURL = %s\n", d->controlurl_CIF); printf(" eventSubURL = %s\n", d->eventsuburl_CIF); printf(" SCPDURL = %s\n", d->scpdurl_CIF); - printf("WAN Connection Device :\n"); - printf(" deviceType = %s\n", d->devicetype); + printf("WAN Connection Device (IP or PPP Connection):\n"); + /*printf(" deviceType = %s\n", d->devicetype);*/ printf(" servicetype = %s\n", d->servicetype); printf(" controlURL = %s\n", d->controlurl); printf(" eventSubURL = %s\n", d->eventsuburl); diff --git a/third-party/miniupnp/igd_desc_parse.h b/third-party/miniupnp/igd_desc_parse.h index 94fb19cc5..aabcb087d 100644 --- a/third-party/miniupnp/igd_desc_parse.h +++ b/third-party/miniupnp/igd_desc_parse.h @@ -1,8 +1,8 @@ -/* $Id: igd_desc_parse.h,v 1.5 2007/04/11 15:21:09 nanard Exp $ */ +/* $Id: igd_desc_parse.h,v 1.6 2008/04/23 11:51:07 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * 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. * */ @@ -16,17 +16,26 @@ struct IGDdatas { char cureltname[MINIUPNPC_URL_MAXSIZE]; char urlbase[MINIUPNPC_URL_MAXSIZE]; int level; - int state; + /*int state;*/ + /* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */ char controlurl_CIF[MINIUPNPC_URL_MAXSIZE]; char eventsuburl_CIF[MINIUPNPC_URL_MAXSIZE]; char scpdurl_CIF[MINIUPNPC_URL_MAXSIZE]; char servicetype_CIF[MINIUPNPC_URL_MAXSIZE]; - char devicetype_CIF[MINIUPNPC_URL_MAXSIZE]; + /*char devicetype_CIF[MINIUPNPC_URL_MAXSIZE];*/ + /* "urn:schemas-upnp-org:service:WANIPConnection:1" + * "urn:schemas-upnp-org:service:WANPPPConnection:1" */ char controlurl[MINIUPNPC_URL_MAXSIZE]; char eventsuburl[MINIUPNPC_URL_MAXSIZE]; char scpdurl[MINIUPNPC_URL_MAXSIZE]; char servicetype[MINIUPNPC_URL_MAXSIZE]; - char devicetype[MINIUPNPC_URL_MAXSIZE]; + /*char devicetype[MINIUPNPC_URL_MAXSIZE];*/ + /* tmp */ + char controlurl_tmp[MINIUPNPC_URL_MAXSIZE]; + char eventsuburl_tmp[MINIUPNPC_URL_MAXSIZE]; + char scpdurl_tmp[MINIUPNPC_URL_MAXSIZE]; + char servicetype_tmp[MINIUPNPC_URL_MAXSIZE]; + /*char devicetype_tmp[MINIUPNPC_URL_MAXSIZE];*/ }; void IGDstartelt(void *, const char *, int);