commit
13a263894a
|
@ -4,6 +4,9 @@ build/
|
|||
*.a
|
||||
*.so
|
||||
*.dll
|
||||
*.dll.def
|
||||
*.exe
|
||||
*.lib
|
||||
*.dylib
|
||||
Makefile.bak
|
||||
miniupnpcstrings.h
|
||||
|
@ -30,3 +33,4 @@ testigddescparse
|
|||
validateigddescparse
|
||||
dist/
|
||||
miniupnpc.egg-info/
|
||||
init
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
$Id: Changelog.txt,v 1.223 2016/04/19 21:06:20 nanard Exp $
|
||||
$Id: Changelog.txt,v 1.226 2016/12/16 08:57:19 nanard Exp $
|
||||
miniUPnP client Changelog.
|
||||
|
||||
2017/05/05:
|
||||
Fix CVE-2017-8798 Thanks to tin/Team OSTStrom
|
||||
|
||||
2016/11/11:
|
||||
check strlen before memcmp in XML parsing portlistingparse.c
|
||||
fix build under SOLARIS and CYGWIN
|
||||
|
||||
2016/10/11:
|
||||
Add python 3 compatibility to IGD test
|
||||
|
||||
VERSION 2.0 : released 2016/04/19
|
||||
|
||||
2016/01/24:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MiniUPnPc
|
||||
Copyright (c) 2005-2015, Thomas BERNARD
|
||||
Copyright (c) 2005-2016, Thomas BERNARD
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
include README
|
||||
include VERSION
|
||||
include LICENSE
|
||||
include miniupnpcmodule.c
|
||||
include setup.py
|
||||
include *.h
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# $Id: Makefile,v 1.133 2016/01/24 17:24:35 nanard Exp $
|
||||
# $Id: Makefile,v 1.134 2016/10/07 09:04:36 nanard Exp $
|
||||
# MiniUPnP Project
|
||||
# http://miniupnp.free.fr/
|
||||
# http://miniupnp.tuxfamily.org/
|
||||
# https://github.com/miniupnp/miniupnp
|
||||
# (c) 2005-2015 Thomas Bernard
|
||||
# (c) 2005-2017 Thomas Bernard
|
||||
# to install use :
|
||||
# $ make DESTDIR=/tmp/dummylocation install
|
||||
# or
|
||||
|
@ -48,7 +48,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
|
|||
endif
|
||||
endif
|
||||
#CFLAGS += -ansi
|
||||
# -DNO_GETADDRINFO
|
||||
#CFLAGS += -DNO_GETADDRINFO
|
||||
INSTALL = install
|
||||
SH = /bin/sh
|
||||
JAVA = java
|
||||
|
@ -65,7 +65,9 @@ JNAERATORARGS = -mode StandaloneJar -runtime JNAerator -library miniupnpc
|
|||
JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12
|
||||
|
||||
ifeq (SunOS, $(OS))
|
||||
LDFLAGS=-lsocket -lnsl -lresolv
|
||||
LDLIBS=-lsocket -lnsl -lresolv
|
||||
CFLAGS += -D__EXTENSIONS__
|
||||
CFLAGS += -std=c99
|
||||
endif
|
||||
|
||||
# APIVERSION is used to build SONAME
|
||||
|
@ -85,7 +87,9 @@ LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
|
|||
connecthostport.o portlistingparse.o receivedata.o upnpdev.o
|
||||
|
||||
ifneq ($(OS), AmigaOS)
|
||||
ifeq (,$(findstring CYGWIN,$(OS)))
|
||||
CFLAGS := -fPIC $(CFLAGS)
|
||||
endif
|
||||
LIBOBJS := $(LIBOBJS) minissdpc.o
|
||||
endif
|
||||
|
||||
|
@ -169,18 +173,18 @@ check: validateminixml validateminiwget validateupnpreplyparse \
|
|||
everything: all $(EXECUTABLES_ADDTESTS)
|
||||
|
||||
pythonmodule: $(LIBRARY) miniupnpcmodule.c setup.py
|
||||
python setup.py build
|
||||
MAKE=$(MAKE) python setup.py build
|
||||
touch $@
|
||||
|
||||
installpythonmodule: pythonmodule
|
||||
python setup.py install
|
||||
MAKE=$(MAKE) python setup.py install
|
||||
|
||||
pythonmodule3: $(LIBRARY) miniupnpcmodule.c setup.py
|
||||
python3 setup.py build
|
||||
MAKE=$(MAKE) python3 setup.py build
|
||||
touch $@
|
||||
|
||||
installpythonmodule3: pythonmodule3
|
||||
python3 setup.py install
|
||||
MAKE=$(MAKE) python3 setup.py install
|
||||
|
||||
validateminixml: minixmlvalid
|
||||
@echo "minixml validation test"
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
Project: miniupnp
|
||||
Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
Project web page: http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||
github: https://github.com/miniupnp/miniupnp
|
||||
freecode: http://freecode.com/projects/miniupnp
|
||||
Author: Thomas Bernard
|
||||
Copyright (c) 2005-2016 Thomas Bernard
|
||||
Copyright (c) 2005-2017 Thomas Bernard
|
||||
This software is subject to the conditions detailed in the
|
||||
LICENSE file provided within this distribution.
|
||||
|
||||
|
@ -58,7 +57,7 @@ If you are using libminiupnpc in your application, please
|
|||
send me an email !
|
||||
|
||||
For any question, you can use the web forum :
|
||||
http://miniupnp.tuxfamily.org/forum/
|
||||
https://miniupnp.tuxfamily.org/forum/
|
||||
|
||||
Bugs should be reported on github :
|
||||
https://github.com/miniupnp/miniupnp/issues
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2010-2015 Thomas Bernard
|
||||
* Copyright (c) 2010-2017 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution. */
|
||||
|
||||
|
@ -36,15 +36,13 @@
|
|||
/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
|
||||
* during the connect() call */
|
||||
#define MINIUPNPC_IGNORE_EINTR
|
||||
#ifndef USE_GETHOSTBYNAME
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#endif /* #ifndef USE_GETHOSTBYNAME */
|
||||
#endif /* #else _WIN32 */
|
||||
|
||||
/* definition of PRINT_SOCKET_ERROR */
|
||||
#ifdef _WIN32
|
||||
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#else
|
||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||
#endif
|
||||
|
@ -100,13 +98,13 @@ int connecthostport(const char * host, unsigned short port,
|
|||
timeout.tv_usec = 0;
|
||||
if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt SO_RCVTIMEO");
|
||||
}
|
||||
timeout.tv_sec = 3;
|
||||
timeout.tv_usec = 0;
|
||||
if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt SO_SNDTIMEO");
|
||||
}
|
||||
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
|
||||
dest.sin_family = AF_INET;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
|
||||
/* Project : miniUPnP
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2011-2015 Thomas Bernard
|
||||
* Copyright (c) 2011-2016 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution.
|
||||
* */
|
||||
|
@ -611,7 +611,7 @@ int main(int argc, char * * argv) {
|
|||
if(pid < 0) {
|
||||
perror("wait");
|
||||
} else {
|
||||
printf("child(%d) terminated with status %d\n", pid, status);
|
||||
printf("child(%d) terminated with status %d\n", (int)pid, status);
|
||||
}
|
||||
--child_to_wait_for;
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ int main(int argc, char * * argv) {
|
|||
if(pid < 0) {
|
||||
perror("wait");
|
||||
} else {
|
||||
printf("child(%d) terminated with status %d\n", pid, status);
|
||||
printf("child(%d) terminated with status %d\n", (int)pid, status);
|
||||
}
|
||||
--child_to_wait_for;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#else
|
||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* $Id: minissdpc.c,v 1.28 2015/09/18 13:05:39 nanard Exp $ */
|
||||
/* $Id: minissdpc.c,v 1.32 2016/10/07 09:04:36 nanard Exp $ */
|
||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
* Project : miniupnp
|
||||
* Web : http://miniupnp.free.fr/
|
||||
* Author : Thomas BERNARD
|
||||
* copyright (c) 2005-2015 Thomas Bernard
|
||||
* copyright (c) 2005-2017 Thomas Bernard
|
||||
* This software is subjet to the conditions detailed in the
|
||||
* provided LICENCE file. */
|
||||
/*#include <syslog.h>*/
|
||||
|
@ -62,7 +62,7 @@ struct sockaddr_un {
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#else
|
||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||
#endif
|
||||
|
@ -73,6 +73,9 @@ struct sockaddr_un {
|
|||
|
||||
#if !defined(HAS_IP_MREQN) && !defined(_WIN32)
|
||||
#include <sys/ioctl.h>
|
||||
#if defined(__sun)
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
|
||||
|
@ -169,7 +172,7 @@ connectToMiniSSDPD(const char * socketpath)
|
|||
{
|
||||
int s;
|
||||
struct sockaddr_un addr;
|
||||
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
|
||||
#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun)
|
||||
struct timeval timeout;
|
||||
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
|
||||
|
||||
|
@ -180,23 +183,25 @@ connectToMiniSSDPD(const char * socketpath)
|
|||
perror("socket(unix)");
|
||||
return MINISSDPC_SOCKET_ERROR;
|
||||
}
|
||||
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
|
||||
#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun)
|
||||
/* setting a 3 seconds timeout */
|
||||
/* not supported for AF_UNIX sockets under Solaris */
|
||||
timeout.tv_sec = 3;
|
||||
timeout.tv_usec = 0;
|
||||
if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
|
||||
{
|
||||
perror("setsockopt");
|
||||
perror("setsockopt SO_RCVTIMEO unix");
|
||||
}
|
||||
timeout.tv_sec = 3;
|
||||
timeout.tv_usec = 0;
|
||||
if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
|
||||
{
|
||||
perror("setsockopt");
|
||||
perror("setsockopt SO_SNDTIMEO unix");
|
||||
}
|
||||
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
|
||||
if(!socketpath)
|
||||
socketpath = "/var/run/minissdpd.sock";
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path));
|
||||
/* TODO : check if we need to handle the EINTR */
|
||||
|
@ -498,6 +503,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
unsigned long _ttl = (unsigned long)ttl;
|
||||
#endif
|
||||
int linklocal = 1;
|
||||
int sentok;
|
||||
|
||||
if(error)
|
||||
*error = MINISSDPC_UNKNOWN_ERROR;
|
||||
|
@ -608,14 +614,22 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(ipv6) {
|
||||
int mcastHops = ttl;
|
||||
if(setsockopt(sudp, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastHops, sizeof(mcastHops)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt(IPV6_MULTICAST_HOPS,...)");
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&_ttl, sizeof(_ttl)) < 0)
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&_ttl, sizeof(_ttl)) < 0)
|
||||
#else /* _WIN32 */
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
|
||||
#endif /* _WIN32 */
|
||||
{
|
||||
/* not a fatal error */
|
||||
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
|
||||
{
|
||||
/* not a fatal error */
|
||||
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
|
||||
}
|
||||
}
|
||||
|
||||
if(multicastif)
|
||||
|
@ -628,7 +642,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
unsigned int ifindex = if_nametoindex(multicastif); /* eth0, etc. */
|
||||
if(setsockopt(sudp, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt IPV6_MULTICAST_IF");
|
||||
}
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
|
@ -643,7 +657,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
|
||||
}
|
||||
} else {
|
||||
#ifdef HAS_IP_MREQN
|
||||
|
@ -653,7 +667,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
reqn.imr_ifindex = if_nametoindex(multicastif);
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&reqn, sizeof(reqn)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
|
||||
}
|
||||
#elif !defined(_WIN32)
|
||||
struct ifreq ifr;
|
||||
|
@ -667,7 +681,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
mc_if.s_addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
|
||||
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
|
||||
{
|
||||
PRINT_SOCKET_ERROR("setsockopt");
|
||||
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
#ifdef DEBUG
|
||||
|
@ -700,6 +714,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
}
|
||||
/* receiving SSDP response packet */
|
||||
for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) {
|
||||
sentok = 0;
|
||||
/* sending the SSDP M-SEARCH packet */
|
||||
n = snprintf(bufr, sizeof(bufr),
|
||||
MSearchMsgFmt,
|
||||
|
@ -743,7 +758,8 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
if(error)
|
||||
*error = MINISSDPC_SOCKET_ERROR;
|
||||
PRINT_SOCKET_ERROR("sendto");
|
||||
break;
|
||||
} else {
|
||||
sentok = 1;
|
||||
}
|
||||
#else /* #ifdef NO_GETADDRINFO */
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
|
@ -775,19 +791,20 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||
#endif
|
||||
PRINT_SOCKET_ERROR("sendto");
|
||||
continue;
|
||||
} else {
|
||||
sentok = 1;
|
||||
}
|
||||
}
|
||||
freeaddrinfo(servinfo);
|
||||
if(n < 0) {
|
||||
if(!sentok) {
|
||||
if(error)
|
||||
*error = MINISSDPC_SOCKET_ERROR;
|
||||
break;
|
||||
}
|
||||
#endif /* #ifdef NO_GETADDRINFO */
|
||||
/* Waiting for SSDP REPLY packet to M-SEARCH
|
||||
* if searchalltypes is set, enter the loop only
|
||||
* when the last deviceType is reached */
|
||||
if(!searchalltypes || !deviceTypes[deviceIndex + 1]) do {
|
||||
if((sentok && !searchalltypes) || !deviceTypes[deviceIndex + 1]) do {
|
||||
n = receivedata(sudp, bufr, sizeof(bufr), delay, &scope_id);
|
||||
if (n < 0) {
|
||||
/* error */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* Project : miniupnp
|
||||
* Author : Thomas BERNARD
|
||||
* website : http://miniupnp.tuxfamily.org/
|
||||
* copyright (c) 2007-2014 Thomas Bernard
|
||||
* copyright (c) 2007-2016 Thomas Bernard
|
||||
* This software is subjet to the conditions detailed in the
|
||||
* provided LICENCE file. */
|
||||
#include <Python.h>
|
||||
|
@ -12,6 +12,10 @@
|
|||
#include "upnpcommands.h"
|
||||
#include "upnperrors.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
/* for compatibility with Python < 2.4 */
|
||||
#ifndef Py_RETURN_NONE
|
||||
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
||||
|
@ -303,7 +307,7 @@ UPnP_addportmapping(UPnPObject *self, PyObject *args)
|
|||
const char * remoteHost;
|
||||
const char * leaseDuration = "0";
|
||||
int r;
|
||||
if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto,
|
||||
if (!PyArg_ParseTuple(args, "HssHzz", &ePort, &proto,
|
||||
&host, &iPort, &desc, &remoteHost))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
|
@ -345,7 +349,7 @@ UPnP_addanyportmapping(UPnPObject *self, PyObject *args)
|
|||
const char * remoteHost;
|
||||
const char * leaseDuration = "0";
|
||||
int r;
|
||||
if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto, &host, &iPort, &desc, &remoteHost))
|
||||
if (!PyArg_ParseTuple(args, "HssHzz", &ePort, &proto, &host, &iPort, &desc, &remoteHost))
|
||||
return NULL;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sprintf(extPort, "%hu", ePort);
|
||||
|
@ -669,6 +673,10 @@ initminiupnpc(void)
|
|||
PyObject* m;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* initialize Winsock. */
|
||||
WSADATA wsaData;
|
||||
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||
|
||||
UPnPType.tp_new = PyType_GenericNew;
|
||||
#endif
|
||||
if (PyType_Ready(&UPnPType) < 0)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* Project : miniupnp
|
||||
* Website : http://miniupnp.free.fr/
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2005-2016 Thomas Bernard
|
||||
* Copyright (c) 2005-2017 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution. */
|
||||
|
||||
|
@ -83,8 +83,10 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
unsigned int content_buf_used = 0;
|
||||
char chunksize_buf[32];
|
||||
unsigned int chunksize_buf_index;
|
||||
#ifdef DEBUG
|
||||
char * reason_phrase = NULL;
|
||||
int reason_phrase_len = 0;
|
||||
#endif
|
||||
|
||||
if(status_code) *status_code = -1;
|
||||
header_buf = malloc(header_buf_len);
|
||||
|
@ -109,7 +111,7 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
chunksize_buf[0] = '\0';
|
||||
chunksize_buf_index = 0;
|
||||
|
||||
while((n = receivedata(s, buf, 2048, 5000, NULL)) > 0)
|
||||
while((n = receivedata(s, buf, sizeof(buf), 5000, NULL)) > 0)
|
||||
{
|
||||
if(endofheaders == 0)
|
||||
{
|
||||
|
@ -181,8 +183,10 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
*status_code = atoi(header_buf + sp + 1);
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
reason_phrase = header_buf + sp + 1;
|
||||
reason_phrase_len = i - sp - 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -280,11 +284,12 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
goto end_of_stream;
|
||||
}
|
||||
}
|
||||
bytestocopy = ((int)chunksize < (n - i))?chunksize:(unsigned int)(n - i);
|
||||
/* it is guaranteed that (n >= i) */
|
||||
bytestocopy = (chunksize < (unsigned int)(n - i))?chunksize:(unsigned int)(n - i);
|
||||
if((content_buf_used + bytestocopy) > content_buf_len)
|
||||
{
|
||||
char * tmp;
|
||||
if(content_length >= (int)(content_buf_used + bytestocopy)) {
|
||||
if((content_length >= 0) && ((unsigned int)content_length >= (content_buf_used + bytestocopy))) {
|
||||
content_buf_len = content_length;
|
||||
} else {
|
||||
content_buf_len = content_buf_used + bytestocopy;
|
||||
|
@ -309,14 +314,15 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
{
|
||||
/* not chunked */
|
||||
if(content_length > 0
|
||||
&& (int)(content_buf_used + n) > content_length) {
|
||||
&& (content_buf_used + n) > (unsigned int)content_length) {
|
||||
/* skipping additional bytes */
|
||||
n = content_length - content_buf_used;
|
||||
}
|
||||
if(content_buf_used + n > content_buf_len)
|
||||
{
|
||||
char * tmp;
|
||||
if(content_length >= (int)(content_buf_used + n)) {
|
||||
if(content_length >= 0
|
||||
&& (unsigned int)content_length >= (content_buf_used + n)) {
|
||||
content_buf_len = content_length;
|
||||
} else {
|
||||
content_buf_len = content_buf_used + n;
|
||||
|
@ -336,7 +342,7 @@ getHTTPResponse(int s, int * size, int * status_code)
|
|||
}
|
||||
}
|
||||
/* use the Content-Length header value if available */
|
||||
if(content_length > 0 && (int)content_buf_used >= content_length)
|
||||
if(content_length > 0 && content_buf_used >= (unsigned int)content_length)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("End of HTTP content\n");
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
*.db
|
||||
.vs
|
||||
Debug/
|
||||
Release/
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D28CE435-CB33-4BAE-8A52-C6EF915956F5}</ProjectGuid>
|
||||
<RootNamespace>miniupnpc</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>14.0.25123.0</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\connecthostport.c" />
|
||||
<ClCompile Include="..\igd_desc_parse.c" />
|
||||
<ClCompile Include="..\minisoap.c" />
|
||||
<ClCompile Include="..\minissdpc.c" />
|
||||
<ClCompile Include="..\miniupnpc.c" />
|
||||
<ClCompile Include="..\miniwget.c" />
|
||||
<ClCompile Include="..\minixml.c" />
|
||||
<ClCompile Include="..\portlistingparse.c" />
|
||||
<ClCompile Include="..\receivedata.c" />
|
||||
<ClCompile Include="..\upnpcommands.c" />
|
||||
<ClCompile Include="..\upnpdev.c" />
|
||||
<ClCompile Include="..\upnperrors.c" />
|
||||
<ClCompile Include="..\upnpreplyparse.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\connecthostport.h" />
|
||||
<ClInclude Include="..\declspec.h" />
|
||||
<ClInclude Include="..\igd_desc_parse.h" />
|
||||
<ClInclude Include="..\minisoap.h" />
|
||||
<ClInclude Include="..\minissdpc.h" />
|
||||
<ClInclude Include="..\miniupnpc.h" />
|
||||
<ClInclude Include="..\miniupnpcstrings.h" />
|
||||
<ClInclude Include="..\miniupnpctypes.h" />
|
||||
<ClInclude Include="..\miniwget.h" />
|
||||
<ClInclude Include="..\minixml.h" />
|
||||
<ClInclude Include="..\portlistingparse.h" />
|
||||
<ClInclude Include="..\receivedata.h" />
|
||||
<ClInclude Include="..\upnpcommands.h" />
|
||||
<ClInclude Include="..\upnpdev.h" />
|
||||
<ClInclude Include="..\upnperrors.h" />
|
||||
<ClInclude Include="..\upnpreplyparse.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Fichiers sources">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers d%27en-tête">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers de ressources">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\connecthostport.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\igd_desc_parse.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\minisoap.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\minissdpc.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\miniupnpc.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\miniwget.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\minixml.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\portlistingparse.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\receivedata.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\upnpcommands.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\upnpdev.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\upnperrors.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\upnpreplyparse.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\connecthostport.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\declspec.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\igd_desc_parse.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\minisoap.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\minissdpc.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\miniupnpc.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\miniupnpcstrings.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\miniupnpctypes.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\miniwget.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\minixml.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\portlistingparse.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\receivedata.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\upnpcommands.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\upnpdev.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\upnperrors.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\upnpreplyparse.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "miniupnpc.vcxproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upnpc-static", "upnpc-static.vcxproj", "{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.Build.0 = Release|Win32
|
||||
{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}</ProjectGuid>
|
||||
<RootNamespace>upnpcstatic</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>14.0.25123.0</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir>$(Configuration)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;MINIUPNP_STATICLIB;DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;IPHlpApi.Lib;Debug\miniupnpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;IPHlpApi.Lib;Release\miniupnpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\upnpc.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="miniupnpc.vcxproj">
|
||||
<Project>{d28ce435-cb33-4bae-8a52-c6ef915956f5}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Fichiers sources">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers d%27en-tête">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers de ressources">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\upnpc.c">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: portlistingparse.c,v 1.9 2015/07/15 12:41:13 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2011-2015 Thomas Bernard
|
||||
* (c) 2011-2016 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
#include <string.h>
|
||||
|
@ -55,7 +55,7 @@ startelt(void * d, const char * name, int l)
|
|||
pdata->curelt = PortMappingEltNone;
|
||||
for(i = 0; elements[i].str; i++)
|
||||
{
|
||||
if(memcmp(name, elements[i].str, l) == 0)
|
||||
if(strlen(elements[i].str) == (size_t)l && memcmp(name, elements[i].str, l) == 0)
|
||||
{
|
||||
pdata->curelt = elements[i].code;
|
||||
break;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
|
||||
#else
|
||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||
#endif
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
#! /usr/bin/python
|
||||
# vim: tabstop=8 shiftwidth=8 expandtab
|
||||
# $Id: setup.py,v 1.9 2012/05/23 08:50:10 nanard Exp $
|
||||
# the MiniUPnP Project (c) 2007-2014 Thomas Bernard
|
||||
# the MiniUPnP Project (c) 2007-2017 Thomas Bernard
|
||||
# http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/
|
||||
#
|
||||
# python script to build the miniupnpc module under unix
|
||||
#
|
||||
# replace libminiupnpc.a by libminiupnpc.so for shared library usage
|
||||
try:
|
||||
from setuptools import setup, Extension
|
||||
except ImportError:
|
||||
from distutils.core import setup, Extension
|
||||
from distutils import sysconfig
|
||||
sysconfig.get_config_vars()["OPT"] = ''
|
||||
sysconfig.get_config_vars()["CFLAGS"] = ''
|
||||
# Uses MAKE environment variable (defaulting to 'make')
|
||||
|
||||
from setuptools import setup, Extension
|
||||
from setuptools.command import build_ext
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
EXT = ['libminiupnpc.a']
|
||||
|
||||
class make_then_build_ext(build_ext.build_ext):
|
||||
def run(self):
|
||||
subprocess.check_call([os.environ.get('MAKE', 'make')] + EXT)
|
||||
build_ext.build_ext.run(self)
|
||||
|
||||
setup(name="miniupnpc",
|
||||
version=open('VERSION').read().strip(),
|
||||
author='Thomas BERNARD',
|
||||
|
@ -21,8 +27,9 @@ setup(name="miniupnpc",
|
|||
license=open('LICENSE').read(),
|
||||
url='http://miniupnp.free.fr/',
|
||||
description='miniUPnP client',
|
||||
cmdclass={'build_ext': make_then_build_ext},
|
||||
ext_modules=[
|
||||
Extension(name="miniupnpc", sources=["miniupnpcmodule.c"],
|
||||
extra_objects=["libminiupnpc.a"])
|
||||
extra_objects=EXT)
|
||||
])
|
||||
|
||||
|
|
|
@ -87,4 +87,4 @@
|
|||
</device>
|
||||
</deviceList>
|
||||
</device>
|
||||
</root>
|
||||
</root>
|
|
@ -8,7 +8,11 @@
|
|||
# import the python miniupnpc module
|
||||
import miniupnpc
|
||||
import socket
|
||||
import BaseHTTPServer
|
||||
|
||||
try:
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
except ImportError:
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
# function definition
|
||||
def list_redirections():
|
||||
|
@ -17,11 +21,11 @@ def list_redirections():
|
|||
p = u.getgenericportmapping(i)
|
||||
if p==None:
|
||||
break
|
||||
print i, p
|
||||
print(i, p)
|
||||
i = i + 1
|
||||
|
||||
#define the handler class for HTTP connections
|
||||
class handler_class(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
class handler_class(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
|
@ -37,20 +41,20 @@ u = miniupnpc.UPnP()
|
|||
u.discoverdelay = 200;
|
||||
|
||||
try:
|
||||
print 'Discovering... delay=%ums' % u.discoverdelay
|
||||
print('Discovering... delay=%ums' % u.discoverdelay)
|
||||
ndevices = u.discover()
|
||||
print ndevices, 'device(s) detected'
|
||||
print(ndevices, 'device(s) detected')
|
||||
|
||||
# select an igd
|
||||
u.selectigd()
|
||||
# display information about the IGD and the internet connection
|
||||
print 'local ip address :', u.lanaddr
|
||||
print('local ip address :', u.lanaddr)
|
||||
externalipaddress = u.externalipaddress()
|
||||
print 'external ip address :', externalipaddress
|
||||
print u.statusinfo(), u.connectiontype()
|
||||
print('external ip address :', externalipaddress)
|
||||
print(u.statusinfo(), u.connectiontype())
|
||||
|
||||
#instanciate a HTTPd object. The port is assigned by the system.
|
||||
httpd = BaseHTTPServer.HTTPServer((u.lanaddr, 0), handler_class)
|
||||
httpd = HTTPServer((u.lanaddr, 0), handler_class)
|
||||
eport = httpd.server_port
|
||||
|
||||
# find a free port for the redirection
|
||||
|
@ -59,26 +63,26 @@ try:
|
|||
eport = eport + 1
|
||||
r = u.getspecificportmapping(eport, 'TCP')
|
||||
|
||||
print 'trying to redirect %s port %u TCP => %s port %u TCP' % (externalipaddress, eport, u.lanaddr, httpd.server_port)
|
||||
print('trying to redirect %s port %u TCP => %s port %u TCP' % (externalipaddress, eport, u.lanaddr, httpd.server_port))
|
||||
|
||||
b = u.addportmapping(eport, 'TCP', u.lanaddr, httpd.server_port,
|
||||
'UPnP IGD Tester port %u' % eport, '')
|
||||
if b:
|
||||
print 'Success. Now waiting for some HTTP request on http://%s:%u' % (externalipaddress ,eport)
|
||||
print('Success. Now waiting for some HTTP request on http://%s:%u' % (externalipaddress ,eport))
|
||||
try:
|
||||
httpd.handle_request()
|
||||
httpd.server_close()
|
||||
except KeyboardInterrupt, details:
|
||||
print "CTRL-C exception!", details
|
||||
except KeyboardInterrupt as details:
|
||||
print("CTRL-C exception!", details)
|
||||
b = u.deleteportmapping(eport, 'TCP')
|
||||
if b:
|
||||
print 'Successfully deleted port mapping'
|
||||
print('Successfully deleted port mapping')
|
||||
else:
|
||||
print 'Failed to remove port mapping'
|
||||
print('Failed to remove port mapping')
|
||||
else:
|
||||
print 'Failed'
|
||||
print('Failed')
|
||||
|
||||
httpd.server_close()
|
||||
|
||||
except Exception, e:
|
||||
print 'Exception :', e
|
||||
except Exception as e:
|
||||
print('Exception :', e)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: upnpc.c,v 1.114 2016/01/22 15:04:23 nanard Exp $ */
|
||||
/* $Id: upnpc.c,v 1.117 2017/05/26 15:26:55 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2005-2016 Thomas Bernard
|
||||
* Copyright (c) 2005-2017 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution. */
|
||||
|
||||
|
@ -242,7 +242,7 @@ static void NewListRedirections(struct UPNPUrls * urls,
|
|||
* 2 - get extenal ip address
|
||||
* 3 - Add port mapping
|
||||
* 4 - get this port mapping from the IGD */
|
||||
static void SetRedirectAndTest(struct UPNPUrls * urls,
|
||||
static int SetRedirectAndTest(struct UPNPUrls * urls,
|
||||
struct IGDdatas * data,
|
||||
const char * iaddr,
|
||||
const char * iport,
|
||||
|
@ -262,13 +262,13 @@ static void SetRedirectAndTest(struct UPNPUrls * urls,
|
|||
if(!iaddr || !iport || !eport || !proto)
|
||||
{
|
||||
fprintf(stderr, "Wrong arguments\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
proto = protofix(proto);
|
||||
if(!proto)
|
||||
{
|
||||
fprintf(stderr, "invalid protocol\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = UPNP_GetExternalIPAddress(urls->controlURL,
|
||||
|
@ -292,9 +292,11 @@ static void SetRedirectAndTest(struct UPNPUrls * urls,
|
|||
r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype,
|
||||
eport, iport, iaddr, description,
|
||||
proto, 0, leaseDuration);
|
||||
if(r!=UPNPCOMMAND_SUCCESS)
|
||||
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||
eport, iport, iaddr, r, strupnperror(r));
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
r = UPNP_GetSpecificPortMappingEntry(urls->controlURL,
|
||||
|
@ -302,17 +304,19 @@ static void SetRedirectAndTest(struct UPNPUrls * urls,
|
|||
eport, proto, NULL/*remoteHost*/,
|
||||
intClient, intPort, NULL/*desc*/,
|
||||
NULL/*enabled*/, duration);
|
||||
if(r!=UPNPCOMMAND_SUCCESS)
|
||||
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||
printf("GetSpecificPortMappingEntry() failed with code %d (%s)\n",
|
||||
r, strupnperror(r));
|
||||
else {
|
||||
return -2;
|
||||
} else {
|
||||
printf("InternalIP:Port = %s:%s\n", intClient, intPort);
|
||||
printf("external %s:%s %s is redirected to internal %s:%s (duration=%s)\n",
|
||||
externalIPAddress, eport, proto, intClient, intPort, duration);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
RemoveRedirect(struct UPNPUrls * urls,
|
||||
struct IGDdatas * data,
|
||||
const char * eport,
|
||||
|
@ -323,19 +327,25 @@ RemoveRedirect(struct UPNPUrls * urls,
|
|||
if(!proto || !eport)
|
||||
{
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
proto = protofix(proto);
|
||||
if(!proto)
|
||||
{
|
||||
fprintf(stderr, "protocol invalid\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, remoteHost);
|
||||
printf("UPNP_DeletePortMapping() returned : %d\n", r);
|
||||
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||
printf("UPNP_DeletePortMapping() failed with code : %d\n", r);
|
||||
return -2;
|
||||
}else {
|
||||
printf("UPNP_DeletePortMapping() returned : %d\n", r);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
RemoveRedirectRange(struct UPNPUrls * urls,
|
||||
struct IGDdatas * data,
|
||||
const char * ePortStart, char const * ePortEnd,
|
||||
|
@ -349,16 +359,22 @@ RemoveRedirectRange(struct UPNPUrls * urls,
|
|||
if(!proto || !ePortStart || !ePortEnd)
|
||||
{
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
proto = protofix(proto);
|
||||
if(!proto)
|
||||
{
|
||||
fprintf(stderr, "protocol invalid\n");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
r = UPNP_DeletePortMappingRange(urls->controlURL, data->first.servicetype, ePortStart, ePortEnd, proto, manage);
|
||||
printf("UPNP_DeletePortMappingRange() returned : %d\n", r);
|
||||
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||
printf("UPNP_DeletePortMappingRange() failed with code : %d\n", r);
|
||||
return -2;
|
||||
}else {
|
||||
printf("UPNP_DeletePortMappingRange() returned : %d\n", r);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* IGD:2, functions for service WANIPv6FirewallControl:1 */
|
||||
|
@ -562,8 +578,8 @@ int main(int argc, char ** argv)
|
|||
}
|
||||
#endif
|
||||
printf("upnpc : miniupnpc library test client, version %s.\n", MINIUPNPC_VERSION_STRING);
|
||||
printf(" (c) 2005-2016 Thomas Bernard.\n");
|
||||
printf("Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/\n"
|
||||
printf(" (c) 2005-2017 Thomas Bernard.\n");
|
||||
printf("Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/\n"
|
||||
"for more information.\n");
|
||||
/* command line processing */
|
||||
for(i=1; i<argc; i++)
|
||||
|
@ -711,29 +727,33 @@ int main(int argc, char ** argv)
|
|||
NewListRedirections(&urls, &data);
|
||||
break;
|
||||
case 'a':
|
||||
SetRedirectAndTest(&urls, &data,
|
||||
if (SetRedirectAndTest(&urls, &data,
|
||||
commandargv[0], commandargv[1],
|
||||
commandargv[2], commandargv[3],
|
||||
(commandargc > 4)?commandargv[4]:"0",
|
||||
description, 0);
|
||||
description, 0) < 0)
|
||||
retcode = 2;
|
||||
break;
|
||||
case 'd':
|
||||
RemoveRedirect(&urls, &data, commandargv[0], commandargv[1],
|
||||
commandargc > 2 ? commandargv[2] : NULL);
|
||||
if (RemoveRedirect(&urls, &data, commandargv[0], commandargv[1],
|
||||
commandargc > 2 ? commandargv[2] : NULL) < 0)
|
||||
retcode = 2;
|
||||
break;
|
||||
case 'n': /* aNy */
|
||||
SetRedirectAndTest(&urls, &data,
|
||||
if (SetRedirectAndTest(&urls, &data,
|
||||
commandargv[0], commandargv[1],
|
||||
commandargv[2], commandargv[3],
|
||||
(commandargc > 4)?commandargv[4]:"0",
|
||||
description, 1);
|
||||
description, 1) < 0)
|
||||
retcode = 2;
|
||||
break;
|
||||
case 'N':
|
||||
if (commandargc < 3)
|
||||
fprintf(stderr, "too few arguments\n");
|
||||
|
||||
RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2],
|
||||
commandargc > 3 ? commandargv[3] : NULL);
|
||||
if (RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2],
|
||||
commandargc > 3 ? commandargv[3] : NULL) < 0)
|
||||
retcode = 2;
|
||||
break;
|
||||
case 's':
|
||||
GetConnectionStatus(&urls, &data);
|
||||
|
@ -749,17 +769,19 @@ int main(int argc, char ** argv)
|
|||
break;
|
||||
} else if(is_int(commandargv[i+1])){
|
||||
/* 2nd parameter is an integer : <port> <external_port> <protocol> */
|
||||
SetRedirectAndTest(&urls, &data,
|
||||
if (SetRedirectAndTest(&urls, &data,
|
||||
lanaddr, commandargv[i],
|
||||
commandargv[i+1], commandargv[i+2], "0",
|
||||
description, 0);
|
||||
description, 0) < 0)
|
||||
retcode = 2;
|
||||
i+=3; /* 3 parameters parsed */
|
||||
} else {
|
||||
/* 2nd parameter not an integer : <port> <protocol> */
|
||||
SetRedirectAndTest(&urls, &data,
|
||||
if (SetRedirectAndTest(&urls, &data,
|
||||
lanaddr, commandargv[i],
|
||||
commandargv[i], commandargv[i+1], "0",
|
||||
description, 0);
|
||||
description, 0) < 0)
|
||||
retcode = 2;
|
||||
i+=2; /* 2 parameters parsed */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* $Id: upnpcommands.c,v 1.46 2015/07/15 12:19:00 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
* Project : miniupnp
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2005-2015 Thomas Bernard
|
||||
* Copyright (c) 2005-2017 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution.
|
||||
* */
|
||||
|
@ -372,10 +373,11 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
|
|||
AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
|
||||
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
||||
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"AddPortMapping", AddPortMappingArgs,
|
||||
&bufsize))) {
|
||||
free(AddPortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"AddPortMapping", AddPortMappingArgs,
|
||||
&bufsize);
|
||||
free(AddPortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
/*DisplayNameValueList(buffer, bufsize);*/
|
||||
|
@ -392,7 +394,6 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(AddPortMappingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -436,10 +437,11 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
|
|||
AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
|
||||
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
||||
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"AddAnyPortMapping", AddPortMappingArgs,
|
||||
&bufsize))) {
|
||||
free(AddPortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"AddAnyPortMapping", AddPortMappingArgs,
|
||||
&bufsize);
|
||||
free(AddPortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -461,7 +463,6 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
|
|||
}
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(AddPortMappingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -490,10 +491,11 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
|
|||
DeletePortMappingArgs[1].val = extPort;
|
||||
DeletePortMappingArgs[2].elt = "NewProtocol";
|
||||
DeletePortMappingArgs[2].val = proto;
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"DeletePortMapping",
|
||||
DeletePortMappingArgs, &bufsize))) {
|
||||
free(DeletePortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"DeletePortMapping",
|
||||
DeletePortMappingArgs, &bufsize);
|
||||
free(DeletePortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
/*DisplayNameValueList(buffer, bufsize);*/
|
||||
|
@ -507,7 +509,6 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(DeletePortMappingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -539,10 +540,11 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
|
|||
DeletePortMappingArgs[3].elt = "NewManage";
|
||||
DeletePortMappingArgs[3].val = manage;
|
||||
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"DeletePortMappingRange",
|
||||
DeletePortMappingArgs, &bufsize))) {
|
||||
free(DeletePortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"DeletePortMappingRange",
|
||||
DeletePortMappingArgs, &bufsize);
|
||||
free(DeletePortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -555,7 +557,6 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(DeletePortMappingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -587,10 +588,11 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
|
|||
return UPNPCOMMAND_MEM_ALLOC_ERROR;
|
||||
GetPortMappingArgs[0].elt = "NewPortMappingIndex";
|
||||
GetPortMappingArgs[0].val = index;
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetGenericPortMappingEntry",
|
||||
GetPortMappingArgs, &bufsize))) {
|
||||
free(GetPortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetGenericPortMappingEntry",
|
||||
GetPortMappingArgs, &bufsize);
|
||||
free(GetPortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -652,7 +654,6 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
|
|||
sscanf(p, "%d", &r);
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(GetPortMappingArgs);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -728,10 +729,11 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
|
|||
GetPortMappingArgs[1].val = extPort;
|
||||
GetPortMappingArgs[2].elt = "NewProtocol";
|
||||
GetPortMappingArgs[2].val = proto;
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetSpecificPortMappingEntry",
|
||||
GetPortMappingArgs, &bufsize))) {
|
||||
free(GetPortMappingArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetSpecificPortMappingEntry",
|
||||
GetPortMappingArgs, &bufsize);
|
||||
free(GetPortMappingArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
/*DisplayNameValueList(buffer, bufsize);*/
|
||||
|
@ -779,7 +781,6 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
|
|||
}
|
||||
|
||||
ClearNameValueList(&pdata);
|
||||
free(GetPortMappingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -824,13 +825,13 @@ UPNP_GetListOfPortMappings(const char * controlURL,
|
|||
GetListOfPortMappingsArgs[4].elt = "NewNumberOfPorts";
|
||||
GetListOfPortMappingsArgs[4].val = numberOfPorts?numberOfPorts:"1000";
|
||||
|
||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetListOfPortMappings",
|
||||
GetListOfPortMappingsArgs, &bufsize))) {
|
||||
free(GetListOfPortMappingsArgs);
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetListOfPortMappings",
|
||||
GetListOfPortMappingsArgs, &bufsize);
|
||||
free(GetListOfPortMappingsArgs);
|
||||
if(!buffer) {
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
free(GetListOfPortMappingsArgs);
|
||||
|
||||
/*DisplayNameValueList(buffer, bufsize);*/
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -954,6 +955,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype
|
|||
GetOutboundPinholeTimeoutArgs[4].val = intClient;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetOutboundPinholeTimeout", GetOutboundPinholeTimeoutArgs, &bufsize);
|
||||
free(GetOutboundPinholeTimeoutArgs);
|
||||
if(!buffer)
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -972,7 +974,6 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype
|
|||
*opTimeout = my_atoui(p);
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(GetOutboundPinholeTimeoutArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1031,6 +1032,7 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype,
|
|||
AddPinholeArgs[5].val = leaseTime;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"AddPinhole", AddPinholeArgs, &bufsize);
|
||||
free(AddPinholeArgs);
|
||||
if(!buffer)
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -1053,7 +1055,6 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype,
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(AddPinholeArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1081,6 +1082,7 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
|
|||
UpdatePinholeArgs[1].val = leaseTime;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"UpdatePinhole", UpdatePinholeArgs, &bufsize);
|
||||
free(UpdatePinholeArgs);
|
||||
if(!buffer)
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -1097,7 +1099,6 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(UpdatePinholeArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1122,6 +1123,7 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char
|
|||
DeletePinholeArgs[0].val = uniqueID;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"DeletePinhole", DeletePinholeArgs, &bufsize);
|
||||
free(DeletePinholeArgs);
|
||||
if(!buffer)
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
/*DisplayNameValueList(buffer, bufsize);*/
|
||||
|
@ -1138,7 +1140,6 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char
|
|||
ret = UPNPCOMMAND_SUCCESS;
|
||||
}
|
||||
ClearNameValueList(&pdata);
|
||||
free(DeletePinholeArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1163,8 +1164,11 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
|
|||
CheckPinholeWorkingArgs[0].val = uniqueID;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"CheckPinholeWorking", CheckPinholeWorkingArgs, &bufsize);
|
||||
free(CheckPinholeWorkingArgs);
|
||||
if(!buffer)
|
||||
{
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
}
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
free(buffer); buffer = NULL;
|
||||
|
||||
|
@ -1185,7 +1189,6 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
|
|||
}
|
||||
|
||||
ClearNameValueList(&pdata);
|
||||
free(CheckPinholeWorkingArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1210,6 +1213,7 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
|
|||
GetPinholePacketsArgs[0].val = uniqueID;
|
||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||
"GetPinholePackets", GetPinholePacketsArgs, &bufsize);
|
||||
free(GetPinholePacketsArgs);
|
||||
if(!buffer)
|
||||
return UPNPCOMMAND_HTTP_ERROR;
|
||||
ParseNameValue(buffer, bufsize, &pdata);
|
||||
|
@ -1230,7 +1234,6 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
|
|||
}
|
||||
|
||||
ClearNameValueList(&pdata);
|
||||
free(GetPinholePacketsArgs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue