miniupnpc: Sync with upstream master (0ab1d67)

This commit is contained in:
Rémi Verschelde 2019-11-12 09:06:31 +01:00
parent 1d0bd3eb71
commit e2fbfb1ded
6 changed files with 32 additions and 25 deletions

View file

@ -284,12 +284,13 @@ File extracted from upstream release tarball (`-apache.tgz` variant):
## miniupnpc ## miniupnpc
- Upstream: https://github.com/miniupnp/miniupnp/tree/master/miniupnpc - Upstream: https://github.com/miniupnp/miniupnp/tree/master/miniupnpc
- Version: git (3cf6efa, 2019) - Version: git (0ab1d67, 2019)
- License: BSD-3-Clause - License: BSD-3-Clause
Extract only the `miniupnpc` folder inside `thirdparty/miniupnpc`. Files extracted from upstream source:
Exclude all non `.c` and `.h` files, plus all files beginning with `test`
`minihttptestserver.c` and `wingenminiupnpcstrings.c`. - All `*.c` and `*.h` files from `miniupnpc` to `thirdparty/miniupnpc/miniupnpc`
- Remove `test*`, `minihttptestserver.c` and `wingenminiupnpcstrings.c`
The only modified file is miniupnpcstrings.h, which was created for Godot The only modified file is miniupnpcstrings.h, which was created for Godot
(it is usually autogenerated by cmake). (it is usually autogenerated by cmake).

View file

@ -24,4 +24,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 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 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.

View file

@ -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 /* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp * Project : miniupnp
* Author : Thomas Bernard * Author : Thomas Bernard
@ -195,6 +195,10 @@ SOCKET connecthostport(const char * host, unsigned short port,
{ {
if(!ISINVALID(s)) if(!ISINVALID(s))
closesocket(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); s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if(ISINVALID(s)) if(ISINVALID(s))
continue; continue;

View file

@ -564,6 +564,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
char * lanaddr, int lanaddrlen) char * lanaddr, int lanaddrlen)
{ {
struct xml_desc { struct xml_desc {
char lanaddr[40];
char * xml; char * xml;
int size; int size;
int is_igd; int is_igd;
@ -573,7 +574,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
int i; int i;
int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */ int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */
char extIpAddr[16]; char extIpAddr[16];
char myLanAddr[40];
int status_code = -1; int status_code = -1;
if(!devlist) if(!devlist)
@ -596,7 +596,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
/* we should choose an internet gateway device. /* we should choose an internet gateway device.
* with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */ * with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
desc[i].xml = miniwget_getaddr(dev->descURL, &(desc[i].size), 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); dev->scope_id, &status_code);
#ifdef DEBUG #ifdef DEBUG
if(!desc[i].xml) if(!desc[i].xml)
@ -613,8 +613,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:"))
{ {
desc[i].is_igd = 1; desc[i].is_igd = 1;
if(lanaddr)
strncpy(lanaddr, myLanAddr, lanaddrlen);
} }
} }
} }
@ -680,6 +678,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
} }
state = 0; state = 0;
free_and_return: free_and_return:
if (lanaddr != NULL && state >= 1 && state <= 3 && i < ndev)
strncpy(lanaddr, desc[i].lanaddr, lanaddrlen);
for(i = 0; i < ndev; i++) for(i = 0; i < ndev; i++)
free(desc[i].xml); free(desc[i].xml);
free(desc); free(desc);
@ -713,4 +713,3 @@ UPNP_GetIGDFromUrl(const char * rootdescurl,
return 0; return 0;
} }
} }

View file

