-$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.
-/* $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
/* 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>
-/* $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
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);
-/* $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
"\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);
-/* $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
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);
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
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 */
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) {
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;
closesocket(sudp);
return devlist;
}
+#endif /* #ifdef NO_GETADDRINFO */
}
/* Waiting for SSDP REPLY packet to M-SEARCH */
n = ReceiveData(sudp, bufr, sizeof(bufr), delay);
-/* $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>
int chunked = 0;
int content_length = -1;
unsigned int chunksize = 0;
+ unsigned int bytestocopy = 0;
/* buffers : */
char * header_buf;
int header_buf_len = 2048;
{
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
}
memcpy(content_buf, header_buf + i, header_buf_used - i);
content_buf_used = header_buf_used - i;
+ i = header_buf_used;
}
}
}
if(chunked)
{
int i = 0;
- unsigned bytestocopy;
while(i < n)
{
if(chunksize == 0)
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);
if(content_length > 0 && content_buf_used >= content_length)
{
#ifdef DEBUG
- printf("termine!\n");
+ printf("End of HTTP content\n");
#endif
break;
}