Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp946470rwb; Fri, 28 Jul 2023 02:14:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7L11vrpkfpSRmPqQbIibXHM1oaFZUyAffAPRDGSBUc4hkU4IxWbZSsUobWRH8y6ZA7I1l X-Received: by 2002:a17:907:2cd2:b0:99b:605b:1f49 with SMTP id hg18-20020a1709072cd200b0099b605b1f49mr1802784ejc.36.1690535677138; Fri, 28 Jul 2023 02:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690535677; cv=none; d=google.com; s=arc-20160816; b=VH2HG1jte1iHqjv0lwXWWK1x+yPyQYTchW5nAQ7jmI5HFuIpDYs08fknQtQbqON4zO /4sTPWIRAU4V/uuhKUZM5G4+wC4issCg9KydmZ51m1GLHNgClxw3Y/buq3IgUT6NNvRr 4m3qdEqx3GmlsYVEKFa6Q7YJuLWv0D//E+nrc4EkpYLuMMOVRZtEOpxvhFym3vRvr9n5 OF8TPmrOJrbhAJ8DAHr0HNG/TxoFVpKm/YXQaCnTz114O2GS/rqYalKHtNDB/P3/bCs5 gA9VhZVYBK30IhZ1d46e+k+kOp2213Zgd06lNzWyw1lMDx6OZVYuHBw/ytl+Hor2sxN3 A39w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YvwrU8X/59pee1qfptP4CoRTFaZVbeHq4fhpo7aiOYM=; fh=Jg5b3SlU0kriz7dG9TxlX0lcLkpuhdKAkKJU/Cg3tjc=; b=YII2oygnGvv6M0lThzN6gfmth30GcWh9b1/5XFH5fBIoZEW+HwOXI295B1z02of3WU tsDYBTKazlQA2R2pXscu+XmeaBEHYL3pEUPoTWUtiks2s/2XnJ2HW5cq1snmK/ty39Tr ZaM3PkDa+R2gY2W0lgHE3D7JoQVElyeuJ3WpmUX0YvWMA//+HS1QurTtcS3BbEIqcZ7z mWPA03ZtZ53b15WIIemWMP19I9cra6ZcvI48zXziV9LJZY1PXmnMFWKYQXesQGescGsa R5/FQycOTEO+cdLx4TOBicPFWpDr8GAa9wOQNMuPSV/u+Emfx4yXn3PIbiqVRl/CM7P2 TwhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b=AqFYMub8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gl23-20020a170906e0d700b009888b617ebbsi2493098ejb.606.2023.07.28.02.14.09; Fri, 28 Jul 2023 02:14:37 -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; dkim=pass header.i=@streamunlimited.com header.s=google header.b=AqFYMub8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233391AbjG1I5r (ORCPT + 99 others); Fri, 28 Jul 2023 04:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234535AbjG1I5Y (ORCPT ); Fri, 28 Jul 2023 04:57:24 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B67D2736 for ; Fri, 28 Jul 2023 01:57:23 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-99bed101b70so68042166b.3 for ; Fri, 28 Jul 2023 01:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1690534642; x=1691139442; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YvwrU8X/59pee1qfptP4CoRTFaZVbeHq4fhpo7aiOYM=; b=AqFYMub8hjuhTdsufihqTaegK++FqJAHB7wVT3XS0Xj4u1AO8Cw93gUDaFF93bqdjq RhSSdGpcwpZynyNXj0/W0Hu5ZBoE6bLd8SOGwWVhlbX56vmjSQNEu4A+qdMNOvocthVb 9I5JMzGoE7WK5YeFiZcN3QBmRF9gyojE/RBsw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690534642; x=1691139442; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YvwrU8X/59pee1qfptP4CoRTFaZVbeHq4fhpo7aiOYM=; b=F4rb1uIZZiS0+v+pmSi/6+8b+wuLfe/OlZaIy4LN77S8fHe205zlNmKlx2jLvVjvH4 Z+Gy08D089of5FYdlnUN9zMp1F5OFtYemxhXdOXdXPKwLgkt4frori8/aie0/9KmrXgI 2By8gfdvn4BSigs/MNAO1Anf7OX6hYG/MKcsJVdi69VAwBFdEzAHzdas9WwQJvlZ0c2J SD1lfS7Tk/vn64FATVFM2No7c0gxYtnAs7OkwAUe1JLkHfITb6GejhEs6R9+44X6yG8u MHyseYdxgjfiZsaiW1cT330MTb/SZe+a2hdFCjtU8BXX4U0pOOWtZpH1/OtmURui6i5y vQ9g== X-Gm-Message-State: ABy/qLaGiE+3LXJf6Lj1ETgl7JEyUqSdM+D45E8I46xNOmJ7ntWoywQ+ yILwbScYgGzTPNKEEAxGOs1ZDb0zcsuacVpYPbo= X-Received: by 2002:a17:906:2c6:b0:98e:2097:f23e with SMTP id 6-20020a17090602c600b0098e2097f23emr1385386ejk.77.1690534641715; Fri, 28 Jul 2023 01:57:21 -0700 (PDT) Received: from smi-ubuntu.sueba ([2a01:390:0:101:353d:c2fa:e0df:3251]) by smtp.gmail.com with ESMTPSA id u7-20020a170906408700b0098de7d28c34sm1782205ejj.193.2023.07.28.01.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 01:57:21 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ] advertising: Fix peripheral adverts when Discoverable = false Date: Fri, 28 Jul 2023 10:57:13 +0200 Message-Id: <20230728085713.683655-1-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 There is a problem with this configuration: Type = peripheral, Discoverable = false and Adapter is discoverable In this state device will start advertise discoverable advertisements even when user wanted non-discoverable advertisements. This change will add empty Flags when "Discoverable" parameter is set. Signed-off-by: Simon Mikuda --- src/advertising.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/advertising.c b/src/advertising.c index d959bf38f..49861e1a2 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -727,11 +727,6 @@ fail: static bool set_flags(struct btd_adv_client *client, uint8_t flags) { - if (!flags) { - bt_ad_clear_flags(client->data); - return true; - } - /* Set BR/EDR Not Supported for LE only */ if (!btd_adapter_get_bredr(client->manager->adapter)) flags |= BT_AD_FLAG_NO_BREDR; @@ -1447,7 +1442,8 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) } } - if (bt_ad_has_flags(client->data)) { + if (bt_ad_get_flags(client->data) & + (BT_AD_FLAG_GENERAL | BT_AD_FLAG_GENERAL)) { /* BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C * page 2042: * A device in the broadcast mode shall not set the -- 2.34.1