/// NetworkNodeID for the host(the first node).
#define UDS_HOST_NETWORKNODEID 0x1
-/// Default value that can be used for udsSendTo() netflags.
-#define UDS_SEND_NETFLAGS_DEFAULT 0xF3
-
/// Node info struct.
typedef struct {
u64 uds_friendcodeseed;//UDS version of the FriendCodeSeed.
* @param bindcontext The output bind context.
* @param NetworkNodeID This is the NetworkNodeID which this bind can receive data from.
* @param spectator False for a regular bind, true for a spectator.
+ * @param 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.
*/
-Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator);
+Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator, u8 data_channel);
/**
* @brief Remove a bind.
/**
* @brief Sends data over the network.
* @param dst_NetworkNodeID Destination NetworkNodeID.
- * @param netflags UDS_SEND_NETFLAGS_DEFAULT can be used for this. This field is sent in the data frame NWM-module header.
+ * @param data_channel See udsBind().
* @param flags Send flags, see the UDS_SENDFLAG enum values.
* @param buf Input send buffer.
* @param size Size of the buffer.
*/
-Result udsSendTo(u16 dst_NetworkNodeID, u8 netflags, u8 flags, const void *buf, size_t size);
+Result udsSendTo(u16 dst_NetworkNodeID, u8 data_channel, u8 flags, const void *buf, size_t size);
/**
* @brief Gets the wifi channel currently being used.
* @param network The NetworkStruct, you can use udsGenerateDefaultNetworkStruct() for generating this.
* @param passphrase Raw input passphrase buffer.
* @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.
+ * @param bindcontext Optional output bind context which will be created for this host, with NetworkNodeID=UDS_BROADCAST_NETWORKNODEID.
+ * @param data_channel This is the data_channel value which will be passed to udsBind().
*/
-Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *bindcontext);
+Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *bindcontext, u8 data_channel);
/**
* @brief Connect to a network.
* @param network The NetworkStruct, you can use udsScanBeacons() for this.
* @param passphrase Raw input passphrase buffer.
* @param passphrase_size Size of the passphrase buffer.
- * @param bindcontext Output bind context which will be created for this host.
+ * @param bindcontext Optional output bind context which will be created for this host.
* @param recv_NetworkNodeID This is the NetworkNodeID passed to udsBind() internally.
* @param connection_type Type of connection, see the udsConnectionType enum values.
+ * @param data_channel This is the data_channel value which will be passed to udsBind() internally.
*/
-Result udsConnectNetwork(const udsNetworkStruct *network, const 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, u8 data_channel);
/**
* @brief Stop hosting the network.
static Result udsipc_RecvBeaconBroadcastData(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8, Handle event);
static Result udsipc_ScanOnConnection(u8 *outbuf, u32 maxsize, nwmScanInputStruct *scaninput, u32 wlancommID, u8 id8);
-static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 input1, u16 NetworkNodeID);
+static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 data_channel, u16 NetworkNodeID);
static Result udsipc_Unbind(udsBindContext *bindcontext);
static Result udsipc_DecryptBeaconData(udsNetworkStruct *network, u8 *tag0, u8 *tag1, udsNodeInfo *out);
return ret;
}
-Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context)
+Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u8 data_channel)
{
Result ret=0;
ret = udsipc_BeginHostingNetwork(network, passphrase, passphrase_size);
if(R_FAILED(ret))return ret;
- ret = udsBind(context, UDS_BROADCAST_NETWORKNODEID, false);
+ if(context)ret = udsBind(context, UDS_BROADCAST_NETWORKNODEID, false, data_channel);
if(R_FAILED(ret))udsDestroyNetwork();
return ret;
}
-Result udsConnectNetwork(const udsNetworkStruct *network, const 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, u8 data_channel)
{
Result ret=0;
bool spectator=false;
ret = udsipc_ConnectToNetwork(network, passphrase, passphrase_size, connection_type);
if(R_FAILED(ret))return ret;
//printf("bind...\n");
- ret = udsBind(context, recv_NetworkNodeID, spectator);
+ if(context)ret = udsBind(context, recv_NetworkNodeID, spectator, data_channel);
if(R_FAILED(ret))udsDisconnectNetwork();
return ret;
}
-Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator)
+Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator, u8 data_channel)
{
u32 pos;
bindcontext->spectator = spectator;
- return udsipc_Bind(bindcontext, 0x2e30, 0xf3, NetworkNodeID);
+ return udsipc_Bind(bindcontext, 0x2e30, data_channel, NetworkNodeID);
}
Result udsUnbind(udsBindContext *bindcontext)
return 0;
}
-static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 input1, u16 NetworkNodeID)//input0 and input1 are unknown.
+static Result udsipc_Bind(udsBindContext *bindcontext, u32 input0, u8 data_channel, u16 NetworkNodeID)
{
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=IPC_MakeHeader(0x12,4,0); // 0x120100
cmdbuf[1]=bindcontext->BindNodeID;
cmdbuf[2]=input0;
- cmdbuf[3]=input1;
+ cmdbuf[3]=data_channel;
cmdbuf[4]=NetworkNodeID;
Result ret=0;
return ret;
}
-Result udsSendTo(u16 dst_NetworkNodeID, u8 netflags, u8 flags, const void *buf, size_t size)
+Result udsSendTo(u16 dst_NetworkNodeID, u8 data_channel, u8 flags, const void *buf, size_t size)
{
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=IPC_MakeHeader(0x17,6,2); // 0x170182
cmdbuf[1]=0x1;//Unused
cmdbuf[2]=dst_NetworkNodeID;
- cmdbuf[3]=netflags;
+ cmdbuf[3]=data_channel;
cmdbuf[4]=aligned_size>>2;
cmdbuf[5]=size;
cmdbuf[6]=flags;