Bluetooth: Mesh: Check if app key is bound in Model Publication Set
Th Configuration Server should respond with and Invalid AppKey Index status code when the AppKey identified by AppKeyIndex is not known to the node or is not bound to the model identified by the ModelIdentifier. Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This commit is contained in:
parent
5199e1bfa9
commit
343c0bd2d3
3 changed files with 5 additions and 4 deletions
|
@ -553,7 +553,7 @@ uint8_t bt_mesh_elem_count(void)
|
||||||
return dev_comp->elem_count;
|
return dev_comp->elem_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool model_has_key(struct bt_mesh_model *mod, uint16_t key)
|
bool bt_mesh_model_has_key(struct bt_mesh_model *mod, uint16_t key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!model_has_key(model, rx->ctx.app_idx)) {
|
if (!bt_mesh_model_has_key(model, rx->ctx.app_idx)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||||
struct net_buf_simple *msg,
|
struct net_buf_simple *msg,
|
||||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||||
{
|
{
|
||||||
if (!model_has_key(model, ctx->app_idx)) {
|
if (!bt_mesh_model_has_key(model, ctx->app_idx)) {
|
||||||
BT_ERR("Model not bound to AppKey 0x%04x", ctx->app_idx);
|
BT_ERR("Model not bound to AppKey 0x%04x", ctx->app_idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ uint8_t bt_mesh_elem_count(void);
|
||||||
struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
|
struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
|
||||||
|
|
||||||
bool bt_mesh_has_addr(uint16_t addr);
|
bool bt_mesh_has_addr(uint16_t addr);
|
||||||
|
bool bt_mesh_model_has_key(struct bt_mesh_model *mod, uint16_t key);
|
||||||
|
|
||||||
void bt_mesh_model_extensions_walk(struct bt_mesh_model *root,
|
void bt_mesh_model_extensions_walk(struct bt_mesh_model *root,
|
||||||
enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod,
|
enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod,
|
||||||
|
|
|
@ -216,7 +216,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bt_mesh_app_key_exists(app_idx)) {
|
if (!bt_mesh_app_key_exists(app_idx) || !bt_mesh_model_has_key(model, app_idx)) {
|
||||||
return STATUS_INVALID_APPKEY;
|
return STATUS_INVALID_APPKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue