From a3328e519c0ef16ffeced49738065b35c7cd3fd7 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 25 Feb 2010 12:39:22 +0000 Subject: [PATCH] update miniupnp to 1.4 --- third-party/miniupnp/Changelog.txt | 40 ++++++++++- third-party/miniupnp/{LICENCE => LICENSE} | 2 +- third-party/miniupnp/README | 12 ++-- third-party/miniupnp/VERSION | 1 + third-party/miniupnp/igd_desc_parse.c | 24 +++---- third-party/miniupnp/minisoap.c | 13 ++-- third-party/miniupnp/minissdpc.c | 10 ++- third-party/miniupnp/miniupnpc.c | 84 +++++++++++++++++++--- third-party/miniupnp/miniupnpcstrings.h.in | 4 +- third-party/miniupnp/miniwget.c | 20 ++++-- 10 files changed, 168 insertions(+), 42 deletions(-) rename third-party/miniupnp/{LICENCE => LICENSE} (97%) create mode 100644 third-party/miniupnp/VERSION diff --git a/third-party/miniupnp/Changelog.txt b/third-party/miniupnp/Changelog.txt index 7ab418852..49ba54349 100644 --- a/third-party/miniupnp/Changelog.txt +++ b/third-party/miniupnp/Changelog.txt @@ -1,6 +1,44 @@ -$Id: Changelog.txt,v 1.93 2009/10/10 19:15:34 nanard Exp $ +$Id: Changelog.txt,v 1.105 2010/01/06 10:03:53 nanard Exp $ miniUPnP client Changelog. +2010/01/06: + #define _DARWIN_C_SOURCE for macosx + +2009/12/19: + Improve MinGW32 build + +2009/12/11: + adding a MSVC9 project to build the static library and executable + +2009/12/10: + Fixing some compilation stuff for Windows/MinGW + +2009/12/07: + adaptations in Makefile and updateminiupnpcstring.sh for AmigaOS + some fixes for Windows when using virtual ethernet adapters (it is the + case with VMWare installed). + +2009/12/04: + some fixes for AmigaOS compilation + Changed HTTP version to HTTP/1.0 for Soap too (to prevent chunked + transfer encoding) + +2009/12/03: + updating printIDG and testigddescparse.c for debug. + modifications to compile under AmigaOS + adding a testminiwget program + Changed miniwget to advertise itself as HTTP/1.0 to prevent chunked + transfer encoding + +2009/11/26: + fixing updateminiupnpcstrings.sh to take into account + which command that does not return an error code. + +VERSION 1.4 : released 2009/10/30 + +2009/10/16: + using Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS in python module. + 2009/10/10: Some fixes for compilation under Solaris compilation fixes : http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1464 diff --git a/third-party/miniupnp/LICENCE b/third-party/miniupnp/LICENSE similarity index 97% rename from third-party/miniupnp/LICENCE rename to third-party/miniupnp/LICENSE index a8cfb5ef3..2b561fb4f 100644 --- a/third-party/miniupnp/LICENCE +++ b/third-party/miniupnp/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2005-2008, Thomas BERNARD +Copyright (c) 2005-2009, Thomas BERNARD All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/third-party/miniupnp/README b/third-party/miniupnp/README index 3aa2a361b..429507062 100644 --- a/third-party/miniupnp/README +++ b/third-party/miniupnp/README @@ -1,9 +1,9 @@ Project: miniupnp Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ Author: Thomas Bernard -Copyright (c) 2005-2008 Thomas Bernard +Copyright (c) 2005-2009 Thomas Bernard This software is subject to the conditions detailed in the -LICENCE file provided within this distribution. +LICENSE file provided within this distribution. For the comfort of Win32 users, bsdqueue.h is included in the distribution. Its licence is included in the header of the file. @@ -11,10 +11,12 @@ bsdqueue.h is a copy of the sys/queue.h of an OpenBSD system. * miniupnp Client * -To compile, simply run 'gmake' (could be 'make'). +To compile, simply run 'gmake' (could be 'make' on your system). Under win32, to compile with MinGW, type "mingw32make.bat". The compilation is known to work under linux, FreeBSD, -OpenBSD, MacOS X and cygwin. +OpenBSD, MacOS X, AmigaOS and cygwin. +The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3. + To install the library and headers on the system use : > su > make install @@ -25,7 +27,7 @@ alternatively, to install in a specific location, use : upnpc.c is a sample client using the libminiupnpc. To use the libminiupnpc in your application, link it with -libminiupnpc.a and use the following functions found in miniupnpc.h, +libminiupnpc.a (or .so) and use the following functions found in miniupnpc.h, upnpcommands.h and miniwget.h : - upnpDiscover() - miniwget() diff --git a/third-party/miniupnp/VERSION b/third-party/miniupnp/VERSION new file mode 100644 index 000000000..c068b2447 --- /dev/null +++ b/third-party/miniupnp/VERSION @@ -0,0 +1 @@ +1.4 diff --git a/third-party/miniupnp/igd_desc_parse.c b/third-party/miniupnp/igd_desc_parse.c index e839ff4c1..aad3c0302 100644 --- a/third-party/miniupnp/igd_desc_parse.c +++ b/third-party/miniupnp/igd_desc_parse.c @@ -1,4 +1,4 @@ -/* $Id: igd_desc_parse.c,v 1.8 2008/04/23 11:51:06 nanard Exp $ */ +/* $Id: igd_desc_parse.c,v 1.9 2009/12/03 13:50:06 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard @@ -95,19 +95,19 @@ void IGDdata(void * d, const char * data, int l) void printIGD(struct IGDdatas * d) { - printf("urlbase = %s\n", d->urlbase); + printf("urlbase = '%s'\n", d->urlbase); printf("WAN Device (Common interface config) :\n"); - /*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(" 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 (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); - printf(" SCPDURL = %s\n", d->scpdurl); + /*printf(" deviceType = '%s'\n", d->devicetype);*/ + printf(" servicetype = '%s'\n", d->servicetype); + printf(" controlURL = '%s'\n", d->controlurl); + printf(" eventSubURL = '%s'\n", d->eventsuburl); + printf(" SCPDURL = '%s'\n", d->scpdurl); } diff --git a/third-party/miniupnp/minisoap.c b/third-party/miniupnp/minisoap.c index 04b1a92b8..26022ad06 100644 --- a/third-party/miniupnp/minisoap.c +++ b/third-party/miniupnp/minisoap.c @@ -1,7 +1,7 @@ -/* $Id: minisoap.c,v 1.16 2008/10/11 16:39:29 nanard Exp $ */ +/* $Id: minisoap.c,v 1.18 2009/12/04 11:29:18 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2009 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * @@ -84,14 +84,17 @@ int soapPostSubmit(int fd, bodysize = (int)strlen(body); /* We are not using keep-alive HTTP connections. * HTTP/1.1 needs the header Connection: close to do that. - * This is the default with HTTP/1.0 */ + * This is the default with HTTP/1.0 + * Using HTTP/1.1 means we need to support chunked transfer-encoding : + * When using HTTP/1.1, the router "BiPAC 7404VNOX" always use chunked + * transfer encoding. */ /* Connection: Close is normally there only in HTTP/1.1 but who knows */ portstr[0] = '\0'; if(port != 80) snprintf(portstr, sizeof(portstr), ":%hu", port); headerssize = snprintf(headerbuf, sizeof(headerbuf), - "POST %s HTTP/1.1\r\n" -/* "POST %s HTTP/1.0\r\n"*/ +/* "POST %s HTTP/1.1\r\n" */ + "POST %s HTTP/1.0\r\n" "Host: %s%s\r\n" "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" "Content-Length: %d\r\n" diff --git a/third-party/miniupnp/minissdpc.c b/third-party/miniupnp/minissdpc.c index 6d65a3268..33ffa3ab5 100644 --- a/third-party/miniupnp/minissdpc.c +++ b/third-party/miniupnp/minissdpc.c @@ -1,4 +1,4 @@ -/* $Id: minissdpc.c,v 1.10 2009/09/21 12:57:42 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.13 2009/12/04 16:57:29 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2005-2009 Thomas Bernard @@ -10,10 +10,18 @@ #include #include #include +#if defined(WIN32) || defined(__amigaos__) || defined(__amigaos4__) #ifdef WIN32 #include #include #include +#endif +#if defined(__amigaos__) || defined(__amigaos4__) +#include +#endif +#if defined(__amigaos__) +#define uint16_t unsigned short +#endif /* Hack */ #define UNIX_PATH_LEN 108 struct sockaddr_un { diff --git a/third-party/miniupnp/miniupnpc.c b/third-party/miniupnp/miniupnpc.c index c3b5b32b9..3ee04d46c 100644 --- a/third-party/miniupnp/miniupnpc.c +++ b/third-party/miniupnp/miniupnpc.c @@ -1,9 +1,9 @@ -/* $Id: miniupnpc.c,v 1.66 2009/10/10 19:15:34 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.74 2010/01/09 23:54:40 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD - * copyright (c) 2005-2009 Thomas Bernard + * copyright (c) 2005-2010 Thomas Bernard * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ + * provided LICENSE file. */ #define __EXTENSIONS__ 1 #if !defined(MACOSX) && !defined(__sun) #if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) @@ -16,6 +16,10 @@ #endif #endif +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif + #include #include #include @@ -24,32 +28,45 @@ #include #include #include +/*#include */ #define snprintf _snprintf #if defined(_MSC_VER) && (_MSC_VER >= 1400) #define strncasecmp _memicmp -#else +#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ #define strncasecmp memicmp -#endif +#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ #define MAXHOSTNAMELEN 64 -#else +#else /* #ifdef WIN32 */ /* Standard POSIX includes */ #include +#if defined(__amigaos__) && !defined(__amigaos4__) +/* Amiga OS 3 specific stuff */ +#define socklen_t int +#else #include +#endif #include #include #include #include #include +#if !defined(__amigaos__) && !defined(__amigaos4__) #include +#endif #include #include #include #define closesocket close #define MINIUPNPC_IGNORE_EINTR -#endif +#endif /* #else WIN32 */ #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT #include #endif +#if defined(__amigaos__) || defined(__amigaos4__) +/* Amiga OS specific stuff */ +#define TIMEVAL struct timeval +#endif + #include "miniupnpc.h" #include "minissdpc.h" #include "miniwget.h" @@ -85,7 +102,8 @@ LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * d #endif } -/* Content-length: nnn */ +/* getcontentlenfromline() : parse the Content-Length HTTP header line. + * Content-length: nnn */ static int getcontentlenfromline(const char * p, int n) { static const char contlenstr[] = "content-length"; @@ -120,6 +138,10 @@ static int getcontentlenfromline(const char * p, int n) return a; } +/* getContentLengthAndHeaderLength() + * retrieve header length and content length from an HTTP response + * TODO : retrieve Transfer-Encoding: header value, in order to support + * HTTP/1.1, chunked transfer encoding must be supported. */ static void getContentLengthAndHeaderLength(char * p, int n, int * contentlen, int * headerlen) @@ -430,8 +452,11 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, int n; struct sockaddr_in sockudp_r, sockudp_w; unsigned int mx; +#ifdef WIN32 + /*MIB_IPFORWARDROW ip_forward;*/ +#endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) /* first try to get infos from minissdpd ! */ if(!minissdpdsock) minissdpdsock = "/var/run/minissdpd.sock"; @@ -467,6 +492,45 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, sockudp_w.sin_family = AF_INET; sockudp_w.sin_port = htons(PORT); sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR); +#ifdef WIN32 +/* This code could help us to use the right Network interface for + * SSDP multicast traffic */ +/* TODO : Get IP associated with the index given in the ip_forward struct + * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */ + /* + if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) { + DWORD dwRetVal = 0; + PMIB_IPADDRTABLE pIPAddrTable; + DWORD dwSize = 0; + IN_ADDR IPAddr; + int i; + printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop); + pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE)); + if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { + free(pIPAddrTable); + pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize); + } + if(pIPAddrTable) { + dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 ); + printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries); + for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) { + printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr; + printf("\tIP Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask; + printf("\tSubnet Mask[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr; + printf("\tBroadCast[%d]: \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr); + printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize); + printf("\tType and State[%d]:", i); + printf("\n"); + } + free(pIPAddrTable); + pIPAddrTable = NULL; + } + } +*/ +#endif #ifdef WIN32 if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0) @@ -652,7 +716,7 @@ FreeUPNPUrls(struct UPNPUrls * urls) int ReceiveData(int socket, char * data, int length, int timeout) { int n; -#ifndef WIN32 +#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) struct pollfd fds[1]; /* for the poll */ #ifdef MINIUPNPC_IGNORE_EINTR do { diff --git a/third-party/miniupnp/miniupnpcstrings.h.in b/third-party/miniupnp/miniupnpcstrings.h.in index be060cc88..8ab3f29f7 100644 --- a/third-party/miniupnp/miniupnpcstrings.h.in +++ b/third-party/miniupnp/miniupnpcstrings.h.in @@ -1,4 +1,4 @@ -/* $Id: miniupnpcstrings.h.in,v 1.1 2009/07/09 16:13:31 nanard Exp $ */ +/* $Id: miniupnpcstrings.h.in,v 1.2 2009/10/30 09:18:18 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard @@ -9,7 +9,7 @@ #define __MINIUPNPCSTRINGS_H__ #define OS_STRING "OS/version" -#define MINIUPNPC_VERSION_STRING "1.3" +#define MINIUPNPC_VERSION_STRING "1.4" #endif diff --git a/third-party/miniupnp/miniwget.c b/third-party/miniupnp/miniwget.c index 51a371ad5..b7e695853 100644 --- a/third-party/miniupnp/miniwget.c +++ b/third-party/miniupnp/miniwget.c @@ -1,4 +1,4 @@ -/* $Id: miniwget.c,v 1.28 2009/10/10 19:15:35 nanard Exp $ */ +/* $Id: miniwget.c,v 1.31 2009/12/04 11:29:19 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005-2009 Thomas Bernard @@ -20,7 +20,11 @@ #else #include #include +#if defined(__amigaos__) && !defined(__amigaos4__) +#define socklen_t int +#else #include +#endif #include #include #include @@ -33,6 +37,9 @@ #if defined(__sun) || defined(sun) #define MIN(x,y) (((x)<(y))?(x):(y)) #endif +#if defined(__amigaos__) || defined(__amigaos4__) +#define herror(A) printf("%s\n", A) +#endif #include "miniupnpcstrings.h" #include "miniwget.h" @@ -132,9 +139,7 @@ miniwget2(const char * url, const char * host, } else { -#ifndef WIN32 - inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len); -#else +#if defined(WIN32) || (defined(__amigaos__) && !defined(__amigaos4__)) /* using INT WINAPI WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD); * But his function make a string with the port : nn.nn.nn.nn:port */ /* if(WSAAddressToStringA((SOCKADDR *)&saddr, sizeof(saddr), @@ -143,6 +148,8 @@ miniwget2(const char * url, const char * host, printf("WSAAddressToStringA() failed : %d\n", WSAGetLastError()); }*/ strncpy(addr_str, inet_ntoa(saddr.sin_addr), addr_str_len); +#else + inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len); #endif } #ifdef DEBUG @@ -151,7 +158,7 @@ miniwget2(const char * url, const char * host, } len = snprintf(buf, sizeof(buf), - "GET %s HTTP/1.1\r\n" + "GET %s HTTP/1.0\r\n" "Host: %s:%d\r\n" "Connection: Close\r\n" "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" @@ -175,6 +182,9 @@ miniwget2(const char * url, const char * host, } } { + /* TODO : in order to support HTTP/1.1, chunked transfer encoding + * must be supported. That means parsing of headers must be + * added. */ int headers=1; char * respbuffer = NULL; int allreadyread = 0;