|
37 | 37 | #include "smp.h" |
38 | 38 | #include "mgmt_util.h" |
39 | 39 | #include "mgmt_config.h" |
| 40 | +#include "msft.h" |
40 | 41 |
|
41 | 42 | #define MGMT_VERSION 1 |
42 | 43 | #define MGMT_REVISION 17 |
@@ -118,6 +119,7 @@ static const u16 mgmt_commands[] = { |
118 | 119 | MGMT_OP_SET_DEF_RUNTIME_CONFIG, |
119 | 120 | MGMT_OP_GET_DEVICE_FLAGS, |
120 | 121 | MGMT_OP_SET_DEVICE_FLAGS, |
| 122 | + MGMT_OP_READ_ADV_MONITOR_FEATURES, |
121 | 123 | }; |
122 | 124 |
|
123 | 125 | static const u16 mgmt_events[] = { |
@@ -3973,6 +3975,51 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data, |
3973 | 3975 | &cp->addr, sizeof(cp->addr)); |
3974 | 3976 | } |
3975 | 3977 |
|
| 3978 | +static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, |
| 3979 | + void *data, u16 len) |
| 3980 | +{ |
| 3981 | + struct adv_monitor *monitor = NULL; |
| 3982 | + struct mgmt_rp_read_adv_monitor_features *rp = NULL; |
| 3983 | + int handle; |
| 3984 | + size_t rp_size = 0; |
| 3985 | + __u32 supported = 0; |
| 3986 | + __u16 num_handles = 0; |
| 3987 | + __u16 handles[HCI_MAX_ADV_MONITOR_NUM_HANDLES]; |
| 3988 | + |
| 3989 | + BT_DBG("request for %s", hdev->name); |
| 3990 | + |
| 3991 | + hci_dev_lock(hdev); |
| 3992 | + |
| 3993 | + if (msft_get_features(hdev) & MSFT_FEATURE_MASK_LE_ADV_MONITOR) |
| 3994 | + supported |= MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS; |
| 3995 | + |
| 3996 | + idr_for_each_entry(&hdev->adv_monitors_idr, monitor, handle) { |
| 3997 | + handles[num_handles++] = monitor->handle; |
| 3998 | + } |
| 3999 | + |
| 4000 | + hci_dev_unlock(hdev); |
| 4001 | + |
| 4002 | + rp_size = sizeof(*rp) + (num_handles * sizeof(u16)); |
| 4003 | + rp = kmalloc(rp_size, GFP_KERNEL); |
| 4004 | + if (!rp) |
| 4005 | + return -ENOMEM; |
| 4006 | + |
| 4007 | + /* Once controller-based monitoring is in place, the enabled_features |
| 4008 | + * should reflect the use. |
| 4009 | + */ |
| 4010 | + rp->supported_features = cpu_to_le32(supported); |
| 4011 | + rp->enabled_features = 0; |
| 4012 | + rp->max_num_handles = cpu_to_le16(HCI_MAX_ADV_MONITOR_NUM_HANDLES); |
| 4013 | + rp->max_num_patterns = HCI_MAX_ADV_MONITOR_NUM_PATTERNS; |
| 4014 | + rp->num_handles = cpu_to_le16(num_handles); |
| 4015 | + if (num_handles) |
| 4016 | + memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); |
| 4017 | + |
| 4018 | + return mgmt_cmd_complete(sk, hdev->id, |
| 4019 | + MGMT_OP_READ_ADV_MONITOR_FEATURES, |
| 4020 | + MGMT_STATUS_SUCCESS, rp, rp_size); |
| 4021 | +} |
| 4022 | + |
3976 | 4023 | static void read_local_oob_data_complete(struct hci_dev *hdev, u8 status, |
3977 | 4024 | u16 opcode, struct sk_buff *skb) |
3978 | 4025 | { |
@@ -7441,6 +7488,7 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { |
7441 | 7488 | HCI_MGMT_VAR_LEN }, |
7442 | 7489 | { get_device_flags, MGMT_GET_DEVICE_FLAGS_SIZE }, |
7443 | 7490 | { set_device_flags, MGMT_SET_DEVICE_FLAGS_SIZE }, |
| 7491 | + { read_adv_mon_features, MGMT_READ_ADV_MONITOR_FEATURES_SIZE }, |
7444 | 7492 | }; |
7445 | 7493 |
|
7446 | 7494 | void mgmt_index_added(struct hci_dev *hdev) |
|
0 commit comments