Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp937865rwb; Mon, 26 Sep 2022 07:43:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sByc8RvWNbNIoDedn6xQ+h5qX087sPN3UIHi0cgf1CxrqfKWIdSC58vWqhgDd1mvzr4Pq X-Received: by 2002:a17:90b:1d12:b0:200:461c:fa7d with SMTP id on18-20020a17090b1d1200b00200461cfa7dmr25274288pjb.38.1664203386989; Mon, 26 Sep 2022 07:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664203386; cv=none; d=google.com; s=arc-20160816; b=d4xBAq8C7QXZnXFLjJ6s/33v91E7miXWoShLb+ByZaQigtU7XjscPWlfja0M/oGP5z 4lelO4rdeXrP1sZoiQXBZ0oWHHIYiXwCNItDspaARVlBtdnFqjnmoPrDMtPBr1r9jSwt aUPrr60PoT3aAI1FaQVJfY4E4ayGjoevhF3WfopXrCJxBiwwSegZ7lbztgWyoDeYH3k3 cPnTNArlMkY0nkR0EBy5Txsxy2QyAd9sjBx2y4g5FRZnZIzZDDPWDQoPZ5mm/EFA6AhB QCaBV3SeutIJz35Gfg1syuLVOkzrsTiF5wjtCkQ6L6gHWj9n4gD47uhbgR+hQJn2Xdc5 F52Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PnJ+zy4VyVeKzLY12dSr+l830gZfSd4xs0GnVHiznhc=; b=gr24wwkHHgMcRo3OhNuIFXM4I3vH5fAroJcZJ22y1ze1p5SoP0/P4T6QxIvS3ZH7h/ I/JfY9ujHcH9Fhk7erxut7SSEijp66idhcpSvBBFe1e3m3knJgDk2UZ792t906ATbAlt XN5Lk5KT6HdORyP03sZxp9ofE0XLFkeYuf8dGuwUNNziaSskwv4BYvYSezyWgZ4YWmjh tTAJFg4luFu9rWOUiLTXSS4UN8FiTz9CD+Toks5Fl8eNRNL5noZXHj6nGHoJ3aoy3UWQ oMEi8ZzaNP3l46gHemjrv9squFkpeda7NrvB6KFzthvnql/24jbDPwrOgj2suAsYtCnP /EtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z18-20020a170903019200b0016f002733e3si2113076plg.497.2022.09.26.07.41.54; Mon, 26 Sep 2022 07:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235058AbiIZOlX (ORCPT + 99 others); Mon, 26 Sep 2022 10:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235060AbiIZOk5 (ORCPT ); Mon, 26 Sep 2022 10:40:57 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C05783239 for ; Mon, 26 Sep 2022 06:01:48 -0700 (PDT) Received: from 212-17-98-152.static.upcbusiness.at ([212.17.98.152] helo=lexx.office.loytec.com) by voyager.loytec.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocnk3-000470-72 for linux-bluetooth@vger.kernel.org; Mon, 26 Sep 2022 15:01:47 +0200 Received: from loytec-dev-vm.delta.corp ([10.101.25.21]) by lexx.office.loytec.com (8.15.2/8.15.2/Some OS 1.2.3-4.5) with ESMTP id 28QD1bCY1107873; Mon, 26 Sep 2022 15:01:45 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 4/4] mesh: Clear HB sub status field if disabled Date: Mon, 26 Sep 2022 15:01:10 +0200 Message-Id: <20220926130110.2146-5-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220926130110.2146-1-isak.westin@loytec.com> References: <20220926130110.2146-1-isak.westin@loytec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 212.17.98.152 X-SA-Exim-Mail-From: isak.westin@loytec.com X-SA-Exim-Scanned: No (on voyager.loytec.com); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When replying to a HB subscription get message, and the current state of source or destination fields is zero (which means that HB subscription is disabled), all fields in the status reply should be zero. --- mesh/cfgmod-server.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 55a2d896b..7044b670d 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -470,7 +470,7 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint16_t hb_subscription_get(struct mesh_node *node, int status) +static uint16_t hb_subscription_status(struct mesh_node *node, int status) { struct mesh_net *net = node_get_net(node); struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); @@ -502,6 +502,28 @@ static uint16_t hb_subscription_get(struct mesh_node *node, int status) return n; } +static uint16_t hb_subscription_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + + /* + * MshPRFv1.0.1 section 4.4.1.2.16, Heartbeat Subscription state: + * If this is a GET request and the source or destination is unassigned, + * all fields shall be set to zero in the status reply. + */ + if (IS_UNASSIGNED(sub->src) || IS_UNASSIGNED(sub->dst)) { + uint16_t n; + + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + memset(msg + n, 0, 9); + n += 9; + return n; + } + + return hb_subscription_status(node, status); +} + static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { uint16_t src, dst; @@ -525,7 +547,7 @@ static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - return hb_subscription_get(node, status); + return hb_subscription_status(node, status); } static uint16_t hb_publication_get(struct mesh_node *node, int status) -- 2.20.1