Improve sceNpSignalingGetLocalNetInfo
This commit is contained in:
@@ -6962,7 +6962,7 @@ error_code sceNpSignalingGetConnectionFromPeerAddress(u32 ctx_id, np_in_addr_t p
|
|||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code sceNpSignalingGetLocalNetInfo(u32 ctx_id, vm::ptr<SceNpSignalingNetInfo> info)
|
error_code sceNpSignalingGetLocalNetInfo(u32 ctx_id, vm::ptr<SceNpSignalingNetInfoDeprecated> info)
|
||||||
{
|
{
|
||||||
sceNp.warning("sceNpSignalingGetLocalNetInfo(ctx_id=%d, info=*0x%x)", ctx_id, info);
|
sceNp.warning("sceNpSignalingGetLocalNetInfo(ctx_id=%d, info=*0x%x)", ctx_id, info);
|
||||||
|
|
||||||
@@ -6973,7 +6973,8 @@ error_code sceNpSignalingGetLocalNetInfo(u32 ctx_id, vm::ptr<SceNpSignalingNetIn
|
|||||||
return SCE_NP_SIGNALING_ERROR_NOT_INITIALIZED;
|
return SCE_NP_SIGNALING_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info || info->size != sizeof(SceNpSignalingNetInfo))
|
// Library has backward support for a version of SceNpSignalingNetInfo without npport
|
||||||
|
if (!info || (info->size != sizeof(SceNpSignalingNetInfo) && info->size != sizeof(SceNpSignalingNetInfoDeprecated)))
|
||||||
{
|
{
|
||||||
return SCE_NP_SIGNALING_ERROR_INVALID_ARGUMENT;
|
return SCE_NP_SIGNALING_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
@@ -6985,7 +6986,12 @@ error_code sceNpSignalingGetLocalNetInfo(u32 ctx_id, vm::ptr<SceNpSignalingNetIn
|
|||||||
info->nat_status = SCE_NP_SIGNALING_NETINFO_NAT_STATUS_TYPE2;
|
info->nat_status = SCE_NP_SIGNALING_NETINFO_NAT_STATUS_TYPE2;
|
||||||
info->upnp_status = nph.get_upnp_status();
|
info->upnp_status = nph.get_upnp_status();
|
||||||
info->npport_status = SCE_NP_SIGNALING_NETINFO_NPPORT_STATUS_OPEN;
|
info->npport_status = SCE_NP_SIGNALING_NETINFO_NPPORT_STATUS_OPEN;
|
||||||
info->npport = SCE_NP_PORT;
|
|
||||||
|
if (info->size == sizeof(SceNpSignalingNetInfo))
|
||||||
|
{
|
||||||
|
auto new_info = vm::unsafe_ptr_cast<SceNpSignalingNetInfo>(info);
|
||||||
|
new_info->npport = SCE_NP_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1584,6 +1584,16 @@ struct SceNpSignalingNetInfo
|
|||||||
be_t<u16> npport;
|
be_t<u16> npport;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SceNpSignalingNetInfoDeprecated
|
||||||
|
{
|
||||||
|
be_t<u32> size;
|
||||||
|
be_t<u32> local_addr; // in_addr
|
||||||
|
be_t<u32> mapped_addr; // in_addr
|
||||||
|
be_t<s32> nat_status;
|
||||||
|
be_t<s32> upnp_status;
|
||||||
|
be_t<s32> npport_status;
|
||||||
|
};
|
||||||
|
|
||||||
struct SceNpCustomMenuAction
|
struct SceNpCustomMenuAction
|
||||||
{
|
{
|
||||||
be_t<u32> options;
|
be_t<u32> options;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace np
|
|||||||
|
|
||||||
std::string communication_id_to_string(const SceNpCommunicationId& communicationId)
|
std::string communication_id_to_string(const SceNpCommunicationId& communicationId)
|
||||||
{
|
{
|
||||||
const std::string com_id_data(communicationId.data, communicationId.data + 9);
|
std::string_view com_id_data(communicationId.data, communicationId.data + 9);
|
||||||
return fmt::format("%s_%02d", com_id_data, communicationId.num);
|
return fmt::format("%s_%02d", com_id_data, communicationId.num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user