aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-09 06:50:12 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:36 -0500
commit124f6e35286c9d8dc96f147a9026081256136615 (patch)
tree6178d641e93808c34e3fecda4eb76dc4b6748e06 /net
parent930fa4aee934ad59ed82163cdbee4922b883ef79 (diff)
Bluetooth: Update and rename mgmt_remove_keys to mgmt_unpair_device
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). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 77bc5a4b026c..c64e5db7f596 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1073,57 +1073,63 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len)
1073 return 0; 1073 return 0;
1074} 1074}
1075 1075
1076static int remove_keys(struct sock *sk, u16 index, void *data, u16 len) 1076static int unpair_device(struct sock *sk, u16 index, void *data, u16 len)
1077{ 1077{
1078 struct hci_dev *hdev; 1078 struct hci_dev *hdev;
1079 struct mgmt_cp_remove_keys *cp = data; 1079 struct mgmt_cp_unpair_device *cp = data;
1080 struct mgmt_rp_remove_keys rp; 1080 struct mgmt_rp_unpair_device rp;
1081 struct hci_cp_disconnect dc; 1081 struct hci_cp_disconnect dc;
1082 struct pending_cmd *cmd; 1082 struct pending_cmd *cmd;
1083 struct hci_conn *conn; 1083 struct hci_conn *conn;
1084 int err; 1084 int err;
1085 1085
1086 if (len != sizeof(*cp)) 1086 if (len != sizeof(*cp))
1087 return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, 1087 return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE,
1088 MGMT_STATUS_INVALID_PARAMS); 1088 MGMT_STATUS_INVALID_PARAMS);
1089 1089
1090 hdev = hci_dev_get(index); 1090 hdev = hci_dev_get(index);
1091 if (!hdev) 1091 if (!hdev)
1092 return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, 1092 return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE,
1093 MGMT_STATUS_INVALID_PARAMS); 1093 MGMT_STATUS_INVALID_PARAMS);
1094 1094
1095 hci_dev_lock(hdev); 1095 hci_dev_lock(hdev);
1096 1096
1097 memset(&rp, 0, sizeof(rp)); 1097 memset(&rp, 0, sizeof(rp));
1098 bacpy(&rp.bdaddr, &cp->bdaddr); 1098 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
1099 rp.addr.type = cp->addr.type;
1099 rp.status = MGMT_STATUS_FAILED; 1100 rp.status = MGMT_STATUS_FAILED;
1100 1101
1101 err = hci_remove_ltk(hdev, &cp->bdaddr); 1102 if (cp->addr.type == MGMT_ADDR_BREDR)
1102 if (err < 0) { 1103 err = hci_remove_link_key(hdev, &cp->addr.bdaddr);
1103 err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); 1104 else
1104 goto unlock; 1105 err = hci_remove_ltk(hdev, &cp->addr.bdaddr);
1105 }
1106 1106
1107 err = hci_remove_link_key(hdev, &cp->bdaddr);
1108 if (err < 0) { 1107 if (err < 0) {
1109 rp.status = MGMT_STATUS_NOT_PAIRED; 1108 rp.status = MGMT_STATUS_NOT_PAIRED;
1110 goto unlock; 1109 goto unlock;
1111 } 1110 }
1112 1111
1113 if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { 1112 if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) {
1114 err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, 1113 err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp,
1115 sizeof(rp)); 1114 sizeof(rp));
1116 goto unlock; 1115 goto unlock;
1117 } 1116 }
1118 1117
1119 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); 1118 if (cp->addr.type == MGMT_ADDR_BREDR)
1119 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK,
1120 &cp->addr.bdaddr);
1121 else
1122 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK,
1123 &cp->addr.bdaddr);
1124
1120 if (!conn) { 1125 if (!conn) {
1121 err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, 1126 err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp,
1122 sizeof(rp)); 1127 sizeof(rp));
1123 goto unlock; 1128 goto unlock;
1124 } 1129 }
1125 1130
1126 cmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_KEYS, hdev, cp, sizeof(*cp)); 1131 cmd = mgmt_pending_add(sk, MGMT_OP_UNPAIR_DEVICE, hdev, cp,
1132 sizeof(*cp));
1127 if (!cmd) { 1133 if (!cmd) {
1128 err = -ENOMEM; 1134 err = -ENOMEM;
1129 goto unlock; 1135 goto unlock;
@@ -1137,7 +1143,7 @@ static int remove_keys(struct sock *sk, u16 index, void *data, u16 len)
1137 1143
1138unlock: 1144unlock:
1139 if (err < 0) 1145 if (err < 0)
1140 err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, 1146 err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp,
1141 sizeof(rp)); 1147 sizeof(rp));
1142 hci_dev_unlock(hdev); 1148 hci_dev_unlock(hdev);
1143 hci_dev_put(hdev); 1149 hci_dev_put(hdev);
@@ -2340,9 +2346,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
2340 case MGMT_OP_LOAD_LINK_KEYS: 2346 case MGMT_OP_LOAD_LINK_KEYS:
2341 err = load_link_keys(sk, index, cp, len); 2347 err = load_link_keys(sk, index, cp, len);
2342 break; 2348 break;
2343 case MGMT_OP_REMOVE_KEYS:
2344 err = remove_keys(sk, index, cp, len);
2345 break;
2346 case MGMT_OP_DISCONNECT: 2349 case MGMT_OP_DISCONNECT:
2347 err = disconnect(sk, index, cp, len); 2350 err = disconnect(sk, index, cp, len);
2348 break; 2351 break;
@@ -2364,6 +2367,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
2364 case MGMT_OP_CANCEL_PAIR_DEVICE: 2367 case MGMT_OP_CANCEL_PAIR_DEVICE:
2365 err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len); 2368 err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len);
2366 break; 2369 break;
2370 case MGMT_OP_UNPAIR_DEVICE:
2371 err = unpair_device(sk, index, cp, len);
2372 break;
2367 case MGMT_OP_USER_CONFIRM_REPLY: 2373 case MGMT_OP_USER_CONFIRM_REPLY:
2368 err = user_confirm_reply(sk, index, cp, len); 2374 err = user_confirm_reply(sk, index, cp, len);
2369 break; 2375 break;
@@ -2624,18 +2630,19 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data)
2624 mgmt_pending_remove(cmd); 2630 mgmt_pending_remove(cmd);
2625} 2631}
2626 2632
2627static void remove_keys_rsp(struct pending_cmd *cmd, void *data) 2633static void unpair_device_rsp(struct pending_cmd *cmd, void *data)
2628{ 2634{
2629 u8 *status = data; 2635 u8 *status = data;
2630 struct mgmt_cp_remove_keys *cp = cmd->param; 2636 struct mgmt_cp_unpair_device *cp = cmd->param;
2631 struct mgmt_rp_remove_keys rp; 2637 struct mgmt_rp_unpair_device rp;
2632 2638
2633 memset(&rp, 0, sizeof(rp)); 2639 memset(&rp, 0, sizeof(rp));
2634 bacpy(&rp.bdaddr, &cp->bdaddr); 2640 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
2641 rp.addr.type = cp->addr.type;
2635 if (status != NULL) 2642 if (status != NULL)
2636 rp.status = *status; 2643 rp.status = *status;
2637 2644
2638 cmd_complete(cmd->sk, cmd->index, MGMT_OP_REMOVE_KEYS, &rp, 2645 cmd_complete(cmd->sk, cmd->index, MGMT_OP_UNPAIR_DEVICE, &rp,
2639 sizeof(rp)); 2646 sizeof(rp));
2640 2647
2641 mgmt_pending_remove(cmd); 2648 mgmt_pending_remove(cmd);
@@ -2659,7 +2666,8 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
2659 if (sk) 2666 if (sk)
2660 sock_put(sk); 2667 sock_put(sk);
2661 2668
2662 mgmt_pending_foreach(MGMT_OP_REMOVE_KEYS, hdev, remove_keys_rsp, NULL); 2669 mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp,
2670 NULL);
2663 2671
2664 return err; 2672 return err;
2665} 2673}