LDN services: Difference between revisions

No edit summary
 
(9 intermediate revisions by 2 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 126: Line 131:
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
|-
|-
| 105 || [13.1.0+] SetBluetoothAudioDeviceConnectableMode
| 105 || [13.1.0+] [[#SetBluetoothAudioDeviceConnectableMode]]
|-
| 106 || [18.0.0+]
|-
|-
| 200 || [[#OpenAccessPoint]]
| 200 || [[#OpenAccessPoint]]
Line 165: 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
| 404 || [19.0.0+]
!  Description
|-
|-
| 0 || None
| 500 || [18.0.0+] EnableActionFrame
|-
|-
| 1 || Initialized
| 501 || [18.0.0+] DisableActionFrame
|-
|-
| 2 || AccessPointOpened
| 502 || [18.0.0+] SendActionFrame
|-
|-
| 3 || AccessPointCreated
| 503 || [18.0.0+] RecvActionFrame
|-
| 4 || StationOpened
|-
|-
| 5 || StationConnected
| 505 || [18.0.0+] [[#SetHomeChannel|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 200: 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"
|-
!  Value
!  Description
|-
| -1 || See above.
|-
| 0 || None
|-
| 1 || User
|-
| 2 || SystemRequest
|-
| 3 || DestroyedByAdmin
|-
| 4 || DestroyedBySystemRequest
|-
| 5 || Admin
|-
| 6 || SignalLost
|}


=== GetSecurityParameter ===
=== GetSecurityParameter ===
Line 268: Line 248:


The input value is written into state.
The input value is written into state.
=== SetBluetoothAudioDeviceConnectableMode ===
Takes an input [[#BluetoothAudioDeviceConnectableMode]], no output.
=== Cmd106 ===
Takes an input u32, no output.
The input is validated, then a vfunc is called.
The cmd_input must be non-zero. BIT(cmd_input) must be set in a state-field, otherwise a separate Result is returned.
The vfunc sends a message to another thread with the input u32 as the param, and returns the response from that.
The thread msg-queue-handler (besides other validation) uses the input param to select what values to write to state fields. Only input value 1 or 3 is allowed, with an error being thrown otherwise.


=== OpenAccessPoint ===
=== OpenAccessPoint ===
Line 401: Line 395:


[[#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.
=== Cmd404 ===
Takes an input PID, an u32, an u32, and an u64 pid_placeholder.
This is similar to [[#InitializeSystem2]], with the additional cmd input u32 now being passed directly to the init func which is called here.
=== SetHomeChannel ===
[20.0.0+] Now takes a total of 2-bytes of input instead of 4-bytes.
== 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 410: Line 424:
|-
|-
| 0 || [[#CreateUserLocalCommunicationService]]
| 0 || [[#CreateUserLocalCommunicationService]]
|-
| 1 || [18.0.0+] [[#CreateClientProcessMonitor]]
|}
|}


Line 448: Line 464:
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
| 104 || [5.0.0+] [[#SetWirelessControllerRestriction]]
|-
|-
| 105 || [13.1.0+] SetBluetoothAudioDeviceConnectableMode
| 105 || [13.1.0+] [[#SetBluetoothAudioDeviceConnectableMode]]
|-
| 106 || [18.0.0+]
|-
|-
| 200 || [[#OpenAccessPoint]]
| 200 || [[#OpenAccessPoint]]
Line 485: Line 503:
|-
|-
| 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|SetHomeChannel]]
|-
| 600 || [18.0.0+] SetTxPower
|-
| 601 || [18.0.0+] ResetTxPower
|}
|}


Line 833: Line 867:
=== Initialize ===
=== Initialize ===
Returns 0.
Returns 0.
= State =
This is "nn::ldn::State".
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
| 0 || None
|-
| 1 || Initialized
|-
| 2 || AccessPoint
|-
| 3 || AccessPointCreated
|-
| 4 || Station
|-
| 5 || StationConnected
|-
| 6 || Error
|-
|}


= Ipv4Address =
= Ipv4Address =
Line 857: Line 915:
! 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 951: Line 1,009:
| 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
|-
| 0x1 || LocalCommunicationId
|-
| 0x2 || SessionId
|-
| 0x4 || NetworkType
|-
|-
| 0 || When set, enables using ScanFilter+0.
| 0x8 || Bssid
|-
|-
| 1 || When set, enables using ScanFilter+0x10.
| 0x10 || Ssid
|-
|-
| 2 || When set, enables using ScanFilter+0x20.
| 0x20 || SceneId
|-
|-
| 3 || When set, enables using the ScanFilter [[#MacAddress|MacAddress]].
| 0x21 || IntentId
|-
|-
| 4 || When set, enables using the ScanFilter [[#Ssid]].
| 0x23 || NetworkId
|-
|-
| 5 || When set, enables using ScanFilter+0xA.
| 0x3F || All
|}
|}


Line 1,028: Line 1,095:
!  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 || Enabled
|}
 
= SecurityMode =
This is "nn::ldn::SecurityMode". This is an u32 enum.
 
{| class="wikitable" border="1"
|-
!  Value
!  Description
|-
| 0 || Any
|-
|-
| 1 || This is the default.
| 1 || Product
|-
| 2 || Debug
|-
| 3 || SystemDebug
|}
|}


Line 1,042: Line 1,139:
! 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,065: Line 1,162:
! 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 || [[#SessionId|SessionId]]
|}
 
= SessionId =
This is "nn::ldn::SessionId".
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
|-
| 0x10 || 0x10 || NetworkId, see [[#NetworkInfo]].
| 0x0 || 0x10 || Random
|}
|}


Line 1,081: Line 1,190:
! 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,099: Line 1,208:
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
| 0x4 || 0x6 || [[#MacAddress|MacAddress]]
|-
|-
| 0xA || 0x2 || Padding
| 0xA || 0x2 || Reserved
|}
|}


Line 1,110: Line 1,219:
!  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,137: Line 1,246:
| 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
Line 1,158: Line 1,267:


This must be <=0x1, besides this validation ConnectOption is ignored by [[#Connect]]/[[#ConnectPrivate]].
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
|}


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


Line 1,277: Line 1,411:
** 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):