1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-10 14:13:23 +00:00

(trunk) upgrade miniupnpc to version 1.7. Should fix bug #4891

This commit is contained in:
Jordan Lee 2012-05-30 18:15:33 +00:00
parent 6e6f20da91
commit 69edb1b0d1
7 changed files with 83 additions and 43 deletions

View file

@ -1,6 +1,15 @@
$Id: Changelog.txt,v 1.166 2012/04/09 12:49:26 nanard Exp $
$Id: Changelog.txt,v 1.169 2012/05/24 18:08:49 nanard Exp $
miniUPnP client Changelog.
VERSION 1.7 : released 2012/05/24
2012/05/01:
Cleanup settings of CFLAGS in Makefile
Fix signed/unsigned integer comparaisons
2012/04/20:
Allow to specify protocol with TCP or UDP for -A option
2012/04/09:
Only try to fetch XML description once in UPNP_GetValidIGD()
Added -ansi flag to compilation, and fixed C++ comments to ANSI C comments.

View file

@ -1,18 +1,24 @@
Project: miniupnp
Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
github: https://github.com/miniupnp/miniupnp
freecode: http://freecode.com/projects/miniupnp
Author: Thomas Bernard
Copyright (c) 2005-2011 Thomas Bernard
Copyright (c) 2005-2012 Thomas Bernard
This software is subject to the conditions detailed in the
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.
bsdqueue.h is a copy of the sys/queue.h of an OpenBSD system.
* miniupnp Client *
* miniUPnP Client - miniUPnPc *
To compile, simply run 'gmake' (could be 'make' on your system).
Under win32, to compile with MinGW, type "mingw32make.bat".
MS Visual C solution and project files are supplied in the msvc/ subdirectory.
The compilation is known to work under linux, FreeBSD,
OpenBSD, MacOS X, AmigaOS and cygwin.
The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3.
@ -23,7 +29,7 @@ To install the library and headers on the system use :
> make install
> exit
alternatively, to install in a specific location, use :
alternatively, to install into a specific location, use :
> INSTALLPREFIX=/usr/local make install
upnpc.c is a sample client using the libminiupnpc.
@ -41,6 +47,7 @@ and -lminiupnpc for the link
Discovery process is speeded up when MiniSSDPd is running on the machine.
* Python module *
you can build a python module with 'make pythonmodule'

View file

@ -1 +1 @@
1.6
1.7

View file

@ -1,4 +1,4 @@
/* $Id: miniupnpc.c,v 1.104 2012/04/09 12:40:11 nanard Exp $ */
/* $Id: miniupnpc.c,v 1.105 2012/04/11 05:50:53 nanard Exp $ */
/* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Author : Thomas BERNARD
@ -17,7 +17,7 @@
#endif
#endif
#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(MACOSX) && !defined(_WIN32)
#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(MACOSX) && !defined(_WIN32) && !defined(__CYGWIN__)
#define HAS_IP_MREQN
#endif

View file

@ -18,7 +18,7 @@
#define UPNPDISCOVER_MEMORY_ERROR (-102)
/* versions : */
#define MINIUPNPC_VERSION "1.6.20120410"
#define MINIUPNPC_VERSION "1.7"
#define MINIUPNPC_API_VERSION 8
#ifdef __cplusplus

View file

