summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-02 13:12:16 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-02 13:19:04 -0600
commitfa7f6a5176a386f8847810f34538d5c0e56f0fb1 (patch)
treeebcab0fd2b7936a53c77ad7c6614f548b0436103 /lib9p/include
parent50cfe77ace4caa424352a163f90bbf7a684b60d6 (diff)
lib9p: Rename checksize to validate
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index b33ae96..1c8f2e5 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -26,9 +26,12 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg);
int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...);
/**
- * Return how much space the message at net_bytes will take when
- * unmarshaled. This number may be larger than net_bytes due to (1)
- * struct padding, (2) nul-terminator byes for strings.
+ * Validate a message's structure; it's size, string encodings, enums,
+ * and bitfields.
+ *
+ * Return how much space the message will take when unmarshaled. This
+ * number may be larger than net_bytes due to (1) struct padding, (2)
+ * nul-terminator bytes for strings.
*
* Emits an error (return -1, set ctx->err_num and ctx->err_msg) if
* either the message type is unknown, or if net_bytes is too short
@@ -39,10 +42,12 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, .
*
* @return required size, or -1 on error
*
- * @errno LINUX_EBADMSG: message is too short for content
+ * @errno LINUX_EBADMSG: message is wrong size for content
* @errno LINUX_EBADMSG: message contains invalid UTF-8
+ * @errno LINUX_EBADMSG: message contains a bitfield with unknown bits
+ * @errno LINUX_EMSGSIZE: would-be return value overflows SSIZE_MAX
*/
-ssize_t lib9p_unmarshal_size(struct lib9p_ctx *ctx, uint8_t *net_bytes);
+ssize_t lib9p_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
/**
* Unmarshal the 9P message `net_bytes` into the C struct `ret_body`.
@@ -55,13 +60,13 @@ ssize_t lib9p_unmarshal_size(struct lib9p_ctx *ctx, uint8_t *net_bytes);
*
* @return ret_typ : the mesage type
* @return ret_tag : the message-ID tag
- * @return ret_body : the message body, must be at least lib9p_unmarshal_size() bytes
+ * @return ret_body : the message body, must be at least lib9p_validate() bytes
*/
void lib9p_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, uint16_t *ret_tag, void *ret_body);
/**
- * Marshal a `struct lib9p_msg_{typ}` structure into a byte-array.
+ * Marshal a `struct lib9p_msg_{typ}` structure into a byte-array.
*
* @param ctx : negotiated protocol parameters, where to record errors
* @param typ : the message type