mesh: Handle messages sent to a fixed group address
PATCH v3 1/1 mesh: Handle messages sent to a fixed group address
This handles the case when an inbound message is addressed to a fixed group, i.e., all-proxies, all-friends, all-relays and all-nodes. The message is delivered to a primary element only, and, with the exception of all-nodes case, if the corresponding feature is enabled on the node.
--- mesh/mesh-defs.h | 2 ++ mesh/model.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-)
mesh/mesh-defs.h +2 -0
@@ -118,4 +118,6 @@#define IS_GROUP (x) ((((x) >= GROUP_ADDRESS_LOW) && \ ((x) < FIXED_GROUP_HIGH)) || \ ((x) == ALL_NODES_ADDRESS)) + +#define IS_FIXED_GROUP_ADDRESS (x) ((x) >= PROXIES_ADDRESS)#define IS_ALL_NODES (x) ((x) == ALL_NODES_ADDRESS)
mesh/model.c +31 -1
@@ -311,7 +311,7 @@ static void forward_model(void *a, void *b)return ; dst = fwd->dst; -if (dst == fwd->unicast ||IS_ALL_NODES (dst)) +if (dst == fwd->unicast ||IS_FIXED_GROUP_ADDRESS (dst)) fwd->has_dst = true;else if (fwd->virt) { virt =l_queue_find (mod->virtuals, simple_match, fwd->virt);
@@ -886,8 +886,30 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,if (!num_ele ||IS_UNASSIGNED (addr)) goto done; +/* +* In case of fixed group addresses check if the +* corresponding mode is enabled. +*/ +if (dst ==PROXIES_ADDRESS && + (node_proxy_mode_get (node) !=MESH_MODE_ENABLED )) + goto done; + +if (dst ==FRIENDS_ADDRESS && + (node_friend_mode_get (node) !=MESH_MODE_ENABLED )) + goto done; + +if (dst ==RELAYS_ADDRESS ) { +uint8_t cnt; +uint16_t interval; + +if (node_relay_mode_get (node, &cnt, &interval) != +MESH_MODE_ENABLED ) + goto done; + } + is_subscription = !(IS_UNICAST (dst)); +for (i =0 ; i < num_ele; i++) {struct l_queue *models;
@@ -927,6 +949,14 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,/* If the message was to unicast address, we are done */ if (!is_subscription && ele_idx == i)break ; + +/* +* For the fixed group addresses, i.e., all-proxies, +* all-friends, all-relays, all-nodes, the message is delivered +* to a primary element only. +*/ +if (IS_FIXED_GROUP_ADDRESS (dst)) +break ; } done:
Signature · 1 line
2.21.0
Gix, Brian
AppliedApplied
Quoted 80 lines · Inga Stotland
This handles the case when an inbound message is addressed to a fixed group, i.e., all-proxies, all-friends, all-relays and all-nodes. The message is delivered to a primary element only, and, with the exception of all-nodes case, if the corresponding feature is enabled on the node.
--- mesh/mesh-defs.h | 2 ++ mesh/model.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-)mesh/mesh-defs.h +2
-0@@ -118,4 +118,6 @@#define IS_GROUP (x) ((((x) >= GROUP_ADDRESS_LOW) && \ ((x) < FIXED_GROUP_HIGH)) || \ ((x) == ALL_NODES_ADDRESS)) + +#define IS_FIXED_GROUP_ADDRESS (x) ((x) >= PROXIES_ADDRESS)#define IS_ALL_NODES (x) ((x) == ALL_NODES_ADDRESS)mesh/model.c +31
-1@@ -311,7 +311,7 @@ static void forward_model(void *a, void *b)return ; dst = fwd->dst; -if (dst == fwd->unicast ||IS_ALL_NODES (dst)) +if (dst == fwd->unicast ||IS_FIXED_GROUP_ADDRESS (dst)) fwd->has_dst = true;else if (fwd->virt) { virt =l_queue_find (mod->virtuals, simple_match, fwd->virt);@@ -886,8 +886,30 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,if (!num_ele ||IS_UNASSIGNED (addr)) goto done; +/* +* In case of fixed group addresses check if the +* corresponding mode is enabled. +*/ +if (dst ==PROXIES_ADDRESS && + (node_proxy_mode_get (node) !=MESH_MODE_ENABLED )) + goto done; + +if (dst ==FRIENDS_ADDRESS && + (node_friend_mode_get (node) !=MESH_MODE_ENABLED )) + goto done; + +if (dst ==RELAYS_ADDRESS ) { +uint8_t cnt; +uint16_t interval; + +if (node_relay_mode_get (node, &cnt, &interval) != +MESH_MODE_ENABLED ) + goto done; + } + is_subscription = !(IS_UNICAST (dst)); +for (i =0 ; i < num_ele; i++) {struct l_queue *models;@@ -927,6 +949,14 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,/* If the message was to unicast address, we are done */ if (!is_subscription && ele_idx == i)break ; + +/* +* For the fixed group addresses, i.e., all-proxies, +* all-friends, all-relays, all-nodes, the message is delivered +* to a primary element only. +*/ +if (IS_FIXED_GROUP_ADDRESS (dst)) +break ; } done: