Bluetooth: Update mgmt to latest API specifiction
Subsystems (2)
cover Bluetooth: Update mgmt to latest API specifiction
Hi,
This patch set updates the kernel mgmt code to match the latest mgmt-api.txt in user space. The main changes are the renaming of mgmt_remove_keys to mgmt_unpair_device and the addition of an address type parameter to serveral messages.
Johan
PATCH 1/8 Bluetooth: Update and rename mgmt_remove_keys to mgmt_unpair_device
From: Johan Hedberg <[email protected]>
This patch renames the mgmt_remove_keys command to mgmt_unpair_device and updates its parameters to match the latest API (specifically, it adds an address type parameter to the command and its response).
--- include/net/bluetooth/mgmt.h | 34 ++++++++++++------------ net/bluetooth/mgmt.c | 60 +++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 43 deletions(-)
include/net/bluetooth/mgmt.h +17 -17
@@ -175,17 +175,7 @@ struct mgmt_cp_load_long_term_keys {struct mgmt_ltk_info keys[0 ]; } __packed; -#define MGMT_OP_REMOVE_KEYS 0x0014 -struct mgmt_cp_remove_keys { -bdaddr_t bdaddr; -__u8 disconnect; -} __packed; -struct mgmt_rp_remove_keys { -bdaddr_t bdaddr; -__u8 status; -}; - -#define MGMT_OP_DISCONNECT 0x0015 +#define MGMT_OP_DISCONNECT 0x0014struct mgmt_cp_disconnect {bdaddr_t bdaddr; } __packed;
@@ -194,13 +184,13 @@ struct mgmt_rp_disconnect {__u8 status; } __packed; -#define MGMT_OP_GET_CONNECTIONS 0x0016 +#define MGMT_OP_GET_CONNECTIONS 0x0015struct mgmt_rp_get_connections {__le16 conn_count;struct mgmt_addr_info addr[0 ]; } __packed; -#define MGMT_OP_PIN_CODE_REPLY 0x0017 +#define MGMT_OP_PIN_CODE_REPLY 0x0016struct mgmt_cp_pin_code_reply {bdaddr_t bdaddr;__u8 pin_len;
@@ -211,17 +201,17 @@ struct mgmt_rp_pin_code_reply {uint8_t status; } __packed; -#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0018 +#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017struct mgmt_cp_pin_code_neg_reply {bdaddr_t bdaddr; } __packed; -#define MGMT_OP_SET_IO_CAPABILITY 0x0019 +#define MGMT_OP_SET_IO_CAPABILITY 0x0018struct mgmt_cp_set_io_capability {__u8 io_capability; } __packed; -#define MGMT_OP_PAIR_DEVICE 0x001A +#define MGMT_OP_PAIR_DEVICE 0x0019struct mgmt_cp_pair_device {struct mgmt_addr_info addr;__u8 io_cap;
@@ -231,7 +221,17 @@ struct mgmt_rp_pair_device {__u8 status; } __packed; -#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001B +#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A + +#define MGMT_OP_UNPAIR_DEVICE 0x001B +struct mgmt_cp_unpair_device { +struct mgmt_addr_info addr; +__u8 disconnect; +} __packed; +struct mgmt_rp_unpair_device { +struct mgmt_addr_info addr; +__u8 status; +};#define MGMT_OP_USER_CONFIRM_REPLY 0x001Cstruct mgmt_cp_user_confirm_reply {
net/bluetooth/mgmt.c +34 -26
138 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 2/8 Bluetooth: Update mgmt_disconnect to match latest API
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch adds an address type parameter to the disconnect command and response in order to match the latest mgmt API specification.
--- include/net/bluetooth/hci_core.h | 3 ++- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/hci_event.c | 28 +++++++++++++++++++++++++--- net/bluetooth/mgmt.c | 28 +++++++++++++--------------- 4 files changed, 42 insertions(+), 21 deletions(-)
include/net/bluetooth/hci_core.h +2 -1
@@ -958,7 +958,8 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 *dev_class);int mgmt_device_disconnected (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type,u8 addr_type); -int mgmt_disconnect_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status); +int mgmt_disconnect_failed (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 link_type,u8 addr_type,u8 status);int mgmt_connect_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type,u8 addr_type,u8 status);int mgmt_pin_code_request (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 secure);
include/net/bluetooth/mgmt.h +2 -2
@@ -177,10 +177,10 @@ struct mgmt_cp_load_long_term_keys {#define MGMT_OP_DISCONNECT 0x0014struct mgmt_cp_disconnect { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;struct mgmt_rp_disconnect { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 status; } __packed;
net/bluetooth/hci_event.c +25 -3
@@ -1550,6 +1550,28 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)hci_dev_unlock (hdev); } +static void hci_cs_disconnect (struct hci_dev *hdev,u8 status) +{ +struct hci_cp_disconnect *cp; +struct hci_conn *conn; + +if (!status) +return ; + + cp =hci_sent_cmd_data (hdev,HCI_OP_DISCONNECT ); +if (!cp) +return ; + +hci_dev_lock (hdev); + + conn =hci_conn_hash_lookup_handle (hdev,__le16_to_cpu (cp->handle)); +if (conn) +mgmt_disconnect_failed (hdev, &conn->dst, conn->type, + conn->dst_type, status); + +hci_dev_unlock (hdev); +} +static void hci_cs_le_create_conn (struct hci_dev *hdev,__u8 status) {struct hci_cp_le_create_conn *cp;
@@ -1839,7 +1861,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buffif (test_and_clear_bit (HCI_CONN_MGMT_CONNECTED , &conn->flags) && (conn->type ==ACL_LINK || conn->type ==LE_LINK )) {if (ev->status !=0 ) -mgmt_disconnect_failed (hdev, &conn->dst, ev->status); +mgmt_disconnect_failed (hdev, &conn->dst, conn->type, + conn->dst_type, ev->status);else mgmt_device_disconnected (hdev, &conn->dst, conn->type, conn->dst_type);
@@ -2350,8 +2373,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)break ;case HCI_OP_DISCONNECT : -if (ev->status !=0 ) -mgmt_disconnect_failed (hdev,NULL , ev->status); +hci_cs_disconnect (hdev, ev->status);break ;case HCI_OP_LE_CREATE_CONN :
net/bluetooth/mgmt.c +13 -15
@@ -1185,9 +1185,10 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &cp->bdaddr); -if (!conn) - conn =hci_conn_hash_lookup_ba (hdev,LE_LINK , &cp->bdaddr); +if (cp->addr.type ==MGMT_ADDR_BREDR ) + conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &cp->addr.bdaddr); +else + conn =hci_conn_hash_lookup_ba (hdev,LE_LINK , &cp->addr.bdaddr);if (!conn) { err = cmd_status(sk, index, MGMT_OP_DISCONNECT,
@@ -2619,7 +2620,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data)struct sock **sk = data;struct mgmt_rp_disconnect rp; -bacpy (&rp.bdaddr, &cp->bdaddr); +bacpy (&rp.addr.bdaddr, &cp->addr.bdaddr); + rp.addr.type = cp->addr.type; rp.status =0 ;cmd_complete (cmd->sk, cmd->index,MGMT_OP_DISCONNECT , &rp,sizeof (rp));
@@ -2672,27 +2674,23 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,return err; } -int mgmt_disconnect_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status) +int mgmt_disconnect_failed (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 link_type,u8 addr_type,u8 status) { +struct mgmt_rp_disconnect rp;struct pending_cmd *cmd; -u8 mgmt_err =mgmt_status (status);int err; cmd =mgmt_pending_find (MGMT_OP_DISCONNECT , hdev);if (!cmd)return -ENOENT ; -if (bdaddr) { -struct mgmt_rp_disconnect rp; - -bacpy (&rp.bdaddr, bdaddr); - rp.status = status; +bacpy (&rp.addr.bdaddr, bdaddr); + rp.addr.type =link_to_mgmt (link_type, addr_type); + rp.status =mgmt_status (status); - err =cmd_complete (cmd->sk, cmd->index,MGMT_OP_DISCONNECT , + err =cmd_complete (cmd->sk, cmd->index,MGMT_OP_DISCONNECT , &rp,sizeof (rp)); - }else - err =cmd_status (cmd->sk, hdev->id,MGMT_OP_DISCONNECT , - mgmt_err);mgmt_pending_remove (cmd);
Signature · 1 line
1.7.9
PATCH 3/8 Bluetooth: Add address type to user_confirm and user_passkey messages
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch upadate the user confirm and user passkey mgmt messages to match the latest API specification by adding an address type parameter to them.
--- include/net/bluetooth/hci_core.h | 18 ++++--- include/net/bluetooth/mgmt.h | 16 +++--- net/bluetooth/hci_event.c | 14 +++-- net/bluetooth/mgmt.c | 98 +++++++++++++++++++------------------ net/bluetooth/smp.c | 4 +- 5 files changed, 79 insertions(+), 71 deletions(-)
include/net/bluetooth/hci_core.h +10 -8
@@ -968,16 +968,18 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,int mgmt_pin_code_neg_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status);int mgmt_user_confirm_request (struct hci_dev *hdev,bdaddr_t *bdaddr, -__le32 value,u8 confirm_hint); +u8 link_type,u8 addr_type,__le32 value, +u8 confirm_hint);int mgmt_user_confirm_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr, -u8 status); -int mgmt_user_confirm_neg_reply_complete (struct hci_dev *hdev, -bdaddr_t *bdaddr,u8 status); -int mgmt_user_passkey_request (struct hci_dev *hdev,bdaddr_t *bdaddr); +u8 link_type,u8 addr_type,u8 status); +int mgmt_user_confirm_neg_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 link_type,u8 addr_type,u8 status); +int mgmt_user_passkey_request (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 link_type,u8 addr_type);int mgmt_user_passkey_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr, -u8 status); -int mgmt_user_passkey_neg_reply_complete (struct hci_dev *hdev, -bdaddr_t *bdaddr,u8 status); +u8 link_type,u8 addr_type,u8 status); +int mgmt_user_passkey_neg_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 link_type,u8 addr_type,u8 status);int mgmt_auth_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status);int mgmt_set_local_name_complete (struct hci_dev *hdev,u8 *name,u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
include/net/bluetooth/mgmt.h +8 -8
@@ -235,31 +235,31 @@ struct mgmt_rp_unpair_device {#define MGMT_OP_USER_CONFIRM_REPLY 0x001Cstruct mgmt_cp_user_confirm_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;struct mgmt_rp_user_confirm_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 status; } __packed;#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001Dstruct mgmt_cp_user_confirm_neg_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_OP_USER_PASSKEY_REPLY 0x001Estruct mgmt_cp_user_passkey_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__le32 passkey; } __packed;struct mgmt_rp_user_passkey_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 status; } __packed;#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001Fstruct mgmt_cp_user_passkey_neg_reply { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020
@@ -376,14 +376,14 @@ struct mgmt_ev_pin_code_request {#define MGMT_EV_USER_CONFIRM_REQUEST 0x000Fstruct mgmt_ev_user_confirm_request { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 confirm_hint;__le32 value; } __packed;#define MGMT_EV_USER_PASSKEY_REQUEST 0x0010struct mgmt_ev_user_passkey_request { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_EV_AUTH_FAILED 0x0011
net/bluetooth/hci_event.c +8 -6
@@ -960,8 +960,8 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)hci_dev_lock (hdev);if (test_bit (HCI_MGMT , &hdev->dev_flags)) -mgmt_user_confirm_reply_complete (hdev, &rp->bdaddr, - rp->status); +mgmt_user_confirm_reply_complete (hdev, &rp->bdaddr,ACL_LINK , +0 , rp->status);hci_dev_unlock (hdev); }
@@ -977,6 +977,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,if (test_bit (HCI_MGMT , &hdev->dev_flags))mgmt_user_confirm_neg_reply_complete (hdev, &rp->bdaddr, +ACL_LINK ,0 , rp->status);hci_dev_unlock (hdev);
@@ -991,8 +992,8 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb)hci_dev_lock (hdev);if (test_bit (HCI_MGMT , &hdev->dev_flags)) -mgmt_user_passkey_reply_complete (hdev, &rp->bdaddr, - rp->status); +mgmt_user_passkey_reply_complete (hdev, &rp->bdaddr,ACL_LINK , +0 , rp->status);hci_dev_unlock (hdev); }
@@ -1008,6 +1009,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev,if (test_bit (HCI_MGMT , &hdev->dev_flags))mgmt_user_passkey_neg_reply_complete (hdev, &rp->bdaddr, +ACL_LINK ,0 , rp->status);hci_dev_unlock (hdev);
@@ -3123,7 +3125,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, } confirm: -mgmt_user_confirm_request (hdev, &ev->bdaddr, ev->passkey, +mgmt_user_confirm_request (hdev, &ev->bdaddr,ACL_LINK ,0 , ev->passkey, confirm_hint); unlock:
@@ -3140,7 +3142,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev,hci_dev_lock (hdev);if (test_bit (HCI_MGMT , &hdev->dev_flags)) -mgmt_user_passkey_request (hdev, &ev->bdaddr); +mgmt_user_passkey_request (hdev, &ev->bdaddr,ACL_LINK ,0 );hci_dev_unlock (hdev); }
net/bluetooth/mgmt.c +50 -48
188 lines not on this page · raw message
net/bluetooth/smp.c +3 -1
@@ -349,9 +349,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,hci_dev_lock (hcon->hdev);if (method ==REQ_PASSKEY ) - ret =mgmt_user_passkey_request (hcon->hdev, conn->dst); + ret =mgmt_user_passkey_request (hcon->hdev, conn->dst, + hcon->type, hcon->dst_type);else ret =mgmt_user_confirm_request (hcon->hdev, conn->dst, + hcon->type, hcon->dst_type,cpu_to_le32 (passkey),0 );hci_dev_unlock (hcon->hdev);
Signature · 1 line
1.7.9
PATCH 4/8 Bluetooth: Add address type to Out Of Band mgmt messages
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch updates the implementation for these mgmt to be up to date with the latest API specification. Right now the address type isn't actually used for anything but that might change in the future.
--- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/mgmt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/net/bluetooth/mgmt.h +2 -2
@@ -270,14 +270,14 @@ struct mgmt_rp_read_local_oob_data {#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021struct mgmt_cp_add_remote_oob_data { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 hash[16 ];__u8 randomizer[16 ]; } __packed;#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022struct mgmt_cp_remove_remote_oob_data { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_OP_START_DISCOVERY 0x0023
net/bluetooth/mgmt.c +2 -2
@@ -1875,7 +1875,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data,hci_dev_lock (hdev); - err =hci_add_remote_oob_data (hdev, &cp->bdaddr, cp->hash, + err =hci_add_remote_oob_data (hdev, &cp->addr.bdaddr, cp->hash, cp->randomizer);if (err <0 ) err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
@@ -1910,7 +1910,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,hci_dev_lock (hdev); - err =hci_remove_remote_oob_data (hdev, &cp->bdaddr); + err =hci_remove_remote_oob_data (hdev, &cp->addr.bdaddr);if (err <0 ) err =cmd_status (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA ,MGMT_STATUS_INVALID_PARAMS );
Signature · 1 line
1.7.9
PATCH 5/8 Bluetooth: Add address type to mgmt blacklist messages
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch updates the implmentation for mgmt_block_device and mgmt_unblock_device and their corresponding events to match the latest API specification.
--- include/net/bluetooth/hci_core.h | 8 ++++---- include/net/bluetooth/mgmt.h | 8 ++++---- net/bluetooth/hci_core.c | 8 ++++---- net/bluetooth/hci_sock.c | 4 ++-- net/bluetooth/mgmt.c | 14 ++++++++------ 5 files changed, 22 insertions(+), 20 deletions(-)
include/net/bluetooth/hci_core.h +4 -4
@@ -646,8 +646,8 @@ int hci_inquiry(void __user *arg);struct bdaddr_list *hci_blacklist_lookup (struct hci_dev *hdev,bdaddr_t *bdaddr);int hci_blacklist_clear (struct hci_dev *hdev); -int hci_blacklist_add (struct hci_dev *hdev,bdaddr_t *bdaddr); -int hci_blacklist_del (struct hci_dev *hdev,bdaddr_t *bdaddr); +int hci_blacklist_add (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type); +int hci_blacklist_del (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type);int hci_uuids_clear (struct hci_dev *hdev);
@@ -992,8 +992,8 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,int mgmt_start_discovery_failed (struct hci_dev *hdev,u8 status);int mgmt_stop_discovery_failed (struct hci_dev *hdev,u8 status);int mgmt_discovering (struct hci_dev *hdev,u8 discovering); -int mgmt_device_blocked (struct hci_dev *hdev,bdaddr_t *bdaddr); -int mgmt_device_unblocked (struct hci_dev *hdev,bdaddr_t *bdaddr); +int mgmt_device_blocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type); +int mgmt_device_unblocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type);int mgmt_new_ltk (struct hci_dev *hdev,struct smp_ltk *key,u8 persistent);
include/net/bluetooth/mgmt.h +4 -4
@@ -299,12 +299,12 @@ struct mgmt_rp_confirm_name {#define MGMT_OP_BLOCK_DEVICE 0x0026struct mgmt_cp_block_device { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_OP_UNBLOCK_DEVICE 0x0027struct mgmt_cp_unblock_device { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_EV_CMD_COMPLETE 0x0001
@@ -405,10 +405,10 @@ struct mgmt_ev_device_found {#define MGMT_EV_DEVICE_BLOCKED 0x0014struct mgmt_ev_device_blocked { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;#define MGMT_EV_DEVICE_UNBLOCKED 0x0015struct mgmt_ev_device_unblocked { -bdaddr_t bdaddr; +struct mgmt_addr_info addr; } __packed;
net/bluetooth/hci_core.c +4 -4
@@ -1489,7 +1489,7 @@ int hci_blacklist_clear(struct hci_dev *hdev)return 0 ; } -int hci_blacklist_add (struct hci_dev *hdev,bdaddr_t *bdaddr) +int hci_blacklist_add (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type) {struct bdaddr_list *entry;
@@ -1507,10 +1507,10 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr)list_add (&entry->list, &hdev->blacklist); -return mgmt_device_blocked (hdev, bdaddr); +return mgmt_device_blocked (hdev, bdaddr, type); } -int hci_blacklist_del (struct hci_dev *hdev,bdaddr_t *bdaddr) +int hci_blacklist_del (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type) {struct bdaddr_list *entry;
@@ -1524,7 +1524,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr)list_del (&entry->list);kfree (entry); -return mgmt_device_unblocked (hdev, bdaddr); +return mgmt_device_unblocked (hdev, bdaddr, type); }static void hci_clear_adv_cache (struct work_struct *work)
net/bluetooth/hci_sock.c +2 -2
@@ -190,7 +190,7 @@ static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg)hci_dev_lock (hdev); - err =hci_blacklist_add (hdev, &bdaddr); + err =hci_blacklist_add (hdev, &bdaddr,0 );hci_dev_unlock (hdev);
@@ -207,7 +207,7 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg)hci_dev_lock (hdev); - err =hci_blacklist_del (hdev, &bdaddr); + err =hci_blacklist_del (hdev, &bdaddr,0 );hci_dev_unlock (hdev);
net/bluetooth/mgmt.c +8 -6
@@ -2114,7 +2114,7 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len)hci_dev_lock (hdev); - err =hci_blacklist_add (hdev, &cp->bdaddr); + err =hci_blacklist_add (hdev, &cp->addr.bdaddr, cp->addr.type);if (err <0 ) err =cmd_status (sk, index,MGMT_OP_BLOCK_DEVICE ,MGMT_STATUS_FAILED );
@@ -2147,7 +2147,7 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len)hci_dev_lock (hdev); - err =hci_blacklist_del (hdev, &cp->bdaddr); + err =hci_blacklist_del (hdev, &cp->addr.bdaddr, cp->addr.type);if (err <0 ) err = cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE,
@@ -3026,27 +3026,29 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) sizeof(discovering), NULL); } -int mgmt_device_blocked (struct hci_dev *hdev,bdaddr_t *bdaddr) +int mgmt_device_blocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type) {struct pending_cmd *cmd;struct mgmt_ev_device_blocked ev; cmd =mgmt_pending_find (MGMT_OP_BLOCK_DEVICE , hdev); -bacpy (&ev.bdaddr, bdaddr); +bacpy (&ev.addr.bdaddr, bdaddr); + ev.addr.type = type;return mgmt_event (MGMT_EV_DEVICE_BLOCKED , hdev, &ev,sizeof (ev), cmd ? cmd->sk :NULL ); } -int mgmt_device_unblocked (struct hci_dev *hdev,bdaddr_t *bdaddr) +int mgmt_device_unblocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type) {struct pending_cmd *cmd;struct mgmt_ev_device_unblocked ev; cmd =mgmt_pending_find (MGMT_OP_UNBLOCK_DEVICE , hdev); -bacpy (&ev.bdaddr, bdaddr); +bacpy (&ev.addr.bdaddr, bdaddr); + ev.addr.type = type;return mgmt_event (MGMT_EV_DEVICE_UNBLOCKED , hdev, &ev,sizeof (ev), cmd ? cmd->sk :NULL );
Signature · 1 line
1.7.9
PATCH 6/8 Bluetooth: Add address type to mgmt_ev_auth_failed
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch updates the Authentication Failed mgmt event to match the latest API specification by adding an address type to it.
--- include/net/bluetooth/hci_core.h | 3 ++- include/net/bluetooth/mgmt.h | 2 +- net/bluetooth/hci_event.c | 6 ++++-- net/bluetooth/mgmt.c | 6 ++++-- net/bluetooth/smp.c | 5 ++++- 5 files changed, 15 insertions(+), 7 deletions(-)
include/net/bluetooth/hci_core.h +2 -1
@@ -980,7 +980,8 @@ int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status);int mgmt_user_passkey_neg_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type,u8 addr_type,u8 status); -int mgmt_auth_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status); +int mgmt_auth_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type, +u8 addr_type,u8 status);int mgmt_set_local_name_complete (struct hci_dev *hdev,u8 *name,u8 status);int mgmt_read_local_oob_data_reply_complete (struct hci_dev *hdev,u8 *hash,u8 *randomizer,u8 status);
include/net/bluetooth/mgmt.h +1 -1
@@ -388,7 +388,7 @@ struct mgmt_ev_user_passkey_request {#define MGMT_EV_AUTH_FAILED 0x0011struct mgmt_ev_auth_failed { -bdaddr_t bdaddr; +struct mgmt_addr_info addr;__u8 status; } __packed;
net/bluetooth/hci_event.c +4 -2
@@ -1901,7 +1901,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->sec_level = conn->pending_sec_level; } }else { -mgmt_auth_failed (hdev, &conn->dst, ev->status); +mgmt_auth_failed (hdev, &conn->dst, conn->type, conn->dst_type, + ev->status); }clear_bit (HCI_CONN_AUTH_PEND , &conn->flags);
@@ -3166,7 +3167,8 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_* event gets always produced as initiator and is also mapped to * the mgmt_auth_failed event */ if (!test_bit (HCI_CONN_AUTH_PEND , &conn->flags) && ev->status !=0 ) -mgmt_auth_failed (hdev, &conn->dst, ev->status); +mgmt_auth_failed (hdev, &conn->dst, conn->type, conn->dst_type, + ev->status);hci_conn_put (conn);
net/bluetooth/mgmt.c +4 -2
@@ -2841,11 +2841,13 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, status, MGMT_OP_USER_PASSKEY_NEG_REPLY); } -int mgmt_auth_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status) +int mgmt_auth_failed (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type, +u8 addr_type,u8 status) {struct mgmt_ev_auth_failed ev; -bacpy (&ev.bdaddr, bdaddr); +bacpy (&ev.addr.bdaddr, bdaddr); + ev.addr.type =link_to_mgmt (link_type, addr_type); ev.status =mgmt_status (status);return mgmt_event (MGMT_EV_AUTH_FAILED , hdev, &ev,sizeof (ev),NULL );
net/bluetooth/smp.c +4 -1
@@ -257,12 +257,15 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size)static void smp_failure (struct l2cap_conn *conn,u8 reason,u8 send) { +struct hci_conn *hcon = conn->hcon; +if (send)smp_send_cmd (conn,SMP_CMD_PAIRING_FAIL ,sizeof (reason), &reason);clear_bit (HCI_CONN_ENCRYPT_PEND , &conn->hcon->flags); -mgmt_auth_failed (conn->hcon->hdev, conn->dst, reason); +mgmt_auth_failed (conn->hcon->hdev, conn->dst, hcon->type, + hcon->dst_type, reason);if (test_and_clear_bit (HCI_CONN_LE_SMP_PEND , &conn->hcon->flags)) {cancel_delayed_work_sync (&conn->security_timer);
Signature · 1 line
1.7.9
PATCH 7/8 Bluetooth: Fix mgmt_unpair_device command status
In reply to [email protected]From: Johan Hedberg <[email protected]>
The default response status to unpair_device should be set as 0 instead of a generic failure value. When disconnection is not needed (i.e. we can reply imediately) we should return success and not failure.
--- net/bluetooth/mgmt.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
net/bluetooth/mgmt.c +0 -1
@@ -1097,7 +1097,6 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len)memset (&rp,0 ,sizeof (rp));bacpy (&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; - rp.status =MGMT_STATUS_FAILED ;if (cp->addr.type ==MGMT_ADDR_BREDR ) err =hci_remove_link_key (hdev, &cp->addr.bdaddr);
Signature · 1 line
1.7.9
PATCH 8/8 Bluetooth: Add Device Unpaired mgmt event
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch add a new Device Unpaired mgmt event. This will be sent to all mgmt sockets except the one that requested unpairing (that socket will get a command complete instead). The event is also reserved for future SMP updates where a remote device will be able to request pairing revocation from us.
--- include/net/bluetooth/mgmt.h | 5 +++++ net/bluetooth/mgmt.c | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-)
include/net/bluetooth/mgmt.h +5 -0
@@ -412,3 +412,8 @@ struct mgmt_ev_device_blocked {struct mgmt_ev_device_unblocked {struct mgmt_addr_info addr; } __packed; + +#define MGMT_EV_DEVICE_UNPAIRED 0x0016 +struct mgmt_ev_device_unpaired { +struct mgmt_addr_info addr; +} __packed;
net/bluetooth/mgmt.c +21 -6
@@ -1073,6 +1073,18 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len)return 0 ; } +static int device_unpaired (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 addr_type,struct sock *skip_sk) +{ +struct mgmt_ev_device_unpaired ev; + +bacpy (&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + +return mgmt_event (MGMT_EV_DEVICE_UNPAIRED , hdev, &ev,sizeof (ev), + skip_sk); +} +static int unpair_device (struct sock *sk,u16 index,void *data,u16 len) {struct hci_dev *hdev;
@@ -1111,6 +1123,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len)if (!test_bit (HCI_UP , &hdev->flags) || !cp->disconnect) { err =cmd_complete (sk, index,MGMT_OP_UNPAIR_DEVICE , &rp,sizeof (rp)); +device_unpaired (hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; }
@@ -1124,6 +1137,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len)if (!conn) { err =cmd_complete (sk, index,MGMT_OP_UNPAIR_DEVICE , &rp,sizeof (rp)); +device_unpaired (hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; }
@@ -2629,18 +2643,17 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data)static void unpair_device_rsp (struct pending_cmd *cmd,void *data) { -u8 *status = data; +struct hci_dev *hdev = data;struct mgmt_cp_unpair_device *cp = cmd->param;struct mgmt_rp_unpair_device rp;memset (&rp,0 ,sizeof (rp));bacpy (&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; -if (status !=NULL ) - rp.status = *status; -cmd_complete (cmd->sk, cmd->index,MGMT_OP_UNPAIR_DEVICE , &rp, -sizeof (rp)); +device_unpaired (hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk); + +cmd_complete (cmd->sk, cmd->index, cmd->opcode, &rp,sizeof (rp));mgmt_pending_remove (cmd); }
@@ -2664,7 +2677,7 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,sock_put (sk);mgmt_pending_foreach (MGMT_OP_UNPAIR_DEVICE , hdev, unpair_device_rsp, -NULL ); + hdev);return err; }
@@ -2689,6 +2702,8 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,mgmt_pending_remove (cmd); +mgmt_pending_foreach (MGMT_OP_UNPAIR_DEVICE , hdev, unpair_device_rsp, + hdev);return err; }
Signature · 1 line
1.7.9
Hi Johan,
Quoted 4 lines
This patch set updates the kernel mgmt code to match the latest mgmt-api.txt in user space. The main changes are the renaming of
mgmt_remove_keystomgmt_unpair_deviceand the addition of an address type parameter to serveral messages.
I looked through all 8 patches and looks all fine to me.
Regards
Marcel