Bluetooth: Audio: Add BT_MCS_VALID_OP

Add the BT_MCS_VALID_OP macro to verify MCS opcodes for
both the MCC and MCS implementations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-02-10 14:11:57 +01:00 committed by Carles Cufí
commit e7770a6a7e
3 changed files with 37 additions and 0 deletions

View file

@ -2735,6 +2735,18 @@ int bt_mcc_send_cmd(struct bt_conn *conn, const struct mpl_cmd *cmd)
return -EINVAL;
}
CHECKIF(cmd == NULL) {
LOG_DBG("cmd is NULL");
return -EINVAL;
}
CHECKIF(!BT_MCS_VALID_OP(cmd->opcode)) {
LOG_DBG("Opcode 0x%02X is invalid", cmd->opcode);
return -EINVAL;
}
length = sizeof(cmd->opcode);
(void)memcpy(mcs_inst->write_buf, &cmd->opcode, length);
if (cmd->use_param) {