LDN services: Difference between revisions
(7 intermediate revisions by the same user not shown) | |||
Line 379: | Line 379: | ||
This is used immediately after object creation. | This is used immediately after object creation. | ||
With [7.0.0+] [[#InitializeWithVersion|InitializeWithVersion]] is used instead. The cmd impl for Initialize uses [[#InitializeWithVersion|InitializeWithVersion]] with | On old sysvers the cmd impl for User/System are identical, except different params are used for the funcs called internally. | ||
With [7.0.0+] [[#InitializeWithVersion|InitializeWithVersion]] is used instead. The cmd impl for Initialize uses [[#InitializeWithVersion|InitializeWithVersion]] with version=0. | |||
=== Finalize === | === Finalize === | ||
Line 398: | Line 400: | ||
=== InitializeWithVersion === | === InitializeWithVersion === | ||
Takes an input PID, | Takes an input PID, a s32 version, and an u64 pid_placeholder. | ||
The priority is determined by whether the interface is User/System: System = 0x38, User = 0x5A. | |||
It then calls the init func, with the cmd input params and the above priority, returning the Result on failure. | |||
On newer sysvers this then adds an entry for the state array used by [[#RegisterClient|RegisterClient]]. | |||
Lastly the input PID and version are written into state, then this returns. | |||
The init func does the following: | |||
* The PID must be non-zero, and the version must not be negative. The priority must be 0x5A or 0x38. | |||
* An error is returned if state fields are invalid. | |||
* The input PID and version are written into state (a state field is also set to interface == User). | |||
* Lastly, a vfunc is called with the input priority, returning the Result from that. | |||
The vfunc does the following: | |||
* On newer sysvers, this uses [[Shared_Database_services|pl:s]] RequestApplicationFunctionAuthorizationByProcessId with the input PID and [[Shared_Database_services|ApplicationFunctionAuthorizationId]] = 2 (SecureLdnLocalCommunication), returning the Result on failure. | |||
* Then a message is sent to a msg-queue with the input priority. | |||
The input | The handler for the above message does the following: | ||
* When state is already initialized, runs handling for that. An error is also thrown if the input priority is larger than a state field. | |||
* Initializes state, etc. | |||
* Various [[Network_Interface_services|nifm]] funcs are eventually used. The input priority is used to determine the value for [[Network_Interface_services#CreateRequest|nn::nifm::RequestParameters]]: value 0x4 or value 0x8 is used, depending on priority > 0x59. | |||
** Newer versions also handle ldn lan_emulation [[System_Settings|sys-settings]] here. For the above value, when lan_emulation is enabled it uses value 0x17, with 0x18 additionally used for priority <= 0x59. | |||
* The rest is state init, including setting [[#State|State]] to value 1. Then 0 is returned. | |||
On old sysvers the cmd impl for User/System are identical, except different params are used for the funcs called internally. With newer sysvers the cmd impl is now identical. | |||
Version values passed by official sw: | |||
[[ | {| class="wikitable" border="1" | ||
|- | |||
! Value || SystemVersion | |||
|- | |||
| 0x1 || [7.0.0+] | |||
|- | |||
| 0x2 || [18.0.0+] | |||
|- | |||
| 0x3 || [19.0.0+] | |||
|- | |||
| 0x4 || [20.0.0+] | |||
|} | |||
=== InitializeWithPriority === | === InitializeWithPriority === | ||
Takes an input PID, | Takes an input PID, a s32 version, a s32 priority, and an u64 pid_placeholder. | ||
This is similar to [[#InitializeWithVersion|InitializeWithVersion]]. The input priority is passed directly to the init func which is called here, instead of determining it from whether the interface is User/System. | |||
Official sw passes input value 0x38 for the priority as the default, when the user doesn't specify the priority. | |||
=== EnableActionFrame === | === EnableActionFrame === | ||
Line 490: | Line 526: | ||
This goes through global state to locate an entry with a matching PID, if none found 0 is returned. The objptr from the state entry is loaded, if NULL this returns 0. This obj is then incref'd and written into the IClientProcessMonitor state. When PID is 0, 0 is returned. It then locates the above state entry again with a matching PID, clearing the entry which matches. Lastly 0 is returned. | This goes through global state to locate an entry with a matching PID, if none found 0 is returned. The objptr from the state entry is loaded, if NULL this returns 0. This obj is then incref'd and written into the IClientProcessMonitor state. When PID is 0, 0 is returned. It then locates the above state entry again with a matching PID, clearing the entry which matches. Lastly 0 is returned. | ||
The initialization [[#InitializeWithPriority|cmds]] adds an entry to the above global state. | |||
= ldn:u = | = ldn:u = | ||
Line 512: | Line 550: | ||
== IUserLocalCommunicationService == | == IUserLocalCommunicationService == | ||
This is "nn::ldn::detail::IUserLocalCommunicationService". | This is "nn::ldn::detail::IUserLocalCommunicationService". | ||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
Line 575: | Line 611: | ||
| 304 || [[#Disconnect|Disconnect]] | | 304 || [[#Disconnect|Disconnect]] | ||
|- | |- | ||
| 400 || [[# | | 400 || [[#Initialize_2|Initialize]] | ||
|- | |- | ||
| 401 || [[# | | 401 || [[#Finalize_2|Finalize]] | ||
|- | |- | ||
| 402 || [7.0.0+] [[# | | 402 || [7.0.0+] [[#InitializeWithVersion|InitializeWithVersion]] | ||
|- | |- | ||
| 403 || [19.0.0+] [[# | | 403 || [19.0.0+] [[#SetOperationMode|SetOperationMode]] | ||
|- | |- | ||
| 500 || [18.0.0+] [[#EnableActionFrame|EnableActionFrame]] | | 500 || [18.0.0+] [[#EnableActionFrame|EnableActionFrame]] | ||
Line 597: | Line 633: | ||
| 601 || [18.0.0+] [[#ResetTxPower|ResetTxPower]] | | 601 || [18.0.0+] [[#ResetTxPower|ResetTxPower]] | ||
|} | |} | ||
= ndd = | = ndd = |