From 1e4ad99311611a7fbb5cdfe4b1b79202381dc717 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 13 Apr 2025 22:13:43 -0600 Subject: Split lib9p into lib9p_core and lib9p_srv --- lib9p/core_tables.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib9p/core_tables.h (limited to 'lib9p/core_tables.h') diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h new file mode 100644 index 0000000..2c5f745 --- /dev/null +++ b/lib9p/core_tables.h @@ -0,0 +1,59 @@ +/* lib9p/core_tables.h - Declare tables of version and message information + * + * Copyright (C) 2024-2025 Luke T. Shumaker + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#ifndef _LIB9P_CORE_TABLES_H_ +#define _LIB9P_CORE_TABLES_H_ + +#include + +/* 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_CORE_TABLES_H_ */ -- cgit v1.2.3-2-g168b