]> granicus.if.org Git - transmission/commitdiff
update miniupnp to 1.4.20101221
authorMitchell Livingston <livings124@transmissionbt.com>
Wed, 22 Dec 2010 16:10:14 +0000 (16:10 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Wed, 22 Dec 2010 16:10:14 +0000 (16:10 +0000)
third-party/miniupnp/Changelog.txt
third-party/miniupnp/connecthostport.c
third-party/miniupnp/igd_desc_parse.c
third-party/miniupnp/minisoap.c
third-party/miniupnp/miniupnpc.c
third-party/miniupnp/miniwget.c

index 78e0dec35c7d1f44705ae58ff6343bd75f368335..88498314ff3483e59d487fdd235402cf23d80a25 100644 (file)
@@ -1,9 +1,16 @@
-$Id: Changelog.txt,v 1.122 2010/12/09 16:11:31 nanard Exp $
+$Id: Changelog.txt,v 1.125 2010/12/21 16:13:13 nanard Exp $
 miniUPnP client Changelog.
 
+2010/12/21:
+  use NO_GETADDRINFO macro to disable the use of getaddrinfo/freeaddrinfo
+
+2010/12/11:
+  Improvements on getHTTPResponse() code.
+
 2010/12/09:
   new code for miniwget that handle Chunked transfer encoding
   using getHTTPResponse() in SOAP call code
+  Adding MANIFEST.in for 'python setup.py bdist_rpm'
 
 2010/11/25:
   changes to minissdpc.c to compile under Win32.
index e52eed09cbb945632aab83b43d6ea439ac1a804b..5e5da3af7aca73938c16836f28ce92854f5db20c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: connecthostport.c,v 1.2 2010/04/05 00:08:15 nanard Exp $ */
+/* $Id: connecthostport.c,v 1.3 2010/12/21 16:13:14 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2010 Thomas Bernard
@@ -7,7 +7,9 @@
 
 /* use getaddrinfo() or gethostbyname()
  * uncomment the following line in order to use gethostbyname() */
-/* #define USE_GETHOSTBYNAME */
+#ifdef NO_GETADDRINFO
+#define USE_GETHOSTBYNAME
+#endif
 
 #include <string.h>
 #include <stdio.h>
index 7440e9f5b17947cd73e273793142ff08a5760a31..8df6950e1be3a7063b19ecec30cf817608300167 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: igd_desc_parse.c,v 1.10 2010/04/05 20:36:59 nanard Exp $ */
+/* $Id: igd_desc_parse.c,v 1.11 2010/12/11 17:56:51 nanard Exp $ */
 /* Project : miniupnp
  * http://miniupnp.free.fr/
  * Author : Thomas Bernard
@@ -97,7 +97,7 @@ void printIGD(struct IGDdatas * d)
        printf(" controlURL = '%s'\n", d->CIF.controlurl);
        printf(" eventSubURL = '%s'\n", d->CIF.eventsuburl);
        printf(" SCPDURL = '%s'\n", d->CIF.scpdurl);
-       printf("WAN Connection Device (IP or PPP Connection):\n");
+       printf("primary WAN Connection Device (IP or PPP Connection):\n");
        /*printf(" deviceType = '%s'\n", d->first.devicetype);*/
        printf(" servicetype = '%s'\n", d->first.servicetype);
        printf(" controlURL = '%s'\n", d->first.controlurl);
index 9afacb787d8e31d88961f3144e9f148b9c99309f..a834c5e2a0f43a483ba8473eb934371a2c9508a0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: minisoap.c,v 1.19 2010/04/12 20:39:41 nanard Exp $ */
+/* $Id: minisoap.c,v 1.20 2010/12/11 17:56:51 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005-2009 Thomas Bernard
@@ -106,8 +106,12 @@ int soapPostSubmit(int fd,
                                           "\r\n",
                                           url, httpversion, host, portstr, bodysize, action);
 #ifdef DEBUG
-       printf("SOAP request : headersize=%d bodysize=%d\n",
+       /*printf("SOAP request : headersize=%d bodysize=%d\n",
               headerssize, bodysize);
+       */
+       printf("SOAP request : POST %s HTTP/%s - Host: %s%s\n",
+               url, httpversion, host, portstr);
+       printf("SOAPAction: \"%s\" - Content-Length: %d\n", action, bodysize);
        /*printf("%s", headerbuf);*/
 #endif
        return httpWrite(fd, body, bodysize, headerbuf, headerssize);
index 961f390f5dee3f21da268dce9f88021d4232275f..d91591c2cec80ad24f13d17137b1d8e43a1c00d7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: miniupnpc.c,v 1.83 2010/12/09 16:11:32 nanard Exp $ */
+/* $Id: miniupnpc.c,v 1.85 2010/12/21 16:13:14 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas BERNARD
  * copyright (c) 2005-2010 Thomas Bernard
@@ -298,6 +298,9 @@ static int simpleUPnPcommand2(int s, const char * url, const char * service,
        buf = getHTTPResponse(s, &n);
        if(n > 0 && buf)
        {
+#ifdef DEBUG
+               printf("SOAP Response :\n%.*s\n", n, buf);
+#endif
                if(*bufsize > n)
                {
                        memcpy(buffer, buf, n);
@@ -438,8 +441,12 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
        int n;
        struct sockaddr sockudp_r;
        unsigned int mx;
+#ifdef NO_GETADDRINFO
+       struct sockaddr_in sockudp_w;
+#else
        int rv;
        struct addrinfo hints, *servinfo, *p;
+#endif
 #ifdef WIN32
        MIB_IPFORWARDROW ip_forward;
 #endif
@@ -484,13 +491,6 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
                        p->sin_port = htons(PORT);
                p->sin_addr.s_addr = INADDR_ANY;
        }
-#if 0
-       /* emission */
-       memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
-       sockudp_w.sin_family = AF_INET;
-       sockudp_w.sin_port = htons(PORT);
-       sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
-#endif
 #ifdef WIN32
 /* This code could help us to use the right Network interface for 
  * SSDP multicast traffic */
@@ -593,7 +593,13 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
                n = snprintf(bufr, sizeof(bufr),
                             MSearchMsgFmt, deviceList[deviceIndex++], mx);
                /*printf("Sending %s", bufr);*/
-#if 0
+#ifdef NO_GETADDRINFO
+               /* the following code is not using getaddrinfo */
+               /* emission */
+               memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
+               sockudp_w.sin_family = AF_INET;
+               sockudp_w.sin_port = htons(PORT);
+               sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
                n = sendto(sudp, bufr, n, 0,
                           (struct sockaddr *)&sockudp_w, sizeof(struct sockaddr_in));
                if (n < 0) {
@@ -601,7 +607,7 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
                        closesocket(sudp);
                        return devlist;
                }
-#endif
+#else /* #ifdef NO_GETADDRINFO */
                memset(&hints, 0, sizeof(hints));
                hints.ai_family = AF_UNSPEC; // AF_INET6 or AF_INET
                hints.ai_socktype = SOCK_DGRAM;
@@ -626,6 +632,7 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
                        closesocket(sudp);
                        return devlist;
                }
+#endif /* #ifdef NO_GETADDRINFO */
        }
        /* Waiting for SSDP REPLY packet to M-SEARCH */
        n = ReceiveData(sudp, bufr, sizeof(bufr), delay);
index f436358eb3b38ef452d7de7f36e7901904326eb1..89afe2e527890a7dd8569365e190c948d76ef9d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: miniwget.c,v 1.38 2010/12/09 15:54:25 nanard Exp $ */
+/* $Id: miniwget.c,v 1.41 2010/12/12 23:52:02 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005-2010 Thomas Bernard
 #define MIN(x,y) (((x)<(y))?(x):(y))
 #define snprintf _snprintf
 #define socklen_t int
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#define strncasecmp _memicmp
+#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
+#define strncasecmp memicmp
+#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
 #else /* #ifdef WIN32 */
 #include <unistd.h>
 #include <sys/param.h>
@@ -55,6 +60,7 @@ getHTTPResponse(int s, int * size)
        int chunked = 0;
        int content_length = -1;
        unsigned int chunksize = 0;
+       unsigned int bytestocopy = 0;
        /* buffers : */
        char * header_buf;
        int header_buf_len = 2048;
@@ -129,43 +135,44 @@ getHTTPResponse(int s, int * size)
                                        {
                                                if(chunked)
                                                {
-                                                       while(i<header_buf_used && isxdigit(header_buf[i]))
+                                                       while(i<header_buf_used)
                                                        {
-                                                               if(header_buf[i] >= '0' && header_buf[i] <= '9')
-                                                                       chunksize = (chunksize << 4) + (header_buf[i] - '0');
-                                                               else
-                                                                       chunksize = (chunksize << 4) + ((header_buf[i] | 32) - 'a' + 10);
-                                                               i++;
-                                                       }
-                                                       /* discarding chunk-extension */
-                                                       while(i < header_buf_used && header_buf[i] != '\r') i++;
-                                                       if(i < header_buf_used && header_buf[i] == '\r') i++;
-                                                       if(i < header_buf_used && header_buf[i] == '\n') i++;
+                                                               while(i<header_buf_used && isxdigit(header_buf[i]))
+                                                               {
+                                                                       if(header_buf[i] >= '0' && header_buf[i] <= '9')
+                                                                               chunksize = (chunksize << 4) + (header_buf[i] - '0');
+                                                                       else
+                                                                               chunksize = (chunksize << 4) + ((header_buf[i] | 32) - 'a' + 10);
+                                                                       i++;
+                                                               }
+                                                               /* discarding chunk-extension */
+                                                               while(i < header_buf_used && header_buf[i] != '\r') i++;
+                                                               if(i < header_buf_used && header_buf[i] == '\r') i++;
+                                                               if(i < header_buf_used && header_buf[i] == '\n') i++;
 #ifdef DEBUG
-                                                       printf("chunksize = %u (%x)\n", chunksize, chunksize);
+                                                               printf("chunksize = %u (%x)\n", chunksize, chunksize);
 #endif
-                                                       if(chunksize == 0)
-                                                       {
+                                                               if(chunksize == 0)
+                                                               {
 #ifdef DEBUG
-                                                               printf("end of stream !\n");
+                                                                       printf("end of HTTP content !\n");
 #endif
-                                                               goto end_of_stream;     
-                                                       }
-                                                       if(header_buf_used - i <= chunksize)
-                                                       {
-                                                               if(content_buf_len < header_buf_used - i)
+                                                                       goto end_of_stream;     
+                                                               }
+                                                               bytestocopy = ((int)chunksize < header_buf_used - i)?chunksize:(header_buf_used - i);
+#ifdef DEBUG
+                                                               printf("chunksize=%u bytestocopy=%u (i=%d header_buf_used=%d)\n",
+                                                                      chunksize, bytestocopy, i, header_buf_used);
+#endif
+                                                               if(content_buf_len < (int)(content_buf_used + bytestocopy))
                                                                {
-                                                                       content_buf = realloc(content_buf, header_buf_used - i);
-                                                                       content_buf_len = header_buf_used - i;
+                                                                       content_buf = realloc(content_buf, content_buf_used + bytestocopy);
+                                                                       content_buf_len = content_buf_used + bytestocopy;
                                                                }
-                                                               memcpy(content_buf, header_buf + i, header_buf_used - i);
-                                                               content_buf_used = header_buf_used - i;
-                                                               chunksize -= (header_buf_used - i);
-                                                               i = header_buf_used;
-                                                       }
-                                                       else
-                                                       {
-                                                               printf("arg ! chunksize < (header_buf_used - i)\n");
+                                                               memcpy(content_buf + content_buf_used, header_buf + i, bytestocopy);
+                                                               content_buf_used += bytestocopy;
+                                                               chunksize -= bytestocopy;
+                                                               i += bytestocopy;
                                                        }
                                                }
                                                else
@@ -177,6 +184,7 @@ getHTTPResponse(int s, int * size)
                                                        }
                                                        memcpy(content_buf, header_buf + i, header_buf_used - i);
                                                        content_buf_used = header_buf_used - i;
