Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11257828ybi; Thu, 25 Jul 2019 12:52:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqweIz+j4/fS0oOfaX3/189IXwWusOYu7U8ZIVl/VYwXNv03srkICW6LLXdbtkjPp68XVIkg X-Received: by 2002:a17:902:830c:: with SMTP id bd12mr94452889plb.237.1564084330715; Thu, 25 Jul 2019 12:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564084330; cv=none; d=google.com; s=arc-20160816; b=QtWgfb7AlDK16/hfESHwU8qJjC2aAkzMFs6FdSCPBxhAVYnTKQRaT+5IAtP3dCvxfv BR4IEzZtB61tMmJqZRerL9ReEWuGqeLOprCAzJgFbU5iXH+ai/k+DsTDG4hs9QS32QGF itB6/uSZEM/Kz4FFzkbg4MoZoBzXWocmMTSbF1QlBhNJCh2YcBQM5jYoz4Vsvzo1OG9B 5hu5FpmFfgd1rk2nBRVOhETuMCgc6xBlPfHpRdFf36ZvuUugGNxreiBCX4YDBDWPVtsw zT89P+ZnlGVt3KKEga1cj2GM3u4n3WDaRHbiIpV5M484e8nr75fbYEU41MsRvVmDrKlc 3Dsg== 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=F+fJJZYoJvrHzHRyvMpQbtQFw8HzYTBlV3b4bduCiyQ=; b=tU3iX3h+AWzZ7yiegvL80skeVMvuedQ6Pp+426xenHRGCd5a1myjGZlTDMqtPcmlM2 CMb9VChB7T31DXuld4qEeflSlLW56FNDqcgyyWvfmG0WE6QwSiqtbvh7aEpgZeoP4J+N ocWc/hKwkvZ8rxRKDSsxPDkFOz37yO7+509AYPhnjiZ09P9POSGlnHdJeaJW2VeO+8E3 wX3O2Jl4Zq/iaQRlj+Us2oY9IflbBvKOULhqA2Rt36gg4z4Ek1CYyASRxtrWDqBM5Cau 8H2zANfZXxR3XQ4Jor0W9dnvkuli9mwcB8Sb4YTgImbLoG/Hr60tlUQFlpw8cSZvYP1k OBLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=fzY9KB2H; 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 d38si18072023pgl.519.2019.07.25.12.51.56; Thu, 25 Jul 2019 12:52:10 -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=fzY9KB2H; 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 S1726349AbfGYTtt (ORCPT + 99 others); Thu, 25 Jul 2019 15:49:49 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:35491 "EHLO mail-lj1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfGYTtt (ORCPT ); Thu, 25 Jul 2019 15:49:49 -0400 Received: by mail-lj1-f179.google.com with SMTP id x25so49220502ljh.2 for ; Thu, 25 Jul 2019 12:49:48 -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=F+fJJZYoJvrHzHRyvMpQbtQFw8HzYTBlV3b4bduCiyQ=; b=fzY9KB2HgjEz7vLzt4joyWW3LaOBY2Duu8huZihffGkIUBmGXhfU0Vru6VB3ACNdB/ 5UtZ3cH6cN2sW5n833yFebxEw0KdZnnORmaybcVo7tSNAenx4sl4q+NhRZtB3YI+PmHJ NwtwDroF6wkB6XxAiqdK2h1kVLln51YXigLwjgn8rWzUbRhEQ433byulOzwVaQ4a0g2c OgS6RhGyR/BvjqBNo5TpNmgab5B8fPowRinUFalsJ9fiDKJ3HxBpozX1GQmPbozIqcMj RMrsRUXCojxj7a0wurhocCDEJFUTVJmocWYjea3Elp4fRXlnc1PwHXqsu86po8Ko/e+f ysqg== 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=F+fJJZYoJvrHzHRyvMpQbtQFw8HzYTBlV3b4bduCiyQ=; b=MGk5u+lbDJIcbL4hW/2FlNW9SEfzsX8afGV++0IUld5DXKGSxkRXetNBamfQsVz9nX d/7X93bH5oTf57BpkCQ2sTjbJTzkdbqFgf+73gdQHlevDLO/utHqEkXTCrrPpwvWpihl 5sQD2feGygOquVVyyFC3GzWSk6tQthWmhB9gqhTUMsiI8neol5ayBVdwHSgSmCD7WV0p 5Jg/Jh5ZZ+oFhOCyaiQ4zarTTTR+qWeV8IVompveDUSjlszbcaRp7Y9xKPD4YTHPxGZ9 ewiohWwsDPj54jMJa9HkrUsfi6lQTreRyB+fWEqJYxnyszC/WIt5vs64hd/7h6mVkjSR GSVA== X-Gm-Message-State: APjAAAXDdBw2/vWwEXCmh+FnLx0XoeexHAFTO4k9iqF+vBQ7k/0DnPTQ 8TfQ75jzTd41PmTH8MLJ6ii263PHwj0= X-Received: by 2002:a2e:9a49:: with SMTP id k9mr46625196ljj.78.1564084187141; Thu, 25 Jul 2019 12:49:47 -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 e62sm9327693ljf.82.2019.07.25.12.49.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 12:49:46 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 5/5] mesh: Check that config server is present in primary element Date: Thu, 25 Jul 2019 21:49:33 +0200 Message-Id: <20190725194933.7321-6-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190725194933.7321-1-michal.lowas-rzechonek@silvair.com> References: <20190725194933.7321-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 1709a25ba..0b02089bf 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