Migration services: Difference between revisions

No edit summary
Line 456: Line 456:
=== ConnectByServerIdAsync ===
=== ConnectByServerIdAsync ===
Takes an input 0x10-byte struct, returns an [[#IAsyncContext|IAsyncContext]].
Takes an input 0x10-byte struct, returns an [[#IAsyncContext|IAsyncContext]].
This async task does the following (handling any errors as needed / calling any logging funcs as needed):
* ...
* Calls a func.
* ...
* Loops through an array to find an entry matching the 0x10-bytes from {func input param}, returning an error if not found. (entryptr is the located entry once done)
* Calls a vfunc. If ret is false:
** Calls a func with entryptr+0x10, for copying the input 0x10-bytes into state.
** Calls a func with entryptr+0x20, for copying 0x8-bytes from the input into state.
** Calls a func with entryptr+0x10, for copying the input 0x10-bytes into state.
* Calls a func.
** Clears a state flag if needed.
** entryptr = { Calls a func which loops through an array to find an entry matching the 0x10-bytes from input. } An error is returned if not found.
** Copies 0x480-bytes from entryptr+0x10 to stack, which is later passed to the connect-network func below.
** Calls a func which initializes [[Sockets_services|sockets]] + [[LDN_services|ldn]] if needed (Initialize, SetProtocol(state_field), SetOperationMode(1), OpenStation).
** Then various funcs are called for socket setup / connecting to the network.
*** ldn [[LDN_services|Connect]] is used, retrying with timeout as needed.
*** The TCP socket is setup, and the server is connected to with the IP from the relevant ldn [[LDN_services|NodeInfo]] (GetNetworkInfo) for the AccessPoint.
** Calls a func. This checks a bool state flag. Each block calls a logging func, a func specific to this block (same params for both), and if this is the flag==false block the flag is then set.
*** The funcs called from the above flag-block are roughly same. These send a message, handle receiving a message, then send another message + receive a message. For flag==false these are [[#Messages|MessageId]] 0x0/0x1, while for flag==true these are MessageId 0x8/0x9.
** A func is called which copies 0x10-bytes from entryptr+0x10+0x26C into state.
* Calls a func to get the [[#ClientProfileNetwork|ClientProfileNetwork]] (which memcpys data from state + calls two funcs to get the values for the last two fields).
* Clears/writes stack data, including copying the above [[#ClientProfileNetwork|ClientProfileNetwork]].
* ...
* Clears stack. Calls a func.
* Calls a func. This sends [[#ClientProfileNetwork|ClientProfileNetwork]] via a [[#Data|Data]] transfer, then receives network data.
* Calls a vfunc.
* When ret is true:
** Calls a func. This essentially handles sending/receiving network data, etc.
** Sets a state flag, then returns 0.
* Otherwise when the vfunc ret is false:
** Calls a func. This is very similar to the func used in the above block.
** Calls a func.
*** Clears stack, and calls a func.
*** Calls a func which handles sending/receiving network data.
*** Calls a func.
** Calls a func. (fs related?)
** Calls a func. This sends a network message with [[#Messages|MessageId]] 0x10, then receives network data. Then the socket is closed. Lastly, a func is called which handles closing [[LDN_services|ldn]] (CloseStation, Finalize) and [[Sockets_services|sockets]].
** Calls a func.
** Clears stack. Enters a block which uses nifm.
*** Calls a func.
*** Clears stack.
*** Calls a func to get a state field.
*** Calls a func which uses network request [[Network|transfer_events/%lld/register_destination]].
** Nifm usage ends here.
** Calls a func.
** Calls a func which handles [[Sockets_services|sockets]] cleanup.
** Calls a func. This essentially does ldn setup again / reconnects to the network. The previously mentioned network messages func used after connection is then called here, with the bool flag being previously updated it would now use MessageId 0x8/0x9. State is also updated.
** Calls a func. This sends data via a [[#Data|Data]] transfer, then receives network data. Afterwards it then calls a vfunc.
** Sets a state flag, then returns 0.


=== CompleteAsync ===
=== CompleteAsync ===