devkitPro / wut

Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
zlib License
244 stars 52 forks source link

nn/uds: Add initial headers #387

Closed DaniElectra closed 4 months ago

DaniElectra commented 4 months ago

This is an initial implementation of nn::uds, which can be used for communicating with nearby 3DS devices locally using local Wi-Fi. Not every function has been added on this PR due to either it being a low level function (such as making Ioctlv calls directly) or missing research. I would like suggestions as to whether the headers are well organized or how to improve them, these have also been organized in a way for future-proofing a nn::dlp implementation in the future, due to header dependencies.

Technical details

nn::uds is essentially a C++ wrapper around the /dev/udscntrl IOSU, which only exposes the needed functionality for hosting a network. A lot of the concepts and structures are the same as on the 3DS implementation, to the extent where most the Ioctlv commands share the same value as the IPC command IDs on the 3DS. For this reason, most of the research and documentation has been inherited from libctru and 3dbrew.

Not everything has been imported though. For example, the broadcast flag on SendTo from the 3DS hasn't been included here due to lack of testing, and the fact that Receive(From) does include a flag argument, whereas on the 3DS doesn't, and thus creating uncertainty as to whether this flag works on here too.

The Initialize function takes a "work memory" buffer (I chose that name based on similar cases on other Wii U libraries), similar to the 3DS "shared memory". It has been observed on various games that the size of 0x14000 was used when allocating this work memory, so I put that as recommendation. If there is a better way to handle this, please let me know!

It should be noted that the Wii U version of UDS only allows hosting networks, you cannot connect to other networks.

Research note: It is unknown whether the /dev/udscntrl IOSU exposes the functionality to connect to networks, and while it may be possible given the similarities on the command IDs, that is considered out of scope.

Testing

This PR has been tested successfully against the 3DS example of UDS, the source code for this (rushed up) test can be found here: https://github.com/DaniElectra/uds-wiiu-test

GaryOderNichts commented 4 months ago

Thanks!