mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
rpcn: signaling handler improvements & upnp
Simplify signaling by making Matching2 a layer over normal signaling. Implements UPNP port forwarding Implement sceNpMatching2AbortRequest Fix reported bw in sceNpUtil Hack for Fat Princess binding udp on 3658 Reenable CB for sceNpBasicAddPlayersHistoryAsync Misc fixes
This commit is contained in:
parent
364c33060b
commit
6186ac0245
45 changed files with 1290 additions and 747 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "sceNp2.h"
|
||||
#include "Emu/NP/np_handler.h"
|
||||
#include "Emu/NP/np_contexts.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
#include "cellSysutil.h"
|
||||
|
||||
LOG_CHANNEL(sceNp2);
|
||||
|
|
@ -444,20 +445,35 @@ error_code sceNpMatching2SignalingGetConnectionStatus(
|
|||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto [res, npid] = nph.local_get_npid(roomId, memberId);
|
||||
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (np::is_same_npid(nph.get_npid(), *npid))
|
||||
return SCE_NP_SIGNALING_ERROR_OWN_NP_ID;
|
||||
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
|
||||
const auto si = sigh.get_sig2_infos(roomId, memberId);
|
||||
auto conn_id = sigh.get_conn_id_from_npid(*npid);
|
||||
if (!conn_id)
|
||||
return SCE_NP_SIGNALING_ERROR_CONN_NOT_FOUND;
|
||||
|
||||
*connStatus = si.connStatus;
|
||||
const auto si = sigh.get_sig_infos(*conn_id);
|
||||
|
||||
if (!si)
|
||||
return SCE_NP_SIGNALING_ERROR_CONN_NOT_FOUND;
|
||||
|
||||
*connStatus = si->conn_status;
|
||||
|
||||
if (peerAddr)
|
||||
{
|
||||
(*peerAddr).np_s_addr = si.addr; // infos.addr is already BE
|
||||
(*peerAddr).np_s_addr = si->addr; // infos.addr is already BE
|
||||
}
|
||||
|
||||
if (peerPort)
|
||||
{
|
||||
*peerPort = si.port;
|
||||
*peerPort = si->port;
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
|
@ -616,42 +632,58 @@ error_code sceNpMatching2SignalingGetConnectionInfo(
|
|||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto [res, npid] = nph.local_get_npid(roomId, memberId);
|
||||
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (np::is_same_npid(nph.get_npid(), *npid))
|
||||
return SCE_NP_SIGNALING_ERROR_OWN_NP_ID;
|
||||
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
const auto si = sigh.get_sig2_infos(roomId, memberId);
|
||||
|
||||
auto conn_id = sigh.get_conn_id_from_npid(*npid);
|
||||
if (!conn_id)
|
||||
return SCE_NP_SIGNALING_ERROR_CONN_NOT_FOUND;
|
||||
|
||||
const auto si = sigh.get_sig_infos(*conn_id);
|
||||
|
||||
if (!si)
|
||||
return SCE_NP_SIGNALING_ERROR_CONN_NOT_FOUND;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case SCE_NP_SIGNALING_CONN_INFO_RTT:
|
||||
{
|
||||
connInfo->rtt = si.rtt;
|
||||
connInfo->rtt = si->rtt;
|
||||
sceNp2.warning("Returning a RTT of %d microseconds", connInfo->rtt);
|
||||
break;
|
||||
}
|
||||
case SCE_NP_SIGNALING_CONN_INFO_BANDWIDTH:
|
||||
{
|
||||
connInfo->bandwidth = 10'000'000; // 10 MBPS HACK
|
||||
connInfo->bandwidth = 100'000'000; // 100 MBPS HACK
|
||||
break;
|
||||
}
|
||||
case SCE_NP_SIGNALING_CONN_INFO_PEER_NPID:
|
||||
{
|
||||
connInfo->npId = si.npid;
|
||||
connInfo->npId = si->npid;
|
||||
break;
|
||||
}
|
||||
case SCE_NP_SIGNALING_CONN_INFO_PEER_ADDRESS:
|
||||
{
|
||||
connInfo->address.port = std::bit_cast<u16, be_t<u16>>(si.port);
|
||||
connInfo->address.addr.np_s_addr = si.addr;
|
||||
connInfo->address.port = std::bit_cast<u16, be_t<u16>>(si->port);
|
||||
connInfo->address.addr.np_s_addr = si->addr;
|
||||
break;
|
||||
}
|
||||
case SCE_NP_SIGNALING_CONN_INFO_MAPPED_ADDRESS:
|
||||
{
|
||||
connInfo->address.port = std::bit_cast<u16, be_t<u16>>(si.mapped_port);
|
||||
connInfo->address.addr.np_s_addr = si.mapped_addr;
|
||||
connInfo->address.port = std::bit_cast<u16, be_t<u16>>(si->mapped_port);
|
||||
connInfo->address.addr.np_s_addr = si->mapped_addr;
|
||||
break;
|
||||
}
|
||||
case SCE_NP_SIGNALING_CONN_INFO_PACKET_LOSS:
|
||||
{
|
||||
connInfo->packet_loss = 1; // HACK
|
||||
connInfo->packet_loss = 0; // HACK
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -709,7 +741,7 @@ error_code sceNpMatching2GetRoomMemberDataExternalList(SceNpMatching2ContextId c
|
|||
|
||||
error_code sceNpMatching2AbortRequest(SceNpMatching2ContextId ctxId, SceNpMatching2RequestId reqId)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2AbortRequest(ctxId=%d, reqId=%d)", ctxId, reqId);
|
||||
sceNp2.warning("sceNpMatching2AbortRequest(ctxId=%d, reqId=%d)", ctxId, reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
|
|
@ -728,6 +760,9 @@ error_code sceNpMatching2AbortRequest(SceNpMatching2ContextId ctxId, SceNpMatchi
|
|||
return SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!nph.abort_request(reqId))
|
||||
return SCE_NP_MATCHING2_ERROR_REQUEST_NOT_FOUND;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1591,7 +1626,7 @@ error_code sceNpMatching2SignalingCancelPeerNetInfo(SceNpMatching2ContextId ctxI
|
|||
|
||||
error_code sceNpMatching2SignalingGetLocalNetInfo(vm::ptr<SceNpMatching2SignalingNetInfo> netinfo)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetLocalNetInfo(netinfo=*0x%x)", netinfo);
|
||||
sceNp2.warning("sceNpMatching2SignalingGetLocalNetInfo(netinfo=*0x%x)", netinfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
|
|
@ -1600,12 +1635,17 @@ error_code sceNpMatching2SignalingGetLocalNetInfo(vm::ptr<SceNpMatching2Signalin
|
|||
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (!netinfo)
|
||||
if (!netinfo || netinfo->size != sizeof(SceNpMatching2SignalingNetInfo))
|
||||
{
|
||||
// TODO: check netinfo->size
|
||||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
netinfo->localAddr = nph.get_local_ip_addr();
|
||||
netinfo->mappedAddr = nph.get_public_ip_addr();
|
||||
|
||||
// Pure speculation below
|
||||
netinfo->natStatus = SCE_NP_SIGNALING_NETINFO_NAT_STATUS_TYPE2;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1639,9 +1679,8 @@ error_code sceNpMatching2SignalingGetPeerNetInfoResult(SceNpMatching2ContextId c
|
|||
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (!netinfo)
|
||||
if (!netinfo || netinfo->size != sizeof(SceNpMatching2SignalingNetInfo))
|
||||
{
|
||||
// TODO: check netinfo->size
|
||||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue