wut v1.8.0
Wii U Toolchain
Loading...
Searching...
No Matches
Cafe.h
Go to the documentation of this file.
1#pragma once
2
3#include <wut.h>
4#include <nn/result.h>
6#include <nn/cfg/CTR.h>
7
15#ifdef __cplusplus
16
18#define UDS_MAX_NODES 0x10
20#define UDS_BROADCAST_NODE_ID 0xFFFF
21
22namespace nn {
23
24namespace uds {
25
26namespace Cafe {
30 uint32_t status;
32 uint32_t reason;
34 uint16_t networkNodeId;
36 uint16_t changedNodes;
40 uint8_t totalNodes;
42 uint8_t maxNodes;
44 uint16_t nodeBitmask;
45 };
46 WUT_CHECK_SIZE(ConnectionStatus, 0x30);
47 WUT_CHECK_OFFSET(ConnectionStatus, 0x00, status);
48 WUT_CHECK_OFFSET(ConnectionStatus, 0x04, reason);
49 WUT_CHECK_OFFSET(ConnectionStatus, 0x08, networkNodeId);
50 WUT_CHECK_OFFSET(ConnectionStatus, 0x0A, changedNodes);
51 WUT_CHECK_OFFSET(ConnectionStatus, 0x0C, nodes);
52 WUT_CHECK_OFFSET(ConnectionStatus, 0x2C, totalNodes);
53 WUT_CHECK_OFFSET(ConnectionStatus, 0x2D, maxNodes);
54 WUT_CHECK_OFFSET(ConnectionStatus, 0x2E, nodeBitmask);
55
57 static constexpr uint32_t kWorkMemorySize = 0x14000;
58
60 using EndpointDescriptor = uint32_t;
61
62 enum PollStateChangeFlags : uint8_t {
65 };
66 WUT_CHECK_SIZE(PollStateChangeFlags, 0x1);
67
68 enum ReceiveFlags : uint8_t {
71 };
72 WUT_CHECK_SIZE(ReceiveFlags, 0x1);
73
78 AllowToConnect() asm("AllowToConnect__Q3_2nn3uds4CafeFv");
79
83 nn::Result
84 AllowToSpectate() asm("AllowToSpectate__Q3_2nn3uds4CafeFv");
85
102 nn::Result
104 uint16_t networkNodeId,
105 uint8_t dataChannel,
106 uint32_t recvBufferSize) asm("Attach__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptorUsUcUi");
107
121 uint32_t
122 CreateLocalCommunicationId(uint32_t uniqueId, bool unknown) asm("CreateLocalCommunicationId__Q3_2nn3uds4CafeFUib");
123
130 nn::Result
131 CreateEndpoint(EndpointDescriptor *fd) asm("CreateEndpoint__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptor");
132
157 nn::Result
158 CreateNetwork(uint8_t id8,
159 uint8_t maxNodes,
160 uint32_t localCommunicationId,
161 const char *passphrase,
162 uint32_t passphraseSize,
163 uint8_t channel) asm("CreateNetwork__Q3_2nn3uds4CafeFUcT1UiPCcT3T1");
164
195 nn::Result
196 CreateNetwork(uint8_t id8,
197 uint8_t maxNodes,
198 uint32_t localCommunicationId,
199 const char *passphrase,
200 uint32_t passphraseSize,
201 uint8_t channel,
202 const void *appData,
203 uint32_t appDataSize) asm("CreateNetwork__Q3_2nn3uds4CafeFUcT1UiPCcT3T1PCvT3");
204
238 nn::Result
239 CreateNetwork(uint8_t id8,
240 uint8_t maxNodes,
241 uint32_t localCommunicationId,
242 const char *passphrase,
243 uint32_t passphraseSize,
244 bool unused,
245 uint8_t channel,
246 const void *appData,
247 uint32_t appDataSize) asm("CreateNetwork__Q3_2nn3uds4CafeFUcT1UiPCcT3bT1PCvT3");
248
255 nn::Result
256 DestroyEndpoint(EndpointDescriptor *fd) asm("DestroyEndpoint__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptor");
257
261 nn::Result
262 DestroyNetwork() asm("DestroyNetwork__Q3_2nn3uds4CafeFv");
263
270 nn::Result
271 DisallowToConnect(bool unknown) asm("DisallowToConnect__Q3_2nn3uds4CafeFb");
272
279 nn::Result
280 EjectClient(uint16_t networkNodeId) asm("EjectClient__Q3_2nn3uds4CafeFUs");
281
285 nn::Result
286 EjectSpectator() asm("EjectSpectator__Q3_2nn3uds4CafeFv");
287
291 void
292 Finalize() asm("Finalize__Q3_2nn3uds4CafeFv");
293
306 nn::Result
308 uint32_t *readSize,
309 uint32_t size) asm("GetApplicationDataFromBeacon__Q3_2nn3uds4CafeFPvPUiUi");
310
317 nn::Result
318 GetChannel(uint8_t *channel) asm("GetChannel__Q3_2nn3uds4CafeFPUc");
319
326 nn::Result
327 GetConnectionStatus(ConnectionStatus *status) asm("GetConnectionStatus__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe16ConnectionStatus");
328
338 nn::Result
339 GetNodeInformation(NodeInformation *info, uint16_t networkNodeId) asm("GetNodeInformation__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe15NodeInformationUs");
340
350 nn::Result
351 Initialize(void *workMemory, uint32_t workMemorySize) asm("Initialize__Q3_2nn3uds4CafeFPvUi");
352
365 nn::Result
366 Initialize(void *workMemory,
367 uint32_t workMemorySize,
368 nn::cfg::CTR::UserName *username) asm("Initialize__Q3_2nn3uds4CafeFPvUiPQ4_2nn3cfg3CTR8UserName");
369
377 nn::Result
378 PollStateChange(uint8_t flags) asm("PollStateChange__Q3_2nn3uds4CafeFUc");
379
401 nn::Result
403 void *buf,
404 uint32_t *receivedSize,
405 uint16_t *networkNodeId,
406 uint32_t size,
407 uint8_t flags) asm("ReceiveFrom__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPvPUiPUsUiUc");
408
427 nn::Result
429 void *buf,
430 uint32_t *receivedSize,
431 uint32_t size,
432 uint8_t flags) asm("Receive__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPvPUiUiUc");
433
455 nn::Result
457 const void *buf,
458 uint32_t size,
459 uint16_t destNodeId,
460 uint8_t dataChannel,
461 uint8_t flags) asm("SendTo__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPCvUiUsUcT5");
462
472 nn::Result
473 SetApplicationDataToBeacon(const void *appData, uint32_t size) asm("SetApplicationDataToBeacon__Q3_2nn3uds4CafeFPCvUi");
474} // namespace Cafe
475
476} // namespace uds
477
478} // namespace nn
479
480#endif
481
Result value type used by nn libraries.
Definition result.h:68
#define UDS_MAX_NODES
Theoretical supported maximum number of nodes connected to a network, including the host.
Definition Cafe.h:18
nn::Result AllowToConnect() asm("AllowToConnect__Q3_2nn3uds4CafeFv")
Allows clients to connect to the network.
nn::Result GetApplicationDataFromBeacon(void *appData, uint32_t *readSize, uint32_t size) asm("GetApplicationDataFromBeacon__Q3_2nn3uds4CafeFPvPUiUi")
Gets the application data from the network.
nn::Result PollStateChange(uint8_t flags) asm("PollStateChange__Q3_2nn3uds4CafeFUc")
Checks if new data can be retrieved through GetConnectionStatus, and waits until new data is availabl...
uint16_t networkNodeId
The network node ID of this device.
Definition Cafe.h:34
void Finalize() asm("Finalize__Q3_2nn3uds4CafeFv")
Finalizes UDS.
nn::Result CreateEndpoint(EndpointDescriptor *fd) asm("CreateEndpoint__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptor")
Creates a new endpoint.
PollStateChangeFlags
Definition Cafe.h:62
@ UDS_POLL_NONBLOCK
Prevents PollStateChange from blocking if no new data is available.
Definition Cafe.h:64
nn::Result DisallowToConnect(bool unknown) asm("DisallowToConnect__Q3_2nn3uds4CafeFb")
Prevents clients from connecting to the network.
uint32_t reason
The reason why the status has changed.
Definition Cafe.h:32
nn::Result SendTo(const EndpointDescriptor &fd, const void *buf, uint32_t size, uint16_t destNodeId, uint8_t dataChannel, uint8_t flags) asm("SendTo__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPCvUiUsUcT5")
Sends data to the specified node ID through the given data channel.
nn::Result CreateNetwork(uint8_t id8, uint8_t maxNodes, uint32_t localCommunicationId, const char *passphrase, uint32_t passphraseSize, uint8_t channel) asm("CreateNetwork__Q3_2nn3uds4CafeFUcT1UiPCcT3T1")
Creates a new network with the given parameters.
nn::Result SetApplicationDataToBeacon(const void *appData, uint32_t size) asm("SetApplicationDataToBeacon__Q3_2nn3uds4CafeFPCvUi")
Sets the application data to the network.
nn::Result Initialize(void *workMemory, uint32_t workMemorySize) asm("Initialize__Q3_2nn3uds4CafeFPvUi")
Initializes UDS.
nn::Result ReceiveFrom(const EndpointDescriptor &fd, void *buf, uint32_t *receivedSize, uint16_t *networkNodeId, uint32_t size, uint8_t flags) asm("ReceiveFrom__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPvPUiPUsUiUc")
Receives data from the specified endpoint.
static constexpr uint32_t kWorkMemorySize
Recommended size to use for work memory buffer.
Definition Cafe.h:57
nn::Result GetConnectionStatus(ConnectionStatus *status) asm("GetConnectionStatus__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe16ConnectionStatus")
Retrieves the connection status of the network.
nn::Result Receive(const EndpointDescriptor &fd, void *buf, uint32_t *receivedSize, uint32_t size, uint8_t flags) asm("Receive__Q3_2nn3uds4CafeFRCQ4_2nn3uds4Cafe18EndpointDescriptorPvPUiUiUc")
Receives data from the specified endpoint.
@ UDS_RECEIVE_NONBLOCK
Prevents Receive from blocking if no new data is available.
Definition Cafe.h:70
uint16_t changedNodes
Bitmask of nodes that have changed.
Definition Cafe.h:36
uint16_t nodes[UDS_MAX_NODES]
Array of nodes connected to the network.
Definition Cafe.h:38
uint8_t maxNodes
Maximum number of nodes that can connect to the network, including the host.
Definition Cafe.h:42
uint32_t EndpointDescriptor
Describes a network endpoint.
Definition Cafe.h:60
nn::Result GetNodeInformation(NodeInformation *info, uint16_t networkNodeId) asm("GetNodeInformation__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe15NodeInformationUs")
Gets information about a specified node.
nn::Result EjectClient(uint16_t networkNodeId) asm("EjectClient__Q3_2nn3uds4CafeFUs")
Ejects the specified client from the network.
uint32_t CreateLocalCommunicationId(uint32_t uniqueId, bool unknown) asm("CreateLocalCommunicationId__Q3_2nn3uds4CafeFUib")
Creates a local communication ID based on the given paramaters.
nn::Result DestroyEndpoint(EndpointDescriptor *fd) asm("DestroyEndpoint__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptor")
Destroys the given endpoint.
nn::Result AllowToSpectate() asm("AllowToSpectate__Q3_2nn3uds4CafeFv")
Allows clients to spectate the network.
nn::Result EjectSpectator() asm("EjectSpectator__Q3_2nn3uds4CafeFv")
Ejects all spectators from the network.
nn::Result Attach(EndpointDescriptor *fd, uint16_t networkNodeId, uint8_t dataChannel, uint32_t recvBufferSize) asm("Attach__Q3_2nn3uds4CafeFPQ4_2nn3uds4Cafe18EndpointDescriptorUsUcUi")
Attaches an endpoint to a specified node.
uint32_t status
The network status.
Definition Cafe.h:30
nn::Result GetChannel(uint8_t *channel) asm("GetChannel__Q3_2nn3uds4CafeFPUc")
Gets the network channel.
uint16_t nodeBitmask
Bitmask of nodes connected to the network.
Definition Cafe.h:44
nn::Result DestroyNetwork() asm("DestroyNetwork__Q3_2nn3uds4CafeFv")
Destroys the previously created network.
uint8_t totalNodes
Total amount of nodes connected to the network.
Definition Cafe.h:40
Stores the connection status of the network.
Definition Cafe.h:28
Stores information about a node.
Definition ac_cpp.h:16