update to miniupnpc-1.2 and libnatpmp-20081009
This commit is contained in:
parent
5ad58ea83e
commit
ab32a5c6e1
|
@ -1,5 +1,7 @@
|
||||||
noinst_LIBRARIES = libnatpmp.a
|
noinst_LIBRARIES = libnatpmp.a
|
||||||
|
|
||||||
|
AM_CPPFLAGS = -DENABLE_STRNATPMPERR
|
||||||
|
|
||||||
libnatpmp_a_SOURCES = \
|
libnatpmp_a_SOURCES = \
|
||||||
getgateway.c \
|
getgateway.c \
|
||||||
natpmp.c
|
natpmp.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
libnatpmp is written by Thomas Bernard.
|
libnatpmp is written by Thomas Bernard.
|
||||||
Its homepage is http://miniupnp.tuxfamily.org/libnatpmp.html
|
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
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef __DECLSPEC_H__
|
#ifndef __DECLSPEC_H__
|
||||||
#define __DECLSPEC_H__
|
#define __DECLSPEC_H__
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined(WIN32) && !defined(STATICLIB)
|
#if defined(WIN32) && !defined(STATICLIB)
|
||||||
#ifdef NATPMP_EXPORTS
|
#ifdef NATPMP_EXPORTS
|
||||||
#define LIBSPEC __declspec(dllexport)
|
#define LIBSPEC __declspec(dllexport)
|
||||||
|
@ -9,11 +8,8 @@
|
||||||
#define LIBSPEC __declspec(dllimport)
|
#define LIBSPEC __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
*/
|
|
||||||
#define LIBSPEC
|
#define LIBSPEC
|
||||||
/*
|
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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
|
/* libnatpmp
|
||||||
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
||||||
*
|
*
|
||||||
|
@ -17,9 +17,6 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#else
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
/* There is no portable method to get the default route gateway.
|
/* There is no portable method to get the default route gateway.
|
||||||
|
@ -149,6 +146,7 @@ int getdefaultgateway(in_addr_t * addr)
|
||||||
if(l>0) {
|
if(l>0) {
|
||||||
buf = malloc(l);
|
buf = malloc(l);
|
||||||
if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) {
|
if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) {
|
||||||
|
free(buf);
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
for(p=buf; p<buf+l; p+=rt->rtm_msglen) {
|
for(p=buf; p<buf+l; p+=rt->rtm_msglen) {
|
||||||
|
|
|
@ -17,10 +17,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <errno.h>
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <Ws2tcpip.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
|
@ -268,6 +267,7 @@ int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_STRNATPMPERR
|
||||||
const char * strnatpmperr(int r)
|
const char * strnatpmperr(int r)
|
||||||
{
|
{
|
||||||
const char * s;
|
const char * s;
|
||||||
|
@ -335,4 +335,5 @@ const char * strnatpmperr(int r)
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,8 @@ LIBSPEC int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout);
|
||||||
* NATPMP_ERR_UNDEFINEDERROR */
|
* NATPMP_ERR_UNDEFINEDERROR */
|
||||||
LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response);
|
LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response);
|
||||||
|
|
||||||
|
#ifdef ENABLE_STRNATPMPERR
|
||||||
LIBSPEC const char * strnatpmperr(int t);
|
LIBSPEC const char * strnatpmperr(int t);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
MiniUPnP is written by Thomas Bernard.
|
MiniUPnP is written by Thomas Bernard.
|
||||||
Its homepage is http://miniupnp.free.fr/
|
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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
/* Project : miniupnp
|
||||||
* Author : Thomas BERNARD
|
* 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
|
* This software is subjet to the conditions detailed in the
|
||||||
* provided LICENCE file. */
|
* provided LICENCE file. */
|
||||||
/*#include <syslog.h>*/
|
/*#include <syslog.h>*/
|
||||||
|
@ -16,11 +16,7 @@
|
||||||
#include "minissdpc.h"
|
#include "minissdpc.h"
|
||||||
#include "miniupnpc.h"
|
#include "miniupnpc.h"
|
||||||
|
|
||||||
#define DECODELENGTH(n, p) n = 0; \
|
#include "codelength.h"
|
||||||
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);
|
|
||||||
|
|
||||||
struct UPNPDev *
|
struct UPNPDev *
|
||||||
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
||||||
|
@ -52,7 +48,7 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
stsize = strlen(devtype);
|
stsize = strlen(devtype);
|
||||||
buffer[0] = 1;
|
buffer[0] = 1; /* request type 1 : request devices/services by type */
|
||||||
p = buffer + 1;
|
p = buffer + 1;
|
||||||
l = stsize; CODELENGTH(l, p);
|
l = stsize; CODELENGTH(l, p);
|
||||||
memcpy(p, devtype, stsize);
|
memcpy(p, devtype, stsize);
|
||||||
|
|
Loading…
Reference in New Issue