+                                                       i = header_buf_used;
                                                }
                                        }
                                }
@@ -188,7 +196,6 @@ getHTTPResponse(int s, int * size)
                        if(chunked)
                        {
                                int i = 0;
-                               unsigned bytestocopy;
                                while(i < n)
                                {
                                        if(chunksize == 0)
@@ -213,14 +220,14 @@ getHTTPResponse(int s, int * size)
                                                if(chunksize == 0)
                                                {
 #ifdef DEBUG
-                                                       printf("end of stream - %d %d\n", i, n);
+                                                       printf("end of HTTP content - %d %d\n", i, n);
                                                        /*printf("'%.*s'\n", n-i, buf+i);*/
 #endif
                                                        goto end_of_stream;
                                                }
                                        }
-                                       bytestocopy = (chunksize < n - i)?chunksize:(n - i);
-                                       if(content_buf_used + bytestocopy > content_buf_len)
+                                       bytestocopy = ((int)chunksize < n - i)?chunksize:(n - i);
+                                       if((int)(content_buf_used + bytestocopy) > content_buf_len)
                                        {
                                                content_buf = (char *)realloc((void *)content_buf, 
                                                                              content_buf_used + bytestocopy);
@@ -247,7 +254,7 @@ getHTTPResponse(int s, int * size)
                if(content_length > 0 && content_buf_used >= content_length)
                {
 #ifdef DEBUG
-                       printf("termine!\n");
+                       printf("End of HTTP content\n");
 #endif
                        break;
                }