mirror of
https://github.com/libretro/RetroArch
synced 2025-02-14 06:40:48 +00:00
Enable GetBestRoute for MSVC 2005 (#13407)
This commit is contained in:
parent
43d0fa6248
commit
b67b93ebfe
@ -35,11 +35,9 @@
|
|||||||
|
|
||||||
#include <net/net_natt.h>
|
#include <net/net_natt.h>
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER > 1400
|
#if !defined(HAVE_SOCKET_LEGACY) && defined(_WIN32)
|
||||||
#if !defined(HAVE_SOCKET_LEGACY) && defined(_WIN32) && defined(IP_MULTICAST_IF)
|
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
static natt_state_t natt_st = {{0}, {{0}}, 0, -1};
|
static natt_state_t natt_st = {{0}, {{0}}, 0, -1};
|
||||||
|
|
||||||
@ -59,10 +57,8 @@ bool natt_init(void)
|
|||||||
"MX: 5\r\n"
|
"MX: 5\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
static struct sockaddr_in msearch_addr = {0};
|
static struct sockaddr_in msearch_addr = {0};
|
||||||
#if !defined(_MSC_VER) || _MSC_VER > 1400
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32) && defined(IP_MULTICAST_IF)
|
|
||||||
MIB_IPFORWARDROW ip_forward;
|
MIB_IPFORWARDROW ip_forward;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
natt_state_t *st = &natt_st;
|
natt_state_t *st = &natt_st;
|
||||||
struct addrinfo *bind_addr = NULL;
|
struct addrinfo *bind_addr = NULL;
|
||||||
@ -93,13 +89,12 @@ bool natt_init(void)
|
|||||||
if (!bind_addr)
|
if (!bind_addr)
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER > 1400
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32) && defined(IP_MULTICAST_IF)
|
|
||||||
if (GetBestRoute(inet_addr("223.255.255.255"),
|
if (GetBestRoute(inet_addr("223.255.255.255"),
|
||||||
0, &ip_forward) == NO_ERROR)
|
0, &ip_forward) == NO_ERROR)
|
||||||
{
|
{
|
||||||
IF_INDEX index = ip_forward.dwForwardIfIndex;
|
DWORD index = ip_forward.dwForwardIfIndex;
|
||||||
PMIB_IPADDRTABLE table = malloc(sizeof(MIB_IPADDRTABLE));
|
PMIB_IPADDRTABLE table = malloc(sizeof(*table));
|
||||||
|
|
||||||
if (table)
|
if (table)
|
||||||
{
|
{
|
||||||
@ -127,8 +122,10 @@ bool natt_init(void)
|
|||||||
|
|
||||||
if (ip_addr->dwIndex == index)
|
if (ip_addr->dwIndex == index)
|
||||||
{
|
{
|
||||||
|
#ifdef IP_MULTICAST_IF
|
||||||
setsockopt(st->fd, IPPROTO_IP, IP_MULTICAST_IF,
|
setsockopt(st->fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||||
(const char *) &ip_addr->dwAddr, sizeof(ip_addr->dwAddr));
|
(const char *) &ip_addr->dwAddr, sizeof(ip_addr->dwAddr));
|
||||||
|
#endif
|
||||||
((struct sockaddr_in *) bind_addr->ai_addr)->sin_addr.s_addr =
|
((struct sockaddr_in *) bind_addr->ai_addr)->sin_addr.s_addr =
|
||||||
ip_addr->dwAddr;
|
ip_addr->dwAddr;
|
||||||
break;
|
break;
|
||||||
@ -140,7 +137,6 @@ bool natt_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IP_MULTICAST_TTL
|
#ifdef IP_MULTICAST_TTL
|
||||||
{
|
{
|
||||||
|
@ -41,11 +41,9 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER > 1400
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32) && defined(IP_MULTICAST_IF)
|
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_DISCORD
|
#ifdef HAVE_DISCORD
|
||||||
#include "../discord.h"
|
#include "../discord.h"
|
||||||
@ -245,15 +243,14 @@ bool init_netplay_discovery(void)
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
#if !defined(_MSC_VER) || _MSC_VER > 1400
|
#ifdef _WIN32
|
||||||
#if defined(_WIN32) && defined(IP_MULTICAST_IF)
|
|
||||||
MIB_IPFORWARDROW ip_forward;
|
MIB_IPFORWARDROW ip_forward;
|
||||||
|
|
||||||
if (GetBestRoute(inet_addr("223.255.255.255"),
|
if (GetBestRoute(inet_addr("223.255.255.255"),
|
||||||
0, &ip_forward) == NO_ERROR)
|
0, &ip_forward) == NO_ERROR)
|
||||||
{
|
{
|
||||||
IF_INDEX index = ip_forward.dwForwardIfIndex;
|
DWORD index = ip_forward.dwForwardIfIndex;
|
||||||
PMIB_IPADDRTABLE table = malloc(sizeof(MIB_IPADDRTABLE));
|
PMIB_IPADDRTABLE table = malloc(sizeof(*table));
|
||||||
|
|
||||||
if (table)
|
if (table)
|
||||||
{
|
{
|
||||||
@ -281,8 +278,10 @@ bool init_netplay_discovery(void)
|
|||||||
|
|
||||||
if (ip_addr->dwIndex == index)
|
if (ip_addr->dwIndex == index)
|
||||||
{
|
{
|
||||||
|
#ifdef IP_MULTICAST_IF
|
||||||
setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||||
(const char *) &ip_addr->dwAddr, sizeof(ip_addr->dwAddr));
|
(const char *) &ip_addr->dwAddr, sizeof(ip_addr->dwAddr));
|
||||||
|
#endif
|
||||||
((struct sockaddr_in *) addr->ai_addr)->sin_addr.s_addr =
|
((struct sockaddr_in *) addr->ai_addr)->sin_addr.s_addr =
|
||||||
ip_addr->dwAddr;
|
ip_addr->dwAddr;
|
||||||
break;
|
break;
|
||||||
@ -294,9 +293,8 @@ bool init_netplay_discovery(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SOL_SOCKET) && defined(SO_BROADCAST)
|
#ifdef SO_BROADCAST
|
||||||
/* Make it broadcastable */
|
/* Make it broadcastable */
|
||||||
{
|
{
|
||||||
int broadcast = 1;
|
int broadcast = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user