* @param sharedmem_size This must be 0x1000-byte aligned.
* @param 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 udsInit(u32 sharedmem_size, const uint8_t *username);
+Result udsInit(size_t sharedmem_size, const char *username);
/// Exits UDS.
void udsExit(void);
* @param nodeinfo Output NodeInfo struct.
* @param 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 udsGenerateNodeInfo(udsNodeInfo *nodeinfo, const uint8_t *username);
+Result udsGenerateNodeInfo(udsNodeInfo *nodeinfo, const char *username);
/**
* @brief Loads the UTF-16 username stored in the input NodeInfo struct, converted to UTF-8.
* @param nodeinfo Input NodeInfo struct.
* @param username This is the output UTF-8 string. Max len is 10 characters without NUL-terminator.
*/
-Result udsGetNodeInfoUsername(udsNodeInfo *nodeinfo, uint8_t *username);
+Result udsGetNodeInfoUsername(const udsNodeInfo *nodeinfo, char *username);
/**
* @brief Checks whether a NodeInfo struct was initialized by NWM-module(not any output from udsGenerateNodeInfo()).
* @param nodeinfo Input NodeInfo struct.
*/
-bool udsCheckNodeInfoInitialized(udsNodeInfo *nodeinfo);
+bool udsCheckNodeInfoInitialized(const udsNodeInfo *nodeinfo);
/**
* @brief Generates a default NetworkStruct for creating networks.
* @param 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 udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress, bool connected);
+Result udsScanBeacons(void *outbuf, size_t maxsize, udsNetworkScanInfo **networks, size_t *total_networks, u32 wlancommID, u8 id8, const u8 *host_macaddress, bool connected);
/**
* @brief This can be used by the host to set the appdata contained in the broadcasted beacons.
* @param buf Appdata buffer.
* @param size Size of the input appdata.
*/
-Result udsSetApplicationData(u8 *buf, u32 size);
+Result udsSetApplicationData(const void *buf, size_t size);
/**
* @brief This can be used while on a network(host/client) to get the appdata from the current beacon.
* @param size Max size of the output buffer.
* @param actual_size If set, the actual size of the appdata written into the buffer is stored here.
*/
-Result udsGetApplicationData(u8 *buf, u32 size, u32 *actual_size);
+Result udsGetApplicationData(void *buf, size_t size, size_t *actual_size);
/**
* @brief This can be used with a NetworkStruct, from udsScanBeacons() mainly, for getting the appdata.
* @param size Max size of the output buffer.
* @param actual_size If set, the actual size of the appdata written into the buffer is stored here.
*/
-Result udsGetNetworkStructApplicationData(udsNetworkStruct *network, u8 *buf, u32 size, u32 *actual_size);
+Result udsGetNetworkStructApplicationData(const udsNetworkStruct *network, void *buf, size_t size, size_t *actual_size);
/**
* @brief Create a bind.
* @param nextEvent Whether to discard the current event and wait for the next event.
* @param wait When true this will not return until the event is signalled. When false this checks if the event was signalled without waiting for it.
*/
-bool udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait);
+bool udsWaitDataAvailable(const udsBindContext *bindcontext, bool nextEvent, bool wait);
/**
* @brief Receives data over the network.
* @param actual_size If set, the actual size written into the output buffer is stored here. This is zero when no data was received.
* @param src_NetworkNodeID If set, the source NetworkNodeID is written here. This is zero when no data was received.
*/
-Result udsPullPacket(udsBindContext *bindcontext, void* buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID);
+Result udsPullPacket(const udsBindContext *bindcontext, void *buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID);
/**
* @brief Sends data over the network.
* @param buf Input send buffer.
* @param size Size of the buffer.
*/
-Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, void* buf, size_t size);
+Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, const void *buf, size_t size);
/**
* @brief Gets the wifi channel currently being used.
* @param passphrase_size Size of the passphrase buffer.
* @param bindcontext Output bind context which will be created for this host, with NetworkNodeID=UDS_BROADCAST_NETWORKNODEID.
*/
-Result udsCreateNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsBindContext *bindcontext);
+Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *bindcontext);
/**
* @brief Connect to a network.
* @param recv_NetworkNodeID This is the NetworkNodeID passed to udsBind() internally.
* @param connection_type Type of connection, see the udsConnectionType enum values.
*/
-Result udsConnectNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type);
+Result udsConnectNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type);
/**
* @brief Stop hosting the network.
static u32 bind_allocbitmask;
-static Result uds_Initialize(u32 sharedmem_size, const uint8_t *username);
+static Result uds_Initialize(u32 sharedmem_size, const char *username);
static Result udsipc_InitializeWithVersion(udsNodeInfo *nodeinfo, Handle sharedmem_handle, u32 sharedmem_size, Handle *eventhandle);
static Result udsipc_Shutdown(void);
-static Result udsipc_BeginHostingNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size);
-static Result udsipc_ConnectToNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsConnectionType connection_type);
+static Result udsipc_BeginHostingNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size);
+static Result udsipc_ConnectToNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsConnectionType connection_type);
static Result udsipc_SetProbeResponseParam(u32 oui, s8 data);
static Result udsipc_RecvBeaconBroadcastData(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8, Handle event);
static Result usd_parsebeacon(u8 *buf, u32 size, udsNetworkScanInfo *networkscan);
-Result udsInit(u32 sharedmem_size, const uint8_t *username)
+Result udsInit(size_t sharedmem_size, const char *username)
{
Result ret=0;
u32 ndm_state = 0;
ndmuExit();
}
-Result udsGenerateNodeInfo(udsNodeInfo *nodeinfo, const uint8_t *username)
+Result udsGenerateNodeInfo(udsNodeInfo *nodeinfo, const char *username)
{
Result ret=0;
ssize_t units=0;
memset(nodeinfo->usercfg, 0, len*2);
- units = utf8_to_utf16((uint16_t*)nodeinfo->usercfg, username, len);
+ units = utf8_to_utf16((uint16_t*)nodeinfo->usercfg, (uint8_t*)username, len);
if(units < 0 || units > len)ret = -2;
}
return ret;
}
-Result udsGetNodeInfoUsername(udsNodeInfo *nodeinfo, uint8_t *username)
+Result udsGetNodeInfoUsername(const udsNodeInfo *nodeinfo, char *username)
{
ssize_t units=0;
size_t len = 10;
- units = utf16_to_utf8(username, (uint16_t*)nodeinfo->usercfg, len);
+ units = utf16_to_utf8((uint8_t*)username, (uint16_t*)nodeinfo->usercfg, len);
if(units < 0 || units > len)return -2;
return 0;
}
-bool udsCheckNodeInfoInitialized(udsNodeInfo *nodeinfo)
+bool udsCheckNodeInfoInitialized(const udsNodeInfo *nodeinfo)
{
if(nodeinfo->NetworkNodeID)return true;
return false;
network->unk_x1f = 1;
}
-static Result uds_Initialize(u32 sharedmem_size, const uint8_t *username)
+static Result uds_Initialize(u32 sharedmem_size, const char *username)
{
Result ret=0;
udsNodeInfo nodeinfo;
return ret;
}
-Result udsCreateNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsBindContext *context)
+Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context)
{
Result ret=0;
return ret;
}
-Result udsConnectNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type)
+Result udsConnectNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type)
{
Result ret=0;
bool spectator=false;
return ret;
}
-Result udsScanBeacons(u8 *outbuf, u32 maxsize, udsNetworkScanInfo **networks, u32 *total_networks, u32 wlancommID, u8 id8, u8 *host_macaddress, bool connected)
+Result udsScanBeacons(void *buf, size_t maxsize, udsNetworkScanInfo **networks, size_t *total_networks, u32 wlancommID, u8 id8, const u8 *host_macaddress, bool connected)
{
Result ret=0;
Handle event=0;
+ u8 *outbuf = (u8*)buf;
u32 entpos, curpos;
nwmScanInputStruct scaninput;
nwmBeaconDataReplyHeader *hdr;
return ret;
}
-bool udsWaitDataAvailable(udsBindContext *bindcontext, bool nextEvent, bool wait)
+bool udsWaitDataAvailable(const udsBindContext *bindcontext, bool nextEvent, bool wait)
{
bool ret = true;
u64 delayvalue = U64_MAX;
return cmdbuf[1];
}
-Result udsSetApplicationData(u8 *buf, u32 size)
+Result udsSetApplicationData(const void *buf, size_t size)
{
u32* cmdbuf=getThreadCommandBuffer();
return cmdbuf[1];
}
-Result udsGetApplicationData(u8 *buf, u32 size, u32 *actual_size)
+Result udsGetApplicationData(void *buf, size_t size, size_t *actual_size)
{
u32* cmdbuf=getThreadCommandBuffer();
u32 saved_threadstorage[2];
return ret;
}
-Result udsGetNetworkStructApplicationData(udsNetworkStruct *network, u8 *buf, u32 size, u32 *actual_size)
+Result udsGetNetworkStructApplicationData(const udsNetworkStruct *network, void *buf, size_t size, size_t *actual_size)
{
if(network->appdata_size > sizeof(network->appdata))return -1;
if(size > network->appdata_size)size = network->appdata_size;
return cmdbuf[1];
}
-Result udsPullPacket(udsBindContext *bindcontext, void* buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID)
+Result udsPullPacket(const udsBindContext *bindcontext, void *buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID)
{
u32* cmdbuf=getThreadCommandBuffer();
u32 saved_threadstorage[2];
return ret;
}
-Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, void* buf, size_t size)
+Result udsSendTo(u16 dst_NetworkNodeID, u8 input8, u8 flags, const void *buf, size_t size)
{
u32* cmdbuf=getThreadCommandBuffer();
return ret;
}
-static Result udsipc_BeginHostingNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size)
+static Result udsipc_BeginHostingNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size)
{
u32* cmdbuf=getThreadCommandBuffer();
return cmdbuf[1];
}
-static Result udsipc_ConnectToNetwork(udsNetworkStruct *network, void* passphrase, size_t passphrase_size, udsConnectionType connection_type)
+static Result udsipc_ConnectToNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsConnectionType connection_type)
{
u32* cmdbuf=getThreadCommandBuffer();