]> granicus.if.org Git - transmission/commitdiff
update to the miniupnpc-20080427 snapshot
authorCharles Kerr <charles@transmissionbt.com>
Sun, 4 May 2008 22:09:33 +0000 (22:09 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 4 May 2008 22:09:33 +0000 (22:09 +0000)
update to the libnatpmp-20080428 snapshot

third-party/libnatpmp/README
third-party/libnatpmp/natpmp.c
third-party/libnatpmp/natpmp.h
third-party/miniupnp/README
third-party/miniupnp/igd_desc_parse.c
third-party/miniupnp/igd_desc_parse.h

index f7df69f247ba6d32ec64dc98254cf070836f29d9..4bf23b0052749a0227228b944868f192f9f51eb3 100644 (file)
@@ -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
 
index 5e5b528cd0d24b8358a11e1b7578a3a33dc5d23e..4aa031d899e99f3c32a4b7c62c819eb0f9ecc65c 100644 (file)
@@ -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 <miniupnp@free.fr>
+ * Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
+ * 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
  * 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 <errno.h>
 #include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
 #include <time.h>
 #include <sys/time.h>
+#ifdef WIN32
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+#include <io.h>
+#else
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#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
+
index a6647f6d1c5d0b8c8863dfb1cb11e9a40668baee..da3f437a715ba687bed4c892e88bef288ec40b10 100644 (file)
@@ -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 <miniupnp@free.fr>
+ * Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
+ * 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
 
 #include <time.h>
 #include <sys/time.h>
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <netinet/in.h>
+#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
index e44feef90e0adefaf339eedf79ba7f0639139067..0e35a5f5319f5b4e5a04c8df982536e2c26e9ca1 100644 (file)
@@ -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
index 5b06faceeebce332408a553e3d3d92ae74daba0d..e839ff4c13b5d3a6ca684d0fa6bbf55a133bbafa 100644 (file)
@@ -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 <stdio.h>
 #include <string.h>
 
+/* 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);
index 94fb19cc5ee25102babc1815c71904fe8207d946..aabcb087d50a51f332d573eab35746d0d88bcc20 100644 (file)
@@ -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);