Logging and debugger improvements (minor)

This commit is contained in:
Henrik Rydgård 2025-01-27 17:30:33 +01:00
parent 1c48910fd7
commit c0fabbf0dc
4 changed files with 32 additions and 11 deletions

View file

@ -76,7 +76,7 @@ bool isAdhocctlNeedLogin = false;
bool isAdhocctlBusy = false;
int adhocctlState = ADHOCCTL_STATE_DISCONNECTED;
int adhocctlCurrentMode = ADHOCCTL_MODE_NONE;
int adhocConnectionType = ADHOC_CONNECT;
AdhocConnectionType adhocConnectionType = ADHOC_CONNECT;
int gameModeSocket = (int)INVALID_SOCKET; // UDP/PDP socket? on Master only?
int gameModeBuffSize = 0;
@ -2457,3 +2457,12 @@ const char *AdhocCtlStateToString(int state) {
default: return "(unk)";
}
}
const char *AdhocConnectionTypeToString(AdhocConnectionType type) {
switch (type) {
case ADHOC_CONNECT: return "CONNECT";
case ADHOC_JOIN: return "JOIN";
case ADHOC_CREATE: return "CREATE";
default: return "UNKNOWN";
}
}

View file

@ -857,6 +857,12 @@ union SockAddrIN4 {
sockaddr_in in;
};
enum AdhocConnectionType : int {
ADHOC_CONNECT = 0,
ADHOC_CREATE = 1,
ADHOC_JOIN = 2,
};
extern uint16_t portOffset;
extern uint32_t minSocketTimeoutUS;
extern bool isOriPort;
@ -879,7 +885,7 @@ extern bool isAdhocctlNeedLogin;
extern bool isAdhocctlBusy;
extern int adhocctlState;
extern int adhocctlCurrentMode;
extern int adhocConnectionType;
extern AdhocConnectionType adhocConnectionType;
extern int gameModeSocket;
extern int gameModeBuffSize;
@ -891,13 +897,6 @@ extern std::vector<SceNetEtherAddr> gameModeMacs;
extern std::map<SceNetEtherAddr, u16_le> gameModePeerPorts;
// End of Aux vars
enum AdhocConnectionType : int
{
ADHOC_CONNECT = 0,
ADHOC_CREATE = 1,
ADHOC_JOIN = 2,
};
// Check if Matching callback is running
bool IsMatchingInCallback(SceNetAdhocMatchingContext * context);
bool SetMatchingInCallback(SceNetAdhocMatchingContext* context, bool IsInCB);
@ -1415,3 +1414,5 @@ const char* getMatchingOpcodeStr(int code);
// Convert adhoc ctl state to string
const char *AdhocCtlStateToString(int state);
const char *AdhocConnectionTypeToString(AdhocConnectionType type);

View file

@ -129,7 +129,7 @@ static u32 sceNetInetInetNtop(int af, u32 srcInAddrPtr, u32 dstBufPtr, u32 bufsi
static u32_le sceNetInetInetAddr(const char *hostname) {
if (hostname == nullptr || hostname[0] == '\0') {
return hleLogError(Log::sceNet, INADDR_NONE, "invalid arg");
return hleLogError(Log::sceNet, INADDR_NONE, "invalid arg ('')", hostname);
}
u32 retval = INADDR_NONE; // inet_addr(hostname); // deprecated?
@ -622,6 +622,8 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
getLocalIp(&sockAddr);
WARN_LOG(Log::sceNet, "Bind: Address Replacement = %s => %s", ip2str(saddr.in.sin_addr).c_str(), ip2str(sockAddr.sin_addr).c_str());
saddr.in.sin_addr.s_addr = sockAddr.sin_addr.s_addr;
} else {
WARN_LOG(Log::sceNet, "Bind: Address Replacement is off: %s", ip2str(saddr.in.sin_addr).c_str());
}
// TODO: Make use Port Offset only for PPSSPP to PPSSPP communications (ie. IP addresses available in the group/friendlist), otherwise should be considered as Online Service thus should use the port as is.
//saddr.in.sin_port = htons(ntohs(saddr.in.sin_port) + portOffset);

View file

@ -540,13 +540,20 @@ static void DrawApctl(ImConfig &cfg) {
return;
}
if (ImGui::CollapsingHeader("Localhost")) {
SceNetEtherAddr mac;
getLocalMac(&mac);
ImGui::Text("%s (%s)", ip2str(g_localhostIP.in.sin_addr).c_str(), mac2str(&mac).c_str());
ImGui::Text("Port offset: %d", g_Config.iPortOffset);
}
ImGui::Text("State: %s", ApctlStateToString(netApctlState));
if (netApctlState != PSP_NET_APCTL_STATE_DISCONNECTED && ImGui::CollapsingHeader("ApCtl Details")) {
ImGui::Text("Name: %s", netApctlInfo.name);
ImGui::Text("IP: %s", netApctlInfo.ip);
ImGui::Text("SubnetMask: %s", netApctlInfo.ip);
ImGui::Text("SSID: %.*s", netApctlInfo.ssidLength, netApctlInfo.ssid);
ImGui::Text("SSID: %.*s", netApctlInfo.ssidLength, netApctlInfo.ssid);
ImGui::Text("Proxy enabled", BoolStr(netApctlInfo.useProxy));
ImGui::Text("Gateway: %s", netApctlInfo.gateway);
ImGui::Text("PrimaryDNS: %s", netApctlInfo.primaryDns);
ImGui::Text("SecondaryDNS: %s", netApctlInfo.secondaryDns);
@ -646,6 +653,8 @@ static void DrawAdhoc(ImConfig &cfg) {
ImGui::Text("GameMode entered: %s", BoolStr(netAdhocGameModeEntered));
ImGui::Text("FriendFinder running: %s", BoolStr(g_adhocServerConnected));
ImGui::Text("sceNetAdhocDiscover status: %s", discoverStatusStr);
ImGui::Text("isLocalServer: %s", BoolStr(isLocalServer));
ImGui::Text("adhocConnectionType %s", AdhocConnectionTypeToString(adhocConnectionType));
if (ImGui::BeginTable("sock", 5, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH | ImGuiTableFlags_Resizable)) {
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed);