Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
cfaeea97bd
|
@ -1,6 +1,16 @@
|
||||||
$Id: Changelog.txt,v 1.187 2013/06/06 21:36:39 nanard Exp $
|
$Id: Changelog.txt,v 1.189 2013/10/07 10:04:55 nanard Exp $
|
||||||
miniUPnP client Changelog.
|
miniUPnP client Changelog.
|
||||||
|
|
||||||
|
2013/12/09:
|
||||||
|
--help and -h arguments in upnpc.c
|
||||||
|
|
||||||
|
2013/10/07:
|
||||||
|
fixed potential buffer overrun in miniwget.c
|
||||||
|
Modified UPNP_GetValidIGD() to check for ExternalIpAddress
|
||||||
|
|
||||||
|
2013/08/01:
|
||||||
|
define MAXHOSTNAMELEN if not already done
|
||||||
|
|
||||||
2013/06/06:
|
2013/06/06:
|
||||||
update upnpreplyparse to allow larger values (128 chars instead of 64)
|
update upnpreplyparse to allow larger values (128 chars instead of 64)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $Id: connecthostport.c,v 1.9 2012/06/26 00:00:27 nanard Exp $ */
|
/* $Id: connecthostport.c,v 1.11 2013/08/01 21:21:25 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Author : Thomas Bernard
|
* Author : Thomas Bernard
|
||||||
* Copyright (c) 2010-2012 Thomas Bernard
|
* Copyright (c) 2010-2013 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. */
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@
|
||||||
|
|
||||||
#include "connecthostport.h"
|
#include "connecthostport.h"
|
||||||
|
|
||||||
|
#ifndef MAXHOSTNAMELEN
|
||||||
|
#define MAXHOSTNAMELEN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
/* connecthostport()
|
/* connecthostport()
|
||||||
* return a socket connected (TCP) to the host and port
|
* return a socket connected (TCP) to the host and port
|
||||||
* or -1 in case of error */
|
* or -1 in case of error */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* $Id: miniupnpc.c,v 1.111 2012/10/09 17:53:14 nanard Exp $ */
|
/* $Id: miniupnpc.c,v 1.113 2013/10/07 10:04:56 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Web : http://miniupnp.free.fr/
|
* Web : http://miniupnp.free.fr/
|
||||||
* Author : Thomas BERNARD
|
* Author : Thomas BERNARD
|
||||||
* copyright (c) 2005-2012 Thomas Bernard
|
* copyright (c) 2005-2013 Thomas Bernard
|
||||||
* This software is subjet to the conditions detailed in the
|
* This software is subjet to the conditions detailed in the
|
||||||
* provided LICENSE file. */
|
* provided LICENSE file. */
|
||||||
#define __EXTENSIONS__ 1
|
#define __EXTENSIONS__ 1
|
||||||
|
@ -71,6 +71,17 @@
|
||||||
#define TIMEVAL struct timeval
|
#define TIMEVAL struct timeval
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
|
||||||
|
/* Several versions of glibc don't define this structure, define it here and compile with CFLAGS NEED_STRUCT_IP_MREQN */
|
||||||
|
struct ip_mreqn
|
||||||
|
{
|
||||||
|
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||||
|
struct in_addr imr_address; /* local IP address of interface */
|
||||||
|
int imr_ifindex; /* Interface index */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "miniupnpc.h"
|
#include "miniupnpc.h"
|
||||||
#include "minissdpc.h"
|
#include "minissdpc.h"
|
||||||
#include "miniwget.h"
|
#include "miniwget.h"
|
||||||
|
@ -86,6 +97,10 @@
|
||||||
#define PRINT_SOCKET_ERROR(x) perror(x)
|
#define PRINT_SOCKET_ERROR(x) perror(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAXHOSTNAMELEN
|
||||||
|
#define MAXHOSTNAMELEN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SOAPPREFIX "s"
|
#define SOAPPREFIX "s"
|
||||||
#define SERVICEPREFIX "u"
|
#define SERVICEPREFIX "u"
|
||||||
#define SERVICEPREFIX2 'u'
|
#define SERVICEPREFIX2 'u'
|
||||||
|
@ -867,7 +882,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
|
||||||
* not connected
|
* not connected
|
||||||
* 3 = an UPnP device has been found but was not recognized as an IGD
|
* 3 = an UPnP device has been found but was not recognized as an IGD
|
||||||
*
|
*
|
||||||
* In any non zero return case, the urls and data structures
|
* In any positive non zero return case, the urls and data structures
|
||||||
* passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
|
* passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
|
||||||
* free allocated memory.
|
* free allocated memory.
|
||||||
*/
|
*/
|
||||||
|
@ -880,11 +895,14 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
||||||
struct xml_desc {
|
struct xml_desc {
|
||||||
char * xml;
|
char * xml;
|
||||||
int size;
|
int size;
|
||||||
|
int is_igd;
|
||||||
} * desc = NULL;
|
} * desc = NULL;
|
||||||
struct UPNPDev * dev;
|
struct UPNPDev * dev;
|
||||||
int ndev = 0;
|
int ndev = 0;
|
||||||
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 */
|
||||||
|
int n_igd = 0;
|
||||||
|
char extIpAddr[16];
|
||||||
if(!devlist)
|
if(!devlist)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -892,6 +910,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* counting total number of devices in the list */
|
||||||
for(dev = devlist; dev; dev = dev->pNext)
|
for(dev = devlist; dev; dev = dev->pNext)
|
||||||
ndev++;
|
ndev++;
|
||||||
if(ndev > 0)
|
if(ndev > 0)
|
||||||
|
@ -900,41 +919,58 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
||||||
if(!desc)
|
if(!desc)
|
||||||
return -1; /* memory allocation error */
|
return -1; /* memory allocation error */
|
||||||
}
|
}
|
||||||
|
/* Step 1 : downloading descriptions and testing type */
|
||||||
|
for(dev = devlist, i = 0; dev; dev = dev->pNext, i++)
|
||||||
|
{
|
||||||
|
/* 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),
|
||||||
|
lanaddr, lanaddrlen,
|
||||||
|
dev->scope_id);
|
||||||
|
#ifdef DEBUG
|
||||||
|
if(!desc[i].xml)
|
||||||
|
{
|
||||||
|
printf("error getting XML description %s\n", dev->descURL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if(desc[i].xml)
|
||||||
|
{
|
||||||
|
memset(data, 0, sizeof(struct IGDdatas));
|
||||||
|
memset(urls, 0, sizeof(struct UPNPUrls));
|
||||||
|
parserootdesc(desc[i].xml, desc[i].size, data);
|
||||||
|
if(0==strcmp(data->CIF.servicetype,
|
||||||
|
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"))
|
||||||
|
{
|
||||||
|
desc[i].is_igd = 1;
|
||||||
|
n_igd++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* iterate the list to find a device depending on state */
|
||||||
for(state = 1; state <= 3; state++)
|
for(state = 1; state <= 3; state++)
|
||||||
{
|
{
|
||||||
for(dev = devlist, i = 0; dev; dev = dev->pNext, i++)
|
for(dev = devlist, i = 0; dev; dev = dev->pNext, i++)
|
||||||
{
|
{
|
||||||
/* we should choose an internet gateway device.
|
|
||||||
* with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
|
|
||||||
if(state == 1)
|
|
||||||
{
|
|
||||||
desc[i].xml = miniwget_getaddr(dev->descURL, &(desc[i].size),
|
|
||||||
lanaddr, lanaddrlen,
|
|
||||||
dev->scope_id);
|
|
||||||
#ifdef DEBUG
|
|
||||||
if(!desc[i].xml)
|
|
||||||
{
|
|
||||||
printf("error getting XML description %s\n", dev->descURL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if(desc[i].xml)
|
if(desc[i].xml)
|
||||||
{
|
{
|
||||||
memset(data, 0, sizeof(struct IGDdatas));
|
memset(data, 0, sizeof(struct IGDdatas));
|
||||||
memset(urls, 0, sizeof(struct UPNPUrls));
|
memset(urls, 0, sizeof(struct UPNPUrls));
|
||||||
parserootdesc(desc[i].xml, desc[i].size, data);
|
parserootdesc(desc[i].xml, desc[i].size, data);
|
||||||
if(0==strcmp(data->CIF.servicetype,
|
if(desc[i].is_igd || state >= 3 )
|
||||||
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")
|
|
||||||
|| state >= 3 )
|
|
||||||
{
|
{
|
||||||
GetUPNPUrls(urls, data, dev->descURL, dev->scope_id);
|
GetUPNPUrls(urls, data, dev->descURL, dev->scope_id);
|
||||||
|
|
||||||
|
/* in state 2 and 3 we dont test if device is connected ! */
|
||||||
|
if(state >= 2)
|
||||||
|
goto free_and_return;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("UPNPIGD_IsConnected(%s) = %d\n",
|
printf("UPNPIGD_IsConnected(%s) = %d\n",
|
||||||
urls->controlURL,
|
urls->controlURL,
|
||||||
UPNPIGD_IsConnected(urls, data));
|
UPNPIGD_IsConnected(urls, data));
|
||||||
#endif
|
#endif
|
||||||
if((state >= 2) || UPNPIGD_IsConnected(urls, data))
|
/* checks that status is connected AND there is a external IP address assigned */
|
||||||
|
if(UPNPIGD_IsConnected(urls, data)
|
||||||
|
&& (UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, extIpAddr) == 0))
|
||||||
goto free_and_return;
|
goto free_and_return;
|
||||||
FreeUPNPUrls(urls);
|
FreeUPNPUrls(urls);
|
||||||
if(data->second.servicetype[0] != '\0') {
|
if(data->second.servicetype[0] != '\0') {
|
||||||
|
@ -952,7 +988,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
||||||
urls->controlURL,
|
urls->controlURL,
|
||||||
UPNPIGD_IsConnected(urls, data));
|
UPNPIGD_IsConnected(urls, data));
|
||||||
#endif
|
#endif
|
||||||
if((state >= 2) || UPNPIGD_IsConnected(urls, data))
|
if(UPNPIGD_IsConnected(urls, data)
|
||||||
|
&& (UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, extIpAddr) == 0))
|
||||||
goto free_and_return;
|
goto free_and_return;
|
||||||
FreeUPNPUrls(urls);
|
FreeUPNPUrls(urls);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* $Id: miniwget.c,v 1.58 2012/08/11 05:52:49 nanard Exp $ */
|
/* $Id: miniwget.c,v 1.60 2013/10/07 10:03:16 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Website : http://miniupnp.free.fr/
|
* Website : http://miniupnp.free.fr/
|
||||||
* Author : Thomas Bernard
|
* Author : Thomas Bernard
|
||||||
* Copyright (c) 2005-2012 Thomas Bernard
|
* Copyright (c) 2005-2013 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. */
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@
|
||||||
#include "connecthostport.h"
|
#include "connecthostport.h"
|
||||||
#include "receivedata.h"
|
#include "receivedata.h"
|
||||||
|
|
||||||
|
#ifndef MAXHOSTNAMELEN
|
||||||
|
#define MAXHOSTNAMELEN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a HTTP response from a socket.
|
* Read a HTTP response from a socket.
|
||||||
* Process Content-Length and Transfer-encoding headers.
|
* Process Content-Length and Transfer-encoding headers.
|
||||||
|
@ -158,7 +162,7 @@ getHTTPResponse(int s, int * size)
|
||||||
chunked = 1;
|
chunked = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(header_buf[i]=='\r' || header_buf[i] == '\n')
|
while((i < (int)header_buf_used) && (header_buf[i]=='\r' || header_buf[i] == '\n'))
|
||||||
i++;
|
i++;
|
||||||
linestart = i;
|
linestart = i;
|
||||||
colon = linestart;
|
colon = linestart;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $Id: testminiwget.sh,v 1.9 2013/04/27 15:47:27 nanard Exp $
|
# $Id: testminiwget.sh,v 1.10 2013/11/13 15:08:08 nanard Exp $
|
||||||
# project miniupnp : http://miniupnp.free.fr/
|
# project miniupnp : http://miniupnp.free.fr/
|
||||||
# (c) 2011-2012 Thomas Bernard
|
# (c) 2011-2012 Thomas Bernard
|
||||||
#
|
#
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
# 4 - kills the local HTTP server and exits
|
# 4 - kills the local HTTP server and exits
|
||||||
#
|
#
|
||||||
# The script was tested and works with ksh, bash
|
# The script was tested and works with ksh, bash
|
||||||
# It fails to run with dash 0.5.5.1 because of "kill %1"
|
# it should now also run with dash
|
||||||
|
|
||||||
TMPD=`mktemp -d miniwgetXXXXXXXXXX`
|
TMPD=`mktemp -d miniwgetXXXXXXXXXX`
|
||||||
HTTPSERVEROUT="${TMPD}/httpserverout"
|
HTTPSERVEROUT="${TMPD}/httpserverout"
|
||||||
|
|
|
@ -506,6 +506,11 @@ int main(int argc, char ** argv)
|
||||||
/* command line processing */
|
/* command line processing */
|
||||||
for(i=1; i<argc; i++)
|
for(i=1; i<argc; i++)
|
||||||
{
|
{
|
||||||
|
if(0 == strcmp(argv[i], "--help") || 0 == strcmp(argv[i], "-h"))
|
||||||
|
{
|
||||||
|
command = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(argv[i][0] == '-')
|
if(argv[i][0] == '-')
|
||||||
{
|
{
|
||||||
if(argv[i][1] == 'u')
|
if(argv[i][1] == 'u')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: upnpcommands.c,v 1.40 2012/06/23 22:36:35 nanard Exp $ */
|
/* $Id: upnpcommands.c,v 1.41 2013/12/09 08:18:23 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Author : Thomas Bernard
|
* Author : Thomas Bernard
|
||||||
* Copyright (c) 2005-2012 Thomas Bernard
|
* Copyright (c) 2005-2012 Thomas Bernard
|
||||||
|
@ -759,7 +759,7 @@ UPNP_GetFirewallStatus(const char * controlURL,
|
||||||
char * fe, *ipa, *p;
|
char * fe, *ipa, *p;
|
||||||
int ret = UPNPCOMMAND_UNKNOWN_ERROR;
|
int ret = UPNPCOMMAND_UNKNOWN_ERROR;
|
||||||
|
|
||||||
if(!firewallEnabled && !inboundPinholeAllowed)
|
if(!firewallEnabled || !inboundPinholeAllowed)
|
||||||
return UPNPCOMMAND_INVALID_ARGS;
|
return UPNPCOMMAND_INVALID_ARGS;
|
||||||
|
|
||||||
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
buffer = simpleUPnPcommand(-1, controlURL, servicetype,
|
||||||
|
|
Loading…
Reference in New Issue