Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp11992ybk; Fri, 8 May 2020 17:00:59 -0700 (PDT) X-Google-Smtp-Source: APiQypK6Cbxrz19KRIN7ZMpw0exkJshDCW4x7gsYZsUKT6ZFn+PGTjJvs2cVr+1I1bXAZA3xOl7r X-Received: by 2002:a17:906:4c46:: with SMTP id d6mr4001051ejw.257.1588982459540; Fri, 08 May 2020 17:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588982459; cv=none; d=google.com; s=arc-20160816; b=v/oGz6dh1x+g/z8On3A/JHGIfdN5bcAHbjFFavielDiReFPnHHHEZL8FkDjo1lnWbX Gw66mM7lz53WzvUyOJ6m3E47aIon9TgFVrmzf2nx3JJx2F5OAJpeLCWQLtPmP8J9Ejg0 0uH0edyvrFkzVAd0bv8cwxEfQa0fl9RMothvKhgaA5wOUs3zWQXYYwzAx+rM2PD9ccW+ F9cHIySLUmw3fuW6Ehz9Mfuhwb0/fpkXZVtQVyyKLdifS19/6kV+y/Iw8d8ohTEc5ohD zj+oKU53T2tpABbcUyEC487J7gJx0QWhpdB7vK5woDR6VzTVHApN/qdfsjRIU1VMBhID Fh/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=gNpQ8Ma2fPqrWYRz4fBwgSozVeS84LDVi0wD7ExHqfw=; b=n3JnMzbTr0BBo5TBMOSd4gXyF4HN0LWcVnlcOZOvo6dEzI9ZGgDPWJbnT0PBPvf0Bq VjM8xL85eXRityy6Lkyc2e6hpiBfcL8cjfky8k0IPIT0OO3nOTSEqbt6+OWmT4Xkj0QW 6zI33JtBieJPtqiDam05wzA6S77kUkGmbGTM0KnlFa1ofWvBcysu+ny8KgsptSkN8Np9 aDAAT0SkvjzL4bl8SSDWH6CgCUDO1dW/mVSOVr1RWuG79KnOJRUdyY2Cl6PlR7ZOjUHm pQpP6vS7f2duG74X420SKqkptq9K0o9iLg4WJ0ftld3dejVMFXgeQ39UE4hsDYYoRUIU Aefg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si1950644edr.444.2020.05.08.17.00.35; Fri, 08 May 2020 17:00:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728368AbgEIAA3 (ORCPT + 99 others); Fri, 8 May 2020 20:00:29 -0400 Received: from mga04.intel.com ([192.55.52.120]:65494 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728351AbgEIAA2 (ORCPT ); Fri, 8 May 2020 20:00:28 -0400 IronPort-SDR: +gqOE3ba+hkID4hGVhVuue38zW3VCNU+uX4Ve5V8N1s7+lT0NSJJa/t9XPPU8BnovbrNU5CpZs tIBz77P1Q6iA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 17:00:27 -0700 IronPort-SDR: 18J4PDrRCI27uTUOSbexTEd1OC6lDhgcZb1Wp4Xf0WP+0udlc1ADaV76jcLAobn5CJxHJvKM2I ykpcDPXut0eQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,369,1583222400"; d="scan'208";a="408275101" Received: from ingas-nuc1.sea.intel.com ([10.254.110.242]) by orsmga004.jf.intel.com with ESMTP; 08 May 2020 17:00:27 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 3/4] mesh: Allow updating CID, PID, VID & CRPL on node attach Date: Fri, 8 May 2020 17:00:23 -0700 Message-Id: <20200509000024.5704-4-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200509000024.5704-1-inga.stotland@intel.com> References: <20200509000024.5704-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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