1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include "mos/io/io.h"
6#include "mos/ipc/ipc.h"
7#include "mos/platform/platform.h"
8
9typedef struct
10{
11 io_t io;
12 ipc_t *ipc;
13} ipc_conn_io_t;
14
15/**
16 * @brief Create a new IPC server
17 * @param name The name of the server
18 * @param max_pending_connections The maximum number of pending connections to allow
19 * @return A new io_t object that represents the server, or an error code on failure
20 *
21 * @note The io_t returned by this function is only to accept new connections or close the server, reading or writing to it will fail.
22 */
23io_t *ipc_create(const char *name, size_t max_pending_connections);
24
25/**
26 * @brief Accept a new connection on an IPC server
27 * @param server The server to accept a connection on
28 * @return An io_t for the server side of the connection, or an error code on failure
29 */
30io_t *ipc_accept(io_t *server);
31
32/**
33 * @brief Connect to an IPC servers
34 * @param name The name of the server to connect to
35 * @param buffer_size The size of a shared-memory buffer to use for the connection
36 * @return A new io_t object that represents the connection, or an error code on failure
37 */
38io_t *ipc_connect(const char *name, size_t buffer_size);
39
40/**
41 * @brief Create a new IPC connection io descriptor
42 *
43 * @param ipc The IPC object to create the connection for
44 * @param is_server_side Whether this is the server side of the connection
45 * @return ipc_conn_io_t* A new IPC connection io descriptor
46 */
47ipc_conn_io_t *ipc_conn_io_create(ipc_t *ipc, bool is_server_side);
48