diff options
Diffstat (limited to 'lib9p/core.c')
-rw-r--r-- | lib9p/core.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib9p/core.c b/lib9p/core.c index d64e23a..f638c12 100644 --- a/lib9p/core.c +++ b/lib9p/core.c @@ -49,9 +49,7 @@ bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) { void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) { assert(ctx); -#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = 0; -#endif ctx->err_msg[0] = '\0'; } @@ -109,22 +107,22 @@ void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum li _lib9p_table_msg[ctx->version][typ].print(w, ctx, body); } -#define _lib9p_validate(LOW_TYP_BIT, ERRMSG, TABLE) do { \ - assert_ver(ctx->version); \ - /* Inspect the first 5 bytes ourselves. */ \ - uint32_t net_size = uint32le_decode(net_bytes); \ - if (net_size < 5) \ - return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is impossibly short"); \ - uint8_t typ = net_bytes[4]; \ - if (typ % 2 != LOW_TYP_BIT) \ - return lib9p_error(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, ERRMSG ": message_type=", lib9p_msgtype_str(ctx->version, typ)); \ - struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \ - if (!tentry.validate) \ - return lib9p_error(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "unknown message type: ", lib9p_msgtype_str(ctx->version, typ), \ - " (protocol_version=", lib9p_version_str(ctx->version), ")"); \ - \ - /* Now use the message-type-specific tentry to process the whole thing. */ \ - return tentry.validate(ctx, net_size, net_bytes); \ +#define _lib9p_validate(LOW_TYP_BIT, ERRMSG, TABLE) do { \ + assert_ver(ctx->version); \ + /* Inspect the first 5 bytes ourselves. */ \ + uint32_t net_size = uint32le_decode(net_bytes); \ + if (net_size < 5) \ + return lib9p_error(ctx, E_POSIX_EBADMSG, "message is impossibly short"); \ + uint8_t typ = net_bytes[4]; \ + if (typ % 2 != LOW_TYP_BIT) \ + return lib9p_error(ctx, E_POSIX_EOPNOTSUPP, ERRMSG ": message_type=", lib9p_msgtype_str(ctx->version, typ)); \ + struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \ + if (!tentry.validate) \ + return lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "unknown message type: ", lib9p_msgtype_str(ctx->version, typ), \ + " (protocol_version=", lib9p_version_str(ctx->version), ")"); \ + \ + /* Now use the message-type-specific tentry to process the whole thing. */ \ + return tentry.validate(ctx, net_size, net_bytes); \ } while (0) ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { |