Use IPC helpers for soc
This commit is contained in:
parent
fa06930406
commit
deb7518153
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
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);
|
memset(tmpaddr, 0, 0x1c);
|
||||||
|
|
||||||
cmdbuf[0] = 0x00040082;
|
cmdbuf[0] = IPC_MakeHeader(0x4,2,2); // 0x40082
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)tmp_addrlen;
|
cmdbuf[2] = (u32)tmp_addrlen;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (tmp_addrlen<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
|
||||||
cmdbuf[0x104>>2] = (u32)tmpaddr;
|
staticbufs[1] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -54,8 +56,8 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
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;
|
tmpaddr[1] = addr->sa_family;
|
||||||
memcpy(&tmpaddr[2], &addr->sa_data, tmp_addrlen-2);
|
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[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)tmp_addrlen;
|
cmdbuf[2] = (u32)tmp_addrlen;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[5] = (((u32)tmp_addrlen)<<14) | 2;
|
cmdbuf[5] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
|
||||||
cmdbuf[6] = (u32)tmpaddr;
|
cmdbuf[6] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
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;
|
tmpaddr[1] = addr->sa_family;
|
||||||
memcpy(&tmpaddr[2], &addr->sa_data, tmp_addrlen-2);
|
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[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)addrlen;
|
cmdbuf[2] = (u32)addrlen;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[5] = (((u32)tmp_addrlen)<<14) | 2;
|
cmdbuf[5] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
|
||||||
cmdbuf[6] = (u32)tmpaddr;
|
cmdbuf[6] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
#define O_NONBLOCK_3DS 0x4
|
#define O_NONBLOCK_3DS 0x4
|
||||||
|
|
||||||
@ -63,11 +64,11 @@ int fcntl(int sockfd, int cmd, ...)
|
|||||||
arg = to_3ds(arg);
|
arg = to_3ds(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x001300C2;
|
cmdbuf[0] = IPC_MakeHeader(0x13,3,2); // 0x1300C2
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)cmd;
|
cmdbuf[2] = (u32)cmd;
|
||||||
cmdbuf[3] = (u32)arg;
|
cmdbuf[3] = (u32)arg;
|
||||||
cmdbuf[4] = 0x20;
|
cmdbuf[4] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
#define MAX_HOSTENT_RESULTS 16
|
#define MAX_HOSTENT_RESULTS 16
|
||||||
static struct hostent SOC_hostent;
|
static struct hostent SOC_hostent;
|
||||||
@ -15,17 +16,18 @@ struct hostent* gethostbyname(const char *name)
|
|||||||
|
|
||||||
h_errno = 0;
|
h_errno = 0;
|
||||||
|
|
||||||
cmdbuf[0] = 0x000D0082;
|
cmdbuf[0] = IPC_MakeHeader(0xD,2,2); // 0xD0082
|
||||||
cmdbuf[1] = strlen(name)+1;
|
cmdbuf[1] = strlen(name)+1;
|
||||||
cmdbuf[2] = sizeof(outbuf);
|
cmdbuf[2] = sizeof(outbuf);
|
||||||
cmdbuf[3] = ((strlen(name)+1) << 14) | 0xC02;
|
cmdbuf[3] = ((strlen(name)+1) << 14) | 0xC02;
|
||||||
cmdbuf[4] = (u32)name;
|
cmdbuf[4] = (u32)name;
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (sizeof(outbuf) << 14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(sizeof(outbuf),0);
|
||||||
cmdbuf[0x104>>2] = (u32)outbuf;
|
staticbufs[1] = (u32)outbuf;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -33,9 +35,8 @@ struct hostent* gethostbyname(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
long gethostid(void)
|
long gethostid(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
u32 *cmdbuf = getThreadCommandBuffer();
|
u32 *cmdbuf = getThreadCommandBuffer();
|
||||||
|
|
||||||
cmdbuf[0] = 0x00160000;
|
cmdbuf[0] = IPC_MakeHeader(0x16,0,0); // 0x160000
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00180082;
|
cmdbuf[0] = IPC_MakeHeader(0x18,2,2); // 0x180082
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = 0x1c;
|
cmdbuf[2] = 0x1c;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (0x1c<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(0x1c,0);
|
||||||
cmdbuf[0x104>>2] = (u32)tmpaddr;
|
staticbufs[1] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -32,8 +34,8 @@ int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00170082;
|
cmdbuf[0] = IPC_MakeHeader(0x17,2,2); // 0x170082
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = 0x1c;
|
cmdbuf[2] = 0x1c;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (0x1c<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(0x1c,0);
|
||||||
cmdbuf[0x104>>2] = (u32)tmpaddr;
|
staticbufs[1] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -32,8 +34,8 @@ int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00110102;
|
cmdbuf[0] = IPC_MakeHeader(0x11,4,2); // 0x110102
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)level;
|
cmdbuf[2] = (u32)level;
|
||||||
cmdbuf[3] = (u32)optname;
|
cmdbuf[3] = (u32)optname;
|
||||||
cmdbuf[4] = (u32)*optlen;
|
cmdbuf[4] = (u32)*optlen;
|
||||||
cmdbuf[5] = 0x20;
|
cmdbuf[5] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = ((*optlen)<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(*optlen,0);
|
||||||
cmdbuf[0x104>>2] = (u32)optval;
|
staticbufs[1] = (u32)optval;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -33,8 +35,8 @@ int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optl
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.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_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
|
||||||
static int soc_close(struct _reent *r, int fd);
|
static int soc_close(struct _reent *r, int fd);
|
||||||
@ -43,10 +44,10 @@ static Result socu_cmd1(Handle memhandle, u32 memsize)
|
|||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u32 *cmdbuf = getThreadCommandBuffer();
|
u32 *cmdbuf = getThreadCommandBuffer();
|
||||||
|
|
||||||
cmdbuf[0] = 0x00010044;
|
cmdbuf[0] = IPC_MakeHeader(0x1,1,4); // 0x10044
|
||||||
cmdbuf[1] = memsize;
|
cmdbuf[1] = memsize;
|
||||||
cmdbuf[2] = 0x20;
|
cmdbuf[2] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[4] = 0;
|
cmdbuf[4] = IPC_Desc_SharedHandles(1);
|
||||||
cmdbuf[5] = memhandle;
|
cmdbuf[5] = memhandle;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
@ -111,7 +112,7 @@ Result SOC_Shutdown(void)
|
|||||||
svcCloseHandle(socMemhandle);
|
svcCloseHandle(socMemhandle);
|
||||||
socMemhandle = 0;
|
socMemhandle = 0;
|
||||||
|
|
||||||
cmdbuf[0] = 0x00190000;
|
cmdbuf[0] = IPC_MakeHeader(0x19,0,0); // 0x190000
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
|
|
||||||
@ -146,9 +147,9 @@ soc_close(struct _reent *r,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
u32 *cmdbuf = getThreadCommandBuffer();
|
u32 *cmdbuf = getThreadCommandBuffer();
|
||||||
|
|
||||||
cmdbuf[0] = 0x000B0042;
|
cmdbuf[0] = IPC_MakeHeader(0xB,1,2); // 0xB0042
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = 0x20;
|
cmdbuf[2] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int listen(int sockfd, int max_connections)
|
int listen(int sockfd, int max_connections)
|
||||||
{
|
{
|
||||||
@ -13,10 +14,10 @@ int listen(int sockfd, int max_connections)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00030082;
|
cmdbuf[0] = IPC_MakeHeader(0x3,2,2); // 0x30082
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)max_connections;
|
cmdbuf[2] = (u32)max_connections;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
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;
|
tmp_fds[i].revents = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00140084;
|
cmdbuf[0] = IPC_MakeHeader(0x14,2,4); // 0x140084
|
||||||
cmdbuf[1] = (u32)nfds;
|
cmdbuf[1] = (u32)nfds;
|
||||||
cmdbuf[2] = (u32)timeout;
|
cmdbuf[2] = (u32)timeout;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[5] = (size<<14) | 0x2802;
|
cmdbuf[5] = IPC_Desc_StaticBuffer(size,10);
|
||||||
cmdbuf[6] = (u32)tmp_fds;
|
cmdbuf[6] = (u32)tmp_fds;
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (size<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(size,0);
|
||||||
cmdbuf[0x104>>2] = (u32)tmp_fds;
|
staticbufs[1] = (u32)tmp_fds;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -55,8 +57,8 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.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)
|
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)
|
if(src_addr)
|
||||||
tmp_addrlen = 0x1c;
|
tmp_addrlen = 0x1c;
|
||||||
|
|
||||||
cmdbuf[0] = 0x00070104;
|
cmdbuf[0] = IPC_MakeHeader(0x7,4,4); // 0x70104
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)len;
|
cmdbuf[2] = (u32)len;
|
||||||
cmdbuf[3] = (u32)flags;
|
cmdbuf[3] = (u32)flags;
|
||||||
cmdbuf[4] = (u32)tmp_addrlen;
|
cmdbuf[4] = (u32)tmp_addrlen;
|
||||||
cmdbuf[5] = 0x20;
|
cmdbuf[5] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[7] = (((u32)len)<<4) | 12;
|
cmdbuf[7] = IPC_Desc_Buffer(len,IPC_BUFFER_W);
|
||||||
cmdbuf[8] = (u32)buf;
|
cmdbuf[8] = (u32)buf;
|
||||||
|
|
||||||
saved_threadstorage[0] = cmdbuf[0x100>>2];
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
saved_threadstorage[1] = cmdbuf[0x104>>2];
|
saved_threadstorage[0] = staticbufs[0];
|
||||||
|
saved_threadstorage[1] = staticbufs[1];
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = (tmp_addrlen<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(tmp_addrlen,0);
|
||||||
cmdbuf[0x104>>2] = (u32)tmpaddr;
|
staticbufs[1] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
@ -36,8 +38,8 @@ ssize_t socuipc_cmd7(int sockfd, void *buf, size_t len, int flags, struct sockad
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0x100>>2] = saved_threadstorage[0];
|
staticbufs[0] = saved_threadstorage[0];
|
||||||
cmdbuf[0x104>>2] = saved_threadstorage[1];
|
staticbufs[1] = saved_threadstorage[1];
|
||||||
|
|
||||||
ret = (int)cmdbuf[1];
|
ret = (int)cmdbuf[1];
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.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)
|
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);
|
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[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)len;
|
cmdbuf[2] = (u32)len;
|
||||||
cmdbuf[3] = (u32)flags;
|
cmdbuf[3] = (u32)flags;
|
||||||
cmdbuf[4] = (u32)tmp_addrlen;
|
cmdbuf[4] = (u32)tmp_addrlen;
|
||||||
cmdbuf[5] = 0x20;
|
cmdbuf[5] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[7] = (tmp_addrlen<<14) | 0x402;
|
cmdbuf[7] = IPC_Desc_StaticBuffer(tmp_addrlen,1);
|
||||||
cmdbuf[8] = (u32)tmpaddr;
|
cmdbuf[8] = (u32)tmpaddr;
|
||||||
cmdbuf[9] = (((u32)len)<<4) | 10;
|
cmdbuf[9] = IPC_Desc_Buffer(len,IPC_BUFFER_R);
|
||||||
cmdbuf[10] = (u32)buf;
|
cmdbuf[10] = (u32)buf;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
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);
|
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[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)len;
|
cmdbuf[2] = (u32)len;
|
||||||
cmdbuf[3] = (u32)flags;
|
cmdbuf[3] = (u32)flags;
|
||||||
cmdbuf[4] = (u32)tmp_addrlen;
|
cmdbuf[4] = (u32)tmp_addrlen;
|
||||||
cmdbuf[5] = 0x20;
|
cmdbuf[5] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[7] = (((u32)len)<<14) | 0x802;
|
cmdbuf[7] = IPC_Desc_StaticBuffer(len,2);
|
||||||
cmdbuf[8] = (u32)buf;
|
cmdbuf[8] = (u32)buf;
|
||||||
cmdbuf[9] = (tmp_addrlen<<14) | 0x402;
|
cmdbuf[9] = IPC_Desc_StaticBuffer(tmp_addrlen,1);
|
||||||
cmdbuf[10] = (u32)tmpaddr;
|
cmdbuf[10] = (u32)tmpaddr;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00120104;
|
cmdbuf[0] = IPC_MakeHeader(0x12,4,4); // 0x120104
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)level;
|
cmdbuf[2] = (u32)level;
|
||||||
cmdbuf[3] = (u32)optname;
|
cmdbuf[3] = (u32)optname;
|
||||||
cmdbuf[4] = (u32)optlen;
|
cmdbuf[4] = (u32)optlen;
|
||||||
cmdbuf[5] = 0x20;
|
cmdbuf[5] = IPC_Desc_CurProcessHandle();
|
||||||
cmdbuf[7] = (optlen<<14) | 0x2402;
|
cmdbuf[7] = IPC_Desc_StaticBuffer(optlen,9);
|
||||||
cmdbuf[8] = (u32)optval;
|
cmdbuf[8] = (u32)optval;
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int shutdown(int sockfd, int shutdown_type)
|
int shutdown(int sockfd, int shutdown_type)
|
||||||
{
|
{
|
||||||
@ -13,10 +14,10 @@ int shutdown(int sockfd, int shutdown_type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x000C0082;
|
cmdbuf[0] = IPC_MakeHeader(0xC,2,2); // 0xC0082
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = (u32)shutdown_type;
|
cmdbuf[2] = (u32)shutdown_type;
|
||||||
cmdbuf[3] = 0x20;
|
cmdbuf[3] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "soc_common.h"
|
#include "soc_common.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int sockatmark(int sockfd)
|
int sockatmark(int sockfd)
|
||||||
{
|
{
|
||||||
@ -13,9 +14,9 @@ int sockatmark(int sockfd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf[0] = 0x00150042;
|
cmdbuf[0] = IPC_MakeHeader(0x15,1,2); // 0x150042
|
||||||
cmdbuf[1] = (u32)sockfd;
|
cmdbuf[1] = (u32)sockfd;
|
||||||
cmdbuf[2] = 0x20;
|
cmdbuf[2] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
ret = svcSendSyncRequest(SOCU_handle);
|
ret = svcSendSyncRequest(SOCU_handle);
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/iosupport.h>
|
#include <sys/iosupport.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <3ds/ipc.h>
|
||||||
|
|
||||||
int socket(int domain, int type, int protocol)
|
int socket(int domain, int type, int protocol)
|
||||||
{
|
{
|
||||||
@ -10,11 +11,11 @@ int socket(int domain, int type, int protocol)
|
|||||||
__handle *handle;
|
__handle *handle;
|
||||||
u32 *cmdbuf = getThreadCommandBuffer();
|
u32 *cmdbuf = getThreadCommandBuffer();
|
||||||
|
|
||||||
cmdbuf[0] = 0x000200C2;
|
cmdbuf[0] = IPC_MakeHeader(0x2,3,2); // 0x200C2
|
||||||
cmdbuf[1] = domain;
|
cmdbuf[1] = domain;
|
||||||
cmdbuf[2] = type;
|
cmdbuf[2] = type;
|
||||||
cmdbuf[3] = protocol;
|
cmdbuf[3] = protocol;
|
||||||
cmdbuf[4] = 0x20;
|
cmdbuf[4] = IPC_Desc_CurProcessHandle();
|
||||||
|
|
||||||
dev = FindDevice("soc:");
|
dev = FindDevice("soc:");
|
||||||
if(dev < 0) {
|
if(dev < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user