@ -1,4 +1,4 @@
/* $Id: miniwget.c,v 1.55 2012/03/05 19:42:47 nanard Exp $ */
/* $Id: miniwget.c,v 1.56 2012/05/01 16:16:08 nanard Exp $ */
/* Project : miniupnp
* Website : http://miniupnp.free.fr/
* Author : Thomas Bernard
@ -69,13 +69,13 @@ getHTTPResponse(int s, int * size)
unsigned int bytestocopy = 0;
/* buffers : */
char * header_buf;
int header_buf_len = 2048;
int header_buf_used = 0;
unsigned int header_buf_len = 2048;
unsigned int header_buf_used = 0;
char * content_buf;
int content_buf_len = 2048;
int content_buf_used = 0;
unsigned int content_buf_len = 2048;
unsigned int content_buf_used = 0;
char chunksize_buf[32];
int chunksize_buf_index;
unsigned int chunksize_buf_index;
header_buf = malloc(header_buf_len);
content_buf = malloc(content_buf_len);
@ -99,14 +99,14 @@ getHTTPResponse(int s, int * size)
/* search for CR LF CR LF (end of headers)
* recognize also LF LF */
i = 0;
while(i < (header_buf_used-1) && (endofheaders == 0)) {
while(i < ((int)header_buf_used-1) && (endofheaders == 0)) {
if(header_buf[i] == '\r') {
i++;
if(header_buf[i] == '\n') {
i++;
if(i < header_buf_used && header_buf[i] == '\r') {
if(i < (int)header_buf_used && header_buf[i] == '\r') {
i++;
if(i < header_buf_used && header_buf[i] == '\n') {
if(i < (int)header_buf_used && header_buf[i] == '\n') {
endofheaders = i+1;
}
}
@ -196,7 +196,7 @@ getHTTPResponse(int s, int * size)
i++; /* discarding chunk-extension */
if(i<n && buf[i] == '\r') i++;
if(i<n && buf[i] == '\n') {
int j;
unsigned int j;
for(j = 0; j < chunksize_buf_index; j++) {
if(chunksize_buf[j] >= '0'
&& chunksize_buf[j] <= '9')
@ -223,13 +223,13 @@ getHTTPResponse(int s, int * size)
goto end_of_stream;
}
}
bytestocopy = ((int)chunksize < n - i)?chunksize:(n - i);
if((int)(content_buf_used + bytestocopy) > content_buf_len)
bytestocopy = ((int)chunksize < (n - i))?chunksize:(unsigned int)(n - i);
if((content_buf_used + bytestocopy) > content_buf_len)
{
if(content_length >= content_buf_used + (int)bytestocopy) {
if(content_length >= (int)(content_buf_used + bytestocopy)) {
content_buf_len = content_length;
} else {
content_buf_len = content_buf_used + (int)bytestocopy;
content_buf_len = content_buf_used + bytestocopy;
}
content_buf = (char *)realloc((void *)content_buf,
content_buf_len);
@ -244,13 +244,13 @@ getHTTPResponse(int s, int * size)
{
/* not chunked */
if(content_length > 0
&& (content_buf_used + n) > content_length) {
&& (int)(content_buf_used + n) > content_length) {
/* skipping additional bytes */
n = content_length - content_buf_used;
}
if(content_buf_used + n > content_buf_len)
{
if(content_length >= content_buf_used + n) {
if(content_length >= (int)(content_buf_used + n)) {
content_buf_len = content_length;
} else {
content_buf_len = content_buf_used + n;
@ -263,7 +263,7 @@ getHTTPResponse(int s, int * size)
}
}
/* use the Content-Length header value if available */
if(content_length > 0 && content_buf_used >= content_length)
if(content_length > 0 && (int)content_buf_used >= content_length)
{
#ifdef DEBUG
printf("End of HTTP content\n");
@ -286,7 +286,7 @@ end_of_stream:
* do all the work.
* Return NULL if something failed. */
static void *
miniwget3(const char * url, const char * host,
miniwget3(const char * host,
unsigned short port, const char * path,
int * size, char * addr_str, int addr_str_len,
const char * httpversion)
@ -390,22 +390,22 @@ miniwget3(const char * url, const char * host,
/* miniwget2() :
* Call miniwget3(); retry with HTTP/1.1 if 1.0 fails. */
static void *
miniwget2(const char * url, const char * host,
miniwget2(const char * host,
unsigned short port, const char * path,
int * size, char * addr_str, int addr_str_len)
{
char * respbuffer;
respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.1");
/*
respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.0");
respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.0");
if (*size == 0)
{
#ifdef DEBUG
printf("Retrying with HTTP/1.1\n");
#endif
free(respbuffer);
respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
respbuffer = miniwget3(host, port, path, size, addr_str, addr_str_len, "1.1");
}
*/
return respbuffer;
@ -502,7 +502,7 @@ void * miniwget(const char * url, int * size)
#ifdef DEBUG
printf("parsed url : hostname='%s' port=%hu path='%s'\n", hostname, port, path);
#endif
return miniwget2(url, hostname, port, path, size, 0, 0);
return miniwget2(hostname, port, path, size, 0, 0);
}
void * miniwget_getaddr(const char * url, int * size, char * addr, int addrlen)
@ -519,6 +519,6 @@ void * miniwget_getaddr(const char * url, int * size, char * addr, int addrlen)
#ifdef DEBUG
printf("parsed url : hostname='%s' port=%hu path='%s'\n", hostname, port, path);
#endif
return miniwget2(url, hostname, port, path, size, addr, addrlen);
return miniwget2(hostname, port, path, size, addr, addrlen);
}

View file

@ -1,8 +1,11 @@
#! /bin/sh
# $Id: updateminiupnpcstrings.sh,v 1.4 2009/07/29 08:34:01 nanard Exp $
# $Id: updateminiupnpcstrings.sh,v 1.7 2011/01/04 11:41:53 nanard Exp $
# project miniupnp : http://miniupnp.free.fr/
# (c) 2009 Thomas Bernard
TEMPLATE_FILE=$1
OUTPUT_FILE=$2
FILE=miniupnpcstrings.h
TMPFILE=miniupnpcstrings.h.tmp
TEMPLATE_FILE=${FILE}.in
# detecting the OS name and version
OS_NAME=`uname -s`
@ -12,18 +15,39 @@ if [ -f /etc/debian_version ]; then
OS_VERSION=`cat /etc/debian_version`
fi
# use lsb_release (Linux Standard Base) when available
if os_name=`lsb_release -i -s 2>/dev/null`; then
OS_NAME=$os_name
OS_VERSION=`lsb_release -r -s`
LSB_RELEASE=`which lsb_release`
if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then
OS_NAME=`${LSB_RELEASE} -i -s`
OS_VERSION=`${LSB_RELEASE} -r -s`
case $OS_NAME in
Debian)
#OS_VERSION=`${LSB_RELEASE} -c -s`
;;
Ubuntu)
#OS_VERSION=`${LSB_RELEASE} -c -s`
;;
esac
fi
# on AmigaOS 3, uname -r returns "unknown", so we use uname -v
if [ "$OS_NAME" = "AmigaOS" ]; then
if [ "$OS_VERSION" = "unknown" ]; then
OS_VERSION=`uname -v`
fi
fi
echo "Detected OS [$OS_NAME] version [$OS_VERSION]"
MINIUPNPC_VERSION=`cat VERSION`
echo "MiniUPnPc version [${MINIUPNPC_VERSION}]"
EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|"
#echo $EXPR
#echo "Backing up $OUTPUT_FILE to $OUTPUT_FILE.bak."
#cp $OUTPUT_FILE $OUTPUT_FILE.bak
test -f ${TEMPLATE_FILE}
echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $OUTPUT_FILE."
sed -e "$EXPR" < $TEMPLATE_FILE > $OUTPUT_FILE
test -f ${FILE}.in
echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE."
sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE
EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|"
echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE."
sed -e "$EXPR" < $TMPFILE > $FILE
rm $TMPFILE