]> Chaos Git - corbenik/ctrulib.git/commitdiff
Use IPC helpers for soc
authorLectem <lectem@gmail.com>
Wed, 9 Sep 2015 20:44:02 +0000 (16:44 -0400)
committerLectem <lectem@gmail.com>
Sat, 3 Oct 2015 10:59:17 +0000 (06:59 -0400)
18 files changed:
libctru/source/services/soc/soc_accept.c
libctru/source/services/soc/soc_bind.c
libctru/source/services/soc/soc_connect.c
libctru/source/services/soc/soc_fcntl.c
libctru/source/services/soc/soc_gethostbyname.c
libctru/source/services/soc/soc_gethostid.c
libctru/source/services/soc/soc_getpeername.c
libctru/source/services/soc/soc_getsockname.c
libctru/source/services/soc/soc_getsockopt.c
libctru/source/services/soc/soc_init.c
libctru/source/services/soc/soc_listen.c
libctru/source/services/soc/soc_poll.c
libctru/source/services/soc/soc_recvfrom.c
libctru/source/services/soc/soc_sendto.c
libctru/source/services/soc/soc_setsockopt.c
libctru/source/services/soc/soc_shutdown.c
libctru/source/services/soc/soc_sockatmark.c
libctru/source/services/soc/soc_socket.c

index 71ce7908e6d2b0ebb3c6090e3403101f0a3bce6f..a5a39e304ca1375d405d2ac0c16e916de0492f76 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 {
@@ -36,16 +37,17 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 
        memset(tmpaddr, 0, 0x1c);
 
-       cmdbuf[0] = 0x00040082;
+       cmdbuf[0] = IPC_MakeHeader(0x4,2,2); // 0x40082
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)tmp_addrlen;
-       cmdbuf[3] = 0x20;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (tmp_addrlen<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)tmpaddr;
+       staticbufs[0] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
+       staticbufs[1] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -54,8 +56,8 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return ret;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-       cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 610cdf607e7f7216d61f907fbea6faa162f73ec3..b452992c17ac64d5c505240b68657a06aa8160c2 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
 {
@@ -31,11 +32,11 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
        tmpaddr[1] = addr->sa_family;
        memcpy(&tmpaddr[2], &addr->sa_data, tmp_addrlen-2);
 
-       cmdbuf[0] = 0x00050084;
+       cmdbuf[0] = IPC_MakeHeader(0x5,2,4); // 0x50084
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)tmp_addrlen;
-       cmdbuf[3] = 0x20;
-       cmdbuf[5] = (((u32)tmp_addrlen)<<14) | 2;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
+       cmdbuf[5] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
        cmdbuf[6] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
index 4cab7cc6a222822b12cf2efe8c7d3dcf72641cbf..5778858ba04217c517b32105ea7f9602fe414682 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
 {
@@ -31,11 +32,11 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
        tmpaddr[1] = addr->sa_family;
        memcpy(&tmpaddr[2], &addr->sa_data, tmp_addrlen-2);
 
-       cmdbuf[0] = 0x00060084;
+       cmdbuf[0] = IPC_MakeHeader(0x6,2,4); // 0x60084
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)addrlen;
-       cmdbuf[3] = 0x20;
-       cmdbuf[5] = (((u32)tmp_addrlen)<<14) | 2;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
+       cmdbuf[5] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
        cmdbuf[6] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
index f14a0e083d8c227b2c8d2734ef4372ab51181c26..824fea0f24b1a8327073ce68ad350d3982db1709 100644 (file)
@@ -2,6 +2,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
+#include <3ds/ipc.h>
 
 #define O_NONBLOCK_3DS 0x4
 
@@ -63,11 +64,11 @@ int fcntl(int sockfd, int cmd, ...)
                arg = to_3ds(arg);
        }
 
-       cmdbuf[0] = 0x001300C2;
+       cmdbuf[0] = IPC_MakeHeader(0x13,3,2); // 0x1300C2
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)cmd;
        cmdbuf[3] = (u32)arg;
-       cmdbuf[4] = 0x20;
+       cmdbuf[4] = IPC_Desc_CurProcessHandle();
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index 2121c3b2909714eaff6ddc1e58c1372cd5532404..50c44aa88f60cd4beabac62c7494c06afd9ae075 100644 (file)
@@ -1,5 +1,6 @@
 #include "soc_common.h"
 #include <netdb.h>
+#include <3ds/ipc.h>
 
 #define MAX_HOSTENT_RESULTS 16
 static struct hostent SOC_hostent;
@@ -15,17 +16,18 @@ struct hostent* gethostbyname(const char *name)
 
        h_errno = 0;
 
-       cmdbuf[0] = 0x000D0082;
+       cmdbuf[0] = IPC_MakeHeader(0xD,2,2); // 0xD0082
        cmdbuf[1] = strlen(name)+1;
        cmdbuf[2] = sizeof(outbuf);
        cmdbuf[3] = ((strlen(name)+1) << 14) | 0xC02;
        cmdbuf[4] = (u32)name;
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (sizeof(outbuf) << 14) | 2;
-       cmdbuf[0x104>>2] = (u32)outbuf;
+       staticbufs[0] = IPC_Desc_StaticBuffer(sizeof(outbuf),0);
+       staticbufs[1] = (u32)outbuf;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -33,9 +35,8 @@ struct hostent* gethostbyname(const char *name)
                return NULL;
        }
 
-
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-        cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 7a254aacea908cf26ec88a36860ddc8288d418e9..ba4fe4fb8b273ec4435c0f3e408c4a4a7301bac7 100644 (file)
@@ -1,12 +1,13 @@
 #include "soc_common.h"
 #include <errno.h>
+#include <3ds/ipc.h>
 
 long gethostid(void)
 {
        int ret = 0;
        u32 *cmdbuf = getThreadCommandBuffer();
 
-       cmdbuf[0] = 0x00160000;
+       cmdbuf[0] = IPC_MakeHeader(0x16,0,0); // 0x160000
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index 977b14b6953296f84ce7ae11ec0f0456cf148a89..b0aedab1b1fdf6201fa53b9fe175fd6b3b36c221 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 {
@@ -15,16 +16,17 @@ int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return -1;
        }
 
-       cmdbuf[0] = 0x00180082;
+       cmdbuf[0] = IPC_MakeHeader(0x18,2,2); // 0x180082
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = 0x1c;
-       cmdbuf[3] = 0x20;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (0x1c<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)tmpaddr;
+       staticbufs[0] = IPC_Desc_StaticBuffer(0x1c,0);
+       staticbufs[1] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -32,8 +34,8 @@ int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return ret;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-       cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 2fd16b36ba554c6a1de071f3e5537fc89a4a4cdb..9b9f0c39debab8618b2cf3a1d5726372d0fd2afb 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 {
@@ -15,16 +16,17 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return -1;
        }
 
-       cmdbuf[0] = 0x00170082;
+       cmdbuf[0] = IPC_MakeHeader(0x17,2,2); // 0x170082
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = 0x1c;
-       cmdbuf[3] = 0x20;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (0x1c<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)tmpaddr;
+       staticbufs[0] = IPC_Desc_StaticBuffer(0x1c,0);
+       staticbufs[1] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -32,8 +34,8 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
                return ret;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-       cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 8b48994859b85eee06c6defd805dcde18687e003..52d0f6e785b7796c2c9801444be6d901ce6d9200 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
 {
@@ -14,18 +15,19 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl
                return -1;
        }
 
-       cmdbuf[0] = 0x00110102;
+       cmdbuf[0] = IPC_MakeHeader(0x11,4,2); // 0x110102
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)level;
        cmdbuf[3] = (u32)optname;
        cmdbuf[4] = (u32)*optlen;
-       cmdbuf[5] = 0x20;
+       cmdbuf[5] = IPC_Desc_CurProcessHandle();
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = ((*optlen)<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)optval;
+       staticbufs[0] = IPC_Desc_StaticBuffer(*optlen,0);
+       staticbufs[1] = (u32)optval;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -33,8 +35,8 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl
                return ret;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-       cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 3b84b65c61d5f94f387f7d9f63e87a028a384d57..e6263d75cc0549fc994ec70f8dbd1abee666e910 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 static int     soc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
 static int     soc_close(struct _reent *r, int fd);
@@ -43,10 +44,10 @@ static Result socu_cmd1(Handle memhandle, u32 memsize)
        Result ret = 0;
        u32 *cmdbuf = getThreadCommandBuffer();
 
-       cmdbuf[0] = 0x00010044;
+       cmdbuf[0] = IPC_MakeHeader(0x1,1,4); // 0x10044
        cmdbuf[1] = memsize;
-       cmdbuf[2] = 0x20;
-       cmdbuf[4] = 0;
+       cmdbuf[2] = IPC_Desc_CurProcessHandle();
+       cmdbuf[4] = IPC_Desc_SharedHandles(1);
        cmdbuf[5] = memhandle;
 
        ret = svcSendSyncRequest(SOCU_handle);
@@ -111,7 +112,7 @@ Result SOC_Shutdown(void)
        svcCloseHandle(socMemhandle);
        socMemhandle = 0;
 
-       cmdbuf[0] = 0x00190000;
+       cmdbuf[0] = IPC_MakeHeader(0x19,0,0); // 0x190000
 
        ret = svcSendSyncRequest(SOCU_handle);
 
@@ -146,9 +147,9 @@ soc_close(struct _reent *r,
        int ret = 0;
        u32 *cmdbuf = getThreadCommandBuffer();
 
-       cmdbuf[0] = 0x000B0042;
+       cmdbuf[0] = IPC_MakeHeader(0xB,1,2); // 0xB0042
        cmdbuf[1] = (u32)sockfd;
-       cmdbuf[2] = 0x20;
+       cmdbuf[2] = IPC_Desc_CurProcessHandle();
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index 53257d2b9d777f52127edb95c2a7209d83b51844..542fa02ac8511f1a6b05dfcc6c15a4af4fbacc1a 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int listen(int sockfd, int max_connections)
 {
@@ -13,10 +14,10 @@ int listen(int sockfd, int max_connections)
                return -1;
        }
 
-       cmdbuf[0] = 0x00030082;
+       cmdbuf[0] = IPC_MakeHeader(0x3,2,2); // 0x30082
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)max_connections;
-       cmdbuf[3] = 0x20;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index 324612c4fbad88d06c4396e35e221c0904b2cc12..2d6f3bca649f414815c15b81af44684e2ed3226b 100644 (file)
@@ -3,6 +3,7 @@
 #include <poll.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <3ds/ipc.h>
 
 int poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
@@ -35,18 +36,19 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
                tmp_fds[i].revents = 0;
        }
 
-       cmdbuf[0] = 0x00140084;
+       cmdbuf[0] = IPC_MakeHeader(0x14,2,4); // 0x140084
        cmdbuf[1] = (u32)nfds;
        cmdbuf[2] = (u32)timeout;
-       cmdbuf[3] = 0x20;
-       cmdbuf[5] = (size<<14) | 0x2802;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
+       cmdbuf[5] = IPC_Desc_StaticBuffer(size,10);
        cmdbuf[6] = (u32)tmp_fds;
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (size<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)tmp_fds;
+       staticbufs[0] = IPC_Desc_StaticBuffer(size,0);
+       staticbufs[1] = (u32)tmp_fds;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -55,8 +57,8 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
                return ret;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-        cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index f9b206abf64607a85293a7930d541088f30590ae..03365f452244118d9b674fc7d809a250b9538a04 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 ssize_t socuipc_cmd7(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
 {
@@ -15,20 +16,21 @@ ssize_t socuipc_cmd7(int sockfd, void *buf, size_t len, int flags, struct sockad
        if(src_addr)
                tmp_addrlen = 0x1c;
 
-       cmdbuf[0] = 0x00070104;
+       cmdbuf[0] = IPC_MakeHeader(0x7,4,4); // 0x70104
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)len;
        cmdbuf[3] = (u32)flags;
        cmdbuf[4] = (u32)tmp_addrlen;
-       cmdbuf[5] = 0x20;
-       cmdbuf[7] = (((u32)len)<<4) | 12;
+       cmdbuf[5] = IPC_Desc_CurProcessHandle();
+       cmdbuf[7] = IPC_Desc_Buffer(len,IPC_BUFFER_W);
        cmdbuf[8] = (u32)buf;
 
-       saved_threadstorage[0] = cmdbuf[0x100>>2];
-       saved_threadstorage[1] = cmdbuf[0x104>>2];
+       u32 * staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0] = staticbufs[0];
+       saved_threadstorage[1] = staticbufs[1];
 
-       cmdbuf[0x100>>2] = (tmp_addrlen<<14) | 2;
-       cmdbuf[0x104>>2] = (u32)tmpaddr;
+       staticbufs[0] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
+       staticbufs[1] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
@@ -36,8 +38,8 @@ ssize_t socuipc_cmd7(int sockfd, void *buf, size_t len, int flags, struct sockad
                return -1;
        }
 
-       cmdbuf[0x100>>2] = saved_threadstorage[0];
-       cmdbuf[0x104>>2] = saved_threadstorage[1];
+       staticbufs[0] = saved_threadstorage[0];
+       staticbufs[1] = saved_threadstorage[1];
 
        ret = (int)cmdbuf[1];
        if(ret == 0)
index 4b84749228b5c63ef0842acb471e6ca77eb71a0f..5c0f3a51f746b448b1d51be9302e5c1cf4d51fd5 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 ssize_t socuipc_cmd9(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
 {
@@ -27,15 +28,15 @@ ssize_t socuipc_cmd9(int sockfd, const void *buf, size_t len, int flags, const s
                memcpy(&tmpaddr[2], &dest_addr->sa_data, tmp_addrlen-2);
        }
 
-       cmdbuf[0] = 0x00090106;
+       cmdbuf[0] = IPC_MakeHeader(0x9,4,6); // 0x90106
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)len;
        cmdbuf[3] = (u32)flags;
        cmdbuf[4] = (u32)tmp_addrlen;
-       cmdbuf[5] = 0x20;
-       cmdbuf[7] = (tmp_addrlen<<14) | 0x402;
+       cmdbuf[5] = IPC_Desc_CurProcessHandle();
+       cmdbuf[7] = IPC_Desc_StaticBuffer(tmp_addrlen,1);
        cmdbuf[8] = (u32)tmpaddr;
-       cmdbuf[9] = (((u32)len)<<4) | 10;
+       cmdbuf[9] = IPC_Desc_Buffer(len,IPC_BUFFER_R);
        cmdbuf[10] = (u32)buf;
 
        ret = svcSendSyncRequest(SOCU_handle);
@@ -81,15 +82,15 @@ ssize_t socuipc_cmda(int sockfd, const void *buf, size_t len, int flags, const s
                memcpy(&tmpaddr[2], &dest_addr->sa_data, tmp_addrlen-2);
        }
 
-       cmdbuf[0] = 0x000A0106;
+       cmdbuf[0] = IPC_MakeHeader(0xA,4,6); // 0xA0106
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)len;
        cmdbuf[3] = (u32)flags;
        cmdbuf[4] = (u32)tmp_addrlen;
-       cmdbuf[5] = 0x20;
-       cmdbuf[7] = (((u32)len)<<14) | 0x802;
+       cmdbuf[5] = IPC_Desc_CurProcessHandle();
+       cmdbuf[7] = IPC_Desc_StaticBuffer(len,2);
        cmdbuf[8] = (u32)buf;
-       cmdbuf[9] = (tmp_addrlen<<14) | 0x402;
+       cmdbuf[9] = IPC_Desc_StaticBuffer(tmp_addrlen,1);
        cmdbuf[10] = (u32)tmpaddr;
 
        ret = svcSendSyncRequest(SOCU_handle);
index 600d8cfa1970e4a11f365b38dc370bac70171a5f..b2386d2e10572fe1cabc82b20c8adfb1476c6962 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 {
@@ -13,13 +14,13 @@ int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t
                return -1;
        }
 
-       cmdbuf[0] = 0x00120104;
+       cmdbuf[0] = IPC_MakeHeader(0x12,4,4); // 0x120104
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)level;
        cmdbuf[3] = (u32)optname;
        cmdbuf[4] = (u32)optlen;
-       cmdbuf[5] = 0x20;
-       cmdbuf[7] = (optlen<<14) | 0x2402;
+       cmdbuf[5] = IPC_Desc_CurProcessHandle();
+       cmdbuf[7] = IPC_Desc_StaticBuffer(optlen,9);
        cmdbuf[8] = (u32)optval;
 
        ret = svcSendSyncRequest(SOCU_handle);
index 89b2db6178ef72d38855c93e3c802d80dbef3a20..0af20a8e79cc4ad8ef07b99640e361ab463fde31 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int shutdown(int sockfd, int shutdown_type)
 {
@@ -13,10 +14,10 @@ int shutdown(int sockfd, int shutdown_type)
                return -1;
        }
 
-       cmdbuf[0] = 0x000C0082;
+       cmdbuf[0] = IPC_MakeHeader(0xC,2,2); // 0xC0082
        cmdbuf[1] = (u32)sockfd;
        cmdbuf[2] = (u32)shutdown_type;
-       cmdbuf[3] = 0x20;
+       cmdbuf[3] = IPC_Desc_CurProcessHandle();
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index f7743898525d7f4cc15b633046cd7301d2c05e95..ea4454351f81e5747dad4dd0a470b5ec9b741400 100644 (file)
@@ -1,6 +1,7 @@
 #include "soc_common.h"
 #include <errno.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int sockatmark(int sockfd)
 {
@@ -13,9 +14,9 @@ int sockatmark(int sockfd)
                return -1;
        }
 
-       cmdbuf[0] = 0x00150042;
+       cmdbuf[0] = IPC_MakeHeader(0x15,1,2); // 0x150042
        cmdbuf[1] = (u32)sockfd;
-       cmdbuf[2] = 0x20;
+       cmdbuf[2] = IPC_Desc_CurProcessHandle();
 
        ret = svcSendSyncRequest(SOCU_handle);
        if(ret != 0) {
index bf0270017b36c99fc10f397cef397beff71995bd..53b7aa230c4a5dfa18ba1f134f0d4de8f53c3784 100644 (file)
@@ -2,6 +2,7 @@
 #include <errno.h>
 #include <sys/iosupport.h>
 #include <sys/socket.h>
+#include <3ds/ipc.h>
 
 int socket(int domain, int type, int protocol)
 {
@@ -10,11 +11,11 @@ int socket(int domain, int type, int protocol)
        __handle *handle;
        u32 *cmdbuf = getThreadCommandBuffer();
 
-       cmdbuf[0] = 0x000200C2;
+       cmdbuf[0] = IPC_MakeHeader(0x2,3,2); // 0x200C2
        cmdbuf[1] = domain;
        cmdbuf[2] = type;
        cmdbuf[3] = protocol;
-       cmdbuf[4] = 0x20;
+       cmdbuf[4] = IPC_Desc_CurProcessHandle();
 
        dev = FindDevice("soc:");
        if(dev < 0) {