summaryrefslogtreecommitdiff
path: root/lib9p/tables.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/tables.h')
-rw-r--r--lib9p/tables.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib9p/tables.h b/lib9p/tables.h
new file mode 100644
index 0000000..edb402a
--- /dev/null
+++ b/lib9p/tables.h
@@ -0,0 +1,59 @@
+/* lib9p/tables.h - Declare tables of version and message information
+ *
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#ifndef _LIB9P_TABLES_H_
+#define _LIB9P_TABLES_H_
+
+#include <lib9p/9p.h>
+
+/* version ********************************************************************/
+
+struct _lib9p_ver_tentry {
+ const char *name;
+ uint32_t min_msg_size;
+};
+
+extern const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM];
+
+/* message ********************************************************************/
+
+typedef lo_interface fmt_formatter (*_box_as_fmt_formatter_fn_t)(void *host_val);
+struct _lib9p_msg_tentry {
+ const char *name;
+ _box_as_fmt_formatter_fn_t box_as_fmt_formatter;
+};
+
+typedef ssize_t (*_validate_fn_t)(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes);
+typedef void (*_unmarshal_fn_t)(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out);
+struct _lib9p_recv_tentry {
+ _validate_fn_t validate;
+ _unmarshal_fn_t unmarshal;
+};
+
+struct _marshal_ret {
+ size_t net_iov_cnt;
+ struct iovec *net_iov;
+ size_t net_copied_size;
+ uint8_t *net_copied;
+};
+typedef bool (*_marshal_fn_t)(struct lib9p_ctx *ctx, void *host_val, struct _marshal_ret *ret);
+struct _lib9p_send_tentry {
+ _marshal_fn_t marshal;
+};
+
+extern const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100];
+extern const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80];
+extern const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80];
+extern const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80];
+extern const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80];
+
+/* stat ***********************************************************************/
+
+ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size);
+void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out);
+bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret);
+
+#endif /* _LIB9P_TABLES_H_ */