update miniupnp to 20100407
This commit is contained in:
parent
4a9f6b3cc7
commit
7a086ec6df
|
@ -137,7 +137,7 @@ tr_upnpPulse( tr_upnp * handle,
|
|||
|
||||
tr_snprintf( portStr, sizeof( portStr ), "%d", handle->port );
|
||||
i = UPNP_GetSpecificPortMappingEntry( handle->urls.controlURL,
|
||||
handle->data.servicetype, portStr,
|
||||
handle->data.first.servicetype, portStr,
|
||||
"TCP", intClient, intPort );
|
||||
if( i != UPNPCOMMAND_SUCCESS )
|
||||
{
|
||||
|
@ -151,12 +151,12 @@ tr_upnpPulse( tr_upnp * handle,
|
|||
char portStr[16];
|
||||
tr_snprintf( portStr, sizeof( portStr ), "%d", handle->port );
|
||||
UPNP_DeletePortMapping( handle->urls.controlURL,
|
||||
handle->data.servicetype,
|
||||
handle->data.first.servicetype,
|
||||
portStr, "TCP", NULL );
|
||||
tr_ninf( getKey( ),
|
||||
_(
|
||||
"Stopping port forwarding through \"%s\", service \"%s\"" ),
|
||||
handle->urls.controlURL, handle->data.servicetype );
|
||||
handle->urls.controlURL, handle->data.first.servicetype );
|
||||
handle->isMapped = 0;
|
||||
handle->state = TR_UPNP_IDLE;
|
||||
handle->port = -1;
|
||||
|
@ -173,7 +173,7 @@ tr_upnpPulse( tr_upnp * handle,
|
|||
int err = -1;
|
||||
errno = 0;
|
||||
|
||||
if( !handle->urls.controlURL || !handle->data.servicetype )
|
||||
if( !handle->urls.controlURL || !handle->data.first.servicetype )
|
||||
handle->isMapped = 0;
|
||||
else
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ tr_upnpPulse( tr_upnp * handle,
|
|||
tr_snprintf( portStr, sizeof( portStr ), "%d", port );
|
||||
tr_snprintf( desc, sizeof( desc ), "%s at %d", TR_NAME, port );
|
||||
err = UPNP_AddPortMapping( handle->urls.controlURL,
|
||||
handle->data.servicetype,
|
||||
handle->data.first.servicetype,
|
||||
portStr, portStr, handle->lanaddr,
|
||||
desc, "TCP", NULL );
|
||||
handle->isMapped = !err;
|
||||
|
@ -190,7 +190,7 @@ tr_upnpPulse( tr_upnp * handle,
|
|||
tr_ninf( getKey( ),
|
||||
_(
|
||||
"Port forwarding through \"%s\", service \"%s\". (local address: %s:%d)" ),
|
||||
handle->urls.controlURL, handle->data.servicetype,
|
||||
handle->urls.controlURL, handle->data.first.servicetype,
|
||||
handle->lanaddr, port );
|
||||
if( handle->isMapped )
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$Id: Changelog.txt,v 1.110 2010/04/05 12:09:51 nanard Exp $
|
||||
$Id: Changelog.txt,v 1.111 2010/04/05 20:36:59 nanard Exp $
|
||||
miniUPnP client Changelog.
|
||||
|
||||
2010/04/05:
|
||||
|
@ -7,6 +7,8 @@ miniUPnP client Changelog.
|
|||
Use getnameinfo() instead of inet_ntop or inet_ntoa
|
||||
Work to make miniupnpc IPV6 compatible...
|
||||
Add java test code.
|
||||
Big changes in order to support device having both WANIPConnection
|
||||
and WANPPPConnection.
|
||||
|
||||
2010/04/04:
|
||||
Use getaddrinfo() instead of gethostbyname() in miniwget.
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/* $Id: igd_desc_parse.c,v 1.9 2009/12/03 13:50:06 nanard Exp $ */
|
||||
/* $Id: igd_desc_parse.c,v 1.10 2010/04/05 20:36:59 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* http://miniupnp.free.fr/
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2005-2008 Thomas Bernard
|
||||
* Copyright (c) 2005-2010 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution.
|
||||
* */
|
||||
* LICENCE file provided in this distribution. */
|
||||
|
||||
#include "igd_desc_parse.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* TODO : rewrite this code so it correctly handle descriptions with
|
||||
* both WANIPConnection and/or WANPPPConnection */
|
||||
|
||||
/* Start element handler :
|
||||
* update nesting level counter and copy element name */
|
||||
void IGDstartelt(void * d, const char * name, int l)
|
||||
|
@ -22,10 +19,10 @@ void IGDstartelt(void * d, const char * name, int l)
|
|||
datas->cureltname[l] = '\0';
|
||||
datas->level++;
|
||||
if( (l==7) && !memcmp(name, "service", l) ) {
|
||||
datas->controlurl_tmp[0] = '\0';
|
||||
datas->eventsuburl_tmp[0] = '\0';
|
||||
datas->scpdurl_tmp[0] = '\0';
|
||||
datas->servicetype_tmp[0] = '\0';
|
||||
datas->tmp.controlurl[0] = '\0';
|
||||
datas->tmp.eventsuburl[0] = '\0';
|
||||
datas->tmp.scpdurl[0] = '\0';
|
||||
datas->tmp.servicetype[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,20 +43,18 @@ void IGDendelt(void * d, const char * name, int l)
|
|||
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"))
|
||||
datas->state ++;
|
||||
*/
|
||||
if(0==strcmp(datas->servicetype_tmp,
|
||||
if(0==strcmp(datas->tmp.servicetype,
|
||||
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) {
|
||||
memcpy(datas->controlurl_CIF, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->eventsuburl_CIF, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->scpdurl_CIF, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->servicetype_CIF, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
} else if(0==strcmp(datas->servicetype_tmp,
|
||||
memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service));
|
||||
} else if(0==strcmp(datas->tmp.servicetype,
|
||||
"urn:schemas-upnp-org:service:WANIPConnection:1")
|
||||
|| 0==strcmp(datas->servicetype_tmp,
|
||||
|| 0==strcmp(datas->tmp.servicetype,
|
||||
"urn:schemas-upnp-org:service:WANPPPConnection:1") ) {
|
||||
memcpy(datas->controlurl, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->eventsuburl, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->scpdurl, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
memcpy(datas->servicetype, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE);
|
||||
if(datas->first.servicetype[0] == '\0') {
|
||||
memcpy(&datas->first, &datas->tmp, sizeof(struct IGDdatas_service));
|
||||
} else {
|
||||
memcpy(&datas->second, &datas->tmp, sizeof(struct IGDdatas_service));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,13 +70,13 @@ void IGDdata(void * d, const char * data, int l)
|
|||
if( !strcmp(datas->cureltname, "URLBase") )
|
||||
dstmember = datas->urlbase;
|
||||
else if( !strcmp(datas->cureltname, "serviceType") )
|
||||
dstmember = datas->servicetype_tmp;
|
||||
dstmember = datas->tmp.servicetype;
|
||||
else if( !strcmp(datas->cureltname, "controlURL") )
|
||||
dstmember = datas->controlurl_tmp;
|
||||
dstmember = datas->tmp.controlurl;
|
||||
else if( !strcmp(datas->cureltname, "eventSubURL") )
|
||||
dstmember = datas->eventsuburl_tmp;
|
||||
dstmember = datas->tmp.eventsuburl;
|
||||
else if( !strcmp(datas->cureltname, "SCPDURL") )
|
||||
dstmember = datas->scpdurl_tmp;
|
||||
dstmember = datas->tmp.scpdurl;
|
||||
/* else if( !strcmp(datas->cureltname, "deviceType") )
|
||||
dstmember = datas->devicetype_tmp;*/
|
||||
if(dstmember)
|
||||
|
@ -97,17 +92,23 @@ void printIGD(struct IGDdatas * d)
|
|||
{
|
||||
printf("urlbase = '%s'\n", d->urlbase);
|
||||
printf("WAN Device (Common interface config) :\n");
|
||||
/*printf(" deviceType = '%s'\n", d->devicetype_CIF);*/
|
||||
printf(" serviceType = '%s'\n", d->servicetype_CIF);
|
||||
printf(" controlURL = '%s'\n", d->controlurl_CIF);
|
||||
printf(" eventSubURL = '%s'\n", d->eventsuburl_CIF);
|
||||
printf(" SCPDURL = '%s'\n", d->scpdurl_CIF);
|
||||
/*printf(" deviceType = '%s'\n", d->CIF.devicetype);*/
|
||||
printf(" serviceType = '%s'\n", d->CIF.servicetype);
|
||||
printf(" controlURL = '%s'\n", d->CIF.controlurl);
|
||||
printf(" eventSubURL = '%s'\n", d->CIF.eventsuburl);
|
||||
printf(" SCPDURL = '%s'\n", d->CIF.scpdurl);
|
||||
printf("WAN Connection Device (IP or PPP Connection):\n");
|
||||
/*printf(" deviceType = '%s'\n", d->devicetype);*/
|
||||
printf(" servicetype = '%s'\n", d->servicetype);
|
||||
printf(" controlURL = '%s'\n", d->controlurl);
|
||||
printf(" eventSubURL = '%s'\n", d->eventsuburl);
|
||||
printf(" SCPDURL = '%s'\n", d->scpdurl);
|
||||
/*printf(" deviceType = '%s'\n", d->first.devicetype);*/
|
||||
printf(" servicetype = '%s'\n", d->first.servicetype);
|
||||
printf(" controlURL = '%s'\n", d->first.controlurl);
|
||||
printf(" eventSubURL = '%s'\n", d->first.eventsuburl);
|
||||
printf(" SCPDURL = '%s'\n", d->first.scpdurl);
|
||||
printf("secondary WAN Connection Device (IP or PPP Connection):\n");
|
||||
/*printf(" deviceType = '%s'\n", d->second.devicetype);*/
|
||||
printf(" servicetype = '%s'\n", d->second.servicetype);
|
||||
printf(" controlURL = '%s'\n", d->second.controlurl);
|
||||
printf(" eventSubURL = '%s'\n", d->second.eventsuburl);
|
||||
printf(" SCPDURL = '%s'\n", d->second.scpdurl);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id: igd_desc_parse.h,v 1.6 2008/04/23 11:51:07 nanard Exp $ */
|
||||
/* $Id: igd_desc_parse.h,v 1.7 2010/04/05 20:36:59 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* http://miniupnp.free.fr/
|
||||
* Author : Thomas Bernard
|
||||
* Copyright (c) 2005-2008 Thomas Bernard
|
||||
* Copyright (c) 2005-2010 Thomas Bernard
|
||||
* This software is subject to the conditions detailed in the
|
||||
* LICENCE file provided in this distribution.
|
||||
* */
|
||||
|
@ -12,30 +12,28 @@
|
|||
/* Structure to store the result of the parsing of UPnP
|
||||
* descriptions of Internet Gateway Devices */
|
||||
#define MINIUPNPC_URL_MAXSIZE (128)
|
||||
struct IGDdatas_service {
|
||||
char controlurl[MINIUPNPC_URL_MAXSIZE];
|
||||
char eventsuburl[MINIUPNPC_URL_MAXSIZE];
|
||||
char scpdurl[MINIUPNPC_URL_MAXSIZE];
|
||||
char servicetype[MINIUPNPC_URL_MAXSIZE];
|
||||
/*char devicetype[MINIUPNPC_URL_MAXSIZE];*/
|
||||
};
|
||||
|
||||
struct IGDdatas {
|
||||
char cureltname[MINIUPNPC_URL_MAXSIZE];
|
||||
char urlbase[MINIUPNPC_URL_MAXSIZE];
|
||||
int level;
|
||||
/*int state;*/
|
||||
/* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */
|
||||
char controlurl_CIF[MINIUPNPC_URL_MAXSIZE];
|
||||
char eventsuburl_CIF[MINIUPNPC_URL_MAXSIZE];
|
||||
char scpdurl_CIF[MINIUPNPC_URL_MAXSIZE];
|
||||
char servicetype_CIF[MINIUPNPC_URL_MAXSIZE];
|
||||
/*char devicetype_CIF[MINIUPNPC_URL_MAXSIZE];*/
|
||||
struct IGDdatas_service CIF;
|
||||
/* "urn:schemas-upnp-org:service:WANIPConnection:1"
|
||||
* "urn:schemas-upnp-org:service:WANPPPConnection:1" */
|
||||
char controlurl[MINIUPNPC_URL_MAXSIZE];
|
||||
char eventsuburl[MINIUPNPC_URL_MAXSIZE];
|
||||
char scpdurl[MINIUPNPC_URL_MAXSIZE];
|
||||
char servicetype[MINIUPNPC_URL_MAXSIZE];
|
||||
/*char devicetype[MINIUPNPC_URL_MAXSIZE];*/
|
||||
struct IGDdatas_service first;
|
||||
/* if both WANIPConnection and WANPPPConnection are present */
|
||||
struct IGDdatas_service second;
|
||||
/* tmp */
|
||||
char controlurl_tmp[MINIUPNPC_URL_MAXSIZE];
|
||||
char eventsuburl_tmp[MINIUPNPC_URL_MAXSIZE];
|
||||
char scpdurl_tmp[MINIUPNPC_URL_MAXSIZE];
|
||||
char servicetype_tmp[MINIUPNPC_URL_MAXSIZE];
|
||||
/*char devicetype_tmp[MINIUPNPC_URL_MAXSIZE];*/
|
||||
struct IGDdatas_service tmp;
|
||||
};
|
||||
|
||||
void IGDstartelt(void *, const char *, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: miniupnpc.c,v 1.77 2010/04/05 12:34:05 nanard Exp $ */
|
||||
/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Author : Thomas BERNARD
|
||||
* copyright (c) 2005-2010 Thomas Bernard
|
||||
|
@ -653,9 +653,9 @@ LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
|
|||
n1 = strlen(descURL);
|
||||
n1 += 2; /* 1 byte more for Null terminator, 1 byte for '/' if needed */
|
||||
n2 = n1; n3 = n1;
|
||||
n1 += strlen(data->scpdurl);
|
||||
n2 += strlen(data->controlurl);
|
||||
n3 += strlen(data->controlurl_CIF);
|
||||
n1 += strlen(data->first.scpdurl);
|
||||
n2 += strlen(data->first.controlurl);
|
||||
n3 += strlen(data->CIF.controlurl);
|
||||
|
||||
urls->ipcondescURL = (char *)malloc(n1);
|
||||
urls->controlURL = (char *)malloc(n2);
|
||||
|
@ -670,19 +670,19 @@ LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
|
|||
strncpy(urls->controlURL, urls->ipcondescURL, n2);
|
||||
strncpy(urls->controlURL_CIF, urls->ipcondescURL, n3);
|
||||
|
||||
url_cpy_or_cat(urls->ipcondescURL, data->scpdurl, n1);
|
||||
url_cpy_or_cat(urls->ipcondescURL, data->first.scpdurl, n1);
|
||||
|
||||
url_cpy_or_cat(urls->controlURL, data->controlurl, n2);
|
||||
url_cpy_or_cat(urls->controlURL, data->first.controlurl, n2);
|
||||
|
||||
url_cpy_or_cat(urls->controlURL_CIF, data->controlurl_CIF, n3);
|
||||
url_cpy_or_cat(urls->controlURL_CIF, data->CIF.controlurl, n3);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("urls->ipcondescURL='%s' %d n1=%d\n", urls->ipcondescURL,
|
||||
strlen(urls->ipcondescURL), n1);
|
||||
printf("urls->controlURL='%s' %d n2=%d\n", urls->controlURL,
|
||||
strlen(urls->controlURL), n2);
|
||||
printf("urls->controlURL_CIF='%s' %d n3=%d\n", urls->controlURL_CIF,
|
||||
strlen(urls->controlURL_CIF), n3);
|
||||
printf("urls->ipcondescURL='%s' %u n1=%d\n", urls->ipcondescURL,
|
||||
(unsigned)strlen(urls->ipcondescURL), n1);
|
||||
printf("urls->controlURL='%s' %u n2=%d\n", urls->controlURL,
|
||||
(unsigned)strlen(urls->controlURL), n2);
|
||||
printf("urls->controlURL_CIF='%s' %u n3=%d\n", urls->controlURL_CIF,
|
||||
(unsigned)strlen(urls->controlURL_CIF), n3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
|
|||
char status[64];
|
||||
unsigned int uptime;
|
||||
status[0] = '\0';
|
||||
UPNP_GetStatusInfo(urls->controlURL, data->servicetype,
|
||||
UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype,
|
||||
status, &uptime, NULL);
|
||||
if(0 == strcmp("Connected", status))
|
||||
{
|
||||
|
@ -812,7 +812,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
|||
parserootdesc(descXML, descXMLsize, data);
|
||||
free(descXML);
|
||||
descXML = NULL;
|
||||
if(0==strcmp(data->servicetype_CIF,
|
||||
if(0==strcmp(data->CIF.servicetype,
|
||||
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")
|
||||
|| state >= 3 )
|
||||
{
|
||||
|
@ -826,6 +826,25 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
|
|||
if((state >= 2) || UPNPIGD_IsConnected(urls, data))
|
||||
return state;
|
||||
FreeUPNPUrls(urls);
|
||||
if(data->second.servicetype[0] != '\0') {
|
||||
#ifdef DEBUG
|
||||
printf("We tried %s, now we try %s !\n",
|
||||
data->first.servicetype, data->second.servicetype);
|
||||
#endif
|
||||
/* swaping WANPPPConnection and WANIPConnection ! */
|
||||
memcpy(&data->tmp, &data->first, sizeof(struct IGDdatas_service));
|
||||
memcpy(&data->first, &data->second, sizeof(struct IGDdatas_service));
|
||||
memcpy(&data->second, &data->tmp, sizeof(struct IGDdatas_service));
|
||||
GetUPNPUrls(urls, data, dev->descURL);
|
||||
#ifdef DEBUG
|
||||
printf("UPNPIGD_IsConnected(%s) = %d\n",
|
||||
urls->controlURL,
|
||||
UPNPIGD_IsConnected(urls, data));
|
||||
#endif
|
||||
if((state >= 2) || UPNPIGD_IsConnected(urls, data))
|
||||
return state;
|
||||
FreeUPNPUrls(urls);
|
||||
}
|
||||
}
|
||||
memset(data, 0, sizeof(struct IGDdatas));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue