summaryrefslogtreecommitdiff
path: root/lib9p/9p.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-12 20:54:28 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-12 20:54:28 -0700
commitd148555bd86e323a51734b7881f92d09e2f08425 (patch)
tree0fa494fa06ca00e72926a6bde8158adb0ddc5a06 /lib9p/9p.c
parent6cd125e1ffd44fdf62c44d22c519561a8c9d7268 (diff)
parentbd0f2f3e0fe721c7fbce63aeacffaec8344e166c (diff)
Merge branch 'lukeshu/misc'
Diffstat (limited to 'lib9p/9p.c')
-rw-r--r--lib9p/9p.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib9p/9p.c b/lib9p/9p.c
index 51ff2eb..c54dae7 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -124,10 +124,12 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
struct lib9p_ctx *ctx, uint8_t *net_bytes) {
/* Inspect the first 5 bytes ourselves. */
struct _validate_ctx subctx = {
+ /* input */
.ctx = ctx,
.net_size = uint32le_decode(net_bytes),
.net_bytes = net_bytes,
+ /* output */
.net_offset = 0,
.host_extra = 0,
};
@@ -171,17 +173,19 @@ static
void _lib9p_unmarshal(const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80],
struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, void *ret_body) {
+ enum lib9p_msg_type typ = net_bytes[4];
+ *ret_typ = typ;
+ struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2];
+
struct _unmarshal_ctx subctx = {
+ /* input */
.ctx = ctx,
.net_bytes = net_bytes,
+ /* output */
.net_offset = 0,
+ .extra = ret_body + tentry.basesize,
};
-
- enum lib9p_msg_type typ = net_bytes[4];
- *ret_typ = typ;
- struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2];
- subctx.extra = ret_body + tentry.basesize;
tentry.unmarshal(&subctx, ret_body);
}
@@ -202,7 +206,10 @@ bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x8
struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
uint8_t *ret_bytes) {
struct _marshal_ctx subctx = {
+ /* input */
.ctx = ctx,
+
+ /* ouptut */
.net_bytes = ret_bytes,
.net_offset = 0,
};
@@ -228,10 +235,12 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
uint32_t *ret_net_size, ssize_t *ret_host_size) {
struct _validate_ctx subctx = {
+ /* input */
.ctx = ctx,
.net_size = net_size,
.net_bytes = net_bytes,
+ /* output */
.net_offset = 0,
.host_extra = 0,
};
@@ -248,11 +257,13 @@ bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_
uint32_t lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
struct lib9p_stat *ret_obj, void *ret_extra) {
struct _unmarshal_ctx subctx = {
- .ctx = ctx,
- .net_bytes = net_bytes,
- .net_offset = 0,
+ /* input */
+ .ctx = ctx,
+ .net_bytes = net_bytes,
- .extra = ret_extra,
+ /* output */
+ .net_offset = 0,
+ .extra = ret_extra,
};
_lib9p_stat_unmarshal(&subctx, ret_obj);
return subctx.net_offset;
@@ -263,7 +274,10 @@ uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct
struct lib9p_ctx _ctx = *ctx;
_ctx.max_msg_size = max_net_size;
struct _marshal_ctx subctx = {
+ /* input */
.ctx = &_ctx,
+
+ /* output */
.net_bytes = ret_bytes,
.net_offset = 0,
};