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 globalinstancereturn
Returns: &
Methods
Section titled “Methods”void Reset()Reset all state to defaults.
Used for testing and cleanup.
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)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 LDNreturn
Returns: bool
GetActiveProcessId
Section titled “GetActiveProcessId”u64 GetActiveProcessId()Get the process ID of the active game.
Process ID, or 0 if no game is activereturn
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 clearparam
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:ureturn
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:ureturn
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 LDNparam
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 whitelistreturn
Parameters:
program_id(u64)
Returns: bool
GetWhitelistSize
Section titled “GetWhitelistSize”size_t GetWhitelistSize()Get the number of games in the whitelist.
Number of games loadedreturn
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 stateparam
Parameters:
state(CommState)
GetLdnState
Section titled “GetLdnState”CommState GetLdnState()Get current LDN communication state.
Current LDN statereturn
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 hostparam
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 hostparam
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 IPCreturn
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 millisecondsparam
Parameters:
rtt_ms(u32)
GetLastRtt
Section titled “GetLastRtt”u32 GetLastRtt()Get last measured RTT.
Round-trip time in milliseconds, or 0 if not measuredreturn
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.
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)return
Returns: bool
Methods
Section titled “Methods”SharedState
Section titled “SharedState”void SharedState()SharedState
Section titled “SharedState”void SharedState(const&)Parameters:
param(const&)
operator=
Section titled “operator=”& operator=(const&)Parameters:
param(const&)
Returns: &