Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11672907ybi; Thu, 25 Jul 2019 21:32:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS1Uy958NrL/UQzRLcn9vLLfDDvWncVYfF3+u6tKQd83nW8NLe3I8Tn+xRmEiTy+Mutr7U X-Received: by 2002:a17:902:6a85:: with SMTP id n5mr87889610plk.73.1564115534838; Thu, 25 Jul 2019 21:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564115534; cv=none; d=google.com; s=arc-20160816; b=gAXFa6LTPuEVJnJ+u5o9mBb1f+jkZFPpCbqp5OcPsJikj6i3TIrRDfGoPWlyr7NnfH 7kFbcdqrLOg7muoNa54Y0aKBinarkikj5+mf+2iaXM/3giaM68Wy5nV487z3B7BMFhck 4jdeDL8dQVqB/YDCpsZ0m9/k/A9BHKT0DVQIQLkxB/o6g/tYM+hR9TSOIe7seIStVdqB QMukPhkCRCSEfGRWkntBv9MiEphulvHEFu6yIt6J4VaQ7i3Ga4ILMQXm4A8d+Sst45nE AGlaST+9wJ08sA64HLpwjddj8cvSXG7dcbqYGbcm11BRNFJJVAkq4DE12GxEnl6cUKSc imkQ== 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:to:from :dkim-signature; bh=PTFzoPOLDPs2mblMT1MJJ9hLSqUVRizwjGmTKckHTNE=; b=dfuFHRoNGSPm7UHBhJEDGrlrB7mLnOkFj5Lz38OhSoF8cmwyHyZxd5Y/VhG/Gpd9s8 MpQpM8mHn2IAnBf3VWIw+OYHKjnIr+P5lKr1QCnnK5ywqC8kKl8hPohjGwDQXaFr6giH uJDJNpGpz1uqePqHmnhw4Qsf0ThW90F6szvEuCuP/kVtbtsO1SNAOXolXIIAnnDt6TCs zsEh55D52NmGDvfV3GaFpbD7cSTqBjdY3pnE40oj7w559PxdBmmthdph6UYQmpi0tmyt 9n2Z+XX41VI0y1C7fVzswsQ4eLI/PDqxZYCDJZ1z1ToqU4Q0cP412HTZ5haVioSAUQ1E Q2sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=lf+9Q60m; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si18323609plt.387.2019.07.25.21.31.53; Thu, 25 Jul 2019 21:32:14 -0700 (PDT) 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; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=lf+9Q60m; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725842AbfGZEaw (ORCPT + 99 others); Fri, 26 Jul 2019 00:30:52 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:46512 "EHLO mail-lf1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfGZEaw (ORCPT ); Fri, 26 Jul 2019 00:30:52 -0400 Received: by mail-lf1-f48.google.com with SMTP id z15so31834632lfh.13 for ; Thu, 25 Jul 2019 21:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PTFzoPOLDPs2mblMT1MJJ9hLSqUVRizwjGmTKckHTNE=; b=lf+9Q60mFb3ob3foKGzHao2qCXIln7YMAdTlEHUfefwml9QleSAenBkyv9SsuRtpv6 h20B9NTIA2LJQvYupmpiTwlluFbY5RCGiMjqx5lsDgn4siRYp54827d7VjiSXY3hbM1o I/fdrJswdZLehpZ/E2G9mEDXqY+Clti0LDw0ZYu/RPy1VNYfAMUTHigQAhSevfcvgcJC M2lxTsnSQlQ/CdW52S9ylM0ETAqOcwL7UnHRcXbRggk0h0MBsF/iUrFBF2GIobqNZ6HZ BUk+Vwyog+XfXdnpWT81vCYABElF/pbfwW7R99IJUaJS6MasK0j0N16BTKZsP9J6s5M4 QFTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PTFzoPOLDPs2mblMT1MJJ9hLSqUVRizwjGmTKckHTNE=; b=ZFslQbtU/BSKtII3UL/USruM7pTnUcrwLQxCiXXY6o0oF3u3pgUSmW80YBClPlTw29 McEC6RCeZTWmcUad8agShNA7diPxPenkvA80QhhHBRdu1bynMJ/wJXJgsD/JJe2KN4ZM Z1HByrWsthHuq/DxevMhSXiVEHv+2gByWDKvTrE0mDzCpt6tITq5ia2gXomDb9j7qR6X dFbbRWZ8Cj2yP8l2PBK9c0CX2WOfK2RM9AxnPrg0yqMiLGq6XGI9/FLgjQA8pY/OAtkt 4ZZaD6PlRL5pYnJ3gmnQ7/5ATLR/v3AH5g9tz+pYprzfDEvmgkhAKSHDR1bnFB3SqOXQ X2Eg== X-Gm-Message-State: APjAAAVnUOJJgBq6PRNEoVd27qKKXNQPx9UoTzNkQGTArjYhog25zNog MFpdy3W+S8UzLOiWtUQRyBCM74aiFBw= X-Received: by 2002:ac2:5609:: with SMTP id v9mr41163802lfd.27.1564115450157; Thu, 25 Jul 2019 21:30:50 -0700 (PDT) Received: from kynes.internet.domowy (apn-95-40-32-72.dynamic.gprs.plus.pl. [95.40.32.72]) by smtp.gmail.com with ESMTPSA id g5sm9792735ljj.69.2019.07.25.21.30.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 21:30:49 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v5 5/5] mesh: Check that config server is present in primary element Date: Fri, 26 Jul 2019 06:30:35 +0200 Message-Id: <20190726043035.9417-6-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190726043035.9417-1-michal.lowas-rzechonek@silvair.com> References: <20190726043035.9417-1-michal.lowas-rzechonek@silvair.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 verifies that Config Server model is supported by element #0, and is not supported by any other element. --- mesh/node.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mesh/node.c b/mesh/node.c index f937fe361..e0f1bbde2 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -899,6 +899,8 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { uint16_t n, features; uint16_t num_ele = 0; + uint8_t *cfgmod_idx = NULL; + const struct l_queue_entry *ele_entry; if (!node || !node->comp || sz < MIN_COMP_SIZE) @@ -961,6 +963,9 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) mod_id = mesh_model_get_model_id( (const struct mesh_model *) mod); + if (mod_id == CONFIG_SRV_MODEL) + cfgmod_idx = &ele->idx; + if ((mod_id & VENDOR_ID_MASK) == VENDOR_ID_MASK) { if (n + 2 > sz) goto element_done; @@ -1006,6 +1011,9 @@ element_done: if (!num_ele) return 0; + if (!cfgmod_idx || *cfgmod_idx != PRIMARY_ELE_IDX) + return 0; + return n; } -- 2.22.0