implement natt fix from void()
This commit is contained in:
parent
4803100dc4
commit
d4fb27a7a9
|
@ -62,7 +62,8 @@ struct natt_status
|
||||||
/**
|
/**
|
||||||
* Initialize global NAT traversal structures (must be called once to use other
|
* Initialize global NAT traversal structures (must be called once to use other
|
||||||
* functions) */
|
* functions) */
|
||||||
void natt_init(void);
|
void natt_init(struct natt_status *status,
|
||||||
|
uint16_t port, enum socket_protocol proto);
|
||||||
|
|
||||||
/** Initialize a NAT traversal status object */
|
/** Initialize a NAT traversal status object */
|
||||||
bool natt_new(struct natt_status *status);
|
bool natt_new(struct natt_status *status);
|
||||||
|
|
|
@ -47,7 +47,13 @@ static struct UPNPUrls urls;
|
||||||
static struct IGDdatas data;
|
static struct IGDdatas data;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void natt_init(void)
|
/*
|
||||||
|
natt_open_port_any(ntsd->nat_traversal_state,
|
||||||
|
ntsd->port, SOCKET_PROTOCOL_TCP);
|
||||||
|
*/
|
||||||
|
|
||||||
|
void natt_init(struct natt_status *status,
|
||||||
|
uint16_t port, enum socket_protocol proto)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_SOCKET_LEGACY
|
#ifndef HAVE_SOCKET_LEGACY
|
||||||
#if HAVE_MINIUPNPC
|
#if HAVE_MINIUPNPC
|
||||||
|
@ -56,8 +62,6 @@ void natt_init(void)
|
||||||
char * descXML;
|
char * descXML;
|
||||||
int descXMLsize = 0;
|
int descXMLsize = 0;
|
||||||
int upnperror = 0;
|
int upnperror = 0;
|
||||||
memset(&urls, 0, sizeof(struct UPNPUrls));
|
|
||||||
memset(&data, 0, sizeof(struct IGDdatas));
|
|
||||||
devlist = upnpDiscover(2000, NULL, NULL, 0, 0, 2, &upnperror);
|
devlist = upnpDiscover(2000, NULL, NULL, 0, 0, 2, &upnperror);
|
||||||
if (devlist)
|
if (devlist)
|
||||||
{
|
{
|
||||||
|
@ -65,22 +69,27 @@ void natt_init(void)
|
||||||
while (dev)
|
while (dev)
|
||||||
{
|
{
|
||||||
if (strstr (dev->st, "InternetGatewayDevice"))
|
if (strstr (dev->st, "InternetGatewayDevice"))
|
||||||
break;
|
{
|
||||||
|
memset(&urls, 0, sizeof(struct UPNPUrls));
|
||||||
|
memset(&data, 0, sizeof(struct IGDdatas));
|
||||||
|
descXML = (char *) miniwget(dev->descURL, &descXMLsize, 0, NULL);
|
||||||
|
if (descXML)
|
||||||
|
{
|
||||||
|
parserootdesc(descXML, descXMLsize, &data);
|
||||||
|
free (descXML);
|
||||||
|
descXML = 0;
|
||||||
|
|
||||||
|
GetUPNPUrls (&urls, &data, dev->descURL, 0);
|
||||||
|
}
|
||||||
|
if(natt_open_port_any(status, port, proto))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
}
|
||||||
dev = dev->pNext;
|
dev = dev->pNext;
|
||||||
}
|
}
|
||||||
if (!dev)
|
|
||||||
dev = devlist;
|
|
||||||
|
|
||||||
descXML = (char *) miniwget(dev->descURL, &descXMLsize, 0, NULL);
|
|
||||||
if (descXML)
|
|
||||||
{
|
|
||||||
parserootdesc(descXML, descXMLsize, &data);
|
|
||||||
free (descXML);
|
|
||||||
descXML = 0;
|
|
||||||
GetUPNPUrls (&urls, &data, dev->descURL, 0);
|
|
||||||
}
|
|
||||||
freeUPNPDevlist(devlist);
|
|
||||||
}
|
}
|
||||||
|
end:
|
||||||
|
freeUPNPDevlist(devlist);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,8 @@ static void task_netplay_nat_traversal_handler(retro_task_t *task)
|
||||||
struct nat_traversal_state_data *ntsd =
|
struct nat_traversal_state_data *ntsd =
|
||||||
(struct nat_traversal_state_data *) task->task_data;
|
(struct nat_traversal_state_data *) task->task_data;
|
||||||
|
|
||||||
natt_init();
|
|
||||||
|
|
||||||
if (natt_new(ntsd->nat_traversal_state))
|
if (natt_new(ntsd->nat_traversal_state))
|
||||||
natt_open_port_any(ntsd->nat_traversal_state,
|
natt_init(ntsd->nat_traversal_state, ntsd->port, SOCKET_PROTOCOL_TCP);
|
||||||
ntsd->port, SOCKET_PROTOCOL_TCP);
|
|
||||||
|
|
||||||
task_set_progress(task, 100);
|
task_set_progress(task, 100);
|
||||||
task_set_finished(task, true);
|
task_set_finished(task, true);
|
||||||
|
|
Loading…
Reference in New Issue