diff options
author | Inga Stotland <inga.stotland@intel.com> | 2020-08-20 22:48:56 -0700 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2020-08-22 07:20:26 -0700 |
commit | 43f0c044acf99c6a2781f0bb26e084995d3e7c98 (patch) | |
tree | b66d434f0dec17899969f428284cd52ed90b8395 /mesh/node.c | |
parent | 4de3420d3352e0773dd6e4a8ef665247a0da8bc2 (diff) | |
download | bluez-43f0c044acf99c6a2781f0bb26e084995d3e7c98.tar.gz |
mesh: Use valid net key index when handling Send call
Retrieve value of bound Net Key index based on the value of
passed AppKey index. Check if the key is present and fail early
in case of error. Also, pass the correct NetKey index to model
layer in mesh_model_send(), instead of hard coded 0.
Diffstat (limited to 'mesh/node.c')
-rw-r--r-- | mesh/node.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mesh/node.c b/mesh/node.c index ebc111a62..a6e9cee65 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -1753,7 +1753,7 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, const char *sender, *ele_path; struct l_dbus_message_iter iter_data; struct node_element *ele; - uint16_t dst, app_idx, src; + uint16_t dst, app_idx, net_idx, src; uint8_t *data; uint32_t len; @@ -1782,10 +1782,15 @@ static struct l_dbus_message *send_call(struct l_dbus *dbus, if (app_idx & ~APP_IDX_MASK) return dbus_error(msg, MESH_ERROR_INVALID_ARGS, - "Invalid key_index"); + "Invalid key index"); + + net_idx = appkey_net_idx(node_get_net(node), app_idx); + if (net_idx == NET_IDX_INVALID) + return dbus_error(msg, MESH_ERROR_INVALID_ARGS, + "Key not found"); - if (!mesh_model_send(node, src, dst, app_idx, 0, DEFAULT_TTL, false, - data, len)) + if (!mesh_model_send(node, src, dst, app_idx, net_idx, DEFAULT_TTL, + false, data, len)) return dbus_error(msg, MESH_ERROR_FAILED, NULL); return l_dbus_message_new_method_return(msg); |