Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp771765pxa; Wed, 5 Aug 2020 12:21:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyTXU/65QrjrJ94qwEuP4pxP/okqKJst5VjagdbJzht/wGfUcm7kRBS3r2/7nFrO2IspF8 X-Received: by 2002:a17:906:3449:: with SMTP id d9mr802957ejb.460.1596655308323; Wed, 05 Aug 2020 12:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596655308; cv=none; d=google.com; s=arc-20160816; b=1EGf7UCTlnSEpTVhqB2mDj+QT/Ty/RykezIYE/NrBGJTSdjZQUmQIQzVHtzvlv9I4d 9HuV2cdjpN0iYDg1IcaVleKKIYS/b8B8IPqEMSHW7Le+M5QdyWRnJ7Lu4AK8I5/nzI5C AFxQjDYbf1dhjOr05/5oGrR4SAoy8b5xiUrre/dTWqenXiu369m9nI4MR3G6H4W+wX4F AuP8cNNApOUVccZACAWgqJqmtn3Mr1fajB+gxE/qugbPwGDQ83sXOte+nsy1qGoGYmbU UuU+YM2IHBL+LCbtfLJeln5T9+6pxQ1J8+ACGKJkQKBtEHCWzboTAQnBMpvqNxH8TnsP Y+Xg== 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=CM9x4K6LABZO6ZiyDCSNEuRz0y1dBYS8XkIrliGrz0E=; b=OTZW+fdmji8oWvmuq91jjsZ9qOGfbLi7zFwRAvGo7u8pDWoVEnFi+v2PnudWgbmXeo qqu4OFWGW4tC2gzqPR7GNRzJ5DKvyh3aPh3d8ExRIaEaKwwf+x0UxycWlovHi9AFAXMD zzB8fRUcDwAvtpzXHM/wOUUY3t3O4KqCvaFbPwWKdl63iYokQA96O1+wJG1sBLhR8jM8 tg/PwPN/uRq39PPjmS602SyUb7Wol8/gY5IVPTit0YMT+j7IWRQp3M9EzhgNjYoXYv3X MuYIHFf8OQMs90xJeHGJtTXYsfNdmKYNBj9V9yeexUifr+g2nVpHauZdp8mTTFl9WPQK Vyug== 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 ck3si1790495edb.324.2020.08.05.12.21.23; Wed, 05 Aug 2020 12:21:48 -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 S1726282AbgHETVT (ORCPT + 99 others); Wed, 5 Aug 2020 15:21:19 -0400 Received: from mga05.intel.com ([192.55.52.43]:42218 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728988AbgHERr1 (ORCPT ); Wed, 5 Aug 2020 13:47:27 -0400 IronPort-SDR: J9rjp3oVY9xGPmS7hmZjJc8/uqil547rGxBETq+KSm2PT1arymo26ZtDL/kjtHIZuV+kLhvVxb vYGGYC3rworQ== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470658" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470658" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 10:45:01 -0700 IronPort-SDR: SPTRrvFqEXg3XhXh3+VEu2X5rEqDgzBzydNUNM/cg7j6h0/m7S6HUlOMn64W67Sl18Pw02AkxF KIETEP5Ei3Jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245758" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.189]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 10:45:00 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v4 07/10] mesh: Clean up handling of config poll timeout message Date: Wed, 5 Aug 2020 10:44:53 -0700 Message-Id: <20200805174456.49342-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805174456.49342-1-inga.stotland@intel.com> References: <20200805174456.49342-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 modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 34 +++++++++++++++++++++++----------- mesh/cfgmod.h | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 6ca1c1dd1..9b1375317 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -638,6 +638,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt) return n + 3 + sz; } +static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) +{ + uint16_t n, addr = l_get_le16(pkt); + uint32_t poll_to; + + if (!IS_UNICAST(addr)) + return 0; + + n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); + l_put_le16(addr, msg + n); + n += 2; + + poll_to = mesh_net_friend_timeout(node_get_net(node), addr); + msg[n++] = poll_to; + msg[n++] = poll_to >> 8; + msg[n++] = poll_to >> 16; + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -673,7 +692,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, struct mesh_net *net; const uint8_t *pkt = data; struct timeval time_now; - uint32_t opcode, tmp32; + uint32_t opcode; int b_res = MESH_STATUS_SUCCESS; struct mesh_net_heartbeat *hb; uint16_t n_idx; @@ -1109,18 +1128,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, msg[n++] = hb->sub_max_hops; break; - case OP_CONFIG_POLL_TIMEOUT_LIST: - if (size != 2 || l_get_le16(pkt) == 0 || - l_get_le16(pkt) > 0x7fff) + case OP_CONFIG_POLL_TIMEOUT_GET: + if (size != 2) return true; - n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg); - l_put_le16(l_get_le16(pkt), msg + n); - n += 2; - tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt)); - msg[n++] = tmp32; - msg[n++] = tmp32 >> 8; - msg[n++] = tmp32 >> 16; + n = cfg_poll_timeout_msg(node, pkt); break; case OP_NODE_RESET: diff --git a/mesh/cfgmod.h b/mesh/cfgmod.h index 7b6a95807..6d73656a7 100644 --- a/mesh/cfgmod.h +++ b/mesh/cfgmod.h @@ -66,7 +66,7 @@ #define OP_CONFIG_MODEL_SUB_LIST 0x802A #define OP_CONFIG_VEND_MODEL_SUB_GET 0x802B #define OP_CONFIG_VEND_MODEL_SUB_LIST 0x802C -#define OP_CONFIG_POLL_TIMEOUT_LIST 0x802D +#define OP_CONFIG_POLL_TIMEOUT_GET 0x802D #define OP_CONFIG_POLL_TIMEOUT_STATUS 0x802E /* Health opcodes in health-mod.h */ #define OP_CONFIG_HEARTBEAT_PUB_GET 0x8038 -- 2.26.2