From 20a233463e2bfffd2d7660317370ff738236fc76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Lowas-Rzechonek?= Date: Fri, 26 Jul 2019 08:36:06 +0200 Subject: [PATCH] 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. Change-Id: I797fa781a64c7f99754e8c609aee5ccb5a20f9a9 Signed-off-by: Anupam Roy --- mesh/node.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mesh/node.c b/mesh/node.c index f3d1701..9075462 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -900,6 +900,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) @@ -962,6 +964,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; @@ -1007,6 +1012,9 @@ element_done: if (!num_ele) return 0; + if (!cfgmod_idx || *cfgmod_idx != PRIMARY_ELE_IDX) + return 0; + return n; } -- 2.7.4