From ab32a5c6e17c5b9a2b974a9ef38dc8eff1cbea01 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 27 Oct 2008 16:08:28 +0000 Subject: [PATCH] update to miniupnpc-1.2 and libnatpmp-20081009 --- third-party/libnatpmp/Makefile.am | 2 ++ third-party/libnatpmp/README | 2 +- third-party/libnatpmp/declspec.h | 4 ---- third-party/libnatpmp/getgateway.c | 6 ++---- third-party/libnatpmp/natpmp.c | 5 +++-- third-party/libnatpmp/natpmp.h | 2 ++ third-party/miniupnp/README | 2 +- third-party/miniupnp/codelength.h | 24 ++++++++++++++++++++++++ third-party/miniupnp/minissdpc.c | 12 ++++-------- 9 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 third-party/miniupnp/codelength.h diff --git a/third-party/libnatpmp/Makefile.am b/third-party/libnatpmp/Makefile.am index 3fca7d53c..923ab169d 100644 --- a/third-party/libnatpmp/Makefile.am +++ b/third-party/libnatpmp/Makefile.am @@ -1,5 +1,7 @@ noinst_LIBRARIES = libnatpmp.a +AM_CPPFLAGS = -DENABLE_STRNATPMPERR + libnatpmp_a_SOURCES = \ getgateway.c \ natpmp.c diff --git a/third-party/libnatpmp/README b/third-party/libnatpmp/README index c9340a987..541b21cb3 100644 --- a/third-party/libnatpmp/README +++ b/third-party/libnatpmp/README @@ -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-20080707 snapshot +This code is from the libnatpmp-20081006 snapshot diff --git a/third-party/libnatpmp/declspec.h b/third-party/libnatpmp/declspec.h index 2128250de..ea479d1e6 100644 --- a/third-party/libnatpmp/declspec.h +++ b/third-party/libnatpmp/declspec.h @@ -1,7 +1,6 @@ #ifndef __DECLSPEC_H__ #define __DECLSPEC_H__ -/* #if defined(WIN32) && !defined(STATICLIB) #ifdef NATPMP_EXPORTS #define LIBSPEC __declspec(dllexport) @@ -9,11 +8,8 @@ #define LIBSPEC __declspec(dllimport) #endif #else -*/ #define LIBSPEC -/* #endif -*/ #endif diff --git a/third-party/libnatpmp/getgateway.c b/third-party/libnatpmp/getgateway.c index 7ce1d78ad..d6c7fe251 100644 --- a/third-party/libnatpmp/getgateway.c +++ b/third-party/libnatpmp/getgateway.c @@ -1,4 +1,4 @@ -/* $Id: getgateway.c,v 1.11 2008/07/02 23:56:11 nanard Exp $ */ +/* $Id: getgateway.c,v 1.12 2008/10/06 10:04:16 nanard Exp $ */ /* libnatpmp * Copyright (c) 2007-2008, Thomas BERNARD * @@ -17,9 +17,6 @@ #include #ifndef WIN32 #include -#else -#include -#include #endif #include /* There is no portable method to get the default route gateway. @@ -149,6 +146,7 @@ int getdefaultgateway(in_addr_t * addr) if(l>0) { buf = malloc(l); if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) { + free(buf); return FAILED; } for(p=buf; prtm_msglen) { diff --git a/third-party/libnatpmp/natpmp.c b/third-party/libnatpmp/natpmp.c index 066804f46..9ea3a053e 100644 --- a/third-party/libnatpmp/natpmp.c +++ b/third-party/libnatpmp/natpmp.c @@ -17,10 +17,9 @@ #include #include #include -#include #ifdef WIN32 #include -#include +#include #include #define EWOULDBLOCK WSAEWOULDBLOCK #define ECONNREFUSED WSAECONNREFUSED @@ -268,6 +267,7 @@ int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response) return n; } +#ifdef ENABLE_STRNATPMPERR const char * strnatpmperr(int r) { const char * s; @@ -335,4 +335,5 @@ const char * strnatpmperr(int r) } return s; } +#endif diff --git a/third-party/libnatpmp/natpmp.h b/third-party/libnatpmp/natpmp.h index ac7ec95f6..9470543f7 100644 --- a/third-party/libnatpmp/natpmp.h +++ b/third-party/libnatpmp/natpmp.h @@ -179,6 +179,8 @@ LIBSPEC int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout); * NATPMP_ERR_UNDEFINEDERROR */ LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response); +#ifdef ENABLE_STRNATPMPERR LIBSPEC const char * strnatpmperr(int t); +#endif #endif diff --git a/third-party/miniupnp/README b/third-party/miniupnp/README index f07869b7f..4ec58bff2 100644 --- a/third-party/miniupnp/README +++ b/third-party/miniupnp/README @@ -1,3 +1,3 @@ MiniUPnP is written by Thomas Bernard. Its homepage is http://miniupnp.free.fr/ -This is from the miniupnpc-20081002 snapshot +This is from the miniupnpc-1.2 tarball (7 Oct 2008) diff --git a/third-party/miniupnp/codelength.h b/third-party/miniupnp/codelength.h new file mode 100644 index 000000000..f11e5e936 --- /dev/null +++ b/third-party/miniupnp/codelength.h @@ -0,0 +1,24 @@ +/* $Id: codelength.h,v 1.1 2008/10/06 22:04:06 nanard Exp $ */ +/* Project : miniupnp + * Author : Thomas BERNARD + * copyright (c) 2005-2008 Thomas Bernard + * This software is subjet to the conditions detailed in the + * provided LICENCE file. */ +#ifndef __CODELENGTH_H__ +#define __CODELENGTH_H__ + +/* Encode length by using 7bit per Byte : + * Most significant bit of each byte specifies that the + * following byte is part of the code */ +#define DECODELENGTH(n, p) n = 0; \ + do { n = (n << 7) | (*p & 0x7f); } \ + while(*(p++)&0x80); + +#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ + if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ + if(n>=16384) *(p++) = (n >> 14) | 0x80; \ + if(n>=128) *(p++) = (n >> 7) | 0x80; \ + *(p++) = n & 0x7f; + +#endif + diff --git a/third-party/miniupnp/minissdpc.c b/third-party/miniupnp/minissdpc.c index 54cbdcfe9..d37599fe6 100644 --- a/third-party/miniupnp/minissdpc.c +++ b/third-party/miniupnp/minissdpc.c @@ -1,7 +1,7 @@ -/* $Id: minissdpc.c,v 1.4 2007/12/19 14:56:58 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.6 2008/10/06 23:08:39 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD - * copyright (c) 2005-2007 Thomas Bernard + * copyright (c) 2005-2008 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ /*#include */ @@ -16,11 +16,7 @@ #include "minissdpc.h" #include "miniupnpc.h" -#define DECODELENGTH(n, p) n = 0; \ - do { n = (n << 7) | (*p & 0x7f); } \ - while(*(p++)&0x80); -#define CODELENGTH(n, p) do { *p = (n & 0x7f) | ((n > 0x7f) ? 0x80 : 0); \ - p++; n >>= 7; } while(n); +#include "codelength.h" struct UPNPDev * getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath) @@ -52,7 +48,7 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath) return NULL; } stsize = strlen(devtype); - buffer[0] = 1; + buffer[0] = 1; /* request type 1 : request devices/services by type */ p = buffer + 1; l = stsize; CODELENGTH(l, p); memcpy(p, devtype, stsize);