update to miniupnpc-1.2 and libnatpmp-20081009

This commit is contained in:
Charles Kerr 2008-10-27 16:08:28 +00:00
parent 5ad58ea83e
commit ab32a5c6e1
9 changed files with 39 additions and 20 deletions

View File

@ -1,5 +1,7 @@
noinst_LIBRARIES = libnatpmp.a
AM_CPPFLAGS = -DENABLE_STRNATPMPERR
libnatpmp_a_SOURCES = \
getgateway.c \
natpmp.c

View File

@ -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

View File

@ -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

View File

@ -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 <miniupnp@free.fr>
*
@ -17,9 +17,6 @@
#include <ctype.h>
#ifndef WIN32
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#include <sys/param.h>
/* 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; p<buf+l; p+=rt->rtm_msglen) {

View File

@ -17,10 +17,9 @@
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <Ws2tcpip.h>
#include <io.h>
#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

View File

@ -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

View File

@ -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)

24
third-party/miniupnp/codelength.h vendored Normal file
View File

@ -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

View File

@ -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 <syslog.h>*/
@ -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);