implement natt fix from void()

This commit is contained in:
Mark W. Kidd 2021-07-08 22:52:19 -04:00
parent 4803100dc4
commit d4fb27a7a9
3 changed files with 28 additions and 21 deletions

View File

@ -62,7 +62,8 @@ struct natt_status
/**
* Initialize global NAT traversal structures (must be called once to use other
* 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 */
bool natt_new(struct natt_status *status);

View File

@ -47,7 +47,13 @@ static struct UPNPUrls urls;
static struct IGDdatas data;
#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
#if HAVE_MINIUPNPC
@ -56,8 +62,6 @@ void natt_init(void)
char * descXML;
int descXMLsize = 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);
if (devlist)
{
@ -65,22 +69,27 @@ void natt_init(void)
while (dev)
{
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;
}
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
}

View File

@ -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 *) task->task_data;
natt_init();
if (natt_new(ntsd->nat_traversal_state))
natt_open_port_any(ntsd->nat_traversal_state,
ntsd->port, SOCKET_PROTOCOL_TCP);
natt_init(ntsd->nat_traversal_state, ntsd->port, SOCKET_PROTOCOL_TCP);
task_set_progress(task, 100);
task_set_finished(task, true);