@ -250,6 +250,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
const char * eport, const char * eport,
const char * proto, const char * proto,
const char * leaseDuration, const char * leaseDuration,
const char * remoteHost,
const char * description, const char * description,
int addAny) int addAny)
{ {
@ -283,7 +284,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
if (addAny) { if (addAny) {
r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype, r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype,
eport, iport, iaddr, description, eport, iport, iaddr, description,
proto, 0, leaseDuration, reservedPort); proto, remoteHost, leaseDuration, reservedPort);
if(r==UPNPCOMMAND_SUCCESS) if(r==UPNPCOMMAND_SUCCESS)
eport = reservedPort; eport = reservedPort;
else else
@ -292,7 +293,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
} else { } else {
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, remoteHost, 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));
@ -302,7 +303,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
r = UPNP_GetSpecificPortMappingEntry(urls->controlURL, r = UPNP_GetSpecificPortMappingEntry(urls->controlURL,
data->first.servicetype, data->first.servicetype,
eport, proto, NULL/*remoteHost*/, eport, proto, remoteHost,
intClient, intPort, NULL/*desc*/, intClient, intPort, NULL/*desc*/,
NULL/*enabled*/, duration); NULL/*enabled*/, duration);
if(r!=UPNPCOMMAND_SUCCESS) { if(r!=UPNPCOMMAND_SUCCESS) {
@ -642,12 +643,12 @@ int main(int argc, char ** argv)
|| (command == 'U' && commandargc<2) || (command == 'U' && commandargc<2)
|| (command == 'D' && commandargc<1)) || (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, "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] -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] -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\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] -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] -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] -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]); 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, if (SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1], commandargv[0], commandargv[1],
commandargv[2], commandargv[3], 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) description, 0) < 0)
retcode = 2; retcode = 2;
break; break;
@ -747,7 +749,8 @@ int main(int argc, char ** argv)
if (SetRedirectAndTest(&urls, &data, if (SetRedirectAndTest(&urls, &data,
commandargv[0], commandargv[1], commandargv[0], commandargv[1],
commandargv[2], commandargv[3], 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) description, 1) < 0)
retcode = 2; retcode = 2;
break; break;
@ -775,7 +778,7 @@ int main(int argc, char ** argv)
/* 2nd parameter is an integer : <port> <external_port> <protocol> */ /* 2nd parameter is an integer : <port> <external_port> <protocol> */
if (SetRedirectAndTest(&urls, &data, if (SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i], lanaddr, commandargv[i],
commandargv[i+1], commandargv[i+2], "0", commandargv[i+1], commandargv[i+2], "0", NULL,
description, 0) < 0) description, 0) < 0)
retcode = 2; retcode = 2;
i+=3; /* 3 parameters parsed */ i+=3; /* 3 parameters parsed */
@ -783,7 +786,7 @@ int main(int argc, char ** argv)
/* 2nd parameter not an integer : <port> <protocol> */ /* 2nd parameter not an integer : <port> <protocol> */
if (SetRedirectAndTest(&urls, &data, if (SetRedirectAndTest(&urls, &data,
lanaddr, commandargv[i], lanaddr, commandargv[i],
commandargv[i], commandargv[i+1], "0", commandargv[i], commandargv[i+1], "0", NULL,
description, 0) < 0) description, 0) < 0)
retcode = 2; retcode = 2;
i+=2; /* 2 parameters parsed */ i+=2; /* 2 parameters parsed */

View file

@ -1,9 +1,10 @@
/* $Id: upnperrors.c,v 1.9 2019/06/25 21:15:46 nanard Exp $ */ /* $Id: upnperrors.c,v 1.10 2019/08/24 08:49:53 nanard Exp $ */
/* Project : miniupnp /* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp
* Author : Thomas BERNARD * Author : Thomas BERNARD
* copyright (c) 2007-2019 Thomas Bernard * copyright (c) 2007-2019 Thomas Bernard
* All Right reserved. * 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 * This software is subjet to the conditions detailed in the
* provided LICENCE file. */ * provided LICENCE file. */
#include <string.h> #include <string.h>
@ -71,7 +72,7 @@ const char * strupnperror(int err)
s = "ProtocolWildcardingNotAllowed"; s = "ProtocolWildcardingNotAllowed";
break; break;
case 708: case 708:
s = "WildcardNotPermittedInSrcIP"; s = "InvalidLayer2Address";
break; break;
case 709: case 709:
s = "NoPacketSent"; s = "NoPacketSent";