[RFC PATCH BlueZ v2 5/7] mesh: main.conf/cfgmod-server: allow to enable proxy support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The proxy settings in the config file and in the configuration server
only affect the _relaying_ between GATT and ADV. Provisioning via
PB-GATT and connecting to the GATT proxy service is always possible
(MshPRT_v1.1, section 4.2.12).

The actual relaying of network messages and beacons is implemented in
the next patches.
---
 mesh/cfgmod-server.c |  9 +++++----
 mesh/mesh-main.conf  |  9 +++++++++
 mesh/mesh.c          | 14 +++++++++++++-
 mesh/mesh.h          |  1 +
 mesh/node.c          |  3 ++-
 5 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index f9f80aff7920..5c0015033d00 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -405,7 +405,8 @@ static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt,
 	if (opcode == OP_CONFIG_RELAY_SET) {
 		count = (pkt[1] & 0x7) + 1;
 		interval = ((pkt[1] >> 3) + 1) * 10;
-		node_relay_mode_set(node, !!pkt[0], count, interval);
+		node_relay_mode_set(node, pkt[0] == MESH_MODE_ENABLED, count,
+								interval);
 	}
 
 	n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg);
@@ -879,7 +880,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
 		break;
 
 	case OP_CONFIG_RELAY_SET:
-		if (size != 2 || pkt[0] > 0x01)
+		if (size != 2 || pkt[0] > MESH_MODE_ENABLED)
 			return true;
 		/* Fall Through */
 
@@ -903,10 +904,10 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
 		break;
 
 	case OP_CONFIG_PROXY_SET:
-		if (size != 1 || pkt[0] > 0x01)
+		if (size != 1 || pkt[0] > MESH_MODE_ENABLED)
 			return true;
 
-		node_proxy_mode_set(node, !!pkt[0]);
+		node_proxy_mode_set(node, pkt[0] == MESH_MODE_ENABLED);
 		/* Fall Through */
 
 	case OP_CONFIG_PROXY_GET:
diff --git a/mesh/mesh-main.conf b/mesh/mesh-main.conf
index aca9e6fa5a36..d917218fcf1a 100644
--- a/mesh/mesh-main.conf
+++ b/mesh/mesh-main.conf
@@ -16,6 +16,15 @@
 # Defaults to true.
 #Relay = true
 
+# Default setting for supporting proxy. The setting applies
+# to all local nodes.
+# If the value is true, then a configuration client can either enable or disable
+# the proxy feature per local node.
+# If the value is false, then the proxy feature cannot be configured for
+# any local node.
+# Defaults to true.
+#Proxy = true
+
 # Default setting for supporting Friendship. The setting applies
 # to all local nodes.
 # If the value is true, then a configuration client can either enable or disable
diff --git a/mesh/mesh.c b/mesh/mesh.c
index db77602d37da..5dbec2b319d0 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -85,7 +85,7 @@ static struct bt_mesh mesh = {
 	.friend_support = true,
 	.relay_support = true,
 	.lpn_support = false,
-	.proxy_support = false,
+	.proxy_support = true,
 	.crpl = DEFAULT_CRPL,
 	.friend_queue_sz = DEFAULT_FRIEND_QUEUE_SZ,
 	.initialized = false
@@ -192,6 +192,11 @@ bool mesh_relay_supported(void)
 	return mesh.relay_support;
 }
 
+bool mesh_proxy_supported(void)
+{
+	return mesh.proxy_support;
+}
+
 bool mesh_friendship_supported(void)
 {
 	return mesh.friend_support;
@@ -231,6 +236,13 @@ static void parse_settings(const char *mesh_conf_fname)
 		l_free(str);
 	}
 
+	str = l_settings_get_string(settings, "General", "Proxy");
+	if (str) {
+		if (!strcasecmp(str, "false"))
+			mesh.proxy_support = false;
+		l_free(str);
+	}
+
 	str = l_settings_get_string(settings, "General", "Friendship");
 	if (str) {
 		if (!strcasecmp(str, "false"))
diff --git a/mesh/mesh.h b/mesh/mesh.h
index c30a8d1f08da..e293d4ba1613 100644
--- a/mesh/mesh.h
+++ b/mesh/mesh.h
@@ -40,6 +40,7 @@ const char *mesh_prov_status_str(uint8_t status);
 const char *mesh_get_storage_dir(void);
 bool mesh_beacon_enabled(void);
 bool mesh_relay_supported(void);
+bool mesh_proxy_supported(void);
 bool mesh_friendship_supported(void);
 uint16_t mesh_get_crpl(void);
 uint8_t mesh_get_friend_queue_size(void);
diff --git a/mesh/node.c b/mesh/node.c
index 7f20e97ea230..18aad67bf8d0 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -209,7 +209,8 @@ uint8_t *node_uuid_get(struct mesh_node *node)
 static void set_defaults(struct mesh_node *node)
 {
 	node->lpn = MESH_MODE_UNSUPPORTED;
-	node->proxy = MESH_MODE_UNSUPPORTED;
+	node->proxy = (mesh_proxy_supported()) ? MESH_MODE_DISABLED :
+							MESH_MODE_UNSUPPORTED;
 	node->mpb = MESH_MODE_DISABLED;
 	node->mpb_period = NET_MPB_REFRESH_DEFAULT;
 	node->friend = (mesh_friendship_supported()) ? MESH_MODE_DISABLED :
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux