miniupnpc: Sync with upstream master (0ab1d67)
This commit is contained in:
parent
1d0bd3eb71
commit
e2fbfb1ded
6 changed files with 32 additions and 25 deletions
9
thirdparty/README.md
vendored
9
thirdparty/README.md
vendored
|
@ -284,12 +284,13 @@ File extracted from upstream release tarball (`-apache.tgz` variant):
|
|||
## miniupnpc
|
||||
|
||||
- Upstream: https://github.com/miniupnp/miniupnp/tree/master/miniupnpc
|
||||
- Version: git (3cf6efa, 2019)
|
||||
- Version: git (0ab1d67, 2019)
|
||||
- License: BSD-3-Clause
|
||||
|
||||
Extract only the `miniupnpc` folder inside `thirdparty/miniupnpc`.
|
||||
Exclude all non `.c` and `.h` files, plus all files beginning with `test`
|
||||
`minihttptestserver.c` and `wingenminiupnpcstrings.c`.
|
||||
Files extracted from upstream source:
|
||||
|
||||
- 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
|
||||
(it is usually autogenerated by cmake).
|
||||
|
|
1
thirdparty/miniupnpc/LICENSE
vendored
1
thirdparty/miniupnpc/LICENSE
vendored
|
@ -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.
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
9
thirdparty/miniupnpc/miniupnpc/miniupnpc.c
vendored
9
thirdparty/miniupnpc/miniupnpc/miniupnpc.c
vendored
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
thirdparty/miniupnpc/miniupnpc/upnpc.c
vendored
23
thirdparty/miniupnpc/miniupnpc/upnpc.c
vendored
|
@ -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 */
|
||||
|
|
9
thirdparty/miniupnpc/miniupnpc/upnperrors.c
vendored
9
thirdparty/miniupnpc/miniupnpc/upnperrors.c
vendored
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue