Add comments (checked that no other host socket numbers leak to the game)

This commit is contained in:
Henrik Rydgård
2025-01-10 12:09:58 +01:00
parent 7f3ff50afb
commit 885724db83
4 changed files with 10 additions and 4 deletions
+1
View File
@@ -1813,6 +1813,7 @@ int getLocalIp(sockaddr_in* SocketAddress) {
}
#else // Alternative way
// Socket doesn't "leak" to the game.
int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock != SOCKET_ERROR) {
const char* kGoogleDnsIp = "8.8.8.8"; // Needs to be an IP string so it can be resolved as fast as possible to IP, doesn't need to be reachable
+6 -2
View File
@@ -1379,6 +1379,7 @@ int sceNetAdhocPdpCreate(const char *mac, int port, int bufferSize, u32 flag) {
// Valid MAC supplied. FIXME: MAC only valid after successful attempt to Create/Connect/Join a Group? (ie. adhocctlCurrentMode != ADHOCCTL_MODE_NONE)
if ((adhocctlCurrentMode != ADHOCCTL_MODE_NONE) && isLocalMAC(saddr)) {
// Create Internet UDP Socket
// Socket is remapped through adhocSockets
int usocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
// Valid Socket produced
if (usocket != INVALID_SOCKET) {
@@ -3257,6 +3258,7 @@ int RecreatePtpSocket(int ptpId) {
closesocket(sock->data.ptp.id);
// Create a new socket
// Socket is remapped through adhocSockets
int tcpsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Valid Socket produced
@@ -3375,7 +3377,8 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
// Valid Arguments
if (bufsize > 0 && rexmt_int > 0 && rexmt_cnt > 0) {
// Create Infrastructure Socket
// Create Infrastructure Socket (?)
// Socket is remapped through adhocSockets
int tcpsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Valid Socket produced
@@ -3977,7 +3980,8 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
// Valid Arguments
if (bufsize > 0 && rexmt_int > 0 && rexmt_cnt > 0 && backlog > 0)
{
// Create Infrastructure Socket
// Create Infrastructure Socket (?)
// Socket is remapped through adhocSockets
int tcpsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Valid Socket produced
+1
View File
@@ -321,6 +321,7 @@ int sceNetInetPoll(u32 fdsPtr, u32 nfds, int timeout) { // timeout in milisecond
FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
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.
inetLastErrno = EINVAL;
return hleLogError(Log::sceNet, -1, "invalid socket id");
}
+2 -2
View File
@@ -96,8 +96,8 @@ typedef struct SceNetInetLinger {
// Polling Event Field
typedef struct SceNetInetPollfd { //similar format to pollfd in 32bit (pollfd in 64bit have different size)
s32_le fd;
s16_le events;
s16_le revents;
s16_le events; // requested events
s16_le revents; // returned events
} PACK SceNetInetPollfd;
// TCP & UDP Socket Union (Internal use only)