diff --git a/include/vfio-user.h b/include/vfio-user.h index 91d69fc1..a749938c 100644 --- a/include/vfio-user.h +++ b/include/vfio-user.h @@ -82,11 +82,11 @@ struct vfio_user_header { uint16_t cmd; uint32_t msg_size; uint32_t flags; -#define VFIO_USER_F_TYPE 0xf -#define VFIO_USER_F_TYPE_COMMAND 0x0 -#define VFIO_USER_F_TYPE_REPLY 0x1 -#define VFIO_USER_F_NO_REPLY 0x10 -#define VFIO_USER_F_ERROR 0x20 +#define VFIO_USER_F_TYPE_MASK (0xf) +#define VFIO_USER_F_TYPE_COMMAND (0x0) +#define VFIO_USER_F_TYPE_REPLY (0x1) +#define VFIO_USER_F_NO_REPLY (0x10) +#define VFIO_USER_F_ERROR (0x20) uint32_t error_no; } __attribute__((packed)); diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 1f886b3d..271a269a 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1283,7 +1283,7 @@ get_request_header(vfu_ctx_t *vfu_ctx, vfu_msg_t **msgp) static bool is_valid_header(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) { - if ((msg->hdr.flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) { + if ((msg->hdr.flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) { vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: not a command req", msg->hdr.msg_id); return false; diff --git a/lib/tran_pipe.c b/lib/tran_pipe.c index d1663018..e7aa84d0 100644 --- a/lib/tran_pipe.c +++ b/lib/tran_pipe.c @@ -131,7 +131,7 @@ tran_pipe_recv(int fd, struct vfio_user_header *hdr, bool is_reply, return ERROR_INT(EPROTO); } - if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_REPLY) { + if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) { return ERROR_INT(EINVAL); } @@ -142,7 +142,7 @@ tran_pipe_recv(int fd, struct vfio_user_header *hdr, bool is_reply, return ERROR_INT(hdr->error_no); } } else { - if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) { + if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) { return ERROR_INT(EINVAL); } if (msg_id != NULL) { diff --git a/lib/tran_sock.c b/lib/tran_sock.c index a737f87d..3f4c8c38 100644 --- a/lib/tran_sock.c +++ b/lib/tran_sock.c @@ -211,7 +211,7 @@ tran_sock_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply, return ERROR_INT(EPROTO); } - if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_REPLY) { + if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) { return ERROR_INT(EINVAL); } @@ -222,7 +222,7 @@ tran_sock_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply, return ERROR_INT(hdr->error_no); } } else { - if ((hdr->flags & VFIO_USER_F_TYPE) != VFIO_USER_F_TYPE_COMMAND) { + if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) { return ERROR_INT(EINVAL); } if (msg_id != NULL) {