Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp771637pxa; Wed, 5 Aug 2020 12:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMoggOeCVJeZfw1q5KNnlLYRbyTCEdaHfpfS4cL5bVdo3fAZGz0foK/EfNZQm4VlLLAVe1 X-Received: by 2002:a50:af86:: with SMTP id h6mr822675edd.132.1596655296366; Wed, 05 Aug 2020 12:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596655296; cv=none; d=google.com; s=arc-20160816; b=DI5z04eFaMZHgC+qPc9eJjacivMtvewXjf50eeCc33BVZB9neTkdq0GXKsFZpCECVe ZUHW+ws6cwe2W6bsbdqoqbYdh941vd4Q7R0s4Z484RhHJRGR/a4KWmrsSm/5SRjFg8LZ RWGy/Pfn2A45WNcvCq1ZyylEYvs8ZEDT8gkelPwdgyXnuJhoOr48Bo4kUvCLnpo/6FeR nTKwNuQ++eY4CEOmxJVo6vrN67DPiINFDp/MmMoqfRT3Gsnz5g4DiO4t/eMq8NKU4R/V uCbHpygFSemt1XabdQHLXYjLHvu3PD6u7GoFX4itduI6I4pcE94GChSutCNBI2wqZzZH pi0A== 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=B9/KC+1ly1Mh8UPp9Kd0USHzunI8bYvifG5DUZ1eRXcNs94jzdfsSx0CJPpPqXq7Ya U981x1HFdmt1iqka0JLbQgOw/IMaMvjAb4YCf9T2R4gXmRaEwthskQv0CxcdowLr0PPA TKi5CkOoCZ7jVL0pIRiQo3RjQMiKcWsVJSGHjfekFLq8jfVPEQatfDTcHE95Tlc3caxy LtouRUp3cLzTS3a7fwkssWa0pnmvR+mINb+xQVkA5buSaFj7C1fMegx+POda4T3KvLCC Sxrs213jmDLBd+Nmt2RKcdMEV7ARgHpPYX+JB670W3zqFaMbWN+NV03cn/lhcmk64P6G lpyA== 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 t23si2252396ejj.626.2020.08.05.12.21.12; Wed, 05 Aug 2020 12:21:36 -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 S1728878AbgHETUn (ORCPT + 99 others); Wed, 5 Aug 2020 15:20:43 -0400 Received: from mga05.intel.com ([192.55.52.43]:42213 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728987AbgHERr2 (ORCPT ); Wed, 5 Aug 2020 13:47:28 -0400 IronPort-SDR: CCSYNJadoEpWMG6Wxyr0at1auLtruYX53uY15jy2z5e07XzfjJjDq2LrxxZPFfhFQLPpTUO/qz vWUlAdf4R0zQ== X-IronPort-AV: E=McAfee;i="6000,8403,9704"; a="237470653" X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="237470653" 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:00 -0700 IronPort-SDR: WAsY6ol6J9SOdoFWzuZuf7GiSCm9tY9IgAZRGXHmIpHOroj7tY+EFqomV7semR9+C2f8rJalrg TFWjSQD3W62Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,438,1589266800"; d="scan'208";a="437245747" 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 06/10] mesh: Clean up handling of config relay messages Date: Wed, 5 Aug 2020 10:44:52 -0700 Message-Id: <20200805174456.49342-7-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 | 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