(Network/Vita) Add net_ifinfo support (#14225)

This commit is contained in:
Cthulhu-throwaway 2022-07-26 12:10:23 -03:00 committed by GitHub
parent eb4440fafa
commit 29f0ba2e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 11 deletions

View File

@ -2126,6 +2126,8 @@ ifeq ($(HAVE_NETWORKING), 1)
ifneq ($(HAVE_SOCKET_LEGACY),1)
OBJ += $(LIBRETRO_COMM_DIR)/net/net_ifinfo.o
else ifeq ($(platform), vita)
OBJ += $(LIBRETRO_COMM_DIR)/net/net_ifinfo.o
endif
ifeq ($(WANT_IFADDRS), 1)

View File

@ -1335,7 +1335,7 @@ NETPLAY
#include "../libretro-common/net/net_compat.c"
#include "../libretro-common/net/net_socket.c"
#include "../libretro-common/net/net_http.c"
#if !defined(HAVE_SOCKET_LEGACY)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA)
#include "../libretro-common/net/net_ifinfo.c"
#endif
#include "../tasks/task_http.c"

View File

@ -33,7 +33,7 @@
#include <iphlpapi.h>
#elif !defined(GEKKO)
#elif !defined(VITA) && !defined(GEKKO)
#if defined(WANT_IFADDRS)
#include <compat/ifaddrs.h>
#elif !defined(HAVE_LIBNX) && !defined(_3DS)
@ -159,6 +159,30 @@ failure:
net_ifinfo_free(list);
return false;
#elif defined(VITA)
SceNetCtlInfo info;
list->entries = (struct net_ifinfo_entry*)calloc(2, sizeof(*list->entries));
if (!list->entries)
{
list->size = 0;
return false;
}
strcpy_literal(list->entries[0].name, "lo");
strcpy_literal(list->entries[0].host, "127.0.0.1");
list->size = 1;
if (!sceNetCtlInetGetInfo(SCE_NETCTL_INFO_GET_IP_ADDRESS, &info))
{
strcpy_literal(list->entries[1].name, "wlan");
strlcpy(list->entries[1].host, info.ip_address,
sizeof(list->entries[1].host));
list->size++;
}
return true;
#elif defined(HAVE_LIBNX) || defined(_3DS) || defined(GEKKO)
uint32_t addr = 0;

View File

@ -137,7 +137,7 @@
#define BYTES_TO_GB(bytes) (((bytes) / 1024) / 1024 / 1024)
#ifdef HAVE_NETWORKING
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
#include <net/net_ifinfo.h>
#endif
#endif
@ -3899,7 +3899,7 @@ static unsigned menu_displaylist_parse_information_list(file_list_t *info_list)
#endif
#ifdef HAVE_NETWORKING
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
if (menu_entries_append_enum(info_list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_INFORMATION),
msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_INFORMATION),
@ -7165,7 +7165,7 @@ unsigned menu_displaylist_build_list(
break;
case DISPLAYLIST_NETWORK_INFO:
#ifdef HAVE_NETWORKING
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
{
net_ifinfo_t interfaces = {0};

View File

@ -22,7 +22,7 @@
#include <retro_miscellaneous.h>
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
#include <net/net_ifinfo.h>
#endif
@ -96,7 +96,7 @@ bool natt_init(struct natt_discovery *discovery)
if (!bind_addr)
goto failure;
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
{
struct sockaddr_in *addr = (struct sockaddr_in *) bind_addr->ai_addr;

View File

@ -40,7 +40,7 @@
#include <features/features_cpu.h>
#include <lrc_hash.h>
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
#include <net/net_ifinfo.h>
#endif
@ -219,7 +219,7 @@ bool init_netplay_discovery(void)
if (ret)
{
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
net_ifinfo_best("223.255.255.255",
&((struct sockaddr_in*)addr->ai_addr)->sin_addr, false);
#endif

View File

@ -26,7 +26,7 @@
#ifdef HAVE_NETWORKING
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
#include <net/net_ifinfo.h>
#endif
@ -39,7 +39,7 @@ static bool find_local_address(struct natt_device *device,
{
bool ret = false;
#if !defined(HAVE_SOCKET_LEGACY) || defined(GEKKO)
#if !defined(HAVE_SOCKET_LEGACY) || defined(VITA) || defined(GEKKO)
struct net_ifinfo interfaces = {0};
struct addrinfo **addrs = NULL;
uint32_t *scores = NULL;