mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(Netplay) Fix NAT traversal announce for HAVE_SOCKET_LEGACY platforms (#14191)
This commit is contained in:
parent
05622ebe85
commit
ee9cb6cb1b
@ -6547,20 +6547,34 @@ static void netplay_handle_slaves(netplay_t *netplay)
|
||||
static void netplay_announce_nat_traversal(netplay_t *netplay,
|
||||
uint16_t ext_port)
|
||||
{
|
||||
#ifndef HAVE_SOCKET_LEGACY
|
||||
char msg[512], host[256], port[6];
|
||||
char msg[512];
|
||||
const char *dmsg = NULL;
|
||||
net_driver_state_t *net_st = &networking_driver_st;
|
||||
|
||||
if (net_st->nat_traversal_request.status == NAT_TRAVERSAL_STATUS_OPENED)
|
||||
{
|
||||
char host[256], port[6];
|
||||
|
||||
netplay->ext_tcp_port = ext_port;
|
||||
|
||||
#ifndef HAVE_SOCKET_LEGACY
|
||||
if (!getnameinfo(
|
||||
(struct sockaddr *)&net_st->nat_traversal_request.request.addr,
|
||||
(struct sockaddr*)&net_st->nat_traversal_request.request.addr,
|
||||
sizeof(net_st->nat_traversal_request.request.addr),
|
||||
host, sizeof(host), port, sizeof(port),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV))
|
||||
#else
|
||||
{
|
||||
uint8_t *addr8 =
|
||||
(uint8_t*)&net_st->nat_traversal_request.request.addr.sin_addr;
|
||||
uint16_t port16 =
|
||||
ntohs(net_st->nat_traversal_request.request.addr.sin_port);
|
||||
|
||||
snprintf(host, sizeof(host), "%d.%d.%d.%d",
|
||||
(int)addr8[0], (int)addr8[1], (int)addr8[2], (int)addr8[3]);
|
||||
snprintf(port, sizeof(port), "%hu", (unsigned short)port16);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "%s: %s:%s",
|
||||
msg_hash_to_str(MSG_PUBLIC_ADDRESS), host, port);
|
||||
@ -6576,7 +6590,6 @@ static void netplay_announce_nat_traversal(netplay_t *netplay,
|
||||
runloop_msg_queue_push(dmsg, 1, 180, false, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user