Added network info

This commit is contained in:
2026-04-17 17:00:03 -05:00
parent 39c775872a
commit 8f2f1fd496
11 changed files with 216 additions and 3 deletions
+1
View File
@@ -14,5 +14,6 @@
#define networkPlatformIsConnected networkPSPIsConnected
#define networkPlatformRequestConnection networkPSPRequestConnection
#define networkPlatformRequestDisconnection networkPSPRequestDisconnection
#define networkPlatformGetInfo networkPSPGetInfo
typedef networkpsp_t networkplatform_t;
+24
View File
@@ -232,4 +232,28 @@ errorret_t networkPSPTerm() {
}
errorOk();
}
networkinfo_t networkPSPGetInfo() {
networkinfo_t netInfo;
memoryZero(&netInfo, sizeof(networkinfo_t));
// Get the IP address of the current connection.
union SceNetApctlInfo info;
int ret = sceNetApctlGetInfo(PSP_NET_APCTL_INFO_IP, &info);
assertTrue(ret >= 0, "Failed to get IP address");
// Parse the IP address string into octets.
netInfo.type = NETWORK_TYPE_IPV4;
ret = sscanf(
info.ip,
"%hhu.%hhu.%hhu.%hhu",
&netInfo.ipv4.ip[0],
&netInfo.ipv4.ip[1],
&netInfo.ipv4.ip[2],
&netInfo.ipv4.ip[3]
);
assertTrue(ret == 4, "Failed to parse IP address");
return netInfo;
}
+9 -1
View File
@@ -7,6 +7,7 @@
#pragma once
#include "error/error.h"
#include "network/networkinfo.h"
#include "system/systempsp.h"
#include <psphttp.h>
#include <pspnet.h>
@@ -99,4 +100,11 @@ void networkPSPRequestDisconnection(
*
* @return Error state (if any).
*/
errorret_t networkPSPTerm();
errorret_t networkPSPTerm();
/**
* Gets the network information for the currently active network connection.
*
* @return Network information for the currently active network connection.
*/
networkinfo_t networkPSPGetInfo();