aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-09 05:59:14 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-09 06:25:27 -0400
commit6659358efe617bb46237e62f7303c76e10568d70 (patch)
treecc4f21038000dd5a617580a7adc542a91c1c592c /net/bluetooth/hci_core.c
parentdcc36c16c2f1c9800146c8416ee5a4c3dc974623 (diff)
Bluetooth: Introduce a whitelist for BR/EDR devices
This patch extends the Add/Remove device commands by letting user space pass BR/EDR addresses to them. The resulting entries get stored in a new hdev->whitelist list. The idea is that we can now selectively accept connections from devices in the list even though HCI_CONNECTABLE is not set (the actual implementation of this is coming in a subsequent patch). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 705f8df7af96..728a6ee471ea 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -191,6 +191,31 @@ static const struct file_operations blacklist_fops = {
191 .release = single_release, 191 .release = single_release,
192}; 192};
193 193
194static int whitelist_show(struct seq_file *f, void *p)
195{
196 struct hci_dev *hdev = f->private;
197 struct bdaddr_list *b;
198
199 hci_dev_lock(hdev);
200 list_for_each_entry(b, &hdev->whitelist, list)
201 seq_printf(f, "%pMR (type %u)\n", &b->bdaddr, b->bdaddr_type);
202 hci_dev_unlock(hdev);
203
204 return 0;
205}
206
207static int whitelist_open(struct inode *inode, struct file *file)
208{
209 return single_open(file, whitelist_show, inode->i_private);
210}
211
212static const struct file_operations whitelist_fops = {
213 .open = whitelist_open,
214 .read = seq_read,
215 .llseek = seq_lseek,
216 .release = single_release,
217};
218
194static int uuids_show(struct seq_file *f, void *p) 219static int uuids_show(struct seq_file *f, void *p)
195{ 220{
196 struct hci_dev *hdev = f->private; 221 struct hci_dev *hdev = f->private;
@@ -1707,6 +1732,8 @@ static int __hci_init(struct hci_dev *hdev)
1707 debugfs_create_u16("hci_revision", 0444, hdev->debugfs, &hdev->hci_rev); 1732 debugfs_create_u16("hci_revision", 0444, hdev->debugfs, &hdev->hci_rev);
1708 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev, 1733 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
1709 &blacklist_fops); 1734 &blacklist_fops);
1735 debugfs_create_file("whitelist", 0444, hdev->debugfs, hdev,
1736 &whitelist_fops);
1710 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops); 1737 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
1711 1738
1712 debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev, 1739 debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev,
@@ -3825,6 +3852,7 @@ struct hci_dev *hci_alloc_dev(void)
3825 3852
3826 INIT_LIST_HEAD(&hdev->mgmt_pending); 3853 INIT_LIST_HEAD(&hdev->mgmt_pending);
3827 INIT_LIST_HEAD(&hdev->blacklist); 3854 INIT_LIST_HEAD(&hdev->blacklist);
3855 INIT_LIST_HEAD(&hdev->whitelist);
3828 INIT_LIST_HEAD(&hdev->uuids); 3856 INIT_LIST_HEAD(&hdev->uuids);
3829 INIT_LIST_HEAD(&hdev->link_keys); 3857 INIT_LIST_HEAD(&hdev->link_keys);
3830 INIT_LIST_HEAD(&hdev->long_term_keys); 3858 INIT_LIST_HEAD(&hdev->long_term_keys);
@@ -4036,6 +4064,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
4036 4064
4037 hci_dev_lock(hdev); 4065 hci_dev_lock(hdev);
4038 hci_bdaddr_list_clear(&hdev->blacklist); 4066 hci_bdaddr_list_clear(&hdev->blacklist);
4067 hci_bdaddr_list_clear(&hdev->whitelist);
4039 hci_uuids_clear(hdev); 4068 hci_uuids_clear(hdev);
4040 hci_link_keys_clear(hdev); 4069 hci_link_keys_clear(hdev);
4041 hci_smp_ltks_clear(hdev); 4070 hci_smp_ltks_clear(hdev);