mesh: Allow to set-up the CRPL with application
authorJakub Witowski <jakub.witowski@silvair.com>
Tue, 2 Jul 2019 12:31:41 +0000 (14:31 +0200)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 17 Dec 2019 15:20:20 +0000 (20:50 +0530)
This adds an optional CRPL property to org.bluez.mesh.Application1
interface, allowing to indicate the depth of reply protection list.

Change-Id: I838ecb7f4f5396d46a67fe20ca87c8944331eb82
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
doc/mesh-api.txt
mesh/node.c

index 4e0a8bf..893a1a6 100644 (file)
@@ -724,6 +724,10 @@ Properties:
 
                A 16-bit vendor-assigned product version identifier
 
+       uint16 CRPL [read-only, optional]
+
+               A 16-bit minimum number of replay protection list entries
+
 
 Mesh Element Hierarchy
 ======================
index 3f5c580..3c0e64c 100644 (file)
@@ -1314,10 +1314,6 @@ static bool create_node_config(struct mesh_node *node)
 static void set_defaults(struct mesh_node *node)
 {
        /* TODO: these values should come from mesh.conf */
-       if (!node->comp)
-               node->comp = l_new(struct node_composition, 1);
-
-       node->comp->crpl = DEFAULT_CRPL;
        node->lpn = MESH_MODE_UNSUPPORTED;
        node->proxy = MESH_MODE_UNSUPPORTED;
        node->friend = MESH_MODE_UNSUPPORTED;
@@ -1340,8 +1336,10 @@ static bool get_app_properties(struct mesh_node *node, const char *path,
 
        l_debug("path %s", path);
 
-       if (is_new)
+       if (is_new) {
                node->comp = l_new(struct node_composition, 1);
+               node->comp->crpl = DEFAULT_CRPL;
+       }
 
        while (l_dbus_message_iter_next_entry(properties, &key, &variant)) {
 
@@ -1374,6 +1372,16 @@ static bool get_app_properties(struct mesh_node *node, const char *path,
                                return false;
 
                        node->comp->vid = value;
+
+               } else if (!strcmp(key, "CRPL")) {
+                       if (!l_dbus_message_iter_get_variant(&variant, "q",
+                                                                       &value))
+                               return false;
+
+                       if (!is_new && node->comp->crpl != value)
+                               return false;
+
+                       node->comp->crpl = value;
                }
        }