From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 3/4] mesh: Allow updating CID, PID, VID & CRPL on node attach
Date: Fri, 8 May 2020 17:00:23 -0700 [thread overview]
Message-ID: <20200509000024.5704-4-inga.stotland@intel.com> (raw)
In-Reply-To: <20200509000024.5704-1-inga.stotland@intel.com>
This allows to update settings of the following composition fields
when an existing node (application) attaches to the daemon:
Company ID (CID), Product ID (PID), Versioin ID (VID),
CRPL (replay protection depth)
---
mesh/mesh-config-json.c | 32 ++++++++++++++++++++++++++++++++
mesh/mesh-config.h | 4 ++++
mesh/node.c | 17 +++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c
index ce7058b5a..9ac3979f8 100644
--- a/mesh/mesh-config-json.c
+++ b/mesh/mesh-config-json.c
@@ -2057,6 +2057,38 @@ bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl)
return save_config(cfg->jnode, cfg->node_dir_path);
}
+bool mesh_config_update_company_id(struct mesh_config *cfg, uint16_t cid)
+{
+ if (!cfg || !write_uint16_hex(cfg->jnode, "cid", cid))
+ return false;
+
+ return save_config(cfg->jnode, cfg->node_dir_path);
+}
+
+bool mesh_config_update_product_id(struct mesh_config *cfg, uint16_t pid)
+{
+ if (!cfg || !write_uint16_hex(cfg->jnode, "pid", pid))
+ return false;
+
+ return save_config(cfg->jnode, cfg->node_dir_path);
+}
+
+bool mesh_config_update_version_id(struct mesh_config *cfg, uint16_t vid)
+{
+ if (!cfg || !write_uint16_hex(cfg->jnode, "vid", vid))
+ return false;
+
+ return save_config(cfg->jnode, cfg->node_dir_path);
+}
+
+bool mesh_config_update_crpl(struct mesh_config *cfg, uint16_t crpl)
+{
+ if (!cfg || !write_uint16_hex(cfg->jnode, "crpl", crpl))
+ return false;
+
+ return save_config(cfg->jnode, cfg->node_dir_path);
+}
+
static bool load_node(const char *fname, const uint8_t uuid[16],
mesh_config_node_func_t cb, void *user_data)
{
diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h
index a5b12bbad..25002f5a7 100644
--- a/mesh/mesh-config.h
+++ b/mesh/mesh-config.h
@@ -172,3 +172,7 @@ bool mesh_config_net_key_set_phase(struct mesh_config *cfg, uint16_t idx,
bool mesh_config_write_address(struct mesh_config *cfg, uint16_t address);
bool mesh_config_write_iv_index(struct mesh_config *cfg, uint32_t idx,
bool update);
+bool mesh_config_update_company_id(struct mesh_config *cfg, uint16_t cid);
+bool mesh_config_update_product_id(struct mesh_config *cfg, uint16_t pid);
+bool mesh_config_update_version_id(struct mesh_config *cfg, uint16_t vid);
+bool mesh_config_update_crpl(struct mesh_config *cfg, uint16_t crpl);
diff --git a/mesh/node.c b/mesh/node.c
index e3f9e52e3..a96c0cae1 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1374,6 +1374,21 @@ static bool add_local_node(struct mesh_node *node, uint16_t unicast, bool kr,
return true;
}
+static void update_composition(struct mesh_node *node, struct mesh_node *attach)
+{
+ if (node->comp.cid != attach->comp.cid)
+ mesh_config_update_company_id(node->cfg, attach->comp.cid);
+
+ if (node->comp.pid != attach->comp.pid)
+ mesh_config_update_product_id(node->cfg, attach->comp.pid);
+
+ if (node->comp.vid != attach->comp.vid)
+ mesh_config_update_version_id(node->cfg, attach->comp.vid);
+
+ if (node->comp.crpl != attach->comp.crpl)
+ mesh_config_update_crpl(node->cfg, attach->comp.crpl);
+}
+
static bool check_req_node(struct managed_obj_request *req)
{
uint8_t node_comp[MAX_MSG_LEN - 2];
@@ -1444,6 +1459,8 @@ static bool attach_req_node(struct mesh_node *attach, struct mesh_node *node)
attach->owner = node->owner;
node->owner = NULL;
+ update_composition(node, attach);
+
node_remove(node);
return true;
--
2.21.3
next prev parent reply other threads:[~2020-05-09 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-09 0:00 [PATCH BlueZ 0/4] Allow some composition fields update Inga Stotland
2020-05-09 0:00 ` [PATCH BlueZ 1/4] mesh: On node attach, verify element/model composition only Inga Stotland
2020-05-09 13:49 ` Gix, Brian
2020-05-14 17:05 ` Gix, Brian
2020-05-09 0:00 ` [PATCH BlueZ 2/4] mesh: Avoid saving duplicate fields in node config Inga Stotland
2020-05-09 0:00 ` Inga Stotland [this message]
2020-05-09 0:00 ` [PATCH BlueZ 4/4] mesh: Remove redundant call to save node configuration Inga Stotland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200509000024.5704-4-inga.stotland@intel.com \
--to=inga.stotland@intel.com \
--cc=brian.gix@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).