aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-01-31 14:55:22 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-02-13 02:51:42 -0500
commit4e39ac81366583486b857c88656409e56befefdf (patch)
tree287e6aebe6cf3fa659724b2a5c1594711b07f894 /net/bluetooth/mgmt.c
parentb1de97d8c06d9d8d38e85dc5b0cf3630372e702c (diff)
Bluetooth: Add management command to allow use of debug keys
Originally allowing the use of debug keys was done via the Load Link Keys management command. However this is BR/EDR specific and to be flexible and allow extending this to LE as well, make this an independent command. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 91ffecd1727e..70a3a7e917b7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -80,6 +80,7 @@ static const u16 mgmt_commands[] = {
80 MGMT_OP_SET_STATIC_ADDRESS, 80 MGMT_OP_SET_STATIC_ADDRESS,
81 MGMT_OP_SET_SCAN_PARAMS, 81 MGMT_OP_SET_SCAN_PARAMS,
82 MGMT_OP_SET_SECURE_CONN, 82 MGMT_OP_SET_SECURE_CONN,
83 MGMT_OP_SET_DEBUG_KEYS,
83}; 84};
84 85
85static const u16 mgmt_events[] = { 86static const u16 mgmt_events[] = {
@@ -4111,6 +4112,38 @@ failed:
4111 return err; 4112 return err;
4112} 4113}
4113 4114
4115static int set_debug_keys(struct sock *sk, struct hci_dev *hdev,
4116 void *data, u16 len)
4117{
4118 struct mgmt_mode *cp = data;
4119 bool changed;
4120 int err;
4121
4122 BT_DBG("request for %s", hdev->name);
4123
4124 if (cp->val != 0x00 && cp->val != 0x01)
4125 return cmd_status(sk, hdev->id, MGMT_OP_SET_DEBUG_KEYS,
4126 MGMT_STATUS_INVALID_PARAMS);
4127
4128 hci_dev_lock(hdev);
4129
4130 if (cp->val)
4131 changed = !test_and_set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
4132 else
4133 changed = test_and_clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
4134
4135 err = send_settings_rsp(sk, MGMT_OP_SET_DEBUG_KEYS, hdev);
4136 if (err < 0)
4137 goto unlock;
4138
4139 if (changed)
4140 err = new_settings(hdev, sk);
4141
4142unlock:
4143 hci_dev_unlock(hdev);
4144 return err;
4145}
4146
4114static bool ltk_is_valid(struct mgmt_ltk_info *key) 4147static bool ltk_is_valid(struct mgmt_ltk_info *key)
4115{ 4148{
4116 if (key->authenticated != 0x00 && key->authenticated != 0x01) 4149 if (key->authenticated != 0x00 && key->authenticated != 0x01)
@@ -4240,6 +4273,7 @@ static const struct mgmt_handler {
4240 { set_static_address, false, MGMT_SET_STATIC_ADDRESS_SIZE }, 4273 { set_static_address, false, MGMT_SET_STATIC_ADDRESS_SIZE },
4241 { set_scan_params, false, MGMT_SET_SCAN_PARAMS_SIZE }, 4274 { set_scan_params, false, MGMT_SET_SCAN_PARAMS_SIZE },
4242 { set_secure_conn, false, MGMT_SETTING_SIZE }, 4275 { set_secure_conn, false, MGMT_SETTING_SIZE },
4276 { set_debug_keys, false, MGMT_SETTING_SIZE },
4243}; 4277};
4244 4278
4245 4279