forked from luck/tmp_suning_uos_patched
Bluetooth: Notify adv monitor removed event
This notifies management sockets on MGMT_EV_ADV_MONITOR_REMOVED event. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Miao-chen Chou <mcchou@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
b52729f27b
commit
cdde92e230
@ -192,6 +192,7 @@ static const u16 mgmt_untrusted_events[] = {
|
|||||||
MGMT_EV_EXT_INFO_CHANGED,
|
MGMT_EV_EXT_INFO_CHANGED,
|
||||||
MGMT_EV_EXP_FEATURE_CHANGED,
|
MGMT_EV_EXP_FEATURE_CHANGED,
|
||||||
MGMT_EV_ADV_MONITOR_ADDED,
|
MGMT_EV_ADV_MONITOR_ADDED,
|
||||||
|
MGMT_EV_ADV_MONITOR_REMOVED,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000)
|
#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000)
|
||||||
@ -3988,6 +3989,16 @@ static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,
|
|||||||
mgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);
|
mgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mgmt_adv_monitor_removed(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_REMOVED, hdev, &ev, sizeof(ev), sk);
|
||||||
|
}
|
||||||
|
|
||||||
static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
|
static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
|
||||||
void *data, u16 len)
|
void *data, u16 len)
|
||||||
{
|
{
|
||||||
@ -4140,6 +4151,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
|
|||||||
{
|
{
|
||||||
struct mgmt_cp_remove_adv_monitor *cp = data;
|
struct mgmt_cp_remove_adv_monitor *cp = data;
|
||||||
struct mgmt_rp_remove_adv_monitor rp;
|
struct mgmt_rp_remove_adv_monitor rp;
|
||||||
|
unsigned int prev_adv_monitors_cnt;
|
||||||
u16 handle;
|
u16 handle;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -4148,6 +4160,7 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
|
|||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
handle = __le16_to_cpu(cp->monitor_handle);
|
handle = __le16_to_cpu(cp->monitor_handle);
|
||||||
|
prev_adv_monitors_cnt = hdev->adv_monitors_cnt;
|
||||||
|
|
||||||
err = hci_remove_adv_monitor(hdev, handle);
|
err = hci_remove_adv_monitor(hdev, handle);
|
||||||
if (err == -ENOENT) {
|
if (err == -ENOENT) {
|
||||||
@ -4156,6 +4169,9 @@ static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hdev->adv_monitors_cnt < prev_adv_monitors_cnt)
|
||||||
|
mgmt_adv_monitor_removed(sk, hdev, handle);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
|
||||||
rp.monitor_handle = cp->monitor_handle;
|
rp.monitor_handle = cp->monitor_handle;
|
||||||
|
Loading…
Reference in New Issue
Block a user