/* Returns: errno code corresponding to the status code in @l3l4_hdr and a message in @strbuf describing the error.  */
int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr, char *strbuf, size_t strbuf_size)
/* Returns: errno code corresponding to the status code in @l3l4_hdr and a message in @strbuf describing the error.  */
int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr, char *strbuf, size_t strbuf_size)
{
	int result;
	enum i2400m_ms status = le16_to_cpu(l3l4_hdr->status);
	const char *str;
	if (status == 0)
		return 0;
	if (status >= ARRAY_SIZE(ms_to_errno)) {
		str = "unknown status code";
		result = -EBADR;
	} else {
		str = ms_to_errno[status].msg;
		result = ms_to_errno[status].errno;
	}
	if (strbuf)
		snprintf(strbuf, strbuf_size, "%s (%d)", str, status);
	return result;
}