diff options
Diffstat (limited to 'lib9p/internal.h')
-rw-r--r-- | lib9p/internal.h | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/lib9p/internal.h b/lib9p/internal.h index 801dc4c..92340a5 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -36,47 +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; - - /* output */ - uint32_t net_offset; - /* Increment `host_extra` to pre-allocate space that is - * "extra" beyond sizeof(). */ - size_t host_extra; -}; -typedef bool (*_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; @@ -96,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]; -bool _lib9p_stat_validate(struct _validate_ctx *ctx); -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 ********************************************************/ |