diff mbox series

[BlueZ,2/2] mesh: Check for enabled modes when dst is fixed address

Message ID 20200818222208.50938-2-inga.stotland@intel.com
State New
Headers show
Series None | expand

Commit Message

Inga Stotland Aug. 18, 2020, 10:22 p.m. UTC
This moves the check for incoming messages addressed to fixed addresses,
e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled,
the message is not processed.
---
 mesh/model.c | 21 ---------------------
 mesh/net.c   |  9 +++++++++
 2 files changed, 9 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/mesh/model.c b/mesh/model.c
index 961391f13..b44e2f669 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -937,27 +937,6 @@  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++) {
diff --git a/mesh/net.c b/mesh/net.c
index 26440b02d..115a76944 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -1658,6 +1658,15 @@  static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index,
 	}
 
 not_for_friend:
+	if (dst == FRIENDS_ADDRESS && !net->friend_enable)
+		return false;
+
+	if (dst == RELAYS_ADDRESS && !net->relay.enable)
+		return false;
+
+	if (dst == PROXIES_ADDRESS && !net->proxy_enable)
+		return false;
+
 	return mesh_model_rx(net->node, szmic, seqAuth, seq, iv_index, net_idx,
 						src, dst, key_aid, data, size);
 }