2019-07-26 04:32:14

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v5 5/5] mesh: Check that config server is present in primary element

This verifies that Config Server model is supported by element #0, and
is not supported by any other element.
---
mesh/node.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mesh/node.c b/mesh/node.c
index f937fe361..e0f1bbde2 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -899,6 +899,8 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz)
{
uint16_t n, features;
uint16_t num_ele = 0;
+ uint8_t *cfgmod_idx = NULL;
+
const struct l_queue_entry *ele_entry;

if (!node || !node->comp || sz < MIN_COMP_SIZE)
@@ -961,6 +963,9 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz)
mod_id = mesh_model_get_model_id(
(const struct mesh_model *) mod);

+ if (mod_id == CONFIG_SRV_MODEL)
+ cfgmod_idx = &ele->idx;
+
if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) {
if (n + 2 > sz)
goto element_done;
@@ -1006,6 +1011,9 @@ element_done:
if (!num_ele)
return 0;

+ if (!cfgmod_idx || *cfgmod_idx != PRIMARY_ELE_IDX)
+ return 0;
+
return n;
}

--
2.22.0