]> Chaos Git - corbenik/ctrulib.git/commitdiff
Implemented udsUpdateNetworkAttribute() and udsSetNewConnectionsBlocked().
authoryellows8 <yellows8@users.noreply.github.com>
Wed, 6 Apr 2016 05:56:02 +0000 (01:56 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Wed, 6 Apr 2016 05:56:02 +0000 (01:56 -0400)
libctru/include/3ds/services/uds.h
libctru/source/services/uds.c

index 0e16f7df05e9f8ca3fe693fd22b5d148b1073eac..7220ed677cae466450696721ae224ca2646153dc 100644 (file)
@@ -103,7 +103,7 @@ typedef struct {
 } udsNetworkScanInfo;
 
 enum {
-       UDSNETATTR_DisableConnectClients = BIT(1), //When set new Clients are not allowed to connect.
+       UDSNETATTR_DisableConnectClients = BIT(1), //When set new Clients are (supposedly) not allowed to connect.
        UDSNETATTR_DisableConnectSpectators = BIT(2), //When set new Spectators are (probably) not allowed to connect.
        UDSNETATTR_Default = BIT(15), //Unknown what this bit is for.
 };
@@ -276,3 +276,18 @@ Result udsDisconnectNetwork(void);
  */
 Result udsEjectClient(u16 NetworkNodeID);
 
+/**
+ * @brief 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.
+ * @param bitmask Bitmask to clear/set in the attributes. See the UDSNETATTR enum values.
+ * @param flag When false, bit-clear, otherwise bit-set.
+ */
+Result udsUpdateNetworkAttribute(u16 bitmask, bool flag);
+
+/**
+ * @brief This uses udsUpdateNetworkAttribute() for (un)blocking new connections to this host with the specified type(s). This is what it was supposed to do, doesn't seem actually to affect new connections though.
+ * @param block When true, block the specified connection types. Otherwise allow them.
+ * @param clients When true, (un)block regular clients.
+ * @param clients When true, (un)block spectators(?).
+ */
+Result udsSetNewConnectionsBlocked(bool block, bool clients, bool spectators);
+
index 02c564c79ebd770b5286b282d6973d97eb854608..81c2aaab24dfc843fc0619194ba908fa809aa408 100644 (file)
@@ -321,6 +321,32 @@ Result udsEjectClient(u16 NetworkNodeID)
        return cmdbuf[1];
 }
 
+Result udsUpdateNetworkAttribute(u16 bitmask, bool flag)
+{
+       u32* cmdbuf=getThreadCommandBuffer();
+
+       if(flag)flag = 1;
+
+       cmdbuf[0]=IPC_MakeHeader(0x7,2,0); // 0x70080
+       cmdbuf[1]=bitmask;
+       cmdbuf[2]=flag;
+
+       Result ret=0;
+       if(R_FAILED(ret=svcSendSyncRequest(__uds_servhandle)))return ret;
+
+       return cmdbuf[1];
+}
+
+Result udsSetNewConnectionsBlocked(bool block, bool clients, bool spectators)
+{
+       u16 bitmask = 0;
+
+       if(clients)bitmask |= UDSNETATTR_DisableConnectClients;
+       if(spectators)bitmask |= UDSNETATTR_DisableConnectSpectators;
+
+       return udsUpdateNetworkAttribute(bitmask, block);
+}
+
 Result udsDestroyNetwork(void)
 {
        u32* cmdbuf=getThreadCommandBuffer();