sceNetGetMacAddress

This commit is contained in:
georgemoralis 2025-01-03 11:47:45 +02:00
parent c122145a66
commit 21ee524322
4 changed files with 46 additions and 6 deletions

View File

@ -262,6 +262,7 @@ set(NETWORK_LIBS src/core/libraries/network/http.cpp
src/core/libraries/network/net_ctl_obj.h
src/core/libraries/network/net_ctl_codes.h
src/core/libraries/network/net.h
src/core/libraries/network/net_error.h
src/core/libraries/network/ssl.cpp
src/core/libraries/network/ssl.h
)

View File

@ -15,6 +15,7 @@
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/network/net.h"
#include "net_error.h"
namespace Libraries::Net {
@ -640,11 +641,6 @@ int PS4_SYSV_ABI sceNetGetIfnameNumList() {
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNetGetMacAddress() {
LOG_ERROR(Lib_Net, "(STUBBED) called");
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNetGetMemoryPoolStats() {
LOG_ERROR(Lib_Net, "(STUBBED) called");
return ORBIS_OK;
@ -1125,6 +1121,33 @@ int PS4_SYSV_ABI sceNetEmulationSet() {
return ORBIS_OK;
}
/*
** Utility functions
**
*/
int PS4_SYSV_ABI sceNetGetMacAddress(OrbisNetEtherAddr* addr, int flags) {
if (addr == nullptr) {
net_errno = ORBIS_NET_EINVAL;
LOG_ERROR(Lib_Net, "address in null");
return ORBIS_NET_ERROR_EINVAL;
}
#ifdef _WIN32
IP_ADAPTER_INFO AdapterInfo[16];
DWORD dwBufLen = sizeof(AdapterInfo);
if (GetAdaptersInfo(AdapterInfo, &dwBufLen) != ERROR_SUCCESS) {
net_errno = ORBIS_NET_EINVAL;
return ORBIS_NET_ERROR_EINVAL;
} else {
memcpy(addr->data, AdapterInfo[0].Address, 6); // get MAC Address from first adapter
}
#else
// TODO: Implement the function for non Windows OS
char fakeaddress[6] = {0x9A, 0x9D, 0xCA, 0xED, 0xA5, 0xCB};
memcpy(addr->data, fakeaddress, 6);
#endif
return ORBIS_OK;
}
void RegisterlibSceNet(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("ZRAJo-A-ukc", "libSceNet", 1, "libSceNet", 1, 1, in6addr_any);
LIB_FUNCTION("XCuA-GqjA-k", "libSceNet", 1, "libSceNet", 1, 1, in6addr_loopback);

View File

@ -36,6 +36,12 @@ struct OrbisNetSockaddrIn {
char sin_zero[6];
};
#define SCE_NET_ETHER_ADDR_LEN 6
struct OrbisNetEtherAddr {
u8 data[6];
};
int PS4_SYSV_ABI in6addr_any();
int PS4_SYSV_ABI in6addr_loopback();
int PS4_SYSV_ABI sce_net_dummy();
@ -160,7 +166,7 @@ int PS4_SYSV_ABI sceNetGetIfList();
int PS4_SYSV_ABI sceNetGetIfListOnce();
int PS4_SYSV_ABI sceNetGetIfName();
int PS4_SYSV_ABI sceNetGetIfnameNumList();
int PS4_SYSV_ABI sceNetGetMacAddress();
int PS4_SYSV_ABI sceNetGetMacAddress(OrbisNetEtherAddr* addr, int flags);
int PS4_SYSV_ABI sceNetGetMemoryPoolStats();
int PS4_SYSV_ABI sceNetGetNameToIndex();
int PS4_SYSV_ABI sceNetGetpeername();

View File

@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
// used by sce_net_errno
constexpr int ORBIS_NET_EINVAL = 22;
// error codes
constexpr int ORBIS_NET_ERROR_EINVAL = 0x80410116;