aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 64b55c7881ee..d83197f9e727 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -114,6 +114,8 @@ static const u16 mgmt_events[] = {
114 MGMT_EV_PASSKEY_NOTIFY, 114 MGMT_EV_PASSKEY_NOTIFY,
115 MGMT_EV_NEW_IRK, 115 MGMT_EV_NEW_IRK,
116 MGMT_EV_NEW_CSRK, 116 MGMT_EV_NEW_CSRK,
117 MGMT_EV_DEVICE_ADDED,
118 MGMT_EV_DEVICE_REMOVED,
117}; 119};
118 120
119#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000) 121#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000)
@@ -4968,6 +4970,18 @@ unlock:
4968 return err; 4970 return err;
4969} 4971}
4970 4972
4973static void device_added(struct sock *sk, struct hci_dev *hdev,
4974 bdaddr_t *bdaddr, u8 type, u8 action)
4975{
4976 struct mgmt_ev_device_added ev;
4977
4978 bacpy(&ev.addr.bdaddr, bdaddr);
4979 ev.addr.type = type;
4980 ev.action = action;
4981
4982 mgmt_event(MGMT_EV_DEVICE_ADDED, hdev, &ev, sizeof(ev), sk);
4983}
4984
4971static int add_device(struct sock *sk, struct hci_dev *hdev, 4985static int add_device(struct sock *sk, struct hci_dev *hdev,
4972 void *data, u16 len) 4986 void *data, u16 len)
4973{ 4987{
@@ -5009,6 +5023,8 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
5009 goto unlock; 5023 goto unlock;
5010 } 5024 }
5011 5025
5026 device_added(sk, hdev, &cp->addr.bdaddr, cp->addr.type, cp->action);
5027
5012 err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, 5028 err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE,
5013 MGMT_STATUS_SUCCESS, &cp->addr, sizeof(cp->addr)); 5029 MGMT_STATUS_SUCCESS, &cp->addr, sizeof(cp->addr));
5014 5030
@@ -5017,6 +5033,17 @@ unlock:
5017 return err; 5033 return err;
5018} 5034}
5019 5035
5036static void device_removed(struct sock *sk, struct hci_dev *hdev,
5037 bdaddr_t *bdaddr, u8 type)
5038{
5039 struct mgmt_ev_device_removed ev;
5040
5041 bacpy(&ev.addr.bdaddr, bdaddr);
5042 ev.addr.type = type;
5043
5044 mgmt_event(MGMT_EV_DEVICE_REMOVED, hdev, &ev, sizeof(ev), sk);
5045}
5046
5020static int remove_device(struct sock *sk, struct hci_dev *hdev, 5047static int remove_device(struct sock *sk, struct hci_dev *hdev,
5021 void *data, u16 len) 5048 void *data, u16 len)
5022{ 5049{
@@ -5043,6 +5070,8 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,
5043 addr_type = ADDR_LE_DEV_RANDOM; 5070 addr_type = ADDR_LE_DEV_RANDOM;
5044 5071
5045 hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type); 5072 hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type);
5073
5074 device_removed(sk, hdev, &cp->addr.bdaddr, cp->addr.type);
5046 } else { 5075 } else {
5047 if (cp->addr.type) { 5076 if (cp->addr.type) {
5048 err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_DEVICE, 5077 err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_DEVICE,