summaryrefslogtreecommitdiff
path: root/thirdparty/miniupnpc
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/miniupnpc')
-rw-r--r--thirdparty/miniupnpc/LICENSE1
-rw-r--r--thirdparty/miniupnpc/miniupnpc/connecthostport.c6
-rw-r--r--thirdparty/miniupnpc/miniupnpc/miniupnpc.c9
-rw-r--r--thirdparty/miniupnpc/miniupnpc/upnpc.c23
-rw-r--r--thirdparty/miniupnpc/miniupnpc/upnperrors.c9
5 files changed, 27 insertions, 21 deletions
diff --git a/thirdparty/miniupnpc/LICENSE b/thirdparty/miniupnpc/LICENSE
index 39e0345f8a..1460310752 100644
--- a/thirdparty/miniupnpc/LICENSE
+++ b/thirdparty/miniupnpc/LICENSE
@@ -24,4 +24,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/thirdparty/miniupnpc/miniupnpc/connecthostport.c b/thirdparty/miniupnpc/miniupnpc/connecthostport.c
index a59dc82437..f3982e1a77 100644
--- a/thirdparty/miniupnpc/miniupnpc/connecthostport.c
+++ b/thirdparty/miniupnpc/miniupnpc/connecthostport.c
@@ -1,4 +1,4 @@
-/* $Id: connecthostport.c,v 1.21 2019/04/23 12:11:08 nanard Exp $ */
+/* $Id: connecthostport.c,v 1.22 2019/10/13 17:22:08 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp
* Author : Thomas Bernard
@@ -195,6 +195,10 @@ SOCKET connecthostport(const char * host, unsigned short port,
{
if(!ISINVALID(s))
closesocket(s);
+#ifdef DEBUG
+ printf("ai_family=%d ai_socktype=%d ai_protocol=%d (PF_INET=%d, PF_INET6=%d)\n",
+ p->ai_family, p->ai_socktype, p->ai_protocol, PF_INET, PF_INET6);
+#endif
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if(ISINVALID(s))
continue;
diff --git a/thirdparty/miniupnpc/miniupnpc/miniupnpc.c b/thirdparty/miniupnpc/miniupnpc/miniupnpc.c
index 3181d10eb6..95ab6cf56b 100644
--- a/thirdparty/miniupnpc/miniupnpc/miniupnpc.c
+++ b/thirdparty/miniupnpc/miniupnpc/miniupnpc.c
@@ -564,6 +564,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
char * lanaddr, int lanaddrlen)
{
struct xml_desc {
+ char lanaddr[40];
char * xml;
int size;
int is_igd;
@@ -573,7 +574,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
int i;
int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */
char extIpAddr[16];
- char myLanAddr[40];
int status_code = -1;
if(!devlist)
@@ -596,7 +596,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
/* we should choose an internet gateway device.
* with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
desc[i].xml = miniwget_getaddr(dev->descURL, &(desc[i].size),
- myLanAddr, sizeof(myLanAddr),
+ desc[i].lanaddr, sizeof(desc[i].lanaddr),
dev->scope_id, &status_code);
#ifdef DEBUG
if(!desc[i].xml)
@@ -613,8 +613,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:"))
{
desc[i].is_igd = 1;
- if(lanaddr)
- strncpy(lanaddr, myLanAddr, lanaddrlen);
}
}
}
@@ -680,6 +678,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
}
state = 0;
free_and_return:
+ if (lanaddr != NULL && state >= 1 && state <= 3 && i < ndev)
+ strncpy(lanaddr, desc[i].lanaddr, lanaddrlen);
for(i = 0; i < ndev; i++)
free(desc[i].xml);
free(desc);
@@ -713,4 +713,3 @@ UPNP_GetIGDFromUrl(const char * rootdescurl,
return 0;
}
}
-
diff --git a/thirdparty/miniupnpc/miniupnpc/upnpc.c b/thirdparty/miniupnpc/miniupnpc/upnpc.c
index 674c89beb0..4325658bee 100644
--- a/thirdparty/miniupnpc/miniupnpc/upnpc.c
+++ b/thirdparty/miniupnpc/miniupnpc/upnpc.c
@@ -250,6 +250,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
const char * eport,
const char * proto,
const char * leaseDuration,
+ const char * remoteHost,
const char * description,
int addAny)
{
@@ -283,7 +284,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
if (addAny) {
r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype,
eport, iport, iaddr, description,
- proto, 0, leaseDuration, reservedPort);
+ proto, remoteHost, leaseDuration, reservedPort);
if(r==UPNPCOMMAND_SUCCESS)
eport = reservedPort;
else
@@ -292,7 +293,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
} else {
r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype,
eport, iport, iaddr, description,
- proto, 0, leaseDuration);
+ proto, remoteHost, leaseDuration);
if(r!=UPNPCOMMAND_SUCCESS) {
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
eport, iport, iaddr, r, strupnperror(r));
@@ -302,7 +303,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
r = UPNP_GetSpecificPortMappingEntry(urls->controlURL,
data->first.servicetype,
- eport, proto, NULL/*remoteHost*/,
+ eport, proto, remoteHost,
intClient, intPort, NULL/*desc*/,
NULL/*enabled*/, duration);
if(r!=UPNPCOMMAND_SUCCESS) {
@@ -642,12 +643,12 @@ int main(int argc, char ** argv)
|| (command == 'U' && commandargc<2)
|| (command == 'D' && commandargc<1))
{
- fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration]\n\t\tAdd port redirection\n", argv[0]);
- fprintf(stderr, " \t%s [options] -d external_port protocol <remote host>\n\t\tDelete port redirection\n", argv[0]);
+ fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration] [remote host]\n\t\tAdd port redirection\n", argv[0]);
+ fprintf(stderr, " \t%s [options] -d external_port protocol [remote host]\n\t\tDelete port redirection\n", argv[0]);
fprintf(stderr, " \t%s [options] -s\n\t\tGet Connection status\n", argv[0]);
fprintf(stderr, " \t%s [options] -l\n\t\tList redirections\n", argv[0]);
fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings (for IGD:2 only)\n", argv[0]);
- fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]);
+ fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration] [remote host]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -N external_port_start external_port_end protocol [manage]\n\t\tDelete range of port redirections (for IGD:2 only)\n", argv[0]);
fprintf(stderr, " \t%s [options] -r port1 [external_port1] protocol1 [port2 [external_port2] protocol2] [...]\n\t\tAdd all redirections to the current host\n", argv[0]);
fprintf(stderr, " \t%s [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time\n\t\tAdd Pinhole (for IGD:2 only)\n", argv[0]);
@@ -734,7 +735,8 @@ int main(int argc, char ** argv)
if (SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1],
commandargv[2], commandargv[3],
- (commandargc > 4)?commandargv[4]:"0",
+ (commandargc > 4)&is_int(commandargv[4])?commandargv[4]:"0",
+ (commandargc > 4)&!is_int(commandargv[4])?commandargv[4]:(commandargc > 5)?commandargv[5]:NULL,
description, 0) < 0)
retcode = 2;
break;
@@ -747,7 +749,8 @@ int main(int argc, char ** argv)
if (SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1],
commandargv[2], commandargv[3],
- (commandargc > 4)?commandargv[4]:"0",
+ (commandargc > 4)&is_int(commandargv[4])?commandargv[4]:"0",
+ (commandargc > 4)&!is_int(commandargv[4])?commandargv[4]:(commandargc > 5)?commandargv[5]:NULL,
description, 1) < 0)
retcode = 2;
break;
@@ -775,7 +778,7 @@ int main(int argc, char ** argv)
/* 2nd parameter is an integer : <port> <external_port> <protocol> */
if (SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i],
- commandargv[i+1], commandargv[i+2], "0",
+ commandargv[i+1], commandargv[i+2], "0", NULL,
description, 0) < 0)
retcode = 2;
i+=3; /* 3 parameters parsed */
@@ -783,7 +786,7 @@ int main(int argc, char ** argv)
/* 2nd parameter not an integer : <port> <protocol> */
if (SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i],
- commandargv[i], commandargv[i+1], "0",
+ commandargv[i], commandargv[i+1], "0", NULL,
description, 0) < 0)
retcode = 2;
i+=2; /* 2 parameters parsed */
diff --git a/thirdparty/miniupnpc/miniupnpc/upnperrors.c b/thirdparty/miniupnpc/miniupnpc/upnperrors.c
index 650af42557..4496e8622c 100644
--- a/thirdparty/miniupnpc/miniupnpc/upnperrors.c
+++ b/thirdparty/miniupnpc/miniupnpc/upnperrors.c
@@ -1,9 +1,10 @@
-/* $Id: upnperrors.c,v 1.9 2019/06/25 21:15:46 nanard Exp $ */
-/* Project : miniupnp
+/* $Id: upnperrors.c,v 1.10 2019/08/24 08:49:53 nanard Exp $ */
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * Project : miniupnp
* Author : Thomas BERNARD
* copyright (c) 2007-2019 Thomas Bernard
* All Right reserved.
- * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* This software is subjet to the conditions detailed in the
* provided LICENCE file. */
#include <string.h>
@@ -71,7 +72,7 @@ const char * strupnperror(int err)
s = "ProtocolWildcardingNotAllowed";
break;
case 708:
- s = "WildcardNotPermittedInSrcIP";
+ s = "InvalidLayer2Address";
break;
case 709:
s = "NoPacketSent";