Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10821124ybi; Thu, 25 Jul 2019 05:45:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWd5Ipw0baTooDXvsqd03cRAmmA6gWMp/2JLno9wy4EByqznUZC12XJCRYjRu8wIRGNy39 X-Received: by 2002:a05:6638:cf:: with SMTP id w15mr12700438jao.136.1564058701903; Thu, 25 Jul 2019 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564058701; cv=none; d=google.com; s=arc-20160816; b=yXiu57NEYE5DKBQgJTRSf4OQ3vT6StsQ/TrSi5ZwjBe4BvG52mf6cbRwkdtMMvbO3v SMVz9rufyPc+qWi10CPCjawy8GPDPEsy7h30ZDYk9oyDIIXDSHnsWxh0lPemTc3h8UWv tkBDd29vIZcm1WC4xAUQ6KAqjZDdw7SN0q2oKbdR9BWltKyQBLnlfwPF927T1NN9CWY6 erKobhvtwqFjFIJ5d9wYn8Zfrm9ZXtTfOC78R8BNuennDdtWT7+P7ymnzQ5zYbdj9pOs 9u6SbsVRFrOjNQ1itwTRcoZNStfFhLeQnh3wDSmX6ws5NS3x80/jU8ZkjxmhWKtEIuKz SHhg== 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=Vt87WHBQva0gCRcE7qsjoztNx6zM5sPwlH5gKqtshNg=; b=MGMrKxt56n3Wfe6tpMFyp8zVcw4a+PJrT9W1f7Mx2yExGAoINsDc+7CWbupJPxgVAD FxAPDINrHmo44ghxx149K9ltiEUZMdJaeeSwC8kE+PTZtTbOHdl6UHTFpwxlU72+zg8s U6QY90prKlvL/A0kqqrCh9wtJveJ3aDY+Y6J/hN2bjIRanegMuqMdJifMifnp/TwxARR EEphNFt7CKHrfsNXKcxvyKcYAOV842mMYG3AvB5ip+51o0jda8/CiMgYWCTDIUyN5d/J h7dAcIW/mZWEotK4sL04w98UT9wwoAPh9gZmS/zYVlyVI6SUq2udn7HRX6zGDt3tpRi5 AEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b="ND5FzI8/"; 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 v20si75934086jan.70.2019.07.25.05.44.37; Thu, 25 Jul 2019 05:45:01 -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="ND5FzI8/"; 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 S2389116AbfGYIOi (ORCPT + 99 others); Thu, 25 Jul 2019 04:14:38 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:32784 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388497AbfGYIOi (ORCPT ); Thu, 25 Jul 2019 04:14:38 -0400 Received: by mail-lj1-f178.google.com with SMTP id h10so47142303ljg.0 for ; Thu, 25 Jul 2019 01:14:37 -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=Vt87WHBQva0gCRcE7qsjoztNx6zM5sPwlH5gKqtshNg=; b=ND5FzI8/EzZuSoNJFkRLaBYqRLq9ACsX+FyIaExGIIvUX8Rwp9GzS1qk2sUcWrjvkc fGwu1WO5YMJ8yp7gzVnKvPRxxwB152VXPOJaSb2kS15uMjl4xJBzhl1An81LjoW2mc0l rC48ZNfUeN3SqFM3WMVgZ4d+f3xz64b/heiC9OyqH9xULmOuO5x4AUzwDpFjZikXrt2q iCJIfRDpn9Ep+BiNF/DfJpgD3DXXpxlzZpuMnGDX/QpFgYgYoVM/m65o9JQiGw4Rfq/s E8m02PDlKfSMY4+mVfC/sUG3sRnndrSlyxBA8f9RhxbTCbbA3tmieoGPRLIUiqf5zv1n XCtg== 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=Vt87WHBQva0gCRcE7qsjoztNx6zM5sPwlH5gKqtshNg=; b=n7RLADhgb4ZvY2TSGdEReEIuDFiGwYjyFnf13GM6SzXBUhXbteTGK94ewM7H6gmWrK JQRbq9NAM+UELhQCudI2oPpLJ81vk9o43zv8CQxRnkiNOTM/odsxsEHXtQEXgAxHvTAs bI2DAKKelzHZyN6vrwUrXo27rZhNjrkpy0dI2nFjp6LSuvxa3Zgtg9tzi4qf6vzZu4RT cAAHTpslwzUOZKhU5YEfdkvTjrSDB/i0QZAsVqFN31/IgQPnrIk0iYEeIt6/Ys7+V9qY NqEYnGfKV9ote9rkUajWJCmQ6JGaxSvzhpT21RnI54d4bsY4QxLbmGtWzb98CwPc0VnP tCiA== X-Gm-Message-State: APjAAAV1y9PmodDqkbYD+C2Y2srBy3KQ6pX7/DfF0Th7HNPqFFBLim4e tAaixOaNw5l5VWn86XPacmx/NNF2OaU= X-Received: by 2002:a2e:25a:: with SMTP id 87mr45989279ljc.183.1564042476280; Thu, 25 Jul 2019 01:14:36 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id 199sm9015251ljf.44.2019.07.25.01.14.35 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 25 Jul 2019 01:14:35 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 5/5] mesh: Check that config server is present in primary element Date: Thu, 25 Jul 2019 10:14:24 +0200 Message-Id: <20190725081424.22621-6-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190725081424.22621-1-michal.lowas-rzechonek@silvair.com> References: <20190725081424.22621-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 1b58d9395..012838d24 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.19.1