Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp387562ybt; Wed, 17 Jun 2020 03:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2GQgZ1BkYkuOF0v13eG4Dx73nhnum9OR1KgGILvUv+BpC7aQxQLwvTszH2zPuzuM01N55 X-Received: by 2002:a05:6402:17e6:: with SMTP id t6mr6363447edy.243.1592390571370; Wed, 17 Jun 2020 03:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592390571; cv=none; d=google.com; s=arc-20160816; b=dWi3oUC9fnwToMytqV78VM2l3egQM+1V2R7RrEIUAM5OO5jcm0e03gnNXcjXP3hlb9 Tig55Py0fwUo30f4QWwraJV/Ib6kRHWyA16P4P6I/XUjhv6iDrUA1BfWKnmXIfNXVB0y xR8XKFYRYw48vA/T0HtY/fVIPpZaIDdfR502gAttBDh5MXLz4opewZ72fI/cti5WnHtu bEDiykbV5F6wd8iqYNz+pVYA6vsGL+9SWbnBjlIjkj8FUHfmCHvaf6V9dWqFFl83O8YD 5qAAQTvBME9uQ+DQrs5LKawCDQ1Q6i7Cdz9syp3Kq0eIQ4bVthZTeNeFd93PlftOweCo aj7Q== 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; bh=Mo+mcM6xKcy1PQuwkeKiEQzgdH8PYq4cxYPC2T19XT4=; b=Dh995oKQ4gKfcY4bXU860NLS+pAz9xTJjnHZIcFrBIKvpv8fQpZkxX9PQ21z6b3Mz0 SIjOaTvQGB0ZqrYPKsqGomEfC/w2UH0v6P3Arf5GsXULL0fcyl+zw7lHkh5k3F2wLyXZ qBgFrt/2gav/UVzDGHLBngBC9Ehqc5zrt1CIjDJJOzBDquZAQqz7Vccp4fFnj6YXgVln wqb0IJ/ITZxixAhYFiXz9cHTVDlUJtuswJ2y9wpoqaDOzgsbYZ87S5k7jK9ijFUEeoGB ruBx6q4j0kM/9/XHUM8TadWMShRet8JPDjF20+qttcoueippSjIjr/qFRK0yt62e2XBg 1/8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy8si11860927edb.595.2020.06.17.03.42.27; Wed, 17 Jun 2020 03:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgFQKmP (ORCPT + 99 others); Wed, 17 Jun 2020 06:42:15 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:45924 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgFQKmN (ORCPT ); Wed, 17 Jun 2020 06:42:13 -0400 Received: from localhost.localdomain (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id D2552CECDC for ; Wed, 17 Jun 2020 12:52:02 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH 10/14] Bluetooth: Notify adv monitor added event Date: Wed, 17 Jun 2020 12:42:01 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: 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 From: Miao-chen Chou This notifies management sockets on MGMT_EV_ADV_MONITOR_ADDED event. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-add command on one console and observe a MGMT_EV_ADV_MONITOR_ADDED event on the other Signed-off-by: Miao-chen Chou Signed-off-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cff24fde72d2..3268d9a00608 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -191,6 +191,7 @@ static const u16 mgmt_untrusted_events[] = { MGMT_EV_EXT_INDEX_REMOVED, MGMT_EV_EXT_INFO_CHANGED, MGMT_EV_EXP_FEATURE_CHANGED, + MGMT_EV_ADV_MONITOR_ADDED, }; #define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000) @@ -3977,6 +3978,16 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data, &cp->addr, sizeof(cp->addr)); } +static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev, + u16 handle) +{ + struct mgmt_ev_adv_monitor_added ev; + + ev.monitor_handle = cpu_to_le16(handle); + + mgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk); +} + static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { @@ -4029,8 +4040,8 @@ static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, struct mgmt_rp_add_adv_patterns_monitor rp; struct adv_monitor *m = NULL; struct adv_pattern *p = NULL; + unsigned int mp_cnt = 0, prev_adv_monitors_cnt; __u8 cp_ofst = 0, cp_len = 0; - unsigned int mp_cnt = 0; int err, i; BT_DBG("request for %s", hdev->name); @@ -4094,6 +4105,8 @@ static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, hci_dev_lock(hdev); + prev_adv_monitors_cnt = hdev->adv_monitors_cnt; + err = hci_add_adv_monitor(hdev, m); if (err) { if (err == -ENOSPC) { @@ -4104,6 +4117,9 @@ static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, goto unlock; } + if (hdev->adv_monitors_cnt > prev_adv_monitors_cnt) + mgmt_adv_monitor_added(sk, hdev, m->handle); + hci_dev_unlock(hdev); rp.monitor_handle = cpu_to_le16(m->handle); -- 2.26.2