Migration services: Difference between revisions

No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 349: Line 349:
No input, returns an [[#IAsyncContext|IAsyncContext]].
No input, returns an [[#IAsyncContext|IAsyncContext]].


The async task does the following:
The async task does the following (handling any errors as needed / calling any logging funcs as needed):
* ...
* ...
* Initializes the data used for the AdvertiseData.
* Initializes the data used for the AdvertiseData.
Line 362: Line 362:
** Uses [[LDN_services|SetAdvertiseData]] with buf/size = 0 (empty AdvertiseData).
** Uses [[LDN_services|SetAdvertiseData]] with buf/size = 0 (empty AdvertiseData).
** Uses [[LDN_services|SetStationAcceptPolicy]] with value 1 (AlwaysReject).
** Uses [[LDN_services|SetStationAcceptPolicy]] with value 1 (AlwaysReject).
** Enters a loop waiting for a state field to become value 0x3. Two funcs are called repeatedly in this loop, with cleanup and return being handled if these return error.
** Enters a loop waiting for a state field to become value 0x3 (network message [[#Initialize|Initialize]]/[[#Initialize|Initialize2]] handled). Two funcs are called repeatedly in this loop. These essentially receive [[#Messages|messages]] + process them, and send the response network message.
*** The first func receives socket data and handles it. The second func calls a func to get data for sending, then sends the socket data. Both have timeout etc handling.
** Updates state and returns 0.
** Updates state and returns 0.
* ...
* Calls a vfunc. When the ret is true:
** Calls a func, which receives [[#SendClientProfile|SendClientProfile]] and sends the response. Also calls a func to process the received data.
** Receives [[#Data|Data]] message 0x10 and sends the response.
* Otherwise when the vfunc ret is false:
** Calls a func identical to the first network-message func called in the above block, except a different func is called at the end.
** Runs the same [[#Data|Data]] message 0x10 handling as above.
** Calls a func. This calls a func, then receives [[#Data|Data]] message 0x12 and sends the response.
** Calls a func. This runs functionality similar to the eariler message-loop, except this waits for the state field to change to !=0x3. The socket is closed, then a func is called which handles [[LDN_services|ldn]] + [[Sockets_services|sockets]] cleanup.
** Calls a func. This essentially calls the network-creation func from eariler, with the input AdvertiseData being 0x10-bytes.
** Calls a func. This receives [[#Suspend|Suspend]] or [[#SynchronizeState|SynchronizeState]] and sends the response.
* Updates a state flag and returns 0.


=== WaitAcceptanceAsync ===
=== WaitAcceptanceAsync ===
Line 380: Line 389:
No input, returns an output u32.
No input, returns an output u32.


This loads a field from state.
This loads a field from state. This originates from +0x100 in the [[#SendClientProfile|SendClientProfile]] request.


=== Cmd203 ===
=== Cmd203 ===
Line 489: Line 498:
** A func is called which copies 0x10-bytes from entryptr+0x10+0x26C into state.
** A func is called which copies 0x10-bytes from entryptr+0x10+0x26C into state.
* Clears stack. Calls a func.
* Clears stack. Calls a func.
* Calls a func. This sends [[#ClientProfileNetwork|ClientProfileNetwork]], then receives network data.
* Calls a func. This sends [[#SendClientProfile|SendClientProfile]], then receives network data.
* Calls a vfunc.
* Calls a vfunc.
* When ret is true:
* When ret is true:
Line 1,205: Line 1,214:
| 0x10 ||  
| 0x10 ||  
|-
|-
| 0x11 || [[#ClientProfileNetwork|ClientProfileNetwork]]
| 0x11 || [[#SendClientProfile|SendClientProfile]]
|-
|-
| 0x12 ||  
| 0x12 ||  
Line 1,223: Line 1,232:


==== 0x10 ====
==== 0x10 ====
This is sent by the client following the last vfunc call in [[#ConnectByServerIdAsync|ConnectByServerIdAsync]] where the bool ret is checked, with both true/false blocks. This follows [[#ClientProfileNetwork|ClientProfileNetwork]].
This is sent by the client following the last vfunc call in [[#ConnectByServerIdAsync|ConnectByServerIdAsync]] where the bool ret is checked, with both true/false blocks. This follows [[#SendClientProfile|SendClientProfile]].


The request only contains the header.
The request only contains the header.
Line 1,238: Line 1,247:
When the aforementioned vfunc returned true, the client only uses the response data for verifying that various fields match state. Otherwise when false the client uses this data.
When the aforementioned vfunc returned true, the client only uses the response data for verifying that various fields match state. Otherwise when false the client uses this data.


==== ClientProfileNetwork ====
==== SendClientProfile ====
Request payload:
Request payload:


Line 1,249: Line 1,258:
| 0x100 || 0x4 ||  
| 0x100 || 0x4 ||  
|-
|-
| 0x100 || 0x4 ||  
| 0x104 || 0x4 ||  
|}
|}


Line 1,303: Line 1,312:


==== PrepareTransferDisconnect ====
==== PrepareTransferDisconnect ====
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]] (this usually not used since the state flag is already set?).
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 request only contains the 0x4-byte header. The u8 at header+0x1 (after DataMessageId) is set to <code>statefield==other_statefield</code>.
The request only contains the 0x4-byte header. The u8 at header+0x1 (after DataMessageId) is set to <code>statefield==other_statefield</code>.