diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2011-01-17 07:41:05 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-07 22:40:07 -0500 |
commit | 55ed8ca10f3530de8edbbf138acb50992bf5005b (patch) | |
tree | 3145b2b995758b2cb64493fc8ec29e63d0e9f0b4 /include | |
parent | 1aff6f09491f454d4cd9f405c783fa5e9d3168a0 (diff) |
Bluetooth: Implement link key handling for the management interface
This patch adds a management commands to feed the kernel with all stored
link keys as well as remove specific ones or all of them. Once the
load_keys command has been called the kernel takes over link key
replies. A new_key event is also added to inform userspace of newly
created link keys that should be stored permanently.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/bluetooth/hci.h | 2 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 17 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 29 |
3 files changed, 48 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 9ce46cd00ba2..08fbf1253b83 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -82,6 +82,8 @@ enum { | |||
82 | HCI_MGMT, | 82 | HCI_MGMT, |
83 | HCI_PAIRABLE, | 83 | HCI_PAIRABLE, |
84 | HCI_SERVICE_CACHE, | 84 | HCI_SERVICE_CACHE, |
85 | HCI_LINK_KEYS, | ||
86 | HCI_DEBUG_KEYS, | ||
85 | }; | 87 | }; |
86 | 88 | ||
87 | /* HCI ioctl defines */ | 89 | /* HCI ioctl defines */ |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index e62da084e01d..009fa63a9048 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -73,6 +73,14 @@ struct bt_uuid { | |||
73 | u8 svc_hint; | 73 | u8 svc_hint; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | struct link_key { | ||
77 | struct list_head list; | ||
78 | bdaddr_t bdaddr; | ||
79 | u8 type; | ||
80 | u8 val[16]; | ||
81 | u8 pin_len; | ||
82 | }; | ||
83 | |||
76 | #define NUM_REASSEMBLY 4 | 84 | #define NUM_REASSEMBLY 4 |
77 | struct hci_dev { | 85 | struct hci_dev { |
78 | struct list_head list; | 86 | struct list_head list; |
@@ -153,6 +161,8 @@ struct hci_dev { | |||
153 | 161 | ||
154 | struct list_head uuids; | 162 | struct list_head uuids; |
155 | 163 | ||
164 | struct list_head link_keys; | ||
165 | |||
156 | struct hci_dev_stats stat; | 166 | struct hci_dev_stats stat; |
157 | 167 | ||
158 | struct sk_buff_head driver_init; | 168 | struct sk_buff_head driver_init; |
@@ -461,6 +471,12 @@ int hci_blacklist_clear(struct hci_dev *hdev); | |||
461 | 471 | ||
462 | int hci_uuids_clear(struct hci_dev *hdev); | 472 | int hci_uuids_clear(struct hci_dev *hdev); |
463 | 473 | ||
474 | int hci_link_keys_clear(struct hci_dev *hdev); | ||
475 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
476 | int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, | ||
477 | u8 *key, u8 type, u8 pin_len); | ||
478 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
479 | |||
464 | void hci_del_off_timer(struct hci_dev *hdev); | 480 | void hci_del_off_timer(struct hci_dev *hdev); |
465 | 481 | ||
466 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); | 482 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
@@ -697,6 +713,7 @@ int mgmt_index_removed(u16 index); | |||
697 | int mgmt_powered(u16 index, u8 powered); | 713 | int mgmt_powered(u16 index, u8 powered); |
698 | int mgmt_discoverable(u16 index, u8 discoverable); | 714 | int mgmt_discoverable(u16 index, u8 discoverable); |
699 | int mgmt_connectable(u16 index, u8 connectable); | 715 | int mgmt_connectable(u16 index, u8 connectable); |
716 | int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type); | ||
700 | 717 | ||
701 | /* HCI info for socket */ | 718 | /* HCI info for socket */ |
702 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 719 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index b092c4c014eb..56b500a2f68c 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -98,6 +98,28 @@ struct mgmt_cp_set_service_cache { | |||
98 | __u8 enable; | 98 | __u8 enable; |
99 | } __packed; | 99 | } __packed; |
100 | 100 | ||
101 | struct mgmt_key_info { | ||
102 | bdaddr_t bdaddr; | ||
103 | u8 type; | ||
104 | u8 val[16]; | ||
105 | u8 pin_len; | ||
106 | } __packed; | ||
107 | |||
108 | #define MGMT_OP_LOAD_KEYS 0x000D | ||
109 | struct mgmt_cp_load_keys { | ||
110 | __le16 index; | ||
111 | __u8 debug_keys; | ||
112 | __le16 key_count; | ||
113 | struct mgmt_key_info keys[0]; | ||
114 | } __packed; | ||
115 | |||
116 | #define MGMT_OP_REMOVE_KEY 0x000E | ||
117 | struct mgmt_cp_remove_key { | ||
118 | __le16 index; | ||
119 | bdaddr_t bdaddr; | ||
120 | __u8 disconnect; | ||
121 | } __packed; | ||
122 | |||
101 | #define MGMT_EV_CMD_COMPLETE 0x0001 | 123 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
102 | struct mgmt_ev_cmd_complete { | 124 | struct mgmt_ev_cmd_complete { |
103 | __le16 opcode; | 125 | __le16 opcode; |
@@ -133,3 +155,10 @@ struct mgmt_ev_index_removed { | |||
133 | #define MGMT_EV_CONNECTABLE 0x0008 | 155 | #define MGMT_EV_CONNECTABLE 0x0008 |
134 | 156 | ||
135 | #define MGMT_EV_PAIRABLE 0x0009 | 157 | #define MGMT_EV_PAIRABLE 0x0009 |
158 | |||
159 | #define MGMT_EV_NEW_KEY 0x000A | ||
160 | struct mgmt_ev_new_key { | ||
161 | __le16 index; | ||
162 | struct mgmt_key_info key; | ||
163 | __u8 old_key_type; | ||
164 | } __packed; | ||