Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5315667ybl; Wed, 22 Jan 2020 14:36:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxXv7EIpLwuE2+FnEj7Yl6/u5XQtdNhWCot/VwT1CcHSshRcf9XiON2pUVPIFKSWiMikG7B X-Received: by 2002:a05:6830:18fa:: with SMTP id d26mr8478373otf.305.1579732560377; Wed, 22 Jan 2020 14:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579732560; cv=none; d=google.com; s=arc-20160816; b=qCk9egvjkmtAbWBFbPIJuTX3xvtZt5flNvAEtFikLw7chh2FhRlqh76ki4RHzljeBr +UV4ohKVvBY5Adh3OkWmnOQzivMNgK+Xl9AhiRNXlwem2nH4W42oH4oqhuYm6SRWe6Zk fOwVvpL9HMr2kAsbtnOVwxiOcg02YuKG90ls7yYbFudUjPftyabUdNRS0j3BImFuIQ8W jho7iWPbRhJS+GO2J5HpYYHagiVV9v/9+S+CCMaGPdfu11HjGCTcffCQQJCU3UEcKe0z FBlda5Gk8YWVCnR5XRjknjU0VfKvIca8I1ZMQpLlI0KT1Nw591KpQhzYjKH0m7Cl+Xu8 gdNA== 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 :message-id:date:subject:cc:to:from; bh=CPNFyHhWtT8aXOI5QaH/l3mj1AyOyPjsQi8kFi7LUBA=; b=xdQikg9oFCBtqEzOEYI4PxdGlt+Qlb73Wk++G5Uee5fUeK5GrpsECl0CNSW6+/mN8q 6GlWIgoABqtP8rZ2SGkS6Mrqds8RVr5lqp+AmEGgDqv+3apC+omeMqY0xlOC+HsxpaSE yDavofB6Os6GOATh95ZulaNsQglCJoaCvEhRG8kCRFR8RvnCBSZro34ta4bEov0ine1Q EFbQSIQ43PPR3R24noG3juWFRSCCcMsRm9bgzin57GKvwl78jZuRhFY2sYtFLshqXkA7 vzB4RlfoPUbhKuLJZVUg0uhE0GaYaBnPqM1QxV1FsqV2IjmS2cW5G1vzm9oNa1oi3orw 3OFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id l20si65289otd.292.2020.01.22.14.35.33; Wed, 22 Jan 2020 14:36:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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 S1725924AbgAVWfd (ORCPT + 99 others); Wed, 22 Jan 2020 17:35:33 -0500 Received: from mga04.intel.com ([192.55.52.120]:63302 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgAVWfd (ORCPT ); Wed, 22 Jan 2020 17:35:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2020 14:35:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,351,1574150400"; d="scan'208";a="275741947" Received: from ingas-nuc1.sea.intel.com ([10.252.135.138]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jan 2020 14:35:31 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] tools/mesh: Add commands for key refresh phase get/set Date: Wed, 22 Jan 2020 14:35:31 -0800 Message-Id: <20200122223531.19112-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.1 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 Add commands to send KEY_REFRESH_PHASE_GET and KEY_REFRESH_PHASE_SET messages. Handle KEY_REFRESH_PHASE_STATUS response. --- tools/mesh/cfgcli.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index cfa573de3..97849ff0d 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -42,6 +42,7 @@ #define MIN_COMPOSITION_LEN 16 #define NO_RESPONSE 0xFFFFFFFF +#define MAX_OPCODE_SZ 3 /* Default timeout for getting a response to a sent config command (seconds) */ #define DEFAULT_TIMEOUT 2 @@ -538,6 +539,19 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, break; + case OP_CONFIG_KEY_REFRESH_PHASE_STATUS: + if (len != 4) + return true; + + bt_shell_printf("\nNode %4.4x Key Refresh Phase status %s\n", + src, mesh_status_str(data[0])); + + net_idx = get_le16(data + 1); + bt_shell_printf("\tNetKey Index %3.3x, phase %d\n", + net_idx, data[3]); + + break; + case OP_CONFIG_MODEL_PUB_STATUS: if (len != 12 && len != 14) return true; @@ -1537,6 +1551,57 @@ static void cmd_netkey_get(int argc, char *argv[]) cmd_default(OP_NETKEY_GET); } +static void cmd_kr_phase_get(int argc, char *argv[]) +{ + uint16_t n; + uint8_t msg[MAX_OPCODE_SZ + 2]; + int parm_cnt; + + n = mesh_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_GET, msg); + + parm_cnt = read_input_parameters(argc, argv); + if (parm_cnt != 1) { + bt_shell_printf("bad arguments\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* NetKey index */ + put_le16(parms[0], msg + n); + n += 2; + + if (!config_send(msg, n, OP_CONFIG_KEY_REFRESH_PHASE_GET)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_kr_phase_set(int argc, char *argv[]) +{ + uint16_t n; + uint8_t msg[MAX_OPCODE_SZ + 3]; + int parm_cnt; + + n = mesh_opcode_set(OP_CONFIG_KEY_REFRESH_PHASE_SET, msg); + + parm_cnt = read_input_parameters(argc, argv); + if (parm_cnt != 2) { + bt_shell_printf("bad arguments\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + /* NetKey index */ + put_le16(parms[0], msg + n); + n += 2; + + /* Transition */ + msg[n++] = parms[1]; + + if (!config_send(msg, n, OP_CONFIG_KEY_REFRESH_PHASE_SET)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static bool tx_setup(model_send_msg_func_t send_func, void *user_data) { if (!send_func) @@ -1566,6 +1631,10 @@ static const struct bt_shell_menu cfg_menu = { "Delete NetKey"}, {"netkey-get", NULL, cmd_netkey_get, "List NetKeys known to the node"}, + {"kr-phase-get", "", cmd_kr_phase_get, + "Get Key Refresh phase of the nodes's subnet"}, + {"kr-phase-set", " ", cmd_kr_phase_set, + "Set Key Refresh phase of the nodes's subnet"}, {"appkey-add", "", cmd_appkey_add, "Add AppKey"}, {"appkey-update", "", cmd_appkey_update, -- 2.21.1