mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-18 17:06:51 +00:00
Merge branch 'master' into randomize_url
This commit is contained in:
commit
57a74f2739
@ -33,7 +33,7 @@ compiler:
|
|||||||
- clang
|
- clang
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- 'if [ "$TRAVIS_OS_NAME" = "osx" -a "$PROJECT" = "miniupnpc-libevent" ]; then brew update > /dev/null && brew install libevent; fi'
|
- 'if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" == "gcc" ] ; then CC=gcc-4.9; fi'
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- 'cd $TRAVIS_BUILD_DIR && cd $PROJECT'
|
- 'cd $TRAVIS_BUILD_DIR && cd $PROJECT'
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
$Id: Changelog.txt,v 1.45 2016/03/01 18:06:46 nanard Exp $
|
$Id: Changelog.txt,v 1.47 2016/12/16 09:22:35 nanard Exp $
|
||||||
|
|
||||||
|
2016/11/11:
|
||||||
|
Fix for Solaris build
|
||||||
|
|
||||||
2016/03/01:
|
2016/03/01:
|
||||||
Fix broken overflow test (p+l > buf+n) thanks to Salva Peiro
|
Fix broken overflow test (p+l > buf+n) thanks to Salva Peiro
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* $Id: ifacewatch.c,v 1.16 2015/09/03 18:31:25 nanard Exp $ */
|
/* $Id: ifacewatch.c,v 1.16 2015/09/03 18:31:25 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* (c) 2011-2012 Thomas Bernard
|
* (c) 2011-2016 Thomas Bernard
|
||||||
* website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
4
miniupnpc/.gitignore
vendored
4
miniupnpc/.gitignore
vendored
@ -4,6 +4,9 @@ build/
|
|||||||
*.a
|
*.a
|
||||||
*.so
|
*.so
|
||||||
*.dll
|
*.dll
|
||||||
|
*.dll.def
|
||||||
|
*.exe
|
||||||
|
*.lib
|
||||||
*.dylib
|
*.dylib
|
||||||
Makefile.bak
|
Makefile.bak
|
||||||
miniupnpcstrings.h
|
miniupnpcstrings.h
|
||||||
@ -30,3 +33,4 @@ testigddescparse
|
|||||||
validateigddescparse
|
validateigddescparse
|
||||||
dist/
|
dist/
|
||||||
miniupnpc.egg-info/
|
miniupnpc.egg-info/
|
||||||
|
init
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
$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.
|
miniUPnP client Changelog.
|
||||||
|
|
||||||
|
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
|
VERSION 2.0 : released 2016/04/19
|
||||||
|
|
||||||
2016/01/24:
|
2016/01/24:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# http://miniupnp.free.fr/
|
# http://miniupnp.free.fr/
|
||||||
# http://miniupnp.tuxfamily.org/
|
# http://miniupnp.tuxfamily.org/
|
||||||
# https://github.com/miniupnp/miniupnp
|
# https://github.com/miniupnp/miniupnp
|
||||||
# (c) 2005-2016 Thomas Bernard
|
# (c) 2005-2017 Thomas Bernard
|
||||||
# to install use :
|
# to install use :
|
||||||
# $ make DESTDIR=/tmp/dummylocation install
|
# $ make DESTDIR=/tmp/dummylocation install
|
||||||
# or
|
# or
|
||||||
@ -48,7 +48,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
#CFLAGS += -ansi
|
#CFLAGS += -ansi
|
||||||
# -DNO_GETADDRINFO
|
#CFLAGS += -DNO_GETADDRINFO
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
SH = /bin/sh
|
SH = /bin/sh
|
||||||
JAVA = java
|
JAVA = java
|
||||||
@ -65,7 +65,7 @@ JNAERATORARGS = -mode StandaloneJar -runtime JNAerator -library miniupnpc
|
|||||||
JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12
|
JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12
|
||||||
|
|
||||||
ifeq (SunOS, $(OS))
|
ifeq (SunOS, $(OS))
|
||||||
LDFLAGS=-lsocket -lnsl -lresolv
|
LDLIBS=-lsocket -lnsl -lresolv
|
||||||
CFLAGS += -D__EXTENSIONS__
|
CFLAGS += -D__EXTENSIONS__
|
||||||
CFLAGS += -std=c99
|
CFLAGS += -std=c99
|
||||||
endif
|
endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */
|
/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Author : Thomas Bernard
|
* 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
|
* This software is subject to the conditions detailed in the
|
||||||
* LICENCE file provided in this distribution. */
|
* LICENCE file provided in this distribution. */
|
||||||
|
|
||||||
@ -36,15 +36,13 @@
|
|||||||
/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
|
/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
|
||||||
* during the connect() call */
|
* during the connect() call */
|
||||||
#define MINIUPNPC_IGNORE_EINTR
|
#define MINIUPNPC_IGNORE_EINTR
|
||||||
#ifndef USE_GETHOSTBYNAME
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif /* #ifndef USE_GETHOSTBYNAME */
|
|
||||||
#endif /* #else _WIN32 */
|
#endif /* #else _WIN32 */
|
||||||
|
|
||||||
/* definition of PRINT_SOCKET_ERROR */
|
/* definition of PRINT_SOCKET_ERROR */
|
||||||
#ifdef _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
|
#else
|
||||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
|
/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
|
||||||
/* Project : miniUPnP
|
/* Project : miniUPnP
|
||||||
* Author : Thomas Bernard
|
* 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
|
* This software is subject to the conditions detailed in the
|
||||||
* LICENCE file provided in this distribution.
|
* LICENCE file provided in this distribution.
|
||||||
* */
|
* */
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef _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
|
#else
|
||||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Project : miniupnp
|
* Project : miniupnp
|
||||||
* Web : http://miniupnp.free.fr/
|
* Web : http://miniupnp.free.fr/
|
||||||
* Author : Thomas BERNARD
|
* Author : Thomas BERNARD
|
||||||
* copyright (c) 2005-2016 Thomas Bernard
|
* copyright (c) 2005-2017 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>*/
|
||||||
@ -62,7 +62,7 @@ struct sockaddr_un {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _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
|
#else
|
||||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||||
#endif
|
#endif
|
||||||
@ -201,6 +201,7 @@ connectToMiniSSDPD(const char * socketpath)
|
|||||||
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
|
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
|
||||||
if(!socketpath)
|
if(!socketpath)
|
||||||
socketpath = "/var/run/minissdpd.sock";
|
socketpath = "/var/run/minissdpd.sock";
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path));
|
strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path));
|
||||||
/* TODO : check if we need to handle the EINTR */
|
/* TODO : check if we need to handle the EINTR */
|
||||||
@ -502,6 +503,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||||||
unsigned long _ttl = (unsigned long)ttl;
|
unsigned long _ttl = (unsigned long)ttl;
|
||||||
#endif
|
#endif
|
||||||
int linklocal = 1;
|
int linklocal = 1;
|
||||||
|
int sentok;
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = MINISSDPC_UNKNOWN_ERROR;
|
*error = MINISSDPC_UNKNOWN_ERROR;
|
||||||
@ -612,14 +614,22 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||||||
return NULL;
|
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
|
#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 */
|
#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 */
|
#endif /* _WIN32 */
|
||||||
{
|
{
|
||||||
/* not a fatal error */
|
/* not a fatal error */
|
||||||
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
|
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(multicastif)
|
if(multicastif)
|
||||||
@ -704,6 +714,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||||||
}
|
}
|
||||||
/* receiving SSDP response packet */
|
/* receiving SSDP response packet */
|
||||||
for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) {
|
for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) {
|
||||||
|
sentok = 0;
|
||||||
/* sending the SSDP M-SEARCH packet */
|
/* sending the SSDP M-SEARCH packet */
|
||||||
n = snprintf(bufr, sizeof(bufr),
|
n = snprintf(bufr, sizeof(bufr),
|
||||||
MSearchMsgFmt,
|
MSearchMsgFmt,
|
||||||
@ -747,7 +758,8 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||||||
if(error)
|
if(error)
|
||||||
*error = MINISSDPC_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
PRINT_SOCKET_ERROR("sendto");
|
PRINT_SOCKET_ERROR("sendto");
|
||||||
break;
|
} else {
|
||||||
|
sentok = 1;
|
||||||
}
|
}
|
||||||
#else /* #ifdef NO_GETADDRINFO */
|
#else /* #ifdef NO_GETADDRINFO */
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
@ -779,19 +791,20 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
|||||||
#endif
|
#endif
|
||||||
PRINT_SOCKET_ERROR("sendto");
|
PRINT_SOCKET_ERROR("sendto");
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
sentok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeaddrinfo(servinfo);
|
freeaddrinfo(servinfo);
|
||||||
if(n < 0) {
|
if(!sentok) {
|
||||||
if(error)
|
if(error)
|
||||||
*error = MINISSDPC_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#endif /* #ifdef NO_GETADDRINFO */
|
#endif /* #ifdef NO_GETADDRINFO */
|
||||||
/* Waiting for SSDP REPLY packet to M-SEARCH
|
/* Waiting for SSDP REPLY packet to M-SEARCH
|
||||||
* if searchalltypes is set, enter the loop only
|
* if searchalltypes is set, enter the loop only
|
||||||
* when the last deviceType is reached */
|
* 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);
|
n = receivedata(sudp, bufr, sizeof(bufr), delay, &scope_id);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Author : Thomas BERNARD
|
* Author : Thomas BERNARD
|
||||||
* website : http://miniupnp.tuxfamily.org/
|
* 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
|
* This software is subjet to the conditions detailed in the
|
||||||
* provided LICENCE file. */
|
* provided LICENCE file. */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
@ -12,6 +12,10 @@
|
|||||||
#include "upnpcommands.h"
|
#include "upnpcommands.h"
|
||||||
#include "upnperrors.h"
|
#include "upnperrors.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* for compatibility with Python < 2.4 */
|
/* for compatibility with Python < 2.4 */
|
||||||
#ifndef Py_RETURN_NONE
|
#ifndef Py_RETURN_NONE
|
||||||
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
|
||||||
@ -669,6 +673,10 @@ initminiupnpc(void)
|
|||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
/* initialize Winsock. */
|
||||||
|
WSADATA wsaData;
|
||||||
|
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||||
|
|
||||||
UPnPType.tp_new = PyType_GenericNew;
|
UPnPType.tp_new = PyType_GenericNew;
|
||||||
#endif
|
#endif
|
||||||
if (PyType_Ready(&UPnPType) < 0)
|
if (PyType_Ready(&UPnPType) < 0)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: portlistingparse.c,v 1.9 2015/07/15 12:41:13 nanard Exp $ */
|
/* $Id: portlistingparse.c,v 1.9 2015/07/15 12:41:13 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* 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
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifdef _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
|
#else
|
||||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||||
#endif
|
#endif
|
||||||
|
@ -292,9 +292,11 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
|
|||||||
r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype,
|
r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype,
|
||||||
eport, iport, iaddr, description,
|
eport, iport, iaddr, description,
|
||||||
proto, 0, leaseDuration);
|
proto, 0, leaseDuration);
|
||||||
if(r!=UPNPCOMMAND_SUCCESS)
|
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||||
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||||
eport, iport, iaddr, r, strupnperror(r));
|
eport, iport, iaddr, r, strupnperror(r));
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = UPNP_GetSpecificPortMappingEntry(urls->controlURL,
|
r = UPNP_GetSpecificPortMappingEntry(urls->controlURL,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* $Id: upnpcommands.c,v 1.46 2015/07/15 12:19:00 nanard Exp $ */
|
/* $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
|
* 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
|
* This software is subject to the conditions detailed in the
|
||||||
* LICENCE file provided in this distribution.
|
* 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[6].val = desc?desc:"libminiupnpc";
|
||||||
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
||||||
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"AddPortMapping", AddPortMappingArgs,
|
"AddPortMapping", AddPortMappingArgs,
|
||||||
&bufsize))) {
|
&bufsize);
|
||||||
free(AddPortMappingArgs);
|
free(AddPortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
/*DisplayNameValueList(buffer, bufsize);*/
|
/*DisplayNameValueList(buffer, bufsize);*/
|
||||||
@ -392,7 +394,6 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(AddPortMappingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,10 +437,11 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
|
|||||||
AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
|
AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
|
||||||
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
AddPortMappingArgs[7].elt = "NewLeaseDuration";
|
||||||
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"AddAnyPortMapping", AddPortMappingArgs,
|
"AddAnyPortMapping", AddPortMappingArgs,
|
||||||
&bufsize))) {
|
&bufsize);
|
||||||
free(AddPortMappingArgs);
|
free(AddPortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -461,7 +463,6 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(AddPortMappingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,10 +491,11 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
|
|||||||
DeletePortMappingArgs[1].val = extPort;
|
DeletePortMappingArgs[1].val = extPort;
|
||||||
DeletePortMappingArgs[2].elt = "NewProtocol";
|
DeletePortMappingArgs[2].elt = "NewProtocol";
|
||||||
DeletePortMappingArgs[2].val = proto;
|
DeletePortMappingArgs[2].val = proto;
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"DeletePortMapping",
|
"DeletePortMapping",
|
||||||
DeletePortMappingArgs, &bufsize))) {
|
DeletePortMappingArgs, &bufsize);
|
||||||
free(DeletePortMappingArgs);
|
free(DeletePortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
/*DisplayNameValueList(buffer, bufsize);*/
|
/*DisplayNameValueList(buffer, bufsize);*/
|
||||||
@ -507,7 +509,6 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(DeletePortMappingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,10 +540,11 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
|
|||||||
DeletePortMappingArgs[3].elt = "NewManage";
|
DeletePortMappingArgs[3].elt = "NewManage";
|
||||||
DeletePortMappingArgs[3].val = manage;
|
DeletePortMappingArgs[3].val = manage;
|
||||||
|
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"DeletePortMappingRange",
|
"DeletePortMappingRange",
|
||||||
DeletePortMappingArgs, &bufsize))) {
|
DeletePortMappingArgs, &bufsize);
|
||||||
free(DeletePortMappingArgs);
|
free(DeletePortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -555,7 +557,6 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(DeletePortMappingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,10 +588,11 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
|
|||||||
return UPNPCOMMAND_MEM_ALLOC_ERROR;
|
return UPNPCOMMAND_MEM_ALLOC_ERROR;
|
||||||
GetPortMappingArgs[0].elt = "NewPortMappingIndex";
|
GetPortMappingArgs[0].elt = "NewPortMappingIndex";
|
||||||
GetPortMappingArgs[0].val = index;
|
GetPortMappingArgs[0].val = index;
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"GetGenericPortMappingEntry",
|
"GetGenericPortMappingEntry",
|
||||||
GetPortMappingArgs, &bufsize))) {
|
GetPortMappingArgs, &bufsize);
|
||||||
free(GetPortMappingArgs);
|
free(GetPortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -652,7 +654,6 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
|
|||||||
sscanf(p, "%d", &r);
|
sscanf(p, "%d", &r);
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(GetPortMappingArgs);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,10 +729,11 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
|
|||||||
GetPortMappingArgs[1].val = extPort;
|
GetPortMappingArgs[1].val = extPort;
|
||||||
GetPortMappingArgs[2].elt = "NewProtocol";
|
GetPortMappingArgs[2].elt = "NewProtocol";
|
||||||
GetPortMappingArgs[2].val = proto;
|
GetPortMappingArgs[2].val = proto;
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"GetSpecificPortMappingEntry",
|
"GetSpecificPortMappingEntry",
|
||||||
GetPortMappingArgs, &bufsize))) {
|
GetPortMappingArgs, &bufsize);
|
||||||
free(GetPortMappingArgs);
|
free(GetPortMappingArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
/*DisplayNameValueList(buffer, bufsize);*/
|
/*DisplayNameValueList(buffer, bufsize);*/
|
||||||
@ -779,7 +781,6 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(GetPortMappingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,13 +825,13 @@ UPNP_GetListOfPortMappings(const char * controlURL,
|
|||||||
GetListOfPortMappingsArgs[4].elt = "NewNumberOfPorts";
|
GetListOfPortMappingsArgs[4].elt = "NewNumberOfPorts";
|
||||||
GetListOfPortMappingsArgs[4].val = numberOfPorts?numberOfPorts:"1000";
|
GetListOfPortMappingsArgs[4].val = numberOfPorts?numberOfPorts:"1000";
|
||||||
|
|
||||||
if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"GetListOfPortMappings",
|
"GetListOfPortMappings",
|
||||||
GetListOfPortMappingsArgs, &bufsize))) {
|
GetListOfPortMappingsArgs, &bufsize);
|
||||||
free(GetListOfPortMappingsArgs);
|
free(GetListOfPortMappingsArgs);
|
||||||
|
if(!buffer) {
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
}
|
}
|
||||||
free(GetListOfPortMappingsArgs);
|
|
||||||
|
|
||||||
/*DisplayNameValueList(buffer, bufsize);*/
|
/*DisplayNameValueList(buffer, bufsize);*/
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -954,6 +955,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype
|
|||||||
GetOutboundPinholeTimeoutArgs[4].val = intClient;
|
GetOutboundPinholeTimeoutArgs[4].val = intClient;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"GetOutboundPinholeTimeout", GetOutboundPinholeTimeoutArgs, &bufsize);
|
"GetOutboundPinholeTimeout", GetOutboundPinholeTimeoutArgs, &bufsize);
|
||||||
|
free(GetOutboundPinholeTimeoutArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -972,7 +974,6 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype
|
|||||||
*opTimeout = my_atoui(p);
|
*opTimeout = my_atoui(p);
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(GetOutboundPinholeTimeoutArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,6 +1032,7 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype,
|
|||||||
AddPinholeArgs[5].val = leaseTime;
|
AddPinholeArgs[5].val = leaseTime;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"AddPinhole", AddPinholeArgs, &bufsize);
|
"AddPinhole", AddPinholeArgs, &bufsize);
|
||||||
|
free(AddPinholeArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -1053,7 +1055,6 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype,
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(AddPinholeArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,6 +1082,7 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
|
|||||||
UpdatePinholeArgs[1].val = leaseTime;
|
UpdatePinholeArgs[1].val = leaseTime;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"UpdatePinhole", UpdatePinholeArgs, &bufsize);
|
"UpdatePinhole", UpdatePinholeArgs, &bufsize);
|
||||||
|
free(UpdatePinholeArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -1097,7 +1099,6 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(UpdatePinholeArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,6 +1123,7 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char
|
|||||||
DeletePinholeArgs[0].val = uniqueID;
|
DeletePinholeArgs[0].val = uniqueID;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"DeletePinhole", DeletePinholeArgs, &bufsize);
|
"DeletePinhole", DeletePinholeArgs, &bufsize);
|
||||||
|
free(DeletePinholeArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
/*DisplayNameValueList(buffer, bufsize);*/
|
/*DisplayNameValueList(buffer, bufsize);*/
|
||||||
@ -1138,7 +1140,6 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char
|
|||||||
ret = UPNPCOMMAND_SUCCESS;
|
ret = UPNPCOMMAND_SUCCESS;
|
||||||
}
|
}
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(DeletePinholeArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1163,8 +1164,11 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
|
|||||||
CheckPinholeWorkingArgs[0].val = uniqueID;
|
CheckPinholeWorkingArgs[0].val = uniqueID;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"CheckPinholeWorking", CheckPinholeWorkingArgs, &bufsize);
|
"CheckPinholeWorking", CheckPinholeWorkingArgs, &bufsize);
|
||||||
|
free(CheckPinholeWorkingArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
|
{
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
|
}
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
free(buffer); buffer = NULL;
|
free(buffer); buffer = NULL;
|
||||||
|
|
||||||
@ -1185,7 +1189,6 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(CheckPinholeWorkingArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1210,6 +1213,7 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
|
|||||||
GetPinholePacketsArgs[0].val = uniqueID;
|
GetPinholePacketsArgs[0].val = uniqueID;
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
"GetPinholePackets", GetPinholePacketsArgs, &bufsize);
|
"GetPinholePackets", GetPinholePacketsArgs, &bufsize);
|
||||||
|
free(GetPinholePacketsArgs);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return UPNPCOMMAND_HTTP_ERROR;
|
return UPNPCOMMAND_HTTP_ERROR;
|
||||||
ParseNameValue(buffer, bufsize, &pdata);
|
ParseNameValue(buffer, bufsize, &pdata);
|
||||||
@ -1230,7 +1234,6 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClearNameValueList(&pdata);
|
ClearNameValueList(&pdata);
|
||||||
free(GetPinholePacketsArgs);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,24 @@
|
|||||||
$Id: Changelog.txt,v 1.428 2016/04/19 21:10:36 nanard Exp $
|
$Id: Changelog.txt,v 1.430 2016/12/16 09:14:40 nanard Exp $
|
||||||
|
|
||||||
|
2017/03/13:
|
||||||
|
default to client address for AddPortMapping when <NewInternalClient>
|
||||||
|
is empty
|
||||||
|
pass ext_if_name to add_pinhole()
|
||||||
|
|
||||||
|
2016/12/23:
|
||||||
|
Fix UDA-1.2.10 Man header empty or invalid
|
||||||
|
|
||||||
|
2016/12/16:
|
||||||
|
Do not try to open IPv6 sockets once it is disabled
|
||||||
|
|
||||||
|
2016/12/01:
|
||||||
|
Fix "AddPinhole Twice" test
|
||||||
|
|
||||||
|
2016/11/11:
|
||||||
|
fixes build for Solaris/SunOS
|
||||||
|
|
||||||
|
2016/07/23:
|
||||||
|
fixes build error on DragonFly BSD
|
||||||
|
|
||||||
VERSION 2.0 : released on 2016/04/19
|
VERSION 2.0 : released on 2016/04/19
|
||||||
|
|
||||||
|
@ -123,6 +123,23 @@ https://github.com/miniupnp/miniupnp/pull/114
|
|||||||
Edit the /etc/miniupnpd.conf file to set options. Almost all options are
|
Edit the /etc/miniupnpd.conf file to set options. Almost all options are
|
||||||
also available through command line switches.
|
also available through command line switches.
|
||||||
|
|
||||||
|
A basic configuration would set :
|
||||||
|
ext_ifname : WAN network interface (interface connected to the internet)
|
||||||
|
listening_ip : LAN network interface (network where to supply NAT traversal)
|
||||||
|
enable_natpmp=yes
|
||||||
|
enable_upnp=yes
|
||||||
|
and the permission rules (see below).
|
||||||
|
|
||||||
|
Historically, LAN had to be specified by IP/mask, such as
|
||||||
|
listening_ip=192.168.0.1/24
|
||||||
|
but if you compiled with IPv6 support, you need to specify an interface name :
|
||||||
|
listening_ip=eth0
|
||||||
|
The current code assumes there is only one IPv4 address assigned to LAN
|
||||||
|
interfaces. That is not the case with some CARP setup, there is then a risk
|
||||||
|
the wrong mask would be picked. You can force the mask when using interface
|
||||||
|
names :
|
||||||
|
listtening_ip=eth0/24
|
||||||
|
|
||||||
Miniupnpd supports some kind of security check for allowing or disallowing
|
Miniupnpd supports some kind of security check for allowing or disallowing
|
||||||
redirection to be made. The UPnP permission rules are read from the
|
redirection to be made. The UPnP permission rules are read from the
|
||||||
miniupnpd.conf configuration file.
|
miniupnpd.conf configuration file.
|
||||||
@ -162,5 +179,3 @@ To stop the daemon use :
|
|||||||
# kill `cat /var/run/miniupnpd.pid`
|
# kill `cat /var/run/miniupnpd.pid`
|
||||||
or if your linux system use /etc/init.d/
|
or if your linux system use /etc/init.d/
|
||||||
# /etc/init.d/miniupnpd stop
|
# /etc/init.d/miniupnpd stop
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ FWNAME = pf
|
|||||||
|
|
||||||
# better way to find if we are using ipf or pf
|
# better way to find if we are using ipf or pf
|
||||||
.if $(OSNAME) == "FreeBSD"
|
.if $(OSNAME) == "FreeBSD"
|
||||||
.if exists(/etc/rc.subr) && exists(/etc/rc.conf)
|
.if exists(/etc/rc.subr) && exists(/etc/default/rc.conf)
|
||||||
FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
|
FWNAME != . /etc/rc.subr; . /etc/default/rc.conf; \
|
||||||
if checkyesno ipfilter_enable; then \
|
if checkyesno ipfilter_enable; then \
|
||||||
echo "ipf"; elif checkyesno pf_enable; then \
|
echo "ipf"; elif checkyesno pf_enable; then \
|
||||||
echo "pf"; elif checkyesno firewall_enable; then \
|
echo "pf"; elif checkyesno firewall_enable; then \
|
||||||
|
@ -20,19 +20,18 @@ In 2012, IGD v2 WANIPv6FirewallControl has been implemented.
|
|||||||
IGD2 is still not enabled by default because of interoperability
|
IGD2 is still not enabled by default because of interoperability
|
||||||
issues.
|
issues.
|
||||||
|
|
||||||
Support for the NAT Port Mapping Protocol (NAT-PMP) has been
|
In addition to UPnP IGD, miniUPnPd supports NAT-PMP and PCP :
|
||||||
added. See information about NAT-PMP here :
|
|
||||||
http://miniupnp.free.fr/nat-pmp.html
|
|
||||||
|
|
||||||
NAT-PMP is the precursor of Port Control Protocol (PCP).
|
See information about NAT Port Mapping Protocol (NAT-PMP) here :
|
||||||
|
http://miniupnp.free.fr/nat-pmp.html
|
||||||
|
NAT-PMP is the precursor of Port Control Protocol (PCP, RFC 6887).
|
||||||
In 2013, support for PCP has been added too.
|
In 2013, support for PCP has been added too.
|
||||||
|
|
||||||
Read the INSTALL file for instructions to compile, install and
|
Read the INSTALL file for instructions to compile, install and
|
||||||
configure miniupnpd on your system.
|
configure miniupnpd on your system.
|
||||||
|
|
||||||
Report bugs to miniupnp@free.fr on the web forum
|
Report bugs to miniupnp@free.fr or on the web forum
|
||||||
http://miniupnp.tuxfamily.org/forum/
|
http://miniupnp.tuxfamily.org/forum/
|
||||||
or using https://github.com/miniupnp/miniupnp/issues
|
or using https://github.com/miniupnp/miniupnp/issues
|
||||||
|
|
||||||
Thomas Bernard
|
Thomas Bernard
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: asyncsendto.c,v 1.7 2015/09/03 18:19:20 nanard Exp $ */
|
/* $Id: asyncsendto.c,v 1.7 2015/09/03 18:19:20 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2014 Thomas Bernard
|
* (c) 2006-2016 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: getroute.c,v 1.12 2015/11/19 11:46:30 nanard Exp $ */
|
/* $Id: getroute.c,v 1.12 2015/11/19 11:46:30 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2015 Thomas Bernard
|
* (c) 2006-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -20,8 +20,9 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../upnputils.h"
|
#include "../upnputils.h"
|
||||||
|
|
||||||
|
/* SA_SIZE() is a multiple of sizeof(long) with a minimum value of sizeof(long) */
|
||||||
#ifndef SA_SIZE
|
#ifndef SA_SIZE
|
||||||
#define SA_SIZE(sa) (SA_LEN(sa))
|
#define SA_SIZE(sa) (((SA_LEN(sa)) == 0) ? sizeof(long) : (1 + (((SA_LEN(sa)) - 1) | (sizeof(long) - 1))))
|
||||||
#endif /* SA_SIZE */
|
#endif /* SA_SIZE */
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -102,7 +103,8 @@ get_src_for_route_to(const struct sockaddr * dst,
|
|||||||
}
|
}
|
||||||
sa = (struct sockaddr *)p;
|
sa = (struct sockaddr *)p;
|
||||||
sockaddr_to_string(sa, tmp, sizeof(tmp));
|
sockaddr_to_string(sa, tmp, sizeof(tmp));
|
||||||
syslog(LOG_DEBUG, "type=%d sa_len=%d sa_family=%d %s",
|
syslog(LOG_DEBUG, "offset=%3d type=%2d sa_len=%d sa_family=%d %s",
|
||||||
|
(int)(p - m_rtmsg.m_space),
|
||||||
i, SA_LEN(sa), sa->sa_family, tmp);
|
i, SA_LEN(sa), sa->sa_family, tmp);
|
||||||
if(i == RTA_IFA) {
|
if(i == RTA_IFA) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
@ -134,14 +136,7 @@ get_src_for_route_to(const struct sockaddr * dst,
|
|||||||
*index = sdl->sdl_index;
|
*index = sdl->sdl_index;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* at least 4 bytes per address are reserved,
|
p += SA_SIZE(sa);
|
||||||
* that is true with OpenBSD 4.3.
|
|
||||||
* The test is only useful when SA_SIZE() is not properly
|
|
||||||
* defined, as it should be always >= sizeof(long) */
|
|
||||||
if(SA_SIZE(sa) > 0)
|
|
||||||
p += SA_SIZE(sa);
|
|
||||||
else
|
|
||||||
p += sizeof(long);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# $Id: genconfig.sh,v 1.90 2016/02/11 10:35:12 nanard Exp $
|
# $Id: genconfig.sh,v 1.90 2016/02/11 10:35:12 nanard Exp $
|
||||||
|
# vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
|
#
|
||||||
# miniupnp daemon
|
# miniupnp daemon
|
||||||
# http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
|
# http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
|
||||||
# (c) 2006-2016 Thomas Bernard
|
# (c) 2006-2016 Thomas Bernard
|
||||||
@ -58,6 +60,10 @@ CONFIGFILE_FINAL="config.h"
|
|||||||
CONFIGMACRO="CONFIG_H_INCLUDED"
|
CONFIGMACRO="CONFIG_H_INCLUDED"
|
||||||
|
|
||||||
MINIUPNPD_DATE=`date +"%Y%m%d"`
|
MINIUPNPD_DATE=`date +"%Y%m%d"`
|
||||||
|
if [ -n "$SOURCE_DATE_EPOCH" ]; then
|
||||||
|
MINIUPNPD_DATE=`date --utc --date="@$SOURCE_DATE_EPOCH" +"%Y%m%d"`
|
||||||
|
fi
|
||||||
|
|
||||||
# Facility to syslog
|
# Facility to syslog
|
||||||
LOG_MINIUPNPD="LOG_DAEMON"
|
LOG_MINIUPNPD="LOG_DAEMON"
|
||||||
|
|
||||||
@ -166,14 +172,14 @@ case $OS_NAME in
|
|||||||
HAVE_IP_MREQN=1
|
HAVE_IP_MREQN=1
|
||||||
# new way to see which one to use PF or IPF.
|
# new way to see which one to use PF or IPF.
|
||||||
# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
|
# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
|
||||||
if [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then
|
if [ -f /etc/rc.subr ] && [ -f /etc/default/rc.conf ] ; then
|
||||||
# source file with handy subroutines like checkyesno
|
# source file with handy subroutines like checkyesno
|
||||||
. /etc/rc.subr
|
. /etc/rc.subr
|
||||||
# source config file so we can probe vars
|
# source config file so we can probe vars
|
||||||
. /etc/rc.conf
|
. /etc/default/rc.conf
|
||||||
if checkyesno ipfilter_enable; then
|
if checkyesno ipfilter_enable; then
|
||||||
echo "Using ipf"
|
echo "Using ipf"
|
||||||
FW=ipf
|
FW=ipf
|
||||||
elif checkyesno pf_enable; then
|
elif checkyesno pf_enable; then
|
||||||
echo "Using pf"
|
echo "Using pf"
|
||||||
FW=pf
|
FW=pf
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: minissdp.c,v 1.77 2015/08/26 07:36:52 nanard Exp $ */
|
/* $Id: minissdp.c,v 1.77 2015/08/26 07:36:52 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2016 Thomas Bernard
|
* (c) 2006-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -17,6 +17,10 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#if defined(ENABLE_IPV6) && defined(UPNP_STRICT)
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
#endif /* defined(ENABLE_IPV6) && defined(UPNP_STRICT) */
|
||||||
|
|
||||||
#include "upnpdescstrings.h"
|
#include "upnpdescstrings.h"
|
||||||
#include "miniupnpdpath.h"
|
#include "miniupnpdpath.h"
|
||||||
#include "upnphttp.h"
|
#include "upnphttp.h"
|
||||||
@ -116,6 +120,29 @@ AddMulticastMembershipIPv6(int s, unsigned int ifindex)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(ENABLE_IPV6) && defined(UPNP_STRICT)
|
||||||
|
static int get_link_local_addr(unsigned scope_id, struct in6_addr * addr6)
|
||||||
|
{
|
||||||
|
struct ifaddrs * ifap;
|
||||||
|
struct ifaddrs * ife;
|
||||||
|
if(getifaddrs(&ifap)<0) {
|
||||||
|
syslog(LOG_ERR, "getifaddrs: %m");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for(ife = ifap; ife != NULL; ife = ife->ifa_next) {
|
||||||
|
if(ife->ifa_addr == NULL) continue;
|
||||||
|
if(ife->ifa_addr->sa_family != AF_INET6) continue;
|
||||||
|
if(!IN6_IS_ADDR_LINKLOCAL(&(((const struct sockaddr_in6 *)ife->ifa_addr)->sin6_addr))) continue;
|
||||||
|
if(scope_id != if_nametoindex(ife->ifa_name)) continue;
|
||||||
|
memcpy(addr6, &(((const struct sockaddr_in6 *)ife->ifa_addr)->sin6_addr), sizeof(struct in6_addr));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
freeifaddrs(ifap);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* defined(ENABLE_IPV6) && defined(UPNP_STRICT) */
|
||||||
|
|
||||||
/* Open and configure the socket listening for
|
/* Open and configure the socket listening for
|
||||||
* SSDP udp packets sent on 239.255.255.250 port 1900
|
* SSDP udp packets sent on 239.255.255.250 port 1900
|
||||||
* SSDP v6 udp packets sent on FF02::C, or FF05::C, port 1900 */
|
* SSDP v6 udp packets sent on FF02::C, or FF05::C, port 1900 */
|
||||||
@ -915,7 +942,26 @@ ProcessSSDPData(int s, const char *bufr, int n,
|
|||||||
mx_value = atoi(mx);
|
mx_value = atoi(mx);
|
||||||
syslog(LOG_DEBUG, "MX: %.*s (value=%d)", mx_len, mx, mx_value);
|
syslog(LOG_DEBUG, "MX: %.*s (value=%d)", mx_len, mx, mx_value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(UPNP_STRICT) || defined(DELAY_MSEARCH_RESPONSE) */
|
||||||
|
#if defined(UPNP_STRICT)
|
||||||
|
/* Fix UDA-1.2.10 Man header empty or invalid */
|
||||||
|
else if((i < n - 4) && (strncasecmp(bufr+i, "man:", 3) == 0))
|
||||||
|
{
|
||||||
|
const char * man;
|
||||||
|
int man_len;
|
||||||
|
man = bufr+i+4;
|
||||||
|
man_len = 0;
|
||||||
|
while((*man == ' ' || *man == '\t') && (man < bufr + n))
|
||||||
|
man++;
|
||||||
|
while(man[man_len]!='\r' && man[man_len]!='\n'
|
||||||
|
&& (man + man_len < bufr + n))
|
||||||
|
man_len++;
|
||||||
|
if(strncmp(man, "\"ssdp:discover\"", 15) != 0) {
|
||||||
|
syslog(LOG_INFO, "ignoring SSDP packet MAN empty or invalid header");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* defined(UPNP_STRICT) */
|
||||||
}
|
}
|
||||||
#ifdef UPNP_STRICT
|
#ifdef UPNP_STRICT
|
||||||
/* For multicast M-SEARCH requests, if the search request does
|
/* For multicast M-SEARCH requests, if the search request does
|
||||||
@ -969,10 +1015,13 @@ ProcessSSDPData(int s, const char *bufr, int n,
|
|||||||
/* retrieve the IPv6 address which
|
/* retrieve the IPv6 address which
|
||||||
* will be used locally to reach sender */
|
* will be used locally to reach sender */
|
||||||
memset(&addr6, 0, sizeof(addr6));
|
memset(&addr6, 0, sizeof(addr6));
|
||||||
if(get_src_for_route_to (sender, &addr6, &addr6_len, &index) < 0) {
|
if(IN6_IS_ADDR_LINKLOCAL(&(((struct sockaddr_in6 *)sender)->sin6_addr))) {
|
||||||
|
get_link_local_addr(((struct sockaddr_in6 *)sender)->sin6_scope_id, &addr6);
|
||||||
|
} else if(get_src_for_route_to (sender, &addr6, &addr6_len, &index) < 0) {
|
||||||
syslog(LOG_WARNING, "get_src_for_route_to() failed, using %s", ipv6_addr_for_http_with_brackets);
|
syslog(LOG_WARNING, "get_src_for_route_to() failed, using %s", ipv6_addr_for_http_with_brackets);
|
||||||
announced_host = ipv6_addr_for_http_with_brackets;
|
announced_host = ipv6_addr_for_http_with_brackets;
|
||||||
} else {
|
}
|
||||||
|
if(announced_host == NULL) {
|
||||||
if(inet_ntop(AF_INET6, &addr6,
|
if(inet_ntop(AF_INET6, &addr6,
|
||||||
announced_host_buf+1,
|
announced_host_buf+1,
|
||||||
sizeof(announced_host_buf) - 2)) {
|
sizeof(announced_host_buf) - 2)) {
|
||||||
|
@ -322,6 +322,7 @@ OpenAndConfHTTPSocket(unsigned short * port)
|
|||||||
syslog(LOG_WARNING, "socket(PF_INET6, ...) failed with EAFNOSUPPORT, disabling IPv6");
|
syslog(LOG_WARNING, "socket(PF_INET6, ...) failed with EAFNOSUPPORT, disabling IPv6");
|
||||||
SETFLAG(IPV6DISABLEDMASK);
|
SETFLAG(IPV6DISABLEDMASK);
|
||||||
ipv6 = 0;
|
ipv6 = 0;
|
||||||
|
/* Try again with IPv4 */
|
||||||
s = socket(PF_INET, SOCK_STREAM, 0);
|
s = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1857,9 +1858,11 @@ main(int argc, char * * argv)
|
|||||||
|
|
||||||
if(
|
if(
|
||||||
#ifdef ENABLE_NATPMP
|
#ifdef ENABLE_NATPMP
|
||||||
!GETFLAG(ENABLENATPMPMASK) &&
|
!GETFLAG(ENABLENATPMPMASK) && !GETFLAG(ENABLEUPNPMASK)
|
||||||
|
#else
|
||||||
|
!GETFLAG(ENABLEUPNPMASK)
|
||||||
#endif
|
#endif
|
||||||
!GETFLAG(ENABLEUPNPMASK) ) {
|
) {
|
||||||
syslog(LOG_ERR, "Why did you run me anyway?");
|
syslog(LOG_ERR, "Why did you run me anyway?");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1930,16 +1933,18 @@ main(int argc, char * * argv)
|
|||||||
#endif /* V6SOCKETS_ARE_V6ONLY */
|
#endif /* V6SOCKETS_ARE_V6ONLY */
|
||||||
#endif /* ENABLE_HTTPS */
|
#endif /* ENABLE_HTTPS */
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
if(find_ipv6_addr(lan_addrs.lh_first ? lan_addrs.lh_first->ifname : NULL,
|
if(!GETFLAG(IPV6DISABLEDMASK)) {
|
||||||
ipv6_addr_for_http_with_brackets, sizeof(ipv6_addr_for_http_with_brackets)) > 0) {
|
if(find_ipv6_addr(lan_addrs.lh_first ? lan_addrs.lh_first->ifname : NULL,
|
||||||
syslog(LOG_NOTICE, "HTTP IPv6 address given to control points : %s",
|
ipv6_addr_for_http_with_brackets, sizeof(ipv6_addr_for_http_with_brackets)) > 0) {
|
||||||
ipv6_addr_for_http_with_brackets);
|
syslog(LOG_NOTICE, "HTTP IPv6 address given to control points : %s",
|
||||||
} else {
|
ipv6_addr_for_http_with_brackets);
|
||||||
memcpy(ipv6_addr_for_http_with_brackets, "[::1]", 6);
|
} else {
|
||||||
syslog(LOG_WARNING, "no HTTP IPv6 address, disabling IPv6");
|
memcpy(ipv6_addr_for_http_with_brackets, "[::1]", 6);
|
||||||
SETFLAG(IPV6DISABLEDMASK);
|
syslog(LOG_WARNING, "no HTTP IPv6 address, disabling IPv6");
|
||||||
|
SETFLAG(IPV6DISABLEDMASK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ENABLE_IPV6 */
|
||||||
|
|
||||||
/* open socket for SSDP connections */
|
/* open socket for SSDP connections */
|
||||||
sudp = OpenAndConfSSDPReceiveSocket(0);
|
sudp = OpenAndConfSSDPReceiveSocket(0);
|
||||||
@ -2007,7 +2012,9 @@ main(int argc, char * * argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_IPV6) && defined(ENABLE_PCP)
|
#if defined(ENABLE_IPV6) && defined(ENABLE_PCP)
|
||||||
spcp_v6 = OpenAndConfPCPv6Socket();
|
if(!GETFLAG(IPV6DISABLEDMASK)) {
|
||||||
|
spcp_v6 = OpenAndConfPCPv6Socket();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* for miniupnpdctl */
|
/* for miniupnpdctl */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# $Id: iptables_init.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $
|
# $Id: iptables_init.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $
|
||||||
IPTABLES="`which iptables`" || exit 1
|
IPTABLES="`which iptables`" || exit 1
|
||||||
|
IPTABLES="$IPTABLES -w"
|
||||||
IP="`which ip`" || exit 1
|
IP="`which ip`" || exit 1
|
||||||
|
|
||||||
#change this parameters :
|
#change this parameters :
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Checks for state of filter before doing anything..
|
# Checks for state of filter before doing anything..
|
||||||
|
|
||||||
IPTABLES="`which iptables`" || exit 1
|
IPTABLES="`which iptables`" || exit 1
|
||||||
|
IPTABLES="$IPTABLES -w"
|
||||||
IP="`which ip`" || exit 1
|
IP="`which ip`" || exit 1
|
||||||
|
|
||||||
#EXTIF=eth0
|
#EXTIF=eth0
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# $Id: iptables_removeall.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $
|
# $Id: iptables_removeall.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $
|
||||||
IPTABLES="`which iptables`" || exit 1
|
IPTABLES="`which iptables`" || exit 1
|
||||||
|
IPTABLES="$IPTABLES -w"
|
||||||
IP="`which ip`" || exit 1
|
IP="`which ip`" || exit 1
|
||||||
|
|
||||||
#change this parameters :
|
#change this parameters :
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: iptpinhole.c,v 1.14 2015/02/10 15:01:03 nanard Exp $ */
|
/* $Id: iptpinhole.c,v 1.14 2015/02/10 15:01:03 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2012-2016 Thomas Bernard
|
* (c) 2012-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -221,6 +221,7 @@ int add_pinhole(const char * ifname,
|
|||||||
if (proto)
|
if (proto)
|
||||||
e->ipv6.flags |= IP6T_F_PROTO;
|
e->ipv6.flags |= IP6T_F_PROTO;
|
||||||
|
|
||||||
|
/* TODO: check if enforcing USE_IFNAME_IN_RULES is needed */
|
||||||
if(ifname)
|
if(ifname)
|
||||||
strncpy(e->ipv6.iniface, ifname, IFNAMSIZ);
|
strncpy(e->ipv6.iniface, ifname, IFNAMSIZ);
|
||||||
if(rem_host && (rem_host[0] != '\0')) {
|
if(rem_host && (rem_host[0] != '\0')) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
* MiniUPnP project
|
* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2012-2016 Thomas Bernard
|
* (c) 2012-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: testobsdrdr.c,v 1.28 2014/03/06 13:02:47 nanard Exp $ */
|
/* $Id: testobsdrdr.c,v 1.28 2014/03/06 13:02:47 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2014 Thomas Bernard
|
* (c) 2006-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ main(int argc, char * * argv)
|
|||||||
printf("get_redirect_rule() failed\n");
|
printf("get_redirect_rule() failed\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("\n%s:%d '%s' packets=%llu bytes=%llu\n", buf, (int)iport, desc,
|
printf("\n%s:%d '%s' packets=%" PRIu64 " bytes=%" PRIu64 "\n", buf, (int)iport, desc,
|
||||||
packets, bytes);
|
packets, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
* MiniUPnP project
|
* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2012-2016 Thomas Bernard
|
* (c) 2012-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ static int print_pinhole(int uid)
|
|||||||
uid, rem_host, rem_port, int_client, int_port,
|
uid, rem_host, rem_port, int_client, int_port,
|
||||||
proto, timestamp);
|
proto, timestamp);
|
||||||
printf(" desc='%s'\n", desc);
|
printf(" desc='%s'\n", desc);
|
||||||
printf(" packets=%llu bytes=%llu\n", packets, bytes);
|
printf(" packets=%" PRIu64 " bytes=%" PRIu64 "\n", packets, bytes);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: upnppinhole.c,v 1.7 2014/12/09 09:13:53 nanard Exp $ */
|
/* $Id: upnppinhole.c,v 1.7 2014/12/09 09:13:53 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2016 Thomas Bernard
|
* (c) 2006-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -134,18 +134,14 @@ upnp_add_inboundpinhole(const char * raddr,
|
|||||||
timestamp = current + leasetime;
|
timestamp = current + leasetime;
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
#if 0
|
*uid = upnp_find_inboundpinhole(raddr, rport, iaddr, iport, proto, NULL, 0, NULL);
|
||||||
if(r == 1 && strcmp(iaddr, iaddr_old)==0 && iport==iport_old)
|
if(*uid >= 0) {
|
||||||
{
|
syslog(LOG_INFO, "Pinhole for inbound traffic from [%s]:%hu to [%s]:%hu with proto %d found uid=%d. Updating it.", raddr, rport, iaddr, iport, proto, *uid);
|
||||||
syslog(LOG_INFO, "Pinhole for inbound traffic from [%s]:%hu to [%s]:%hu with protocol %s already done. Updating it.", raddr, rport, iaddr_old, iport_old, protocol);
|
r = upnp_update_inboundpinhole(*uid, timestamp);
|
||||||
t = upnp_update_inboundpinhole(idfound, leaseTime);
|
return (r >= 0) ? 1 : r;
|
||||||
*uid = atoi(idfound);
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#if defined(USE_PF) || defined(USE_NETFILTER)
|
#if defined(USE_PF) || defined(USE_NETFILTER)
|
||||||
*uid = add_pinhole (0/*ext_if_name*/, raddr, rport,
|
*uid = add_pinhole (ext_if_name, raddr, rport,
|
||||||
iaddr, iport, proto, desc, timestamp);
|
iaddr, iport, proto, desc, timestamp);
|
||||||
return *uid >= 0 ? 1 : -1;
|
return *uid >= 0 ? 1 : -1;
|
||||||
#else
|
#else
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $Id: upnpsoap.c,v 1.144 2016/02/12 12:35:03 nanard Exp $ */
|
/* $Id: upnpsoap.c,v 1.144 2016/02/12 12:35:03 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2016 Thomas Bernard
|
* (c) 2006-2017 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
* in the LICENCE file provided within the distribution */
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -388,12 +389,19 @@ AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
|||||||
|
|
||||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
||||||
int_ip = GetValueFromNameValueList(&data, "NewInternalClient");
|
int_ip = GetValueFromNameValueList(&data, "NewInternalClient");
|
||||||
if (!int_ip)
|
if (int_ip) {
|
||||||
|
/* trim */
|
||||||
|
while(int_ip[0] == ' ')
|
||||||
|
int_ip++;
|
||||||
|
}
|
||||||
|
#ifdef UPNP_STRICT
|
||||||
|
if (!int_ip || int_ip[0] == '\0')
|
||||||
{
|
{
|
||||||
ClearNameValueList(&data);
|
ClearNameValueList(&data);
|
||||||
SoapError(h, 402, "Invalid Args");
|
SoapError(h, 402, "Invalid Args");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* IGD 2 MUST support both wildcard and specific IP address values
|
/* IGD 2 MUST support both wildcard and specific IP address values
|
||||||
* for RemoteHost (only the wildcard value was REQUIRED in release 1.0) */
|
* for RemoteHost (only the wildcard value was REQUIRED in release 1.0) */
|
||||||
@ -409,6 +417,16 @@ AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UPNP_STRICT
|
||||||
|
/* if <NewInternalClient> arg is empty, use client address
|
||||||
|
* see https://github.com/miniupnp/miniupnp/issues/236 */
|
||||||
|
if (!int_ip || int_ip[0] == '\0')
|
||||||
|
{
|
||||||
|
int_ip = h->clientaddr_str;
|
||||||
|
memcpy(&result_ip, &(h->clientaddr), sizeof(struct in_addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
/* if ip not valid assume hostname and convert */
|
/* if ip not valid assume hostname and convert */
|
||||||
if (inet_pton(AF_INET, int_ip, &result_ip) <= 0)
|
if (inet_pton(AF_INET, int_ip, &result_ip) <= 0)
|
||||||
{
|
{
|
||||||
@ -1604,8 +1622,14 @@ AddPinhole(struct upnphttp * h, const char * action, const char * ns)
|
|||||||
goto clear_and_exit;
|
goto clear_and_exit;
|
||||||
}
|
}
|
||||||
/* I guess it is useless to convert int_ip to literal ipv6 address */
|
/* I guess it is useless to convert int_ip to literal ipv6 address */
|
||||||
|
if(rem_host)
|
||||||
|
{
|
||||||
|
/* trim */
|
||||||
|
while(isspace(rem_host[0]))
|
||||||
|
rem_host++;
|
||||||
|
}
|
||||||
/* rem_host should be converted to literal ipv6 : */
|
/* rem_host should be converted to literal ipv6 : */
|
||||||
if(rem_host && (rem_host[0] != '\0'))
|
if(rem_host && (rem_host[0] != '\0') && (rem_host[0] != '*'))
|
||||||
{
|
{
|
||||||
struct addrinfo *ai, *p;
|
struct addrinfo *ai, *p;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user