mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-11 16:49:27 +01:00
Merge pull request #20221 from hrydgard/net-fixes-3
More infrastructure networking fixes
This commit is contained in:
10 files changed
+124
-73
No files matched your search
@@ -69,6 +69,8 @@ bool HTTPSRequest::Done() {
|
||||
if (completed_)
|
||||
return true;
|
||||
|
||||
_dbg_assert_(res_ != nullptr);
|
||||
|
||||
if (!naettComplete(res_)) {
|
||||
int total = 0;
|
||||
int size = naettGetTotalBytesRead(res_, &total);
|
||||
|
||||
+27
-2
@@ -6,9 +6,11 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/Net/SocketCompat.h"
|
||||
|
||||
@@ -411,7 +413,15 @@ static bool parse_dns_response(unsigned char *buffer, size_t response_len, uint3
|
||||
return false;
|
||||
}
|
||||
|
||||
// This was written by ChatGPT! (And then cleaned up...)
|
||||
// This was written by ChatGPT, although not much of that remains, after all the cleanup and fixing...
|
||||
|
||||
// Specialized cache for the direct DNS lookups
|
||||
struct DNSCacheEntry {
|
||||
uint32_t ipv4Address;
|
||||
};
|
||||
|
||||
static std::map<std::string, DNSCacheEntry> g_directDNSCache;
|
||||
|
||||
bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t *ipv4_addr) {
|
||||
if (!strlen(dns_server_ip)) {
|
||||
WARN_LOG(Log::sceNet, "Direct lookup: DNS server not specified");
|
||||
@@ -423,6 +433,15 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string key = StringFromFormat("%s:%s", dns_server_ip, domain);
|
||||
|
||||
auto iter = g_directDNSCache.find(key);
|
||||
if (iter != g_directDNSCache.end()) {
|
||||
INFO_LOG(Log::sceNet, "Returning cached response from direct DNS request for '%s' to DNS server '%s", domain, dns_server_ip);
|
||||
*ipv4_addr = iter->second.ipv4Address;
|
||||
return true;
|
||||
}
|
||||
|
||||
SOCKET sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
// Create UDP socket
|
||||
if (sockfd < 0) {
|
||||
@@ -470,11 +489,17 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
closesocket(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Close socket
|
||||
closesocket(sockfd);
|
||||
|
||||
// Done communicating, time to parse.
|
||||
return parse_dns_response(buffer, response_len, ipv4_addr);
|
||||
if (!parse_dns_response(buffer, response_len, ipv4_addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
g_directDNSCache[key] = DNSCacheEntry{ *ipv4_addr };
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
@@ -116,13 +116,12 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
std::string json;
|
||||
if (!jsonReady_ && PollInfraJsonDownload(&json)) {
|
||||
if (!json.empty()) {
|
||||
INFO_LOG(Log::sceNet, "PollInfraJsonDownload returned a string");
|
||||
if (!LoadAutoDNS(json)) {
|
||||
// If the JSON parse fails, throw away the cache file at least.
|
||||
ERROR_LOG(Log::sceNet, "Failed to parse bad json. Deleting cache file.");
|
||||
DeleteAutoDNSCacheFile();
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "Got and processed the AutoDNS json.");
|
||||
DEBUG_LOG(Log::sceNet, "Got and processed the AutoDNS json.");
|
||||
}
|
||||
} else {
|
||||
// TODO: Show a notice?
|
||||
|
||||
+15
-6
@@ -348,8 +348,11 @@ bool LoadAutoDNS(std::string_view json) {
|
||||
if (inet_ntop(ptr->ai_family, &(((struct sockaddr_in*)ptr->ai_addr)->sin_addr), ipstr, sizeof(ipstr)) != 0) {
|
||||
INFO_LOG(Log::sceNet, "Successfully resolved '%s' to '%s', overriding DNS.", dyn_dns.c_str(), ipstr);
|
||||
if (g_infraDNSConfig.dns != ipstr) {
|
||||
WARN_LOG(Log::sceNet, "Replacing specified DNS IP %s with dyndns %s!", g_infraDNSConfig.dns.c_str(), ipstr);
|
||||
INFO_LOG(Log::sceNet, "Replacing specified DNS IP %s with dyndns %s!", g_infraDNSConfig.dns.c_str(), ipstr);
|
||||
g_infraDNSConfig.dns = ipstr;
|
||||
// If dyndns is working, we do not need the fixed lookups. So let's kick them.
|
||||
INFO_LOG(Log::sceNet, "Clearing fixed DNS lookups.");
|
||||
g_infraDNSConfig.fixedDNS.clear();
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "DynDNS: %s already up to date", g_infraDNSConfig.dns.c_str());
|
||||
}
|
||||
@@ -382,14 +385,18 @@ void StartInfraJsonDownload() {
|
||||
WARN_LOG(Log::sceNet, "json is already being downloaded. Still, starting a new download.");
|
||||
}
|
||||
|
||||
const char *acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
|
||||
g_infraDL = g_DownloadManager.StartDownload(jsonUrl, Path(), http::RequestFlags::Cached24H, acceptMime);
|
||||
if (!g_Config.bDontDownloadInfraJson) {
|
||||
const char * const acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
|
||||
g_infraDL = g_DownloadManager.StartDownload(jsonUrl, Path(), http::RequestFlags::Cached24H, acceptMime);
|
||||
}
|
||||
}
|
||||
|
||||
bool PollInfraJsonDownload(std::string *jsonOutput) {
|
||||
if (!g_Config.bInfrastructureAutoDNS) {
|
||||
INFO_LOG(Log::sceNet, "Auto DNS disabled, returning success");
|
||||
jsonOutput->clear();
|
||||
// In case there's an old request, get rid of it.
|
||||
g_infraDL.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -402,6 +409,8 @@ bool PollInfraJsonDownload(std::string *jsonOutput) {
|
||||
return true; // A clear output but returning true means something vent very wrong.
|
||||
}
|
||||
*jsonOutput = std::string((const char *)jsonStr.get(), jsonSize);
|
||||
// In case there's an old request, get rid of it.
|
||||
g_infraDL.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -871,7 +880,7 @@ static u32 sceNetTerm() {
|
||||
|
||||
// Give time to make sure everything are cleaned up
|
||||
hleEatMicro(adhocDefaultDelay);
|
||||
return hleLogWarning(Log::sceNet, retval, "at %08x", currentMIPS->pc);
|
||||
return hleLogInfo(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -920,7 +929,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
|
||||
return hleLogError(Log::sceNet, SCE_KERNEL_ERROR_NO_MEMORY, "unable to allocate pool");
|
||||
}
|
||||
|
||||
WARN_LOG(Log::sceNet, "sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, currentMIPS->pc);
|
||||
INFO_LOG(Log::sceNet, "sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d) at %08x", poolSize, calloutPri, calloutStack, netinitPri, netinitStack, currentMIPS->pc);
|
||||
|
||||
netMallocStat.pool = poolSize - 0x20; // On Vantage Master Portable this is slightly (32 bytes) smaller than the poolSize arg when tested with JPCSP + prx files
|
||||
netMallocStat.maximum = 0x4050; // Dummy maximum foot print
|
||||
@@ -1356,7 +1365,7 @@ static int NetApctl_AddHandler(u32 handlerPtr, u32 handlerArg) {
|
||||
return retval;
|
||||
}
|
||||
apctlHandlers[retval] = handler;
|
||||
WARN_LOG(Log::sceNet, "Added Apctl handler(%x, %x): %d", handlerPtr, handlerArg, retval);
|
||||
INFO_LOG(Log::sceNet, "Added Apctl handler(%x, %x): %d", handlerPtr, handlerArg, retval);
|
||||
}
|
||||
else {
|
||||
ERROR_LOG(Log::sceNet, "Existing Apctl handler(%x, %x)", handlerPtr, handlerArg);
|
||||
|
||||
@@ -2425,7 +2425,7 @@ static u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) {
|
||||
return retval;
|
||||
}
|
||||
adhocctlHandlers[retval] = handler;
|
||||
WARN_LOG(Log::sceNet, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval);
|
||||
INFO_LOG(Log::sceNet, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval);
|
||||
} else if(foundHandler) {
|
||||
ERROR_LOG(Log::sceNet, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg);
|
||||
retval = 0; //Faking success
|
||||
|
||||
+68
-54
@@ -27,25 +27,32 @@
|
||||
#endif
|
||||
|
||||
// This is the PSP networking errno.
|
||||
// TODO: It should probably be thread-local - one value for each PSP thread?
|
||||
int g_inetLastErrno = 0;
|
||||
// It has a separate value per-thread, hence the map.
|
||||
|
||||
static std::map<int, int> g_inetLastErrno;
|
||||
|
||||
// Functions should only call this on error, NOT on success.
|
||||
// Returns a PSP errno (ERROR_INET_*), in case it's needed.
|
||||
static int UpdateErrnoFromHost(int hostErrno, const char *func) {
|
||||
static int UpdateErrnoFromHost(int threadID, int hostErrno, const char *func) {
|
||||
int newErrno = convertInetErrnoHost2PSP(hostErrno);
|
||||
if (g_inetLastErrno == 0 && newErrno == 0) {
|
||||
|
||||
// This will do the right thing if not already present - insert a zero value.
|
||||
int lastErrno = g_inetLastErrno[threadID];
|
||||
|
||||
if (lastErrno == 0 && newErrno == 0) {
|
||||
WARN_LOG(Log::sceNet, "BAD: errno set to 0 in %s. Functions should not clear errno.", func);
|
||||
} else if (g_inetLastErrno != 0 && newErrno == 0) {
|
||||
ERROR_LOG(Log::sceNet, "BAD: errno cleared (previously %s) in %s. Functions should not clear errno.", convertInetErrno2str(g_inetLastErrno), func);
|
||||
g_inetLastErrno = 0;
|
||||
} else if (g_inetLastErrno == newErrno) {
|
||||
} else if (lastErrno != 0 && newErrno == 0) {
|
||||
ERROR_LOG(Log::sceNet, "BAD: errno cleared (previously %s) in %s. Functions should not clear errno.", convertInetErrno2str(lastErrno), func);
|
||||
lastErrno = 0;
|
||||
} else if (lastErrno == newErrno) {
|
||||
VERBOSE_LOG(Log::sceNet, "errno remained %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "errno set to %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
|
||||
g_inetLastErrno = newErrno;
|
||||
DEBUG_LOG(Log::sceNet, "errno set to %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
|
||||
lastErrno = newErrno;
|
||||
}
|
||||
return g_inetLastErrno;
|
||||
|
||||
g_inetLastErrno[threadID] = lastErrno;
|
||||
return lastErrno;
|
||||
}
|
||||
|
||||
bool netInetInited = false;
|
||||
@@ -57,32 +64,40 @@ void __NetInetShutdown() {
|
||||
|
||||
netInetInited = false;
|
||||
g_socketManager.CloseAll();
|
||||
g_inetLastErrno.clear();
|
||||
}
|
||||
|
||||
static int sceNetInetInit() {
|
||||
if (netInetInited)
|
||||
return hleLogError(Log::sceNet, ERROR_NET_INET_ALREADY_INITIALIZED);
|
||||
g_inetLastErrno.clear();
|
||||
netInetInited = true;
|
||||
return hleLogDebug(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
static int sceNetInetTerm() {
|
||||
WARN_LOG(Log::sceNet, "UNIMPL sceNetInetTerm()");
|
||||
INFO_LOG(Log::sceNet, "sceNetInetTerm()");
|
||||
__NetInetShutdown();
|
||||
return hleLogDebug(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
static int sceNetInetGetErrno() {
|
||||
if (g_inetLastErrno == ERROR_INET_EAGAIN) {
|
||||
return hleLogVerbose(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc);
|
||||
int threadID = __KernelGetCurThread();
|
||||
const int lastErrno = g_inetLastErrno[threadID];
|
||||
|
||||
if (lastErrno == ERROR_INET_EAGAIN) {
|
||||
return hleLogVerbose(Log::sceNet, lastErrno, "returning %s at %08x", convertInetErrno2str(lastErrno), currentMIPS->pc);
|
||||
} else {
|
||||
return hleLogDebug(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc);
|
||||
return hleLogDebug(Log::sceNet, lastErrno, "returning %s at %08x", convertInetErrno2str(lastErrno), currentMIPS->pc);
|
||||
}
|
||||
}
|
||||
|
||||
static int sceNetInetGetPspError() {
|
||||
uint32_t error = convertInetErrno2PSPError(g_inetLastErrno);
|
||||
return hleLogInfo(Log::sceNet, error, "returning %s converted to %08x at %08x", convertInetErrno2str(g_inetLastErrno), error, currentMIPS->pc);
|
||||
int threadID = __KernelGetCurThread();
|
||||
const int lastErrno = g_inetLastErrno[threadID];
|
||||
|
||||
uint32_t error = convertInetErrno2PSPError(lastErrno);
|
||||
return hleLogInfo(Log::sceNet, error, "returning %s converted to %08x at %08x", convertInetErrno2str(lastErrno), error, currentMIPS->pc);
|
||||
}
|
||||
|
||||
static int sceNetInetInetPton(int af, const char* hostname, u32 inAddrPtr) {
|
||||
@@ -93,7 +108,7 @@ static int sceNetInetInetPton(int af, const char* hostname, u32 inAddrPtr) {
|
||||
int retval = inet_pton(convertSocketDomainPSP2Host(af), hostname, (void*)Memory::GetPointer(inAddrPtr));
|
||||
// Note that inet_pton can set errno!
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return hleLogDebug(Log::sceNet, retval);
|
||||
@@ -117,7 +132,7 @@ static u32 sceNetInetInetNtop(int af, u32 srcInAddrPtr, u32 dstBufPtr, u32 bufsi
|
||||
return hleLogError(Log::sceNet, 0, "invalid arg");
|
||||
}
|
||||
if (!Memory::IsValidAddress(dstBufPtr) || bufsize < 1/*8*/) { // usually 8 or 16, but Coded Arms Contagion is using bufsize = 4
|
||||
UpdateErrnoFromHost(ENOSPC, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOSPC, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, 0, "invalid arg");
|
||||
}
|
||||
|
||||
@@ -140,7 +155,7 @@ static u32_le sceNetInetInetAddr(const char *hostname) {
|
||||
|
||||
static int sceNetInetGetpeername(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
if (!Memory::IsValidAddress(namePtr) || !Memory::IsValidAddress(namelenPtr)) {
|
||||
UpdateErrnoFromHost(EFAULT, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, -1, "invalid arg");
|
||||
}
|
||||
|
||||
@@ -162,7 +177,7 @@ static int sceNetInetGetpeername(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
DEBUG_LOG(Log::sceNet, "Getpeername: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
*namelen = len;
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
@@ -174,7 +189,7 @@ static int sceNetInetGetpeername(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
|
||||
static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
if (!Memory::IsValidAddress(namePtr) || !Memory::IsValidAddress(namelenPtr)) {
|
||||
UpdateErrnoFromHost(EFAULT, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, -1, "invalid arg");
|
||||
}
|
||||
|
||||
@@ -195,7 +210,7 @@ static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
DEBUG_LOG(Log::sceNet, "Getsockname: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
*namelen = len;
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
@@ -319,7 +334,7 @@ int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr
|
||||
}
|
||||
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleDelayResult(hleLogDebug(Log::sceNet, retval), "workaround until blocking-socket", 500); // Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
}
|
||||
return hleDelayResult(hleLogDebug(Log::sceNet, retval), "workaround until blocking-socket", 500); // Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
@@ -339,7 +354,7 @@ int sceNetInetPoll(u32 fdsPtr, u32 nfds, int timeout) { // timeout in milisecond
|
||||
for (int i = 0; i < (s32)nfds; i++) {
|
||||
if (fdarray[i].fd < 0) {
|
||||
// In Unix, this is OK and means it the fd should be ignored, except fdarray[i].revents should be zeroed.
|
||||
UpdateErrnoFromHost(EINVAL, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EINVAL, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, -1, "invalid socket id");
|
||||
}
|
||||
SOCKET hostSocket = g_socketManager.GetHostSocketFromInetSocket(fdarray[i].fd);
|
||||
@@ -361,7 +376,7 @@ int sceNetInetPoll(u32 fdsPtr, u32 nfds, int timeout) { // timeout in milisecond
|
||||
// TODO: Simulate blocking behaviour when timeout is non-zero to prevent PPSSPP from freezing
|
||||
retval = select(maxHostFd + 1, &readfds, &writefds, &exceptfds, /*(timeout<0)? NULL:*/&tmout);
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(EINTR, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EINTR, __FUNCTION__);
|
||||
return hleDelayResult(hleLogError(Log::sceNet, retval), "workaround until blocking-socket", 500); // Using hleDelayResult as a workaround for games that need blocking-socket to be implemented
|
||||
}
|
||||
|
||||
@@ -393,7 +408,7 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recv(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
retval = hleLogError(Log::sceNet, retval);
|
||||
@@ -422,22 +437,21 @@ static int sceNetInetSend(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = send(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return hleLogInfo(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
static int sceNetInetSocket(int domain, int type, int protocol) {
|
||||
// Still using WARN_LOG to make this stand out in the log.
|
||||
WARN_LOG(Log::sceNet, "sceNetInetSocket(%i, %i, %i) at %08x - Socket: Domain = %s, Type = %s, Protocol = %s",
|
||||
INFO_LOG(Log::sceNet, "sceNetInetSocket(%d, %d, %d) at %08x - Socket: Domain = %s, Type = %s, Protocol = %s",
|
||||
domain, type, protocol, currentMIPS->pc, inetSocketDomain2str(domain).c_str(), inetSocketType2str(type).c_str(), inetSocketProto2str(protocol).c_str());
|
||||
|
||||
int socket;
|
||||
int hostErrno = 0;
|
||||
InetSocket *inetSock = g_socketManager.CreateSocket(&socket, &hostErrno, SocketState::UsedNetInet, domain, type, protocol);
|
||||
if (!inetSock) {
|
||||
UpdateErrnoFromHost(hostErrno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), hostErrno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, -1);
|
||||
}
|
||||
|
||||
@@ -459,7 +473,7 @@ static int sceNetInetSetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
}
|
||||
|
||||
u32 optval = optvalPtr ? Memory::Read_U32(optvalPtr) : 0;
|
||||
WARN_LOG(Log::sceNet, "sceNetInetSetsockopt(%i, %i, %i, %08x, %i) at %08x: Level = %s, OptName = %s, OptValue = %d",
|
||||
INFO_LOG(Log::sceNet, "sceNetInetSetsockopt(%i, %i, %i, %08x, %i) at %08x: Level = %s, OptName = %s, OptValue = %d",
|
||||
socket, level, optname, optvalPtr, optlen, currentMIPS->pc,
|
||||
inetSockoptLevel2str(level).c_str(), inetSockoptName2str(optname, level).c_str(), optval);
|
||||
|
||||
@@ -496,7 +510,7 @@ static int sceNetInetSetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
case PSP_NET_INET_SO_SNDBUF: // PSP_NET_INET_SO_NOSIGPIPE ?
|
||||
// TODO: For SOCK_STREAM max buffer size is 8 Mb on BSD, while max SOCK_DGRAM is 65535 minus the IP & UDP Header size
|
||||
if (optval > 8 * 1024 * 1024) {
|
||||
UpdateErrnoFromHost(ENOBUFS, __FUNCTION__); // FIXME: return ENOBUFS for SOCK_STREAM, and EINVAL for SOCK_DGRAM
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOBUFS, __FUNCTION__); // FIXME: return ENOBUFS for SOCK_STREAM, and EINVAL for SOCK_DGRAM
|
||||
return hleLogError(Log::sceNet, -1, "buffer size too large?");
|
||||
}
|
||||
break;
|
||||
@@ -520,7 +534,7 @@ static int sceNetInetSetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
retval = setsockopt(inetSock->sock, convertSockoptLevelPSP2Host(level), convertSockoptNamePSP2Host(optname, level), (char*)&optval, optlen);
|
||||
}
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return hleLogDebug(Log::sceNet, retval);
|
||||
@@ -584,7 +598,7 @@ static int sceNetInetGetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
retval = getsockopt(inetSock->sock, convertSockoptLevelPSP2Host(level), convertSockoptNamePSP2Host(optname, level), (char*)optval, optlen);
|
||||
}
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
DEBUG_LOG(Log::sceNet, "SockOpt: OptValue = %d", *optval);
|
||||
@@ -592,7 +606,7 @@ static int sceNetInetGetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
}
|
||||
|
||||
static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
|
||||
WARN_LOG(Log::sceNet, "sceNetInetBind(%i, %08x, %i) at %08x", socket, namePtr, namelen, currentMIPS->pc);
|
||||
INFO_LOG(Log::sceNet, "sceNetInetBind(%i, %08x, %i) at %08x", socket, namePtr, namelen, currentMIPS->pc);
|
||||
|
||||
InetSocket *inetSock;
|
||||
if (!g_socketManager.GetInetSocket(socket, &inetSock)) {
|
||||
@@ -617,7 +631,7 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
|
||||
// Get Local IP Address
|
||||
sockaddr_in sockAddr{};
|
||||
getLocalIp(&sockAddr);
|
||||
WARN_LOG(Log::sceNet, "Bind: Address Replacement = %s => %s", ip2str(saddr.in.sin_addr).c_str(), ip2str(sockAddr.sin_addr).c_str());
|
||||
INFO_LOG(Log::sceNet, "Bind: Address Replacement = %s => %s", ip2str(saddr.in.sin_addr).c_str(), ip2str(sockAddr.sin_addr).c_str());
|
||||
saddr.in.sin_addr.s_addr = sockAddr.sin_addr.s_addr;
|
||||
}
|
||||
// TODO: Make use Port Offset only for PPSSPP to PPSSPP communications (ie. IP addresses available in the group/friendlist), otherwise should be considered as Online Service thus should use the port as is.
|
||||
@@ -631,7 +645,7 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
|
||||
changeBlockingMode(inetSock->sock, 0);
|
||||
int retval = bind(inetSock->sock, (struct sockaddr*)&saddr, len);
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
changeBlockingMode(inetSock->sock, 1);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
@@ -673,11 +687,11 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
|
||||
int retval = connect(inetSock->sock, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
if (retval < 0) {
|
||||
int hostErrno = socket_errno;
|
||||
UpdateErrnoFromHost(hostErrno, __FUNCTION__);
|
||||
int pspErrno = UpdateErrnoFromHost(__KernelGetCurThread(), hostErrno, __FUNCTION__);
|
||||
if (connectInProgress(hostErrno))
|
||||
retval = hleLogDebug(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
retval = hleLogDebug(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(pspErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
else
|
||||
retval = hleLogError(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
retval = hleLogError(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(pspErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
changeBlockingMode(inetSock->sock, 1);
|
||||
// TODO: Since we're temporarily forcing blocking-mode we'll need to change errno from ETIMEDOUT to EAGAIN
|
||||
/*if (inetLastErrno == ETIMEDOUT)
|
||||
@@ -703,7 +717,7 @@ static int sceNetInetListen(int socket, int backlog) {
|
||||
|
||||
int retval = listen(inetSock->sock, (backlog == PSP_NET_INET_SOMAXCONN ? SOMAXCONN : backlog));
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
@@ -724,7 +738,7 @@ static int sceNetInetAccept(int socket, u32 addrPtr, u32 addrLenPtr) {
|
||||
|
||||
int newHostSocket = accept(inetSock->sock, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (newHostSocket < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
return hleLogDebug(Log::sceNet, -1, "EAGAIN");
|
||||
} else {
|
||||
return hleLogError(Log::sceNet, -1);
|
||||
@@ -735,7 +749,7 @@ static int sceNetInetAccept(int socket, u32 addrPtr, u32 addrLenPtr) {
|
||||
InetSocket *newInetSocket = g_socketManager.AdoptSocket(&newSocketId, newHostSocket, inetSock);
|
||||
if (!newInetSocket) {
|
||||
// Ran out of space. Shouldn't really happen.
|
||||
UpdateErrnoFromHost(ENOMEM, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOMEM, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, -1, "Out of socket IDs");;
|
||||
}
|
||||
|
||||
@@ -819,7 +833,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
retval = hleLogError(Log::sceNet, retval);
|
||||
@@ -848,7 +862,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", retval, datahex.c_str());
|
||||
|
||||
// Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
return hleDelayResult(hleLogInfo(Log::sceNet, retval,
|
||||
return hleDelayResult(hleLogDebug(Log::sceNet, retval,
|
||||
"RecvFrom: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port)), "workaround until blocking-socket", 500);
|
||||
}
|
||||
|
||||
@@ -914,14 +928,14 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
}
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
return hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
}
|
||||
|
||||
return hleLogInfo(Log::sceNet, retval, "SendTo: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
return hleLogDebug(Log::sceNet, retval, "SendTo: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
}
|
||||
|
||||
// Similar to POSIX's sendmsg or Winsock2's WSASendMsg? Are their packets compatible one another?
|
||||
@@ -930,7 +944,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
// Note: sendmsg is concatenating iovec buffers before sending it, and send/sendto is just a wrapper for sendmsg according to https://stackoverflow.com/questions/4258834/how-sendmsg-works
|
||||
int retval = -1;
|
||||
if (!Memory::IsValidAddress(msghdrPtr)) {
|
||||
UpdateErrnoFromHost(EFAULT, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
|
||||
@@ -955,7 +969,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
iovec* iov = (iovec*)malloc(pspMsghdr->msg_iovlen * iovecsize);
|
||||
#endif
|
||||
if (iov == NULL) {
|
||||
UpdateErrnoFromHost(ENOBUFS, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOBUFS, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
memset(iov, 0, pspMsghdr->msg_iovlen * iovecsize);
|
||||
@@ -1003,7 +1017,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
chdr = (cmsghdr*)malloc(pspMsghdr->msg_controllen);
|
||||
#endif
|
||||
if (chdr == NULL) {
|
||||
UpdateErrnoFromHost(ENOBUFS, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOBUFS, __FUNCTION__);
|
||||
free(iov);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
@@ -1113,7 +1127,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
free(buf);
|
||||
*/
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
return hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
@@ -1135,7 +1149,7 @@ static int sceNetInetRecvmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
// Reference: http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch14lev1sec5.html
|
||||
int retval = -1;
|
||||
if (!Memory::IsValidAddress(msghdrPtr)) {
|
||||
UpdateErrnoFromHost(EFAULT, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointer(msghdrPtr);
|
||||
@@ -1154,7 +1168,7 @@ static int sceNetInetRecvmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
iovec* iov = (iovec*)malloc(pspMsghdr->msg_iovlen * iovecsize);
|
||||
#endif
|
||||
if (iov == NULL) {
|
||||
UpdateErrnoFromHost(ENOBUFS, __FUNCTION__);
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), ENOBUFS, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
memset(iov, 0, pspMsghdr->msg_iovlen * iovecsize);
|
||||
|
||||
@@ -259,7 +259,7 @@ static int sceNetResolverCreate(u32 resolverIdPtr, u32 bufferPtr, int bufferLen)
|
||||
};
|
||||
|
||||
Memory::WriteUnchecked_U32(currentNetResolverId, resolverIdPtr);
|
||||
return hleLogInfo(Log::sceNet, 0, "ID: %d", currentNetResolverId);
|
||||
return hleLogDebug(Log::sceNet, 0, "ID: %d", currentNetResolverId);
|
||||
}
|
||||
|
||||
static int sceNetResolverStop(u32 resolverId) {
|
||||
@@ -278,7 +278,7 @@ static int sceNetResolverStop(u32 resolverId) {
|
||||
}
|
||||
|
||||
resolverIter->second.isRunning = false;
|
||||
return hleLogInfo(Log::sceNet, 0);
|
||||
return hleLogDebug(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
static int sceNetResolverDelete(u32 resolverId) {
|
||||
@@ -292,7 +292,7 @@ static int sceNetResolverDelete(u32 resolverId) {
|
||||
}
|
||||
g_netResolvers.erase(resolverIter);
|
||||
|
||||
return hleLogInfo(Log::sceNet, 0);
|
||||
return hleLogDebug(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
const HLEFunction sceNetResolver[] = {
|
||||
|
||||
@@ -88,6 +88,8 @@ static void NotifyLoadStatusAtrac(int state, u32 loadAddr, u32 totalSize) {
|
||||
if ((DisableHLEFlags)g_Config.iDisableHLE & DisableHLEFlags::sceAtrac) {
|
||||
ERROR_LOG(Log::ME, "sceAtrac HLE is disabled, and the game tries to load sceAtrac from firmware - this won't work!");
|
||||
_dbg_assert_(false);
|
||||
|
||||
// Actually, if the user has an F0 (psardumper) dump, we could go look for the file there.
|
||||
}
|
||||
|
||||
// We try to imitate a recent version of the prx.
|
||||
|
||||
+2
-2
@@ -283,7 +283,7 @@ void GamePauseScreen::update() {
|
||||
const bool networkConnected = IsNetworkConnected();
|
||||
const InfraDNSConfig &dnsConfig = GetInfraDNSConfig();
|
||||
if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected || lastOnline_ != networkConnected || lastDNSConfigLoaded_ != dnsConfig.loaded) {
|
||||
INFO_LOG(Log::sceNet, "Network status changed, recreating views");
|
||||
INFO_LOG(Log::sceNet, "Network status changed (or pause dialog just popped up), recreating views");
|
||||
RecreateViews();
|
||||
lastNetInetInited_ = netInetInited;
|
||||
lastNetInited_ = g_netInited;
|
||||
@@ -388,7 +388,7 @@ void GamePauseScreen::CreateViews() {
|
||||
char buf[512];
|
||||
size_t sz = Achievements::GetRichPresenceMessage(buf, sizeof(buf));
|
||||
if (sz != (size_t)-1) {
|
||||
leftColumnItems->Add(new TextView(std::string_view(buf, sz), new UI::LinearLayoutParams(Margins(5, 5))))->SetSmall(true);
|
||||
leftColumnItems->Add(new TextView(std::string_view(buf, sz), FLAG_WRAP_TEXT, true, new UI::LinearLayoutParams(Margins(5, 5))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
"group": "MOHH Revival",
|
||||
"url": "https://mohh-revival.pages.dev/"
|
||||
},
|
||||
"dns": "ablondel.ddns.net",
|
||||
"dns": "86.223.243.173",
|
||||
"dyn_dns": "ablondel.ddns.net",
|
||||
"domains": {
|
||||
"pspmoh07.ea.com": "ablondel.ddns.net",
|
||||
"tos.ea.com": "ablondel.ddns.net"
|
||||
"pspmoh07.ea.com": "86.223.243.173",
|
||||
"tos.ea.com": "86.223.243.173"
|
||||
},
|
||||
"score": 5,
|
||||
"known_working_ids": [
|
||||
|
||||
Reference in new issue
Block a user