mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-01 15:02:40 +00:00
RE sceNetConnect
This commit is contained in:
parent
7eb4f192e4
commit
ee1c78158f
@ -379,6 +379,8 @@ set(NETWORK_LIBS src/core/libraries/network/http.cpp
|
|||||||
src/core/libraries/network/ssl.h
|
src/core/libraries/network/ssl.h
|
||||||
src/core/libraries/network/ssl2.cpp
|
src/core/libraries/network/ssl2.cpp
|
||||||
src/core/libraries/network/ssl2.h
|
src/core/libraries/network/ssl2.h
|
||||||
|
src/core/libraries/network/sys_net.cpp
|
||||||
|
src/core/libraries/network/sys_net.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(AVPLAYER_LIB src/core/libraries/avplayer/avplayer_common.cpp
|
set(AVPLAYER_LIB src/core/libraries/avplayer/avplayer_common.cpp
|
||||||
|
@ -18,6 +18,7 @@ namespace Libraries::Kernel {
|
|||||||
void ErrSceToPosix(int result);
|
void ErrSceToPosix(int result);
|
||||||
int ErrnoToSceKernelError(int e);
|
int ErrnoToSceKernelError(int e);
|
||||||
void SetPosixErrno(int e);
|
void SetPosixErrno(int e);
|
||||||
|
int* PS4_SYSV_ABI __Error();
|
||||||
|
|
||||||
template <StringLiteral name, class F, F f>
|
template <StringLiteral name, class F, F f>
|
||||||
struct WrapperImpl;
|
struct WrapperImpl;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <core/libraries/kernel/kernel.h>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
@ -19,11 +20,14 @@
|
|||||||
#include "net_error.h"
|
#include "net_error.h"
|
||||||
#include "net_util.h"
|
#include "net_util.h"
|
||||||
#include "netctl.h"
|
#include "netctl.h"
|
||||||
|
#include "sys_net.h"
|
||||||
|
|
||||||
namespace Libraries::Net {
|
namespace Libraries::Net {
|
||||||
|
|
||||||
static thread_local int32_t net_errno = 0;
|
static thread_local int32_t net_errno = 0;
|
||||||
|
|
||||||
|
static bool g_isNetInitialized = true; // TODO init it properly
|
||||||
|
|
||||||
int PS4_SYSV_ABI in6addr_any() {
|
int PS4_SYSV_ABI in6addr_any() {
|
||||||
LOG_ERROR(Lib_Net, "(STUBBED) called");
|
LOG_ERROR(Lib_Net, "(STUBBED) called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
@ -469,9 +473,46 @@ int PS4_SYSV_ABI sceNetConfigWlanSetDeviceConfig() {
|
|||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNetConnect() {
|
int PS4_SYSV_ABI sceNetConnect(OrbisNetId s, OrbisNetSockaddr* addr, u32 addrlen) {
|
||||||
LOG_ERROR(Lib_Net, "(STUBBED) called");
|
if (!g_isNetInitialized) {
|
||||||
return ORBIS_OK;
|
return ORBIS_NET_ERROR_ENOTINIT;
|
||||||
|
}
|
||||||
|
int result;
|
||||||
|
int err;
|
||||||
|
int positiveErr;
|
||||||
|
|
||||||
|
do {
|
||||||
|
result = posix_connect(s, addr, addrlen);
|
||||||
|
|
||||||
|
if (result >= 0) {
|
||||||
|
return result; // Success
|
||||||
|
}
|
||||||
|
|
||||||
|
err = *Libraries::Kernel::__Error(); // Standard errno
|
||||||
|
|
||||||
|
// Convert to positive error for comparison
|
||||||
|
int positiveErr = (err < 0) ? -err : err;
|
||||||
|
|
||||||
|
if ((positiveErr & 0xfff0000) != 0) {
|
||||||
|
// Unknown/fatal error range
|
||||||
|
*sceNetErrnoLoc() = ORBIS_NET_ERETURN;
|
||||||
|
return -positiveErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retry if interrupted
|
||||||
|
} while (positiveErr == ORBIS_NET_EINTR);
|
||||||
|
|
||||||
|
if (positiveErr == ORBIS_NET_EADDRINUSE) {
|
||||||
|
result = -ORBIS_NET_EBADF;
|
||||||
|
} else if (positiveErr == ORBIS_NET_EALREADY) {
|
||||||
|
result = -ORBIS_NET_EINTR;
|
||||||
|
} else {
|
||||||
|
result = -positiveErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
*sceNetErrnoLoc() = -result;
|
||||||
|
|
||||||
|
return (-result) | ORBIS_NET_ERROR_BASE; // Convert to official ORBIS_NET_ERROR code
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNetControl() {
|
int PS4_SYSV_ABI sceNetControl() {
|
||||||
|
@ -117,7 +117,7 @@ int PS4_SYSV_ABI sceNetConfigWlanInfraLeave();
|
|||||||
int PS4_SYSV_ABI sceNetConfigWlanInfraScanJoin();
|
int PS4_SYSV_ABI sceNetConfigWlanInfraScanJoin();
|
||||||
int PS4_SYSV_ABI sceNetConfigWlanScan();
|
int PS4_SYSV_ABI sceNetConfigWlanScan();
|
||||||
int PS4_SYSV_ABI sceNetConfigWlanSetDeviceConfig();
|
int PS4_SYSV_ABI sceNetConfigWlanSetDeviceConfig();
|
||||||
int PS4_SYSV_ABI sceNetConnect();
|
int PS4_SYSV_ABI sceNetConnect(OrbisNetId s, OrbisNetSockaddr* addr, u32 addrlen);
|
||||||
int PS4_SYSV_ABI sceNetControl();
|
int PS4_SYSV_ABI sceNetControl();
|
||||||
int PS4_SYSV_ABI sceNetDhcpdStart();
|
int PS4_SYSV_ABI sceNetDhcpdStart();
|
||||||
int PS4_SYSV_ABI sceNetDhcpdStop();
|
int PS4_SYSV_ABI sceNetDhcpdStop();
|
||||||
|
@ -79,6 +79,7 @@ constexpr int ORBIS_NET_ENOMEM = 12;
|
|||||||
constexpr int ORBIS_NET_ENOBUFS = 55;
|
constexpr int ORBIS_NET_ENOBUFS = 55;
|
||||||
|
|
||||||
// error codes
|
// error codes
|
||||||
|
constexpr int ORBIS_NET_ERROR_BASE = 0x80410100; // not existed used for calculation
|
||||||
constexpr int ORBIS_NET_ERROR_EPERM = 0x80410101;
|
constexpr int ORBIS_NET_ERROR_EPERM = 0x80410101;
|
||||||
constexpr int ORBIS_NET_ERROR_ENOENT = 0x80410102;
|
constexpr int ORBIS_NET_ERROR_ENOENT = 0x80410102;
|
||||||
constexpr int ORBIS_NET_ERROR_EINTR = 0x80410104;
|
constexpr int ORBIS_NET_ERROR_EINTR = 0x80410104;
|
||||||
|
14
src/core/libraries/network/sys_net.cpp
Normal file
14
src/core/libraries/network/sys_net.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "sys_net.h"
|
||||||
|
|
||||||
|
namespace Libraries::Net {
|
||||||
|
|
||||||
|
int sys_connect(OrbisNetId s, OrbisNetSockaddr* addr, u32 addrlen) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Libraries::Net
|
13
src/core/libraries/network/sys_net.h
Normal file
13
src/core/libraries/network/sys_net.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
|
namespace Libraries::Net {
|
||||||
|
|
||||||
|
int sys_connect(OrbisNetId s, OrbisNetSockaddr* addr, u32 addrlen);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user