LDN services: Difference between revisions

No edit summary
No edit summary
(9 intermediate revisions by 3 users not shown)
Line 90: Line 90:
|-
|-
| 0 || [[#CreateSystemLocalCommunicationService]]
| 0 || [[#CreateSystemLocalCommunicationService]]
|-
| 1 || [18.0.0+] [[#CreateClientProcessMonitor]]
|}
|}


== CreateSystemLocalCommunicationService ==
== CreateSystemLocalCommunicationService ==
Returns an [[#ISystemLocalCommunicationService]].
No input. Returns an [[#ISystemLocalCommunicationService]].


The user-process closes the ISystemServiceCreator object immediately after using this cmd. Official sw ignores errors from this cmd.
The user-process closes the ISystemServiceCreator object immediately after using this cmd. Official sw ignores errors from this cmd.
== CreateClientProcessMonitor ==
No input. Returns an [[#IClientProcessMonitor]].


== ISystemLocalCommunicationService ==
== ISystemLocalCommunicationService ==
Line 125: Line 130:
|-
|-
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
|-
| 105 || [13.1.0+] [[#SetBluetoothAudioDeviceConnectableMode]]
|-
| 106 || [18.0.0+]
|-
|-
| 200 || [[#OpenAccessPoint]]
| 200 || [[#OpenAccessPoint]]
Line 163: Line 172:
|-
|-
| 403 || [7.0.0+] [[#InitializeSystem2]]
| 403 || [7.0.0+] [[#InitializeSystem2]]
|}
=== GetState ===
No input, returns an output u32.
sdknso implements this by <code>return</code>ing the u32, with 0 being returned on error / when service isn't initialized.
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
|-
| 0 || None
| 404 || [19.0.0+]
|-
|-
| 1 || Initialized
| 500 || [18.0.0+] EnableActionFrame
|-
|-
| 2 || AccessPointOpened
| 501 || [18.0.0+] DisableActionFrame
|-
|-
| 3 || AccessPointCreated
| 502 || [18.0.0+] SendActionFrame
|-
|-
| 4 || StationOpened
| 503 || [18.0.0+] RecvActionFrame
|-
|-
| 5 || StationConnected
| 505 || [18.0.0+] SetHomeChannel
|-
|-
| 6 || Error
| 600 || [18.0.0+] SetTxPower
|-
|-
| 601 || [18.0.0+] ResetTxPower
|}
|}
=== GetState ===
No input, returns an output [[#State]].
sdknso implements this by <code>return</code>ing the u32, with 0 being returned on error / when service isn't initialized.


=== GetNetworkInfo ===
=== GetNetworkInfo ===
Line 198: Line 202:


=== GetDisconnectReason ===
=== GetDisconnectReason ===
No input, returns an output s16.
No input, returns an output [[#DisconnectReason]].


sdknso implements this by <code>return</code>ing the s16 as a s32, with -1 being returned on error.
sdknso implements this by <code>return</code>ing the s16 as a s32, with -1 being returned on error.


{| class="wikitable" border="1"
=== GetSecurityParameter ===
|-
No input, returns an output [[#SecurityParameter]].
!  Value
!  Description
|-
| -1 || See above.
|-
| 0 || None
|-
| 1 || User
|-
| 2 || SystemRequest
|-
| 3 || DestroyedByAdmin
|-
| 4 || DestroyedBySystemRequest
|-
| 5 || Admin
|-
| 6 || SignalLost
|}
 
=== GetSecurityParameter ===
No input, returns an output [[#SecurityParameter]].


=== GetNetworkConfig ===
=== GetNetworkConfig ===
Line 266: Line 248:


The input value is written into state.
The input value is written into state.
=== SetBluetoothAudioDeviceConnectableMode ===
Takes an input [[#BluetoothAudioDeviceConnectableMode]], no output.


=== OpenAccessPoint ===
=== OpenAccessPoint ===
Line 399: Line 384:


[[#GetState|State]] must be 0, this cmd eventually sets the State to value 1.
[[#GetState|State]] must be 0, this cmd eventually sets the State to value 1.
== IClientProcessMonitor ==
This is "nn::ldn::detail::IClientProcessMonitor".
This was added with [18.0.0+].
{| class="wikitable" border="1"
|-
! Cmd || Name
|-
| 0 || RegisterClient
|}


= ldn:u =
= ldn:u =
Line 408: Line 405:
|-
|-
| 0 || [[#CreateUserLocalCommunicationService]]
| 0 || [[#CreateUserLocalCommunicationService]]
|-
| 1 || [18.0.0+] [[#CreateClientProcessMonitor]]
|}
|}


Line 445: Line 444:
|-
|-
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
|-
| 105 || [13.1.0+] [[#SetBluetoothAudioDeviceConnectableMode]]
|-
| 106 || [18.0.0+]
|-
|-
| 200 || [[#OpenAccessPoint]]
| 200 || [[#OpenAccessPoint]]
Line 481: Line 484:
|-
|-
| 402 || [7.0.0+] [[#Initialize2]]
| 402 || [7.0.0+] [[#Initialize2]]
|-
| 403 || [19.0.0+]
|-
| 500 || [18.0.0+] EnableActionFrame
|-
| 501 || [18.0.0+] DisableActionFrame
|-
| 502 || [18.0.0+] SendActionFrame
|-
| 503 || [18.0.0+] RecvActionFrame
|-
| 505 || [18.0.0+] SetHomeChannel
|-
| 600 || [18.0.0+] SetTxPower
|-
| 601 || [18.0.0+] ResetTxPower
|}
|}


Line 569: Line 588:


= lp2p:app, lp2p:sys =
= lp2p:app, lp2p:sys =
These are "nn::lp2p::detail::INetworkServiceCreator".
These are "nn::lp2p::detail::ISfServiceCreator".


These were added with [9.0.0+].
These were added with [9.0.0+].
Line 585: Line 604:


== CreateNetworkService ==
== CreateNetworkService ==
Takes a PID-descriptor, a reserved input u64 and an input u32. Returns an output [[#INetworkService]].
Takes a PID-descriptor, a reserved input u64 and an input u32. Returns an output [[#ISfService]].


The input u32 must be value 0x1.
The input u32 must be value 0x1.


== CreateNetworkServiceMonitor ==
== CreateNetworkServiceMonitor ==
Takes a PID-descriptor and a reserved input u64. Returns an output [[#INetworkServiceMonitor]].
Takes a PID-descriptor and a reserved input u64. Returns an output [[#ISfServiceMonitor]].


== INetworkService ==
== ISfService ==
This is "nn::lp2p::detail::INetworkService".
This is "nn::lp2p::detail::ISfService".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 703: Line 722:
No input/output.
No input/output.


== INetworkServiceMonitor ==
== ISfServiceMonitor ==
This is "nn::lp2p::detail::INetworkServiceMonitor".
This is "nn::lp2p::detail::ISfServiceMonitor".


This interface has no commands, until [9.1.0+] which added actual commands.
This interface has no commands, until [9.1.0+] which added actual commands.
Line 799: Line 818:


= lp2p:m =
= lp2p:m =
This is "nn::lp2p::detail::IMonitorServiceCreator".
This is "nn::lp2p::monitor::detail::ISfMonitorServiceCreator".


This was added with [9.1.0+].
This was added with [9.1.0+].
Line 811: Line 830:


== CreateMonitorService ==
== CreateMonitorService ==
Takes a PID-descriptor, a reserved input u64 and an input u64. Returns an [[#IMonitorService]].
Takes a PID-descriptor, a reserved input u64 and an input u64. Returns an [[#ISfMonitorService]].


== IMonitorService ==
== ISfMonitorService ==
This is "nn::lp2p::detail::IMonitorService".
This is "nn::lp2p::monitor::detail::ISfMonitorService".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 830: Line 849:
Returns 0.
Returns 0.


= Ipv4Address =
= State =
This is "nn::ldn::Ipv4Address". This is a 0x4-byte struct with 4-byte alignment.
This is "nn::ldn::State".
 
This is essentially the same as <code>struct in_addr</code>, except this is little-endian.


This is generally "169.254.XXX.{...}", where XXX is random per created network.
{| class="wikitable" border="1"
 
|-
= SubnetMask =
!  Value
This is "nn::ldn::SubnetMask". This is a 0x4-byte struct with 4-byte alignment.
!  Description
|-
| 0 || None
|-
| 1 || Initialized
|-
| 2 || AccessPoint
|-
| 3 || AccessPointCreated
|-
| 4 || Station
|-
| 5 || StationConnected
|-
| 6 || Error
|-
|}
 
= Ipv4Address =
This is "nn::ldn::Ipv4Address". This is a 0x4-byte struct with 4-byte alignment.
 
This is essentially the same as <code>struct in_addr</code>, except this is little-endian.
 
This is generally "169.254.XXX.{...}", where XXX is random per created network.
 
= SubnetMask =
This is "nn::ldn::SubnetMask". This is a 0x4-byte struct with 4-byte alignment.


This is essentially the same as <code>struct in_addr</code>, except this is little-endian.
This is essentially the same as <code>struct in_addr</code>, except this is little-endian.
Line 853: Line 896:
! Description
! Description
|-
|-
| 0x0 || 0x1 || Length excluding NUL-terminator, must be 0x1-0x20.
| 0x0 || 0x1 || Length (excluding NUL-terminator, must be 0x1-0x20)
|-
|-
| 0x1 || 0x21 || SSID string including NUL-terminator, str[{above length}] must be 0.
| 0x1 || 0x21 || Raw (SSID string including NUL-terminator, str[{above length}] must be 0)
|}
|}


Line 947: Line 990:
| 0x4C || 0x10 || Cleared to zero for the tmp struct.
| 0x4C || 0x10 || Cleared to zero for the tmp struct.
|-
|-
| 0x5C || 0x4 || Flags. Masked with 0x37 for [[#Scan]], with [[#ScanPrivate]] this is masked with 0x3F.
| 0x5C || 0x4 || [[#ScanFilterFlag|Flag]] (masked with 0x37 for [[#Scan]], with [[#ScanPrivate]] this is masked with 0x3F)
|}
|}


Flags:
= ScanFilterFlag =
This is "nn::ldn::ScanFilterFlag".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Bit
! Value
! Description
! Description
|-
| 0x0 || None
|-
|-
| 0 || When set, enables using ScanFilter+0.
| 0x1 || LocalCommunicationId
|-
|-
| 1 || When set, enables using ScanFilter+0x10.
| 0x2 || SessionId
|-
|-
| 2 || When set, enables using ScanFilter+0x20.
| 0x4 || NetworkType
|-
|-
| 3 || When set, enables using the ScanFilter [[#MacAddress|MacAddress]].
| 0x8 || Bssid
|-
|-
| 4 || When set, enables using the ScanFilter [[#Ssid]].
| 0x10 || Ssid
|-
|-
| 5 || When set, enables using ScanFilter+0xA.
| 0x20 || SceneId
|}
|-
| 0x21 || IntentId
|-
| 0x23 || NetworkId
|-
| 0x3F || All
|}


= NetworkConfig =
= NetworkConfig =
Line 1,024: Line 1,076:
!  Description
!  Description
|-
|-
| 0 ||  
| 0 || Disabled
|-
| 1 || Enabled
|}
 
= BluetoothAudioDeviceConnectableMode =
This is "nn::ldn::BluetoothAudioDeviceConnectableMode". This is an u32 enum.
 
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
| 0 || Disabled
|-
|-
| 1 || This is the default.
| 1 || Enabled
|}
 
= SecurityMode =
This is "nn::ldn::SecurityMode". This is an u32 enum.
 
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
| 0 || Any
|-
| 1 || Product
|-
| 2 || Debug
|-
| 3 || SystemDebug
|}
|}


Line 1,038: Line 1,120:
! Description
! Description
|-
|-
| 0x0 || 0x2 || Type, a default of value 1 can be used here. Overwritten by [[#CreateNetwork]]/[[#CreateNetworkPrivate]] and [[#Connect]]/[[#ConnectPrivate]]. The value used internally by these cmds must be 1-3.
| 0x0 || 0x2 || [[#SecurityMode|SecurityMode]] (overwritten by [[#CreateNetwork]]/[[#CreateNetworkPrivate]] and [[#Connect]]/[[#ConnectPrivate]], the value used internally by these cmds must be 1-3)
|-
|-
| 0x2 || 0x2 || Data size. Must be 0x10-0x40.
| 0x2 || 0x2 || PassphraseSize (must be 0x10-0x40)
|-
|-
| 0x4 || 0x40 || Data, used with key derivation.
| 0x4 || 0x40 || Passphrase (used with key derivation)
|}
|}


Line 1,061: Line 1,143:
! Description
! Description
|-
|-
| 0x0 || 0x10 || Data, used with the same key derivation as [[#SecurityConfig]].
| 0x0 || 0x10 || ServerRandom (used with the same key derivation as [[#SecurityConfig]])
|-
|-
| 0x10 || 0x10 || NetworkId, see [[#NetworkInfo]].
| 0x10 || 0x10 || [[#SessionId|SessionId]]
|}
|}


= UserConfig =
= SessionId =
This is "nn::ldn::UserConfig". This is a 0x30-byte struct with 1-byte alignment.
This is "nn::ldn::SessionId".
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x10 || Random
|}
 
= UserConfig =
This is "nn::ldn::UserConfig". This is a 0x30-byte struct with 1-byte alignment.


sdknso copies the input UserConfig to a tmp struct on stack, which is then used with the cmd.
sdknso copies the input UserConfig to a tmp struct on stack, which is then used with the cmd.
Line 1,077: Line 1,171:
! Description
! Description
|-
|-
| 0x0 || 0x20 || NUL-terminated string for the user nickname.
| 0x0 || 0x21 || UserName (NUL-terminated string for the user nickname)
|-
|-
| 0x20 || 0x10 || Cleared to zero during the copy.
| 0x21 || 0xF || Reserved (cleared to zero during the copy)
|}
|}


Line 1,095: Line 1,189:
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
|-
|-
| 0xA || 0x2 || Padding
| 0xA || 0x2 || Reserved
|}
|}


Line 1,106: Line 1,200:
!  Description
!  Description
|-
|-
| 0 || Allow all.
| 0 || AlwaysAccept
|-
|-
| 1 || Deny all.
| 1 || AlwaysReject
|-
|-
| 2 || Blacklist, addresses in the [[#AddAcceptFilterEntry|list]] are not allowed.
| 2 || BlackList (addresses in the [[#AddAcceptFilterEntry|list]] are not allowed)
|-
|-
| 3 || Whitelist, only addresses in the [[#AddAcceptFilterEntry|list]] are allowed.
| 3 || WhiteList (only addresses in the [[#AddAcceptFilterEntry|list]] are allowed)
|}
|}


Line 1,126: Line 1,220:
|-
|-
! Offset
! Offset
! Size
! Size
! Description
! Description
|-
|-
| 0x0 || 0x4 || [[#Ipv4Address]]
| 0x0 || 0x4 || [[#Ipv4Address]]
|-
|-
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
|-
|-
| 0xA || 0x1 || s8 ID / index
| 0xA || 0x1 || NodeId
|-
|-
| 0xB || 0x1 || IsConnected
| 0xB || 0x1 || IsConnected
|-
|-
| 0xC || 0x20 || First 0x20-bytes of [[#UserConfig]].
| 0xC || 0x21 || UserName (first 0x21-bytes of [[#UserConfig]])
|-
|-
| 0x2C || 0x2 || Reserved
| 0x2D || 0x1 || Reserved
|-
|-
| 0x2E || 0x2 || s16 LocalCommunicationVersion
| 0x2E || 0x2 || LocalCommunicationVersion
|-
|-
| 0x30 || 0x10 || Reserved
| 0x30 || 0x10 || Reserved
|}
 
= ConnectOption =
This is "nn::ldn::ConnectOption". This is an u32 bitmask.
 
There's two versions of the sdknso funcs for [[#Connect]]/[[#ConnectPrivate]]: the version where the ConnectOption isn't user-specified uses a default value of 0x1 for it, with the same ShowError code without the bit0 check.
 
When bit0 here is set after using the above cmds, the sdknso funcs will use [[Error_Applet|ShowError]] with the returned Result if: (rc & 0x3FE1FF) == 0xE0CB.
 
This must be <=0x1, besides this validation ConnectOption is ignored by [[#Connect]]/[[#ConnectPrivate]].
 
= DisconnectReason =
This is "nn::ldn::DisconnectReason".
 
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
| -1 || Unknown
|-
| 0 || None
|-
| 1 || DisconnectedByUser
|-
| 2 || DisconnectedBySystem
|-
| 3 || DestroyedByUser
|-
| 4 || DestroyedBySystem
|-
| 5 || Rejected
|-
| 6 || SignalLost
|}
|}
= ConnectOption =
This is "nn::ldn::ConnectOption". This is an u32 bitmask.
There's two versions of the sdknso funcs for [[#Connect]]/[[#ConnectPrivate]]: the version where the ConnectOption isn't user-specified uses a default value of 0x1 for it, with the same ShowError code without the bit0 check.
When bit0 here is set after using the above cmds, the sdknso funcs will use [[Error_Applet|ShowError]] with the returned Result if: (rc & 0x3FE1FF) == 0xE0CB.
This must be <=0x1, besides this validation ConnectOption is ignored by [[#Connect]]/[[#ConnectPrivate]].


= OperationMode =
= OperationMode =
Line 1,167: Line 1,286:
!  Description
!  Description
|-
|-
| 0 || This is the default.
| 0 || Stable
|-
|-
| 1 ||  
| 1 || HighSpeed
|}
|}


Line 1,273: Line 1,392:
** All string characters which were already written are summed same way as above. Then: <code>return character_lookup_table[sum % 0x2B];</code> (If the length passed to this function is 0, this will instead just return character_lookup_table[0])
** All string characters which were already written are summed same way as above. Then: <code>return character_lookup_table[sum % 0x2B];</code> (If the length passed to this function is 0, this will instead just return character_lookup_table[0])
*** character_lookup_table contains 0x2B entries: [V-A][k-a][5-0][Z-W].
*** character_lookup_table contains 0x2B entries: [V-A][k-a][5-0][Z-W].


loaded_flags are first loaded from elsewhere, then masked with the above flags when available. loaded_flags are used when +0x8A is 0. global_flags are loaded from global data. These flags are only used with [[#CreateGroup]]/[[#Join]]. Flags (note that the following was updated with [11.0.0+], and differs from below):
loaded_flags are first loaded from elsewhere, then masked with the above flags when available. loaded_flags are used when +0x8A is 0. global_flags are loaded from global data. These flags are only used with [[#CreateGroup]]/[[#Join]]. Flags (note that the following was updated with [11.0.0+], and differs from below):
Line 1,556: Line 1,673:


The beacon is identical to ldn, except for the following (besides SSID length difference and the lp2p-only Nintendo tags):  
The beacon is identical to ldn, except for the following (besides SSID length difference and the lp2p-only Nintendo tags):  
* "Tag: Traffic Indication Map (TIM)": "DTIM count" for lp2p is 1, with ldn it's 0.
* "Tag: HT Capabilities (802.11n D1.10)": "HT Short GI for 20MHz" is set to "Not supported", for ldn it's "Supported".
* "Tag: HT Capabilities (802.11n D1.10)": "HT Short GI for 20MHz" is set to "Not supported", for ldn it's "Supported".
* "Tag: Vendor Specific: Microsoft Corp.: WMM/WME: Parameter Element" "Ac Parameters ACI 0": "CW Min: 15" for lp2p, "CW Min: 63" for ldn.
* "Tag: Vendor Specific: Microsoft Corp.: WMM/WME: Parameter Element" "Ac Parameters ACI 0": "CW Min: 15" for lp2p, "CW Min: 63" for ldn.