ams::mitm::ldn::SharedState
ams::mitm::ldn::SharedState
Section titled “ams::mitm::ldn::SharedState”Members
Section titled “Members”m_mutex
Section titled “m_mutex”Type: ams::os::SdkMutex
m_game_active
Section titled “m_game_active”Type: bool
m_process_id
Section titled “m_process_id”Type: u64
m_ldn_pid
Section titled “m_ldn_pid”Type: u64
PID that opened ldn:u (set before Initialize)
m_ldn_state
Section titled “m_ldn_state”Type: CommState
m_node_count
Section titled “m_node_count”Type: u8
m_max_nodes
Section titled “m_max_nodes”Type: u8
m_local_node_id
Section titled “m_local_node_id”Type: u8
m_is_host
Section titled “m_is_host”Type: bool
m_last_rtt_ms
Section titled “m_last_rtt_ms”Type: u32
m_reconnect_requested
Section titled “m_reconnect_requested”Type: bool
m_ldn_games
Section titled “m_ldn_games”Type: std::unordered_set< u64 >
Set of program_ids with LDN support.
Methods
Section titled “Methods”GetInstance
Section titled “GetInstance”& GetInstance()Get the singleton instance.
Reference to the globalinstance @gdb{tag=“LDN:STATE”, msg=“SharedState: constructor”}return
Returns: &
Methods
Section titled “Methods”void Reset()Reset all state to defaults.
Used for testing and cleanup. @gdb{tag=“LDN:STATE”, msg=“SharedState: Reset”}
SetGameActive
Section titled “SetGameActive”void SetGameActive(bool active, u64 process_id)Set game active state.
Called by MITM service when a game initializes or finalizes LDN. When set to false, also resets all runtime state.activeTrue if a game is using LDNprocess_idProcess ID of the game (0 when inactive) @gdb{tag=“LDN:STATE”, msg=“SetGameActive: active=%d pid=%lu”, args=“$x1, $x2”}param
Parameters:
active(bool)process_id(u64)
IsGameActive
Section titled “IsGameActive”bool IsGameActive()Check if a game is actively using LDN.
True if a game is using LDN @gdb{tag=“LDN:STATE”, msg=“IsGameActive”}return
Returns: bool
GetActiveProcessId
Section titled “GetActiveProcessId”u64 GetActiveProcessId()Get the process ID of the active game.
Process ID, or 0 if no game is active @gdb{tag=“LDN:STATE”, msg=“GetActiveProcessId”}return
Returns: u64
SetLdnPid
Section titled “SetLdnPid”void SetLdnPid(u64 pid)Set the PID that has opened ldn:u service.
Called immediately whenis created, BEFORE Initialize(). This allows BSD MITM to know which process to intercept even before the game calls Initialize().pidProcess ID that opened ldn:u, or 0 to clear @gdb{tag=“LDN:STATE”, msg=“SetLdnPid: pid=%lu”, args=“$x1”}param
Parameters:
pid(u64)
GetLdnPid
Section titled “GetLdnPid”u64 GetLdnPid()Get the PID that has opened ldn:u service.
Process ID, or 0 if no process has opened ldn:u @gdb{tag=“LDN:STATE”, msg=“GetLdnPid”}return
Returns: u64
IsLdnPid
Section titled “IsLdnPid”bool IsLdnPid(u64 pid)Check if a PID has opened ldn:u.
pidProcess ID to checkparamtrue if this PID has opened ldn:u @gdb{tag=“LDN:STATE”, msg=“IsLdnPid: pid=%lu”, args=“$x1”}return
Parameters:
pid(u64)
Returns: bool
LoadLdnWhitelist
Section titled “LoadLdnWhitelist”void LoadLdnWhitelist(const std::vector< u64 > & game_ids)Load the LDN game whitelist.
Called at startup to load the list of games that support LDN. This replaces any existing whitelist.game_idsVector of program IDs that support LDN @gdb{tag=“LDN:STATE”, msg=“LoadLdnWhitelist”}param
Parameters:
game_ids(const std::vector< u64 > &)
IsLdnGame
Section titled “IsLdnGame”bool IsLdnGame(u64 program_id)Check if a program_id is in the LDN whitelist.
Called by BSD ShouldMitm to decide whether to intercept.program_idThe program ID to checkparamtrue if this program is in the whitelist @gdb{tag=“LDN:STATE”, msg=“IsLdnGame: program_id=0x%lx”, args=“$x1”}return
Parameters:
program_id(u64)
Returns: bool
GetWhitelistSize
Section titled “GetWhitelistSize”size_t GetWhitelistSize()Get the number of games in the whitelist.
Number of games loaded @gdb{tag=“LDN:STATE”, msg=“GetWhitelistSize”}return
Returns: size_t
SetLdnState
Section titled “SetLdnState”void SetLdnState(CommState state)Set current LDN communication state.
Called by MITM service on state transitions.stateNew LDN state @gdb{tag=“LDN:STATE”, msg=“SetLdnState: state=%d”, args=“$x1”}param
Parameters:
state(CommState)
GetLdnState
Section titled “GetLdnState”CommState GetLdnState()Get current LDN communication state.
Current LDN state @gdb{tag=“LDN:STATE”, msg=“GetLdnState”}return
Returns: CommState
SetSessionInfo
Section titled “SetSessionInfo”void SetSessionInfo(u8 node_count, u8 max_nodes, u8 local_node_id, bool is_host)Set session information.
Called by MITM service when network info is updated.node_countCurrent number of nodesmax_nodesMaximum nodes allowedlocal_node_idThis node’s IDis_hostTrue if this node is the host @gdb{tag=“LDN:STATE”, msg=“SetSessionInfo: node_count=%d max=%d local=%d is_host=%d”, args=“$x1, $x2, $x3, $x4”}param
Parameters:
node_count(u8)max_nodes(u8)local_node_id(u8)is_host(bool)
GetSessionInfo
Section titled “GetSessionInfo”void GetSessionInfo(u8 & node_count, u8 & max_nodes, u8 & local_node_id, bool & is_host)Get session information.
node_countCurrent number of nodesmax_nodesMaximum nodes allowedlocal_node_idThis node’s IDis_hostTrue if this node is the host @gdb{tag=“LDN:STATE”, msg=“GetSessionInfo”}param
Parameters:
node_count(u8 &)max_nodes(u8 &)local_node_id(u8 &)is_host(bool &)
GetSessionInfoStruct
Section titled “GetSessionInfoStruct”SessionInfo GetSessionInfoStruct()Get session information as struct.
structure for IPC @gdb{tag=“LDN:STATE”, msg=“GetSessionInfoStruct”}return
Returns: SessionInfo
SetLastRtt
Section titled “SetLastRtt”void SetLastRtt(u32 rtt_ms)Set last measured RTT.
Called by network client after ping response.rtt_msRound-trip time in milliseconds @gdb{tag=“LDN:STATE”, msg=“SetLastRtt: rtt=%u”, args=“$x1”}param
Parameters:
rtt_ms(u32)
GetLastRtt
Section titled “GetLastRtt”u32 GetLastRtt()Get last measured RTT.
Round-trip time in milliseconds, or 0 if not measured @gdb{tag=“LDN:STATE”, msg=“GetLastRtt”}return
Returns: u32
RequestReconnect
Section titled “RequestReconnect”void RequestReconnect()Request a reconnection.
Called by config service when user requests reconnect from overlay. The MITM service should periodically check and consume this flag. @gdb{tag=“LDN:STATE”, msg=“RequestReconnect”}
ConsumeReconnectRequest
Section titled “ConsumeReconnectRequest”bool ConsumeReconnectRequest()Consume reconnect request.
Called by MITM service to check and clear the reconnect flag.True if reconnect was requested (flag is cleared) @gdb{tag=“LDN:STATE”, msg=“ConsumeReconnectRequest”}return
Returns: bool
Methods
Section titled “Methods”SharedState
Section titled “SharedState”void SharedState()@gdb{tag=“LDN:STATE”, msg=“SharedState: constructor”}
SharedState
Section titled “SharedState”void SharedState(const&)Parameters:
param(const&)
operator=
Section titled “operator=”& operator=(const&)Parameters:
param(const&)
Returns: &