Implemented SOCU_AddGlobalSocket.

This commit is contained in:
yellows8 2016-03-30 13:52:15 -04:00
parent 7adab4d940
commit b7b78414da
2 changed files with 28 additions and 0 deletions

View File

@ -138,3 +138,10 @@ int SOCU_GetNetworkOpt(int level, NetworkOpt optname, void * optval, socklen_t *
* @return error * @return error
*/ */
int SOCU_GetIPInfo(struct in_addr *ip, struct in_addr *netmask, struct in_addr *broadcast); int SOCU_GetIPInfo(struct in_addr *ip, struct in_addr *netmask, struct in_addr *broadcast);
/**
* @brief Adds a global socket.
* @param sockfd The socket fd.
* @return error
*/
int SOCU_AddGlobalSocket(int sockfd);

View File

@ -0,0 +1,21 @@
#include "soc_common.h"
#include <3ds/ipc.h>
#include <3ds/result.h>
int SOCU_AddGlobalSocket(int sockfd)
{
u32 *cmdbuf = getThreadCommandBuffer();
sockfd = soc_get_fd(sockfd);
if(sockfd < 0) {
errno = -sockfd;
return -1;
}
cmdbuf[0] = IPC_MakeHeader(0x23,1,0); // 0x230040
cmdbuf[1] = (u32)sockfd;
int ret = svcSendSyncRequest(SOCU_handle);
if(R_FAILED(ret))return ret;
return cmdbuf[1];
}