libnx v4.9.0
Loading...
Searching...
No Matches
htcs.h
Go to the documentation of this file.
1/**
2 * @file htcs.h
3 * @brief HTC sockets (htcs) service IPC wrapper. Please use <<TODO>> instead.
4 * @author SciresM
5 * @copyright libnx Authors
6 */
7#pragma once
8
9#include "../types.h"
10#include "../sf/service.h"
11
12#define HTCS_PEER_NAME_MAX 32
13#define HTCS_PORT_NAME_MAX 32
14
15#define HTCS_SESSION_COUNT_MAX 0x10
16#define HTCS_SOCKET_COUNT_MAX 40
17#define HTCS_FD_SET_SIZE HTCS_SOCKET_COUNT_MAX
18
19typedef uint16_t HtcsAddressFamilyType;
20
21typedef struct {
22 char name[HTCS_PEER_NAME_MAX];
24
25typedef struct {
26 char name[HTCS_PORT_NAME_MAX];
28
29typedef struct {
30 HtcsAddressFamilyType family;
31 HtcsPeerName peer_name;
32 HtcsPortName port_name;
34
35typedef struct {
36 s64 tv_sec;
37 s64 tv_usec;
39
40typedef struct {
41 int fds[HTCS_FD_SET_SIZE];
42} HtcsFdSet;
43
44typedef enum {
45 HTCS_ENONE = 0,
46 HTCS_EACCES = 2,
47 HTCS_EADDRINUSE = 3,
48 HTCS_EADDRNOTAVAIL = 4,
49 HTCS_EAGAIN = 6,
50 HTCS_EALREADY = 7,
51 HTCS_EBADF = 8,
52 HTCS_EBUSY = 10,
53 HTCS_ECONNABORTED = 13,
54 HTCS_ECONNREFUSED = 14,
55 HTCS_ECONNRESET = 15,
56 HTCS_EDESTADDRREQ = 17,
57 HTCS_EFAULT = 21,
58 HTCS_EINPROGRESS = 26,
59 HTCS_EINTR = 27,
60 HTCS_EINVAL = 28,
61 HTCS_EIO = 29,
62 HTCS_EISCONN = 30,
63 HTCS_EMFILE = 33,
64 HTCS_EMSGSIZE = 35,
65 HTCS_ENETDOWN = 38,
66 HTCS_ENETRESET = 39,
67 HTCS_ENOBUFS = 42,
68 HTCS_ENOMEM = 49,
69 HTCS_ENOTCONN = 56,
70 HTCS_ETIMEDOUT = 76,
71 HTCS_EUNKNOWN = 79,
72
73 HTCS_EWOULDBLOCK = HTCS_EAGAIN,
74} HtcsSocketError;
75
76typedef enum {
77 HTCS_MSG_PEEK = 1,
78 HTCS_MSG_WAITALL = 2,
79} HtcsMessageFlag;
80
81typedef enum {
82 HTCS_SHUT_RD = 0,
83 HTCS_SHUT_WR = 1,
84 HTCS_SHUT_RDWR = 2,
85} HtcsShutdownType;
86
87typedef enum {
88 HTCS_F_GETFL = 3,
89 HTCS_F_SETFL = 4,
90} HtcsFcntlOperation;
91
92typedef enum {
93 HTCS_O_NONBLOCK = 4,
94} HtcsFcntlFlag;
95
96typedef enum {
97 HTCS_AF_HTCS = 0,
98} HtcsAddressFamily;
99
100typedef struct {
101 Service s;
102} HtcsSocket;
103
104
105/// Initialize the HTCS service.
107
108/// Exit the HTCS service.
109void htcsExit(void);
110
111/// Gets the Service object for the actual HTCS manager service session.
113
114/// Gets the Service object for the actual HTCS monitor service session.
116
117/// Manager functionality.
119Result htcsGetDefaultHostName(HtcsPeerName *out);
120Result htcsCreateSocket(s32 *out_err, HtcsSocket *out, bool enable_disconnection_emulation);
121Result htcsStartSelect(u32 *out_task_id, Handle *out_event_handle, const s32 *read, size_t num_read, const s32 *write, size_t num_write, const s32 *except, size_t num_except, s64 tv_sec, s64 tv_usec);
122Result htcsEndSelect(s32 *out_err, s32 *out_count, s32 *read, size_t num_read, s32 *write, size_t num_write, s32 *except, size_t num_except, u32 task_id);
123
124/// Socket functionality.
125Result htcsSocketClose(HtcsSocket *s, s32 *out_err, s32 *out_res);
126Result htcsSocketConnect(HtcsSocket *s, s32 *out_err, s32 *out_res, const HtcsSockAddr *address);
127Result htcsSocketBind(HtcsSocket *s, s32 *out_err, s32 *out_res, const HtcsSockAddr *address);
128Result htcsSocketListen(HtcsSocket *s, s32 *out_err, s32 *out_res, s32 backlog_count);
129Result htcsSocketShutdown(HtcsSocket *s, s32 *out_err, s32 *out_res, s32 how);
130Result htcsSocketFcntl(HtcsSocket *s, s32 *out_err, s32 *out_res, s32 command, s32 value);
131
132Result htcsSocketAcceptStart(HtcsSocket *s, u32 *out_task_id, Handle *out_event_handle);
133Result htcsSocketAcceptResults(HtcsSocket *s, s32 *out_err, HtcsSocket *out_socket, HtcsSockAddr *out_address, u32 task_id);
134
135Result htcsSocketRecvStart(HtcsSocket *s, u32 *out_task_id, Handle *out_event_handle, s32 mem_size, s32 flags);
136Result htcsSocketRecvResults(HtcsSocket *s, s32 *out_err, s64 *out_size, void *buffer, size_t buffer_size, u32 task_id);
137
138Result htcsSocketSendStart(HtcsSocket *s, u32 *out_task_id, Handle *out_event_handle, const void *buffer, size_t buffer_size, s32 flags);
139Result htcsSocketSendResults(HtcsSocket *s, s32 *out_err, s64 *out_size, u32 task_id);
140
141Result htcsSocketStartSend(HtcsSocket *s, u32 *out_task_id, Handle *out_event_handle, s64 *out_max_size, s64 size, s32 flags);
142Result htcsSocketContinueSend(HtcsSocket *s, s64 *out_size, bool *out_wait, const void *buffer, size_t buffer_size, u32 task_id);
143Result htcsSocketEndSend(HtcsSocket *s, s32 *out_err, s64 *out_size, u32 task_id);
144
145Result htcsSocketStartRecv(HtcsSocket *s, u32 *out_task_id, Handle *out_event_handle, s64 size, s32 flags);
146Result htcsSocketEndRecv(HtcsSocket *s, s32 *out_err, s64 *out_size, void *buffer, size_t buffer_size, u32 task_id);
147
148Result htcsSocketGetPrimitive(HtcsSocket *s, s32 *out);
149
150void htcsCloseSocket(HtcsSocket *s);
void htcsExit(void)
Exit the HTCS service.
Service * htcsGetManagerServiceSession(void)
Gets the Service object for the actual HTCS manager service session.
Result htcsGetPeerNameAny(HtcsPeerName *out)
Manager functionality.
Result htcsInitialize(u32 num_sessions)
Initialize the HTCS service.
Service * htcsGetMonitorServiceSession(void)
Gets the Service object for the actual HTCS monitor service session.
Result htcsSocketClose(HtcsSocket *s, s32 *out_err, s32 *out_res)
Socket functionality.
Definition htcs.h:40
Definition htcs.h:21
Definition htcs.h:25
Definition htcs.h:29
Definition htcs.h:100
Definition htcs.h:35
Service object structure.
Definition service.h:14
int64_t s64
64-bit signed integer.
Definition types.h:28
u32 Handle
Kernel object handle.
Definition types.h:43
u32 Result
Function error code result type.
Definition types.h:44
int32_t s32
32-bit signed integer.
Definition types.h:27
uint32_t u32
32-bit unsigned integer.
Definition types.h:21