summaryrefslogtreecommitdiffstats
path: root/lib/protocol.h
diff options
context:
space:
mode:
authorJulian Bouzas <julian.bouzas@collabora.com>2021-04-20 04:08:58 -0400
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2021-07-28 13:19:02 +0300
commitf25bb13718f334bc0c96d29ea9f3a57c0a6f3a34 (patch)
treeeaa30eafe2df92e3d5d75571d022c3a775246bff /lib/protocol.h
parent7bf96bda703dd157385cbb175ec90bd6f38af404 (diff)
lib: add wpipc library
Simple library that uses sockets for inter-process communication. It provides an API to create server and client objects. Users can add custom handlers in the server, and clients can send requests for those custom handlers. Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'lib/protocol.h')
-rw-r--r--lib/protocol.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/lib/protocol.h b/lib/protocol.h
new file mode 100644
index 0000000..730c918
--- /dev/null
+++ b/lib/protocol.h
@@ -0,0 +1,87 @@
+/* PipeWire AGL Cluster IPC
+ *
+ * Copyright © 2021 Collabora Ltd.
+ * @author Julian Bouzas <julian.bouzas@collabora.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef __ICIPC_PROTOCOL_H__
+#define __ICIPC_PROTOCOL_H__
+
+#include <spa/pod/pod.h>
+
+#include "defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* request */
+
+ICIPC_API
+size_t
+icipc_protocol_calculate_request_size (const char *name,
+ const struct spa_pod *args);
+
+ICIPC_API
+void
+icipc_protocol_build_request (uint8_t *buffer,
+ size_t size,
+ const char *name,
+ const struct spa_pod *args);
+
+ICIPC_API
+bool
+icipc_protocol_parse_request (const uint8_t *buffer,
+ size_t size,
+ const char **name,
+ const struct spa_pod **args);
+
+/* reply */
+
+ICIPC_API
+size_t
+icipc_protocol_calculate_reply_ok_size (const struct spa_pod *value);
+
+ICIPC_API
+size_t
+icipc_protocol_calculate_reply_error_size (const char *msg);
+
+ICIPC_API
+void
+icipc_protocol_build_reply_ok (uint8_t *buffer,
+ size_t size,
+ const struct spa_pod *value);
+
+ICIPC_API
+void
+icipc_protocol_build_reply_error (uint8_t *buffer,
+ size_t size,
+ const char *msg);
+
+ICIPC_API
+bool
+icipc_protocol_is_reply_ok (const uint8_t *buffer, size_t size);
+
+ICIPC_API
+bool
+icipc_protocol_is_reply_error (const uint8_t *buffer, size_t size);
+
+ICIPC_API
+bool
+icipc_protocol_parse_reply_ok (const uint8_t *buffer,
+ size_t size,
+ const struct spa_pod **value);
+
+ICIPC_API
+bool
+icipc_protocol_parse_reply_error (const uint8_t *buffer,
+ size_t size,
+ const char **msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif