libctru
v2.4.1
|
UDS(NWMUDS) local-WLAN service. More...
Go to the source code of this file.
Data Structures | |
struct | udsNodeInfo |
Node info struct. More... | |
struct | udsConnectionStatus |
Connection status struct. More... | |
struct | udsNetworkStruct |
Network struct stored as big-endian. More... | |
struct | udsBindContext |
struct | nwmScanInputStruct |
General NWM input structure used for AP scanning. More... | |
struct | nwmBeaconDataReplyHeader |
General NWM output structure from AP scanning. More... | |
struct | nwmBeaconDataReplyEntry |
General NWM output structure from AP scanning, for each entry. More... | |
struct | udsNetworkScanInfo |
Output structure generated from host scanning output. More... | |
Macros | |
#define | UDS_MAXNODES 16 |
Maximum number of nodes(devices) that can be connected to the network. | |
#define | UDS_BROADCAST_NETWORKNODEID 0xFFFF |
Broadcast value for NetworkNodeID / alias for all NetworkNodeIDs. | |
#define | UDS_HOST_NETWORKNODEID 0x1 |
NetworkNodeID for the host(the first node). | |
#define | UDS_DEFAULT_RECVBUFSIZE 0x2E30 |
Default recv_buffer_size that can be used for udsBind() input / code which uses udsBind() internally. | |
#define | UDS_DATAFRAME_MAXSIZE 0x5C6 |
Max size of user data-frames. | |
#define | UDS_CHECK_SENDTO_FATALERROR(x) (R_FAILED(x) && x!=0xC86113F0) |
Check whether a fatal udsSendTo error occured(some error(s) from udsSendTo() can be ignored, but the frame won't be sent when that happens). | |
Functions | |
Result | udsInit (size_t sharedmem_size, const char *username) |
Initializes UDS. More... | |
void | udsExit (void) |
Exits UDS. | |
Result | udsGenerateNodeInfo (udsNodeInfo *nodeinfo, const char *username) |
Generates a NodeInfo struct with data loaded from system-config. More... | |
Result | udsGetNodeInfoUsername (const udsNodeInfo *nodeinfo, char *username) |
Loads the UTF-16 username stored in the input NodeInfo struct, converted to UTF-8. More... | |
bool | udsCheckNodeInfoInitialized (const udsNodeInfo *nodeinfo) |
Checks whether a NodeInfo struct was initialized by NWM-module(not any output from udsGenerateNodeInfo()). More... | |
void | udsGenerateDefaultNetworkStruct (udsNetworkStruct *network, u32 wlancommID, u8 id8, u8 max_nodes) |
Generates a default NetworkStruct for creating networks. More... | |
Result | udsScanBeacons (void *outbuf, size_t maxsize, udsNetworkScanInfo **networks, size_t *total_networks, u32 wlancommID, u8 id8, const u8 *host_macaddress, bool connected) |
Scans for networks via beacon-scanning. More... | |
Result | udsSetApplicationData (const void *buf, size_t size) |
This can be used by the host to set the appdata contained in the broadcasted beacons. More... | |
Result | udsGetApplicationData (void *buf, size_t size, size_t *actual_size) |
This can be used while on a network(host/client) to get the appdata from the current beacon. More... | |
Result | udsGetNetworkStructApplicationData (const udsNetworkStruct *network, void *buf, size_t size, size_t *actual_size) |
This can be used with a NetworkStruct, from udsScanBeacons() mainly, for getting the appdata. More... | |
Result | udsBind (udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator, u8 data_channel, u32 recv_buffer_size) |
Create a bind. More... | |
Result | udsUnbind (udsBindContext *bindcontext) |
Remove a bind. More... | |
bool | udsWaitDataAvailable (const udsBindContext *bindcontext, bool nextEvent, bool wait) |
Waits for the bind event to occur, or checks if the event was signaled. More... | |
Result | udsPullPacket (const udsBindContext *bindcontext, void *buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID) |
Receives data over the network. More... | |
Result | udsSendTo (u16 dst_NetworkNodeID, u8 data_channel, u8 flags, const void *buf, size_t size) |
Sends data over the network. More... | |
Result | udsGetChannel (u8 *channel) |
Gets the wifi channel currently being used. More... | |
Result | udsCreateNetwork (const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u8 data_channel, u32 recv_buffer_size) |
Starts hosting a new network. More... | |
Result | udsConnectNetwork (const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type, u8 data_channel, u32 recv_buffer_size) |
Connect to a network. More... | |
Result | udsDestroyNetwork (void) |
Stop hosting the network. | |
Result | udsDisconnectNetwork (void) |
Disconnect this client device from the network. | |
Result | udsEjectClient (u16 NetworkNodeID) |
This can be used by the host to force-disconnect client(s). More... | |
Result | udsEjectSpectator (void) |
This can be used by the host to force-disconnect the spectators. More... | |
Result | udsUpdateNetworkAttribute (u16 bitmask, bool flag) |
This can be used by the host to update the network attributes. More... | |
Result | udsSetNewConnectionsBlocked (bool block, bool clients, bool flag) |
This uses udsUpdateNetworkAttribute() for (un)blocking new connections to this host. More... | |
Result | udsAllowSpectators (void) |
This uses udsUpdateNetworkAttribute() for unblocking new spectator connections to this host. More... | |
Result | udsGetConnectionStatus (udsConnectionStatus *output) |
This loads the current ConnectionStatus struct. More... | |
bool | udsWaitConnectionStatusEvent (bool nextEvent, bool wait) |
Waits for the ConnectionStatus event to occur, or checks if the event was signaled. More... | |
Result | udsGetNodeInformation (u16 NetworkNodeID, udsNodeInfo *output) |
This loads a NodeInfo struct for the specified NetworkNodeID. More... | |
UDS(NWMUDS) local-WLAN service.
Result udsAllowSpectators | ( | void | ) |
This uses udsUpdateNetworkAttribute() for unblocking new spectator connections to this host.
See udsEjectSpectator() for blocking new spectators.
Result udsBind | ( | udsBindContext * | bindcontext, |
u16 | NetworkNodeID, | ||
bool | spectator, | ||
u8 | data_channel, | ||
u32 | recv_buffer_size | ||
) |
Create a bind.
bindcontext | The output bind context. |
NetworkNodeID | This is the NetworkNodeID which this bind can receive data from. |
spectator | False for a regular bind, true for a spectator. |
data_channel | This is an arbitrary value to use for data-frame filtering. This bind will only receive data frames which contain a matching data_channel value, which was specified by udsSendTo(). The data_channel must be non-zero. |
recv_buffer_size | Size of the buffer under sharedmem used for temporarily storing received data-frames which are then loaded by udsPullPacket(). The system requires this to be >=0x5F4. UDS_DEFAULT_RECVBUFSIZE can be used for this. |
bool udsCheckNodeInfoInitialized | ( | const udsNodeInfo * | nodeinfo | ) |
Checks whether a NodeInfo struct was initialized by NWM-module(not any output from udsGenerateNodeInfo()).
nodeinfo | Input NodeInfo struct. |
Result udsConnectNetwork | ( | const udsNetworkStruct * | network, |
const void * | passphrase, | ||
size_t | passphrase_size, | ||
udsBindContext * | context, | ||
u16 | recv_NetworkNodeID, | ||
udsConnectionType | connection_type, | ||
u8 | data_channel, | ||
u32 | recv_buffer_size | ||
) |
Connect to a network.
network | The NetworkStruct, you can use udsScanBeacons() for this. |
passphrase | Raw input passphrase buffer. |
passphrase_size | Size of the passphrase buffer. |
context | Optional output bind context which will be created for this host. |
recv_NetworkNodeID | This is the NetworkNodeID passed to udsBind() internally. |
connection_type | Type of connection, see the udsConnectionType enum values. |
data_channel | This is the data_channel value which will be passed to udsBind() internally. |
recv_buffer_size | This is the recv_buffer_size value which will be passed to udsBind() internally. |
Result udsCreateNetwork | ( | const udsNetworkStruct * | network, |
const void * | passphrase, | ||
size_t | passphrase_size, | ||
udsBindContext * | context, | ||
u8 | data_channel, | ||
u32 | recv_buffer_size | ||
) |
Starts hosting a new network.
network | The NetworkStruct, you can use udsGenerateDefaultNetworkStruct() for generating this. |
passphrase | Raw input passphrase buffer. |
passphrase_size | Size of the passphrase buffer. |
context | Optional output bind context which will be created for this host, with NetworkNodeID=UDS_BROADCAST_NETWORKNODEID. |
data_channel | This is the data_channel value which will be passed to udsBind() internally. |
recv_buffer_size | This is the recv_buffer_size value which will be passed to udsBind() internally. |
This can be used by the host to force-disconnect client(s).
NetworkNodeID | Target NetworkNodeID. UDS_BROADCAST_NETWORKNODEID can be used to disconnect all clients. |
Result udsEjectSpectator | ( | void | ) |
This can be used by the host to force-disconnect the spectators.
Afterwards new spectators will not be allowed to connect until udsAllowSpectators() is used.
void udsGenerateDefaultNetworkStruct | ( | udsNetworkStruct * | network, |
u32 | wlancommID, | ||
u8 | id8, | ||
u8 | max_nodes | ||
) |
Generates a default NetworkStruct for creating networks.
network | The output struct. |
wlancommID | Unique local-WLAN communications ID for each application. |
id8 | Additional ID that can be used by the application for different types of networks. |
max_nodes | Maximum number of nodes(devices) that can be connected to the network, including the host. |
Result udsGenerateNodeInfo | ( | udsNodeInfo * | nodeinfo, |
const char * | username | ||
) |
Generates a NodeInfo struct with data loaded from system-config.
nodeinfo | Output NodeInfo struct. |
username | If set, this is the UTF-8 string to convert for use in the struct. Max len is 10 characters without NUL-terminator. |
Result udsGetApplicationData | ( | void * | buf, |
size_t | size, | ||
size_t * | actual_size | ||
) |
This can be used while on a network(host/client) to get the appdata from the current beacon.
buf | Appdata buffer. |
size | Max size of the output buffer. |
actual_size | If set, the actual size of the appdata written into the buffer is stored here. |
Gets the wifi channel currently being used.
channel | Output channel. |
Result udsGetConnectionStatus | ( | udsConnectionStatus * | output | ) |
This loads the current ConnectionStatus struct.
output | Output ConnectionStatus struct. |
Result udsGetNetworkStructApplicationData | ( | const udsNetworkStruct * | network, |
void * | buf, | ||
size_t | size, | ||
size_t * | actual_size | ||
) |
This can be used with a NetworkStruct, from udsScanBeacons() mainly, for getting the appdata.
buf | Appdata buffer. |
size | Max size of the output buffer. |
actual_size | If set, the actual size of the appdata written into the buffer is stored here. |
Result udsGetNodeInformation | ( | u16 | NetworkNodeID, |
udsNodeInfo * | output | ||
) |
This loads a NodeInfo struct for the specified NetworkNodeID.
The broadcast alias can't be used with this.
NetworkNodeID | Target NetworkNodeID. |
output | Output NodeInfo struct. |
Result udsGetNodeInfoUsername | ( | const udsNodeInfo * | nodeinfo, |
char * | username | ||
) |
Loads the UTF-16 username stored in the input NodeInfo struct, converted to UTF-8.
nodeinfo | Input NodeInfo struct. |
username | This is the output UTF-8 string. Max len is 10 characters without NUL-terminator. |
Result udsInit | ( | size_t | sharedmem_size, |
const char * | username | ||
) |
Initializes UDS.
sharedmem_size | This must be 0x1000-byte aligned. |
username | Optional custom UTF-8 username(converted to UTF-16 internally) that other nodes on the UDS network can use. If not set the username from system-config is used. Max len is 10 characters without NUL-terminator. |
Result udsPullPacket | ( | const udsBindContext * | bindcontext, |
void * | buf, | ||
size_t | size, | ||
size_t * | actual_size, | ||
u16 * | src_NetworkNodeID | ||
) |
Receives data over the network.
This data is loaded from the recv_buffer setup by udsBind(). When a node disconnects, this will still return data from that node until there's no more frames from that node in the recv_buffer.
bindcontext | Bind context. |
buf | Output receive buffer. |
size | Size of the buffer. |
actual_size | If set, the actual size written into the output buffer is stored here. This is zero when no data was received. |
src_NetworkNodeID | If set, the source NetworkNodeID is written here. This is zero when no data was received. |
Result udsScanBeacons | ( | void * | outbuf, |
size_t | maxsize, | ||
udsNetworkScanInfo ** | networks, | ||
size_t * | total_networks, | ||
u32 | wlancommID, | ||
u8 | id8, | ||
const u8 * | host_macaddress, | ||
bool | connected | ||
) |
Scans for networks via beacon-scanning.
outbuf | Buffer which will be used by the beacon-scanning command and for the data parsing afterwards. Normally there's no need to use the contents of this buffer once this function returns. |
maxsize | Max size of the buffer. @Param networks Ptr where the allocated udsNetworkScanInfo array buffer is written. The allocsize is sizeof(udsNetworkScanInfo)*total_networks. @Param total_networks Total number of networks stored under the networks buffer. |
wlancommID | Unique local-WLAN communications ID for each application. |
id8 | Additional ID that can be used by the application for different types of networks. |
host_macaddress | When set, this code will only return network info from the specified host MAC address. @connected When not connected to a network this must be false. When connected to a network this must be true. |
Result udsSendTo | ( | u16 | dst_NetworkNodeID, |
u8 | data_channel, | ||
u8 | flags, | ||
const void * | buf, | ||
size_t | size | ||
) |
Sends data over the network.
dst_NetworkNodeID | Destination NetworkNodeID. |
data_channel | See udsBind(). |
flags | Send flags, see the UDS_SENDFLAG enum values. |
buf | Input send buffer. |
size | Size of the buffer. |
Result udsSetApplicationData | ( | const void * | buf, |
size_t | size | ||
) |
This can be used by the host to set the appdata contained in the broadcasted beacons.
buf | Appdata buffer. |
size | Size of the input appdata. |
Result udsSetNewConnectionsBlocked | ( | bool | block, |
bool | clients, | ||
bool | flag | ||
) |
This uses udsUpdateNetworkAttribute() for (un)blocking new connections to this host.
block | When true, block the specified connection types(bitmask set). Otherwise allow them(bitmask clear). |
clients | When true, (un)block regular clients. |
flag | When true, update UDSNETATTR_x4. Normally this should be false. |
Result udsUnbind | ( | udsBindContext * | bindcontext | ) |
This can be used by the host to update the network attributes.
If bitmask 0x4 is clear in the input bitmask, this clears that bit in the value before actually writing the value into state. Normally you should use the below wrapper functions.
bitmask | Bitmask to clear/set in the attributes. See the UDSNETATTR enum values. |
flag | When false, bit-clear, otherwise bit-set. |
bool udsWaitConnectionStatusEvent | ( | bool | nextEvent, |
bool | wait | ||
) |
Waits for the ConnectionStatus event to occur, or checks if the event was signaled.
This event is signaled when the data from udsGetConnectionStatus() was updated internally.
nextEvent | Whether to discard the current event and wait for the next event. |
wait | When true this will not return until the event is signaled. When false this checks if the event was signaled without waiting for it. |
bool udsWaitDataAvailable | ( | const udsBindContext * | bindcontext, |
bool | nextEvent, | ||
bool | wait | ||
) |
Waits for the bind event to occur, or checks if the event was signaled.
This event is signaled every time new data is available via udsPullPacket().
bindcontext | The bind context. |
nextEvent | Whether to discard the current event and wait for the next event. |
wait | When true this will not return until the event is signaled. When false this checks if the event was signaled without waiting for it. |