Migration services: Difference between revisions

No edit summary
Line 432: Line 432:
* Call the above vfunc again. If the ret is still false, return an error.
* Call the above vfunc again. If the ret is still false, return an error.
* When a state flag is not set, calls a func.
* When a state flag is not set, calls a func.
** Calls a func. This receives [[#Suspend|Suspend]] or [[#PrepareTransferDisconnect|PrepareTransferDisconnect]] and sends the response.
** Calls a func. This receives [[#Suspend|Suspend]] or [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]] and sends the response.
** When the output bool from [[#PrepareTransferDisconnect|PrepareTransferDisconnect]] above is true, just return 0.
** When the output bool from [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]] above is true, just return 0.
** Calls the same func as [[#WaitConnectionAsync|WaitConnectionAsync]], which has a message-loop + socket-closing and cleanup.
** Calls the same func as [[#WaitConnectionAsync|WaitConnectionAsync]], which has a message-loop + socket-closing and cleanup.
** Calls the same func as [[#TransferNextAsync|TransferNextAsync]] for using the network request.
** Calls the same func as [[#TransferNextAsync|TransferNextAsync]] for using the network request.
Line 441: Line 441:
** Calls a func.
** Calls a func.
*** Initializes stack data.
*** Initializes stack data.
*** Calls a func. This receives [[#Suspend|Suspend]], [[#SynchronizeState|SynchronizeState]], or [[#PrepareTransfer|PrepareTransfer]] and sends the response. Besides handling Suspend afterwards, this also copies a field to output (this is the output s32 mentioned below).
*** Calls a func. This receives [[#Suspend|Suspend]], [[#SynchronizeState|SynchronizeState]], or [[#PrepareTransfer2|PrepareTransfer2]] and sends the response. Besides handling Suspend afterwards, this also copies a field to output (this is the output s32 mentioned below).
*** Calls a vfunc. When ret is true, cleanup and return 0.
*** Calls a vfunc. When ret is true, cleanup and return 0.
*** Receives [[#TransferNext|TransferNext]] and sends the response.
*** Receives [[#Transfer2|Transfer2]] and sends the response.
** Calls a vfunc. When ret is true, return 0.
** Calls a vfunc. When ret is true, return 0.
** If the Result from the above func is within the fs range for ResultDataCorrupted, and the output s32 from the func is not negative:
** If the Result from the above func is within the fs range for ResultDataCorrupted, and the output s32 from the func is not negative:
Line 656: Line 656:
** Loops through the fs data previously received by [[#GetList|GetList]]. With each entry, calls a func. This uses [[Filesystem_services|FindSaveDataWithFilter]] and uses the output with [[NS_services|IApplicationManagerInterface DeleteSaveData]].
** Loops through the fs data previously received by [[#GetList|GetList]]. With each entry, calls a func. This uses [[Filesystem_services|FindSaveDataWithFilter]] and uses the output with [[NS_services|IApplicationManagerInterface DeleteSaveData]].
* If a state flag is not set, a func is called:
* If a state flag is not set, a func is called:
** Uses network message [[#PrepareTransferDisconnect|PrepareTransferDisconnect]].
** Uses network message [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]].
** If the state fields checked by [[#PrepareTransferDisconnect|PrepareTransferDisconnect]] for header+0x1 match, this just returns.
** If the state fields checked by [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]] for header+0x1 match, this just returns.
** Calls the func which handles disconnecting from the network.
** Calls the func which handles disconnecting from the network.
** Calls two funcs.
** Calls two funcs.
Line 666: Line 666:
* Calls a func which validates the entry data output from the above func (u8 +0x0).
* Calls a func which validates the entry data output from the above func (u8 +0x0).
* Logs a report with [[PSC_services|srepo]]. Includes data from the above entry, etc.
* Logs a report with [[PSC_services|srepo]]. Includes data from the above entry, etc.
* Uses network message [[#PrepareTransfer|PrepareTransfer]]. Uses [[Filesystem_services|ISaveDataTransferManagerWithDivision SetLocalKeySeedPackage]] with the relevant response data.
* Uses network message [[#PrepareTransfer2|PrepareTransfer2]]. Uses [[Filesystem_services|ISaveDataTransferManagerWithDivision SetLocalKeySeedPackage]] with the relevant response data.
* Logs a report with [[PSC_services|srepo]]. "tr_size" is logged by adding two u64 fields from the 0x20-byte struct returned by [[#PrepareTransfer|PrepareTransfer]]: +0x18 and +0x8.
* Logs a report with [[PSC_services|srepo]]. "tr_size" is logged by adding two u64 fields from the 0x20-byte struct returned by [[#PrepareTransfer2|PrepareTransfer2]]: +0x18 and +0x8.
* Calls a func, for loading data from the above entry.
* Calls a func, for loading data from the above entry.
* Calls a func for getting state data.
* Calls a func for getting state data.
* Calls a func which writes the various input to the output struct. This is then passed to the the following func which is called:
* Calls a func which writes the various input to the output struct. This is then passed to the the following func which is called:
** Calls a func.
** Calls a func.
** Uses network message [[#TransferNext|TransferNext]].
** Uses network message [[#Transfer2|Transfer2]].
** Calls a func.
** Calls a func.
* Logs a report with [[PSC_services|srepo]].
* Logs a report with [[PSC_services|srepo]].
Line 1,327: Line 1,327:
| 0x20 || [[#AcceptDecline|AcceptDecline]]
| 0x20 || [[#AcceptDecline|AcceptDecline]]
|-
|-
| 0xE0 || [[#PrepareTransferDisconnect|PrepareTransferDisconnect]]
| 0xE0 || [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]]
|-
|-
| 0xE1 || [[#PrepareTransfer|PrepareTransfer]]
| 0xE1 || [[#PrepareTransfer2|PrepareTransfer2]]
|-
|-
| 0xE2 || [[#TransferNext|TransferNext]]
| 0xE2 || [[#Transfer2|Transfer2]]
|-
|-
| 0xF0 || [[#SynchronizeState|SynchronizeState]]
| 0xF0 || [[#SynchronizeState|SynchronizeState]]
Line 1,481: Line 1,481:
The response only contains the header.
The response only contains the header.


==== PrepareTransferDisconnect ====
==== PrepareTransferDisconnect2 ====
The client sends this via [[#TransferNextAsync|TransferNextAsync]] if a state flag is not set, prior to temporarily disconnecting from the network for using network request [[Network|transfer_events/%lld/save_datas/%lld/generate_key_seed_package]].
The client sends this via [[#TransferNextAsync|TransferNextAsync]] if a state flag is not set, prior to temporarily disconnecting from the network for using network request [[Network|transfer_events/%lld/save_datas/%lld/generate_key_seed_package]].


Line 1,488: Line 1,488:
The response only contains the 0x4-byte header.
The response only contains the 0x4-byte header.


==== PrepareTransfer ====
==== PrepareTransfer2 ====
The client sends this via [[#TransferNextAsync|TransferNextAsync]] (after [[#PrepareTransferDisconnect|PrepareTransferDisconnect]] if using it was enabled).
The client sends this via [[#TransferNextAsync|TransferNextAsync]] (after [[#PrepareTransferDisconnect2|PrepareTransferDisconnect2]] if using it was enabled).


The request only contains the header, which besides the DataMessageId contains:
The request only contains the header, which besides the DataMessageId contains:
Line 1,511: Line 1,511:
|}
|}


==== TransferNext ====
==== Transfer2 ====
The client sends this via [[#TransferNextAsync|TransferNextAsync]], after [[#PrepareTransfer|PrepareTransfer]].
The client sends this via [[#TransferNextAsync|TransferNextAsync]], after [[#PrepareTransfer2|PrepareTransfer2]].


The request only contains the header.
The request only contains the header.
Line 1,527: Line 1,527:
|}
|}


With savedata the transfer payload is the output from exporting savedata from [[Filesystem_services|ISaveDataTransferManagerWithDivision]] (see [[#Notes]]), which the client then imports.
With savedata the transfer payload is the output from exporting savedata from [[Filesystem_services|ISaveDataTransferManagerWithDivision]], which the client then imports.


==== SynchronizeState ====
==== SynchronizeState ====
Line 1,582: Line 1,582:
Savedata transfer ("nn::migration::savedata::IServer"/"nn::migration::savedata::IClient") requires that accounts are linked to the same network-account. acc:su [[NS_services#IManagerForSystemService|IManagerForSystemService]] GetAccountId is used here. The server stores this Id into state, and also stores it in the [[LDN_services|ldn]] AdvertiseData. The client also verifies the Id in AdvertiseData against the Id from GetAccountId for the account(s) being used, during ScanServersAsync.
Savedata transfer ("nn::migration::savedata::IServer"/"nn::migration::savedata::IClient") requires that accounts are linked to the same network-account. acc:su [[NS_services#IManagerForSystemService|IManagerForSystemService]] GetAccountId is used here. The server stores this Id into state, and also stores it in the [[LDN_services|ldn]] AdvertiseData. The client also verifies the Id in AdvertiseData against the Id from GetAccountId for the account(s) being used, during ScanServersAsync.


[20.0.0+] [[Filesystem_services#ISaveDataTransferManagerWithDivision|ISaveDataTransferManagerWithDivision]] is now used instead of ISaveDataTransferManager. Besides [[Filesystem_services|SetKeySeedPackage]] being used now as needed, [[Filesystem_services|SetLocalKeySeedPackage]] is now used by the relevant functionality in [[#IClient_2|IClient]] TransferNextAsync.
[20.0.0+] [[Filesystem_services#ISaveDataTransferManagerWithDivision|ISaveDataTransferManagerWithDivision]] is now used (from "nn::migration::savedata::*") instead of ISaveDataTransferManager. Besides [[Filesystem_services|SetKeySeedPackage]] being used now as needed, [[Filesystem_services|SetLocalKeySeedPackage]] is now used by the relevant functionality in [[#IClient_2|IClient]] TransferNextAsync.


[S2] System Settings now has an additional menu once send-savedata is selected, for selecting whether to send to Nintendo Switch or Nintendo Switch 2. If Switch 2 is selected, and there's a S1 receiving, the S2 will display a message regarding wrong target system. The receiving system also displays an error. Note that savedata for S2-only applications is only listed with the dest-S2 option (S1-applications are also listed).
[S2] System Settings now has an additional menu once send-savedata is selected, for selecting whether to send to Nintendo Switch or Nintendo Switch 2. If Switch 2 is selected, and there's a S1 receiving, the S2 will display a message regarding wrong target system. The receiving system also displays an error. Note that savedata for S2-only applications is only listed with the dest-S2 option (S1-applications are also listed).


[[Category:Services]]
[[Category:Services]]