NIM services: Difference between revisions

No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 66: Line 66:
| 30 || [2.0.0+] RequestVersionList
| 30 || [2.0.0+] RequestVersionList
|-
|-
| 31 || [2.0.0+] CreateApplyDeltaTask
| 31 || [2.0.0+] [[#CreateApplyDeltaTask]]
|-
|-
| 32 || [2.0.0+] DestroyApplyDeltaTask
| 32 || [2.0.0+] DestroyApplyDeltaTask
Line 188: Line 188:
| 91 || [6.0.0-14.1.2]
| 91 || [6.0.0-14.1.2]
|-
|-
| 92 || [6.0.0+] RequestQueryRevokeReason
| 92 || [6.0.0-19.0.1] RequestQueryRevokeReason
|-
|-
| 93 || [6.0.0+] RequestReportActiveELicenses
| 93 || [6.0.0+] RequestReportActiveELicenses
Line 242: Line 242:
| 118 || [10.0.0+] MarkNoDownloadRightsErrorResolved
| 118 || [10.0.0+] MarkNoDownloadRightsErrorResolved
|-
|-
| 119 || [11.0.0+] GetApplyDeltaTaskAllAppliedContentMeta
| 119 || [11.0.0+] [[#GetApplyDeltaTaskAllAppliedContentMeta]]
|-
|-
| 120 || [11.0.0+] PrioritizeNetworkInstallTask
| 120 || [11.0.0+] PrioritizeNetworkInstallTask
Line 290: Line 290:
| 142 || [17.0.0+] RequestCheckSafeSystemVersion
| 142 || [17.0.0+] RequestCheckSafeSystemVersion
|-
|-
| 143 || [17.0.0+] RequestApplicationIcon
| 143 || [17.0.0+] [[#RequestApplicationIcon]]
|-
|-
| 144 || [17.0.0+] RequestDownloadIdbeIconFile
| 144 || [17.0.0+] RequestDownloadIdbeIconFile
Line 299: Line 299:
|-
|-
| 150 || [19.0.0+]
| 150 || [19.0.0+]
|-
| 151 || [20.0.0+]
|-
| 152 || [20.0.0+]
|-
| 153 || [20.0.0+]
|-
| 154 || [20.0.0+]
|-
| 155 || [20.0.0+]
|-
| 156 || [20.0.0+]
|-
| 157 || [20.0.0+]
|-
| 158 || [20.0.0+]
|-
| 159 || [20.0.0+]
|-
| 160 || [20.0.0+]
|-
| 161 || [20.0.0+]
|-
| 162 || [20.0.0+]
|-
| 163 || [20.0.0+]
|-
| 164 || [20.0.0+]
|-
| 165 || [20.0.0+]
|-
| 166 || [20.0.0+]
|-
| 167 || [20.0.0+]
|-
| 168 || [20.0.0+]
|-
| 169 || [20.0.0+]
|-
| 170 || [20.0.0+]
|-
| 171 || [20.0.0+]
|-
| 172 || [20.0.0+]
|-
| 173 || [20.1.0+]
|-
| 2000 || [20.0.0+]
|-
| 2001 || [20.0.0+]
|-
| 2002 || [20.0.0+]
|-
| 2003 || [20.0.0+]
|-
| 2004 || [20.0.0+]
|-
| 2007 || [20.0.0+]
|-
| 2011 || [20.0.0+]
|-
| 2012 || [20.0.0+]
|-
| 2013 || [20.0.0+]
|-
| 2014 || [20.0.0+]
|-
| 2015 || [20.0.0+]
|-
| 2016 || [20.0.0+]
|-
| 2017 || [20.0.0+]
|-
| 2018 || [20.0.0+]
|-
| 2019 || [20.0.0+]
|-
| 2020 || [20.0.0+]
|-
| 2021 || [20.0.0+]
|-
| 2022 || [20.0.0+]
|-
| 2023 || [20.0.0+]
|-
| 2024 || [20.0.0+]
|-
| 2025 || [20.0.0+]
|-
| 2026 || [20.0.0+]
|-
| 2027 || [20.0.0+]
|-
| 2028 || [20.0.0+]
|-
| 2029 || [20.0.0+]
|-
| 2030 || [20.0.0+]
|-
| 2031 || [20.0.0+]
|-
| 2032 || [20.0.0+]
|-
| 2033 || [20.0.0+]
|-
| 2034 || [20.0.0+]
|-
| 2035 || [20.0.0+]
|-
| 2036 || [20.0.0+]
|-
| 2037 || [20.0.0+]
|-
| 2038 || [20.0.0+]
|-
| 2039 || [20.0.0+]
|-
| 2040 || [20.0.0+]
|-
| 2041 || [20.0.0+]
|-
| 2042 || [20.0.0+]
|-
| 2043 || [20.0.0+]
|-
| 2044 || [20.0.0+]
|-
| 2045 || [20.0.0+]
|-
| 2046 || [20.0.0+]
|-
| 2047 || [20.0.0+]
|-
| 2048 || [20.0.0+]
|-
| 2049 || [20.0.0+]
|-
| 2050 || [20.0.0+]
|-
| 2051 || [20.0.0+]
|-
|-
| 3000 || [17.0.0+] RequestLatestApplicationIcon
| 3000 || [17.0.0+] RequestLatestApplicationIcon
Line 310: Line 450:


== CreateSystemUpdateTask ==
== CreateSystemUpdateTask ==
Takes an input u32 firmware_variation, an u32 '''unk''', a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#SystemUpdateTaskId]].
Takes an input u32 firmware_variation, a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#SystemUpdateTaskId]].
 
[8.0.0+] Takes an input u32 firmware_variation, an u32 '''unk''', a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#SystemUpdateTaskId]].


Official sw sets '''unk''' to: <code>unk = inflag & 1 ? 0xC : 0x4</code>.
Official sw sets '''unk''' to: <code>unk = inflag & 1 ? 0xC : 0x4</code>.
Line 333: Line 475:
== GetNetworkInstallTaskInfo ==
== GetNetworkInstallTaskInfo ==
Takes an input [[#NetworkInstallTaskId]], returns an output [[#NetworkInstallTaskInfo]].
Takes an input [[#NetworkInstallTaskId]], returns an output [[#NetworkInstallTaskInfo]].
[10.0.0+] This now returns a total of 0x48-bytes of output instead of 0x40-bytes.


== GetDownloadedSystemDataPath ==
== GetDownloadedSystemDataPath ==
Line 343: Line 483:
== IsExFatDriverIncluded ==
== IsExFatDriverIncluded ==
Takes an input [[#SystemUpdateTaskId]], returns an output u8 bool flag.
Takes an input [[#SystemUpdateTaskId]], returns an output u8 bool flag.
== CreateApplyDeltaTask ==
[20.0.0+] The type-0x5 input buffer is now 0x18-bytes instead of 0x10-bytes.


== GetApplyDeltaTaskInfo ==
== GetApplyDeltaTaskInfo ==
Line 362: Line 505:
Takes an input [[#LocalCommunicationReceiveApplicationTaskId]], returns an output [[#LocalCommunicationReceiveApplicationTaskInfo]].
Takes an input [[#LocalCommunicationReceiveApplicationTaskId]], returns an output [[#LocalCommunicationReceiveApplicationTaskInfo]].


This is the ReceiveApplication version of [[#GetSystemUpdateTaskInfo]].
This is the ReceiveApplication version of [[#GetLocalCommunicationReceiveSystemUpdateTaskInfo]].


== CreateLocalCommunicationSendApplicationTask ==
== CreateLocalCommunicationSendApplicationTask ==
Takes an input u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, a type-0x5 input buffer containing an array of {unknown}, returns an output [[#LocalCommunicationSendApplicationTaskId]].
Takes an input u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, a type-0x5 input buffer containing an array of {0x18-byte struct}, returns an output [[#LocalCommunicationSendApplicationTaskId]].


This is the SendApplication version of [[#CreateLocalCommunicationReceiveSystemUpdateTask]].
This is the SendApplication version of [[#CreateLocalCommunicationSendSystemUpdateTask]].


== RequestLocalCommunicationSendApplicationTaskRun ==
== RequestLocalCommunicationSendApplicationTaskRun ==
Takes an input [[#LocalCommunicationSendApplicationTaskId]], returns an output Event and an [[#IAsyncResult]].
Takes an input [[#LocalCommunicationSendApplicationTaskId]], returns an output Event and an [[#IAsyncResult]].


This is the SendApplicationTask version of [[#RequestLocalCommunicationReceiveSystemUpdateTaskRun]].
This is the SendApplication version of [[#RequestLocalCommunicationSendSystemUpdateTaskRun]].


== GetLocalCommunicationSendApplicationTaskInfo ==
== GetLocalCommunicationSendApplicationTaskInfo ==
Takes an input [[#LocalCommunicationSendApplicationTaskId]], returns an output [[#LocalCommunicationSendApplicationTaskInfo]].
Takes an input [[#LocalCommunicationSendApplicationTaskId]], returns an output [[#LocalCommunicationSendApplicationTaskInfo]].


This is the SendApplication version of [[#GetSystemUpdateTaskInfo]].
This is the SendApplication version of [[#GetLocalCommunicationSendSystemUpdateTaskInfo]].


== ListApplicationLocalCommunicationReceiveApplicationTask ==
== ListApplicationLocalCommunicationReceiveApplicationTask ==
Line 387: Line 530:
Takes a type-0x6 output buffer containing an array of [[#LocalCommunicationSendApplicationTaskId]] and an input u64 <code>nn::ncm::ApplicationId</code>. Returns a s32 for total output entries.
Takes a type-0x6 output buffer containing an array of [[#LocalCommunicationSendApplicationTaskId]] and an input u64 <code>nn::ncm::ApplicationId</code>. Returns a s32 for total output entries.


This is the SendApplication version of [[#ListLocalCommunicationReceiveSystemUpdateTask]].
This is the SendApplication version of [[#ListLocalCommunicationSendSystemUpdateTask]].


== CreateLocalCommunicationReceiveSystemUpdateTask ==
== CreateLocalCommunicationReceiveSystemUpdateTask ==
Takes an input u16 port, an u32 Ipv4Address, an u32 firmware_variation, an u32 '''unk''', a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationReceiveSystemUpdateTaskId]].
Takes an input u16 port, an u32 Ipv4Address, an u32 firmware_variation, a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationReceiveSystemUpdateTaskId]].
 
[8.0.0+] Takes an input u16 port, an u32 Ipv4Address, an u32 firmware_variation, an u32 '''unk''', a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationReceiveSystemUpdateTaskId]].


Official sw sets '''unk''' to: <code>unk = stateflag==0 ? 0x4 : 0xC</code>. The port/Ipv4Address params originate from the [[NS_Services#RequestReceiveSystemUpdate|RequestReceiveSystemUpdate]] params.
Official sw sets '''unk''' to: <code>unk = stateflag==0 ? 0x4 : 0xC</code>. The port/Ipv4Address params originate from the [[NS_Services#RequestReceiveSystemUpdate|RequestReceiveSystemUpdate]] params.
Line 435: Line 580:


== CreateLocalCommunicationSendSystemUpdateTask ==
== CreateLocalCommunicationSendSystemUpdateTask ==
Takes an input u16 port, an u32 Ipv4Address, an u32 firmware_variation, and a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationSendSystemUpdateTaskId]].
Takes an input u16 port, an u32 Ipv4Address, and a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationSendSystemUpdateTaskId]].


[8.0.0+] This now takes an additional 0x8-bytes of input.
[8.0.0+] Takes an input u16 port, an u32 Ipv4Address, an u32 firmware_variation, and a [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output [[#LocalCommunicationSendSystemUpdateTaskId]].


The port/Ipv4Address params originate from the [[NS_Services#RequestSendSystemUpdate|RequestSendSystemUpdate]] params.
The port/Ipv4Address params originate from the [[NS_Services#RequestSendSystemUpdate|RequestSendSystemUpdate]] params.
Line 454: Line 599:
* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}
* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}
* u32 tmpval2=1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &tmpval2, sizeof(tmpval2)); {handle error on fail}
* u32 tmpval2=1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &tmpval2, sizeof(tmpval2)); {handle error on fail}
* Initializes sockaddr_in: sin_addr = htonl({input ipaddr}), sin_port = htons({input port}), and sin_family = AF_INET (sin_len is left at 0).
* Initializes sockaddr_in: sin_addr = htonl(INADDR_ANY), sin_port = htons({input port}), and sin_family = AF_INET (sin_len is left at 0).
* bind(sockfd, sockaddr_in, sizeof(sockaddr_in)); {handle error on fail}
* bind(sockfd, sockaddr_in, sizeof(sockaddr_in)); {handle error on fail}
* listen(sockfd, 1); {handle error on fail}
* listen(sockfd, 1); {handle error on fail}
Line 476: Line 621:


This is the Send version of [[#ListLocalCommunicationReceiveSystemUpdateTask]].
This is the Send version of [[#ListLocalCommunicationReceiveSystemUpdateTask]].
== GetApplyDeltaTaskAllAppliedContentMeta ==
[20.0.0+] Now takes a 0x18-bytes type-0x6 output buffer and returns 4-bytes of output instead of 0x18-bytes.
== RequestApplicationIcon ==
[20.0.0+] Now takes 0x20-bytes of input instead of 0x18-bytes.


= nim:shp =
= nim:shp =
Line 720: Line 871:


[3.0.0+] This is a 0x40-byte struct.
[3.0.0+] This is a 0x40-byte struct.
[10.0.0+] This is a 0x48-byte struct.
[14.0.0+] This is a 0x58-byte struct.
[16.0.0+] This is a 0x60-byte struct.


= ApplyDeltaTaskId =
= ApplyDeltaTaskId =
Line 883: Line 1,040:


The Receive async [[#RequestLocalCommunicationReceiveSystemUpdateTaskRun|thread]] does the following:
The Receive async [[#RequestLocalCommunicationReceiveSystemUpdateTaskRun|thread]] does the following:
* Sets the <code>nn::fs::PriorityRaw</code> using a value loaded from state.
* [5.0.0+] Sets the <code>nn::fs::PriorityRaw</code> using a value loaded from state.
* Calls a func, and writes the returned Result into state.
* Calls a func, and writes the returned Result into state.
* Signals the async Event and returns.
* Signals the async Event and returns.
Line 892: Line 1,049:
* This is identical to the Receive thread except the called func is different.
* This is identical to the Receive thread except the called func is different.
** That func does:
** That func does:
** Gets [[System_Settings|system-setting]] <code>nim.errorsimulate!error_localcommunication_result</code>, returning that as an error if set + non-zero.
** [5.0.0+] Gets [[System_Settings|system-setting]] <code>nim.errorsimulate!error_localcommunication_result</code>, returning that as an error if set + non-zero.
** Does socket setup:
** Does socket setup:
** Calls a func.
** Calls a func.
Line 911: Line 1,068:
* The following is done after the loop:
* The following is done after the loop:
* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}
* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}
* Uses [[Network_Interface_services|nifm]] GetInternetConnectionStatus, returning an error if this is successful. Hence, the output from this is ignored.
* [4.0.0-16.1.0] Uses [[Network_Interface_services|nifm]] GetInternetConnectionStatus, returning an error when the Result is 0xD46E ([6.0.0+] error is thrown when successful). Hence, the output from this is ignored.
* Uses fcntl with F_GETFL/F_SETFL to clear O_NONBLOCK with sockfd, handling error on fail.
* Uses fcntl with F_GETFL/F_SETFL to clear O_NONBLOCK with sockfd, handling error on fail.
* u32 tmpval2=0x4000;
* [4.0.0-10.2.0] u32 tmpval2=0x4000; u32 tmpval3=0x20000;
* u32 tmpval3=0x20000;
* [4.0.0-10.2.0] setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &tmpval2, sizeof(tmpval2)); {error is ignored}
* setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &tmpval2, sizeof(tmpval2)); {error is ignored}
* [4.0.0-10.2.0] setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &tmpval3, sizeof(tmpval3)); {error is ignored}
* setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &tmpval3, sizeof(tmpval3)); {error is ignored}
* Writes sockfd to the output state sockfd and returns 0.
* Writes sockfd to the output state sockfd and returns 0.
** The func used with the above loop does the following:
** The func used with the above loop does the following:
Line 957: Line 1,113:
| 0x2 || 0x18-bytes: [[NCM_services#ContentId|ContentId]], u8 flag, u8 pad[7]. When flag is 0, during the transfer [[#LocalCommunicationSendSystemUpdateTaskInfo]] [[NS_Services#SystemUpdateProgress|SystemUpdateProgress]] current_size is increased using the size of the current chunk. Once the transfer is finished, the end result is that it would be increased by the total content-size. The only time the nim client sets this flag to 1 with SystemUpdate is with the SystemUpdate Meta content. || Size from [[NCM_services#GetSizeFromContentId|GetSizeFromContentId]] with data from [[NCM_services#ReadContentIdFile|ReadContentIdFile]]. || Gets the entire content data for the specified ContentId. The client uses each received chunk of data during the transfer with [[NCM_services|WritePlaceHolder]].
| 0x2 || 0x18-bytes: [[NCM_services#ContentId|ContentId]], u8 flag, u8 pad[7]. When flag is 0, during the transfer [[#LocalCommunicationSendSystemUpdateTaskInfo]] [[NS_Services#SystemUpdateProgress|SystemUpdateProgress]] current_size is increased using the size of the current chunk. Once the transfer is finished, the end result is that it would be increased by the total content-size. The only time the nim client sets this flag to 1 with SystemUpdate is with the SystemUpdate Meta content. || Size from [[NCM_services#GetSizeFromContentId|GetSizeFromContentId]] with data from [[NCM_services#ReadContentIdFile|ReadContentIdFile]]. || Gets the entire content data for the specified ContentId. The client uses each received chunk of data during the transfer with [[NCM_services|WritePlaceHolder]].
|-
|-
| 0x3 || 0x10-byte input for [[ETicket_services|es]] GetCommonTicketAndCertificateSize/GetCommonTicketAndCertificateData. || 0x8-bytes: two size u32s. Then two blocks of data with the sizes specified by the u32s. The server loads the sizes and data from [[ETicket_services|es]] GetCommonTicketAndCertificateSize/GetCommonTicketAndCertificateData. || The two blocks of data are used as the buffers for [[ETicket_services|es]] ImportTicket by the client. This is used for transferring the specified Application Patch CommonTicket.
| 0x3 || 0x10-byte input for [[ETicket_services|es]] GetCommonTicketAndCertificateSize/GetCommonTicketAndCertificateData ([10.1.0+] also GetTicketInfo). || 0x8-bytes: two size u32s. Then two blocks of data with the sizes specified by the u32s. The server loads the sizes and data from [[ETicket_services|es]] GetCommonTicketAndCertificateSize/GetCommonTicketAndCertificateData. || The two blocks of data are used as the buffers for [[ETicket_services|es]] ImportTicket by the client. This is used for transferring the specified Application Patch CommonTicket.
[10.1.0+] Prior to using GetCommonTicketAndCertificate*, additional functionality with [[ETicket_services|es]] GetTicketInfo was added. This loops through the output array to locate an entry with u64 +0 == 0x0, throwing an error if not found. Then in the located entry, u16 +0x32 bit4 must be clear otherwise an error is thrown.
|-
|-
| 0x4 || s64 total_size || 0x0 || The input data is copied into the server state, for [[#LocalCommunicationSendSystemUpdateTaskInfo]] [[NS_Services#SystemUpdateProgress|SystemUpdateProgress]] total_size.
| 0x4 || s64 total_size || 0x0 || The input data is copied into the server state, for [[#LocalCommunicationSendSystemUpdateTaskInfo]] [[NS_Services#SystemUpdateProgress|SystemUpdateProgress]] total_size.