mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-01 02:03:47 +01:00
Shows a warning log when bound port is shifted to negative port (may cause port issue when wrapped to 1024 or lower on android)
This commit is contained in:
1 parent
a062c177a3
commit
d23e1c0949
1 file changed
+6
@@ -1259,6 +1259,8 @@ static int sceNetAdhocPdpCreate(const char *mac, int port, int bufferSize, u32 f
|
||||
// Update sport with the port assigned internal->lport = ntohs(local.sin_port)
|
||||
socklen_t len = sizeof(addr);
|
||||
if (getsockname(usocket, (sockaddr*)&addr, &len) == 0) {
|
||||
if (port + static_cast<int>(portOffset) > 65535 || static_cast<int>(ntohs(addr.sin_port)) - static_cast<int>(portOffset) <= 0)
|
||||
WARN_LOG(SCENET, "sceNetAdhocPdpCreate - Shifting to Negative Port: %d -> %d -> %d", port, port + portOffset, ntohs(addr.sin_port) - portOffset);
|
||||
port = ntohs(addr.sin_port) - portOffset;
|
||||
}
|
||||
|
||||
@@ -3155,6 +3157,8 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
|
||||
// Update sport with the port assigned internal->lport = ntohs(local.sin_port)
|
||||
socklen_t len = sizeof(addr);
|
||||
if (getsockname(tcpsocket, (sockaddr*)&addr, &len) == 0) {
|
||||
if (sport + static_cast<int>(portOffset) > 65535 || static_cast<int>(ntohs(addr.sin_port)) - static_cast<int>(portOffset) <= 0)
|
||||
WARN_LOG(SCENET, "sceNetAdhocPtpOpen - Shifting to Negative Port: %d -> %d -> %d", sport, sport + portOffset, ntohs(addr.sin_port) - portOffset);
|
||||
sport = ntohs(addr.sin_port) - portOffset;
|
||||
}
|
||||
|
||||
@@ -3718,6 +3722,8 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
|
||||
// Update sport with the port assigned internal->lport = ntohs(local.sin_port)
|
||||
socklen_t len = sizeof(addr);
|
||||
if (getsockname(tcpsocket, (sockaddr*)&addr, &len) == 0) {
|
||||
if (sport + static_cast<int>(portOffset) > 65535 || static_cast<int>(ntohs(addr.sin_port)) - static_cast<int>(portOffset) <= 0)
|
||||
WARN_LOG(SCENET, "sceNetAdhocPtpListen - Shifting to Negative Port: %d -> %d -> %d", sport, sport + portOffset, ntohs(addr.sin_port) - portOffset);
|
||||
sport = ntohs(addr.sin_port) - portOffset;
|
||||
}
|
||||
// Switch into Listening Mode
|
||||
|
||||
Reference in new issue
Block a user