Commit 88c3df13 authored by Johan Hedberg's avatar Johan Hedberg

Bluetooth: Update mgmt_disconnect to match latest API

This patch adds an address type parameter to the disconnect command and
response in order to match the latest mgmt API specification.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 124f6e35
...@@ -958,7 +958,8 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ...@@ -958,7 +958,8 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 *dev_class); u8 *dev_class);
int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type); 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, int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 status); u8 addr_type, u8 status);
int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure);
......
...@@ -177,10 +177,10 @@ struct mgmt_cp_load_long_term_keys { ...@@ -177,10 +177,10 @@ struct mgmt_cp_load_long_term_keys {
#define MGMT_OP_DISCONNECT 0x0014 #define MGMT_OP_DISCONNECT 0x0014
struct mgmt_cp_disconnect { struct mgmt_cp_disconnect {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
} __packed; } __packed;
struct mgmt_rp_disconnect { struct mgmt_rp_disconnect {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
__u8 status; __u8 status;
} __packed; } __packed;
......
...@@ -1550,6 +1550,28 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) ...@@ -1550,6 +1550,28 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
hci_dev_unlock(hdev); 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) static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
{ {
struct hci_cp_le_create_conn *cp; struct hci_cp_le_create_conn *cp;
...@@ -1839,7 +1861,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -1839,7 +1861,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) &&
(conn->type == ACL_LINK || conn->type == LE_LINK)) { (conn->type == ACL_LINK || conn->type == LE_LINK)) {
if (ev->status != 0) 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 else
mgmt_device_disconnected(hdev, &conn->dst, conn->type, mgmt_device_disconnected(hdev, &conn->dst, conn->type,
conn->dst_type); conn->dst_type);
...@@ -2350,8 +2373,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2350,8 +2373,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
break; break;
case HCI_OP_DISCONNECT: case HCI_OP_DISCONNECT:
if (ev->status != 0) hci_cs_disconnect(hdev, ev->status);
mgmt_disconnect_failed(hdev, NULL, ev->status);
break; break;
case HCI_OP_LE_CREATE_CONN: case HCI_OP_LE_CREATE_CONN:
......
...@@ -1185,9 +1185,10 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) ...@@ -1185,9 +1185,10 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len)
goto failed; goto failed;
} }
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); if (cp->addr.type == MGMT_ADDR_BREDR)
if (!conn) conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr);
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->bdaddr); else
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr);
if (!conn) { if (!conn) {
err = cmd_status(sk, index, MGMT_OP_DISCONNECT, err = cmd_status(sk, index, MGMT_OP_DISCONNECT,
...@@ -2619,7 +2620,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) ...@@ -2619,7 +2620,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data)
struct sock **sk = data; struct sock **sk = data;
struct mgmt_rp_disconnect rp; 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; rp.status = 0;
cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, &rp, sizeof(rp)); 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, ...@@ -2672,27 +2674,23 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
return err; 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; struct pending_cmd *cmd;
u8 mgmt_err = mgmt_status(status);
int err; int err;
cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev);
if (!cmd) if (!cmd)
return -ENOENT; return -ENOENT;
if (bdaddr) { bacpy(&rp.addr.bdaddr, bdaddr);
struct mgmt_rp_disconnect rp; rp.addr.type = link_to_mgmt(link_type, addr_type);
rp.status = mgmt_status(status);
bacpy(&rp.bdaddr, bdaddr);
rp.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)); &rp, sizeof(rp));
} else
err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT,
mgmt_err);
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment