ams::mitm::ldn::LdnNodeMapper
ams::mitm::ldn::LdnNodeMapper
Section titled “ams::mitm::ldn::LdnNodeMapper”Node mapper for LDN proxy data routing.
Maps node IDs to their network information for routing proxy data. Thread-safe using SdkMutex.
Members
Section titled “Members”MaxNodes
Section titled “MaxNodes”Type: constexpr size_t
Maximum number of nodes in LDN network.
BroadcastNodeId
Section titled “BroadcastNodeId”Type: constexpr u32
Broadcast destination node ID.
Members
Section titled “Members”m_mutex
Section titled “m_mutex”Type: os::SdkMutex
Thread safety mutex.
m_nodes
Section titled “m_nodes”Type: NodeEntry
Node entries.
m_local_node_id
Section titled “m_local_node_id”Type: u8
This client’s node ID.
Methods
Section titled “Methods”LdnNodeMapper
Section titled “LdnNodeMapper”void LdnNodeMapper()Constructor - initializes empty node map.
Sets up all node entries with default values:
AddNode
Section titled “AddNode”void AddNode(u32 node_id, u32 ipv4)Add or update a node in the map.
Called when a new player joins the network or when network info is synchronized. If the node already exists, its IP is updated.node_idNode ID (0-7), ignored if >= MaxNodesipv4IPv4 address in network byte orderparam
Parameters:
node_id(u32)ipv4(u32)
RemoveNode
Section titled “RemoveNode”void RemoveNode(u32 node_id)Remove a node from the map.
Called when a player disconnects from the network. The entry is marked as disconnected but IP is preserved for potential reconnection scenarios.node_idNode ID to remove, ignored if >= MaxNodesparam
Parameters:
node_id(u32)
IsNodeConnected
Section titled “IsNodeConnected”bool IsNodeConnected(u32 node_id)Check if a node is connected.
Used before attempting to route data to a node.node_idNode ID to checkparamtrue if node exists and is connected, false otherwisereturn
Parameters:
node_id(u32)
Returns: bool
GetNodeIp
Section titled “GetNodeIp”u32 GetNodeIp(u32 node_id)Get node’s IPv4 address.
Returns the IPv4 address for routing packets to this node.node_idNode IDparamIPv4 address in network byte order, 0 if node not foundreturn
Parameters:
node_id(u32)
Returns: u32
GetConnectedCount
Section titled “GetConnectedCount”size_t GetConnectedCount()Get number of connected nodes.
Counts all nodes marked as connected. Used for statistics and to determine broadcast target count.Number of connected nodes (0-8)return
Returns: size_t
void Clear()Clear all nodes.
Resets the mapper to initial state. Called when:
UpdateFromNetworkInfo
Section titled “UpdateFromNetworkInfo”void UpdateFromNetworkInfo(const& info)Update fromstructure.
Synchronizes the node map with thereceived from the server. This replaces all existing node data.MappingNetworkInfo.ldn.nodes[i].nodeId → m_nodes indexNetworkInfo.ldn.nodes[i].ipv4Address → m_nodes[].ipv4_addressNetworkInfo.ldn.nodes[i].isConnected → m_nodes[].is_connectedinfoNetwork info containing node listparam
Parameters:
info(const&)
ShouldRouteToNode
Section titled “ShouldRouteToNode”bool ShouldRouteToNode(u32 dest_node_id, u32 source_node_id, u32 target_node_id)Check if packet should be routed to a specific node.
Determines whether a proxy data packet should be forwarded to a particular node based on the packet’s destination and routing rules.Routing RulesBroadcast (dest_node_id == BroadcastNodeId)Route to ALL connected nodes EXCEPT the source nodePrevents echo back to sender (specific dest_node_id)Route ONLY to the destination nodeDestination must be connecteddest_node_idDestination from packet header (or BroadcastNodeId for broadcast)source_node_idSource from packet header (used to avoid echo)target_node_idThe node we’re considering routing toparamtrue if packet should be sent to target_node_idreturn
Parameters:
dest_node_id(u32)source_node_id(u32)target_node_id(u32)
Returns: bool
GetLocalNodeId
Section titled “GetLocalNodeId”u8 GetLocalNodeId()Get local node ID (this client’s node)
Local node ID (0xFF if not set)return
Returns: u8
SetLocalNodeId
Section titled “SetLocalNodeId”void SetLocalNodeId(u8 node_id)Set local node ID.
node_idLocal node IDparam
Parameters:
node_id(u8)