From 5478200c1560ebbb1ac6dcf8d96cf94c3fa3693e Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 25 Mar 2025 12:36:41 -0600 Subject: lib9p: Remove specialized contexts Now that the validate/unmarshal/marshal functions are all flat, they don't need specialized contexts. --- lib9p/internal.h | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'lib9p/internal.h') diff --git a/lib9p/internal.h b/lib9p/internal.h index 4820f10..92340a5 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -36,41 +36,18 @@ static_assert(CONFIG_9P_MAX_ERR_SIZE <= UINT16_MAX); static_assert(CONFIG_9P_MAX_MSG_SIZE <= CONFIG_9P_MAX_HOSTMSG_SIZE); static_assert(CONFIG_9P_MAX_HOSTMSG_SIZE <= SSIZE_MAX); -/* specialized contexts *******************************************************/ - -struct _validate_ctx { - /* input */ - struct lib9p_ctx *ctx; - uint32_t net_size; - uint8_t *net_bytes; -}; -typedef ssize_t (*_validate_fn_t)(struct _validate_ctx *ctx); - -struct _unmarshal_ctx { - /* input */ - struct lib9p_ctx *ctx; - uint8_t *net_bytes; - - /* output */ - uint32_t net_offset; - /* `extra` points to the beginning of unallocated space. */ - void *extra; -}; -typedef void (*_unmarshal_fn_t)(struct _unmarshal_ctx *ctx, void *out); +/* tables / exports ***********************************************************/ -struct _marshal_ctx { - /* input */ - struct lib9p_ctx *ctx; +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); - /* output */ +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 _marshal_ctx *ctx, void *host_val); - -/* tables / exports ***********************************************************/ +typedef bool (*_marshal_fn_t)(struct lib9p_ctx *ctx, void *host_val, struct _marshal_ret *ret); struct _lib9p_recv_tentry { size_t basesize; @@ -90,9 +67,9 @@ extern const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x8 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]; -ssize_t _lib9p_stat_validate(struct _validate_ctx *ctx, uint32_t *ret_net_size); -void _lib9p_stat_unmarshal(struct _unmarshal_ctx *ctx, struct lib9p_stat *out); -bool _lib9p_stat_marshal(struct _marshal_ctx *ctx, struct lib9p_stat *val); +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); /* unmarshal utilities ********************************************************/ -- cgit v1.2.3-2-g168b