mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
added ORBIS_NET_CTL_INFO_IP_ADDRESS case in sceNetCtlGetInfo
This commit is contained in:
parent
c030e821cb
commit
ba55486e9f
@ -1,6 +1,15 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||||
|
#include <Ws2tcpip.h>
|
||||||
|
#include <iphlpapi.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#else
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
@ -154,10 +163,27 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
|
|||||||
case ORBIS_NET_CTL_INFO_LINK:
|
case ORBIS_NET_CTL_INFO_LINK:
|
||||||
info->link = ORBIS_NET_CTL_LINK_DISCONNECTED;
|
info->link = ORBIS_NET_CTL_LINK_DISCONNECTED;
|
||||||
break;
|
break;
|
||||||
|
case ORBIS_NET_CTL_INFO_IP_ADDRESS: {
|
||||||
|
strcpy(info->ip_address,
|
||||||
|
"127.0.0.1"); // placeholder in case gethostbyname can't find another ip
|
||||||
|
char devname[80];
|
||||||
|
gethostname(devname, 80);
|
||||||
|
struct hostent* resolved = gethostbyname(devname);
|
||||||
|
for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) {
|
||||||
|
struct in_addr addrIn;
|
||||||
|
memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32));
|
||||||
|
char* addr = inet_ntoa(addrIn);
|
||||||
|
if (strcmp(addr, "127.0.0.1") != 0) {
|
||||||
|
strcpy(info->ip_address, addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Lib_NetCtl, "{} unsupported code", code);
|
LOG_ERROR(Lib_NetCtl, "{} unsupported code", code);
|
||||||
}
|
}
|
||||||
LOG_ERROR(Lib_NetCtl, "(STUBBED) called");
|
LOG_DEBUG(Lib_NetCtl, "(STUBBED) called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ typedef union OrbisNetCtlInfo {
|
|||||||
// GetInfo codes
|
// GetInfo codes
|
||||||
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
constexpr int ORBIS_NET_CTL_INFO_DEVICE = 1;
|
||||||
constexpr int ORBIS_NET_CTL_INFO_LINK = 4;
|
constexpr int ORBIS_NET_CTL_INFO_LINK = 4;
|
||||||
|
constexpr int ORBIS_NET_CTL_INFO_IP_ADDRESS = 14;
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNetBweCheckCallbackIpcInt();
|
int PS4_SYSV_ABI sceNetBweCheckCallbackIpcInt();
|
||||||
int PS4_SYSV_ABI sceNetBweClearEventIpcInt();
|
int PS4_SYSV_ABI sceNetBweClearEventIpcInt();
|
||||||
|
Loading…
Reference in New Issue
Block a user