Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp606345pxa; Tue, 4 Aug 2020 13:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4Yd5anHGAIge2lW9vIewwDuFv65q0AwB8veLUem9HxSGIxEtppOa9+uXgbJjCYQdiQuPe X-Received: by 2002:a50:fe0a:: with SMTP id f10mr21875345edt.264.1596572317600; Tue, 04 Aug 2020 13:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596572317; cv=none; d=google.com; s=arc-20160816; b=xV9w/h7a18ghMN51FWRuhY7LkYjEKXNFsimIstJR56oTTK/s1UP/pB27PlLT2w7VrR LswM4t1ZPISQi/qmehSr2grupsvVRwk+6FvtjhxJWbh8zK67HDAo/ljKXxf8YtZ8xOol ij0KoKLMspi9wmt76cWWmbgijh2QYOGNshzOhZyeH6wvTBDJTPRE4cQexBZzn+9fH6as VJtwyb6nJxXPK7wyxldikz9DoPEqIya+F05oY857BBuPT30oLpY8mDfLCeFdlmhOtEcs CIQYOEycZ5qVNI+znJO/ItFt+pfO/pBzO48okCjpvAKOpdT0n4w7ctSEeATb30te7M2T kqEw== 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=HKO7hf+eElYOtWiNmZ3PxlK+/8u/txrrwLXZ/GMhcTU=; b=N6thBHtnBE55jkA3hrr/DZrwvsfXIB2F2UbY1fUyIj2XDk2nx3aiEXsfvlPN57O251 q9/dhN+vvpJHxSd2pyt2vM+ZqzDtxiSypHYnIlPmXKe/uPk+it9mEaqk6695gfSNhc85 bzO0q1wzv04H2m6K2Bdu9JY+5AEIo8By8MsKvzgLIkVzsRnSl57P0NLD+vpP36EjNw6g f4z6fMMDKHMzHLJFEgfSND2nswwJ66xUH0ZvTFV06XC11tTTZDULct1A5IyfvQvZmFDg OdWRh0gDB8FhjbvksqXh2COUKtp3ZhbZJaUqMFfLjCFVIzY77ks0szGv6Zw0jSnTg9Y9 zHBg== 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 v6si14185798edi.91.2020.08.04.13.18.13; Tue, 04 Aug 2020 13:18:37 -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 S1726861AbgHDURz (ORCPT + 99 others); Tue, 4 Aug 2020 16:17:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbgHDURt (ORCPT ); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: 51mzmAnOZFda4tHcmnISHRtbn4fnqiWJ3JApP/hIuurV9ZK3ciEZlCHDeFi2GUVU/GVT2v+5uL YCnsJlzkihCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565393" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565393" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:48 -0700 IronPort-SDR: yYxMPNnptyVkbpV4iz+vou+d7DPTps8lCIU2X+TOVGVaJqifGBOAMCTFxs1z8HtkLe0mOo72d4 7n73rOriGvIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783843" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:48 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v3 06/10] mesh: Clean up handling of config relay messages Date: Tue, 4 Aug 2020 13:17:40 -0700 Message-Id: <20200804201744.23327-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-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 | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 030f9e744..6ca1c1dd1 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -396,6 +396,30 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt, return n; } +static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t count; + uint16_t interval; + uint16_t n; + + if (pkt[0] > 0x01) + return 0; + + if (opcode == OP_CONFIG_RELAY_SET) { + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; + node_relay_mode_set(node, !!pkt[0], count, interval); + } + + n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); + + msg[n++] = node_relay_mode_get(node, &count, &interval); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); + + return n; +} + static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data) { struct mesh_net *net = user_data; @@ -765,24 +789,14 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, break; case OP_CONFIG_RELAY_SET: - if (size != 2 || pkt[0] > 0x01) + if (size != 2) return true; - - count = (pkt[1] & 0x7) + 1; - interval = ((pkt[1] >> 3) + 1) * 10; - node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ - case OP_CONFIG_RELAY_GET: if (opcode == OP_CONFIG_RELAY_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); - - msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Relay Config (%d)", msg[n-1]); + n = cfg_relay_msg(node, pkt, opcode); break; case OP_CONFIG_NETWORK_TRANSMIT_SET: -- 2.26.2