return cmd_complete(sk, hdev->id, opcode, &settings, sizeof(settings));
}
-static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
+static int set_powered(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_mode *cp;
+ struct mgmt_mode *cp = data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
int err, up;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_cp_set_discoverable *cp;
+ struct mgmt_cp_set_discoverable *cp = data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
u8 scan;
int err;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int set_connectable(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_mode *cp;
+ struct mgmt_mode *cp = data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
u8 scan;
int err;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return 0;
}
-static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int set_pairable(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_mode *cp;
+ struct mgmt_mode *cp = data;
struct hci_dev *hdev;
__le32 ev;
int err;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
+static int add_uuid(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_cp_add_uuid *cp;
+ struct mgmt_cp_add_uuid *cp = data;
struct hci_dev *hdev;
struct bt_uuid *uuid;
int err;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
+static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len)
{
+ struct mgmt_cp_remove_uuid *cp = data;
struct list_head *p, *n;
- struct mgmt_cp_remove_uuid *cp;
struct hci_dev *hdev;
u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int err, found;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_set_dev_class *cp;
+ struct mgmt_cp_set_dev_class *cp = data;
int err;
- cp = (void *) data;
-
BT_DBG("request for hci%u", index);
if (len != sizeof(*cp))
return err;
}
-static int load_link_keys(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_load_link_keys *cp;
+ struct mgmt_cp_load_link_keys *cp = data;
u16 key_count, expected_len;
int i;
- cp = (void *) data;
-
if (len < sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS);
return 0;
}
-static int remove_keys(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int remove_keys(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_remove_keys *cp;
+ struct mgmt_cp_remove_keys *cp = data;
struct mgmt_rp_remove_keys rp;
struct hci_cp_disconnect dc;
struct pending_cmd *cmd;
struct hci_conn *conn;
int err;
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS,
MGMT_STATUS_INVALID_PARAMS);
return err;
}
-static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len)
+static int disconnect(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_disconnect *cp;
+ struct mgmt_cp_disconnect *cp = data;
struct hci_cp_disconnect dc;
struct pending_cmd *cmd;
struct hci_conn *conn;
BT_DBG("");
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_DISCONNECT,
MGMT_STATUS_INVALID_PARAMS);
return err;
}
-static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
struct hci_conn *conn;
- struct mgmt_cp_pin_code_reply *cp;
+ struct mgmt_cp_pin_code_reply *cp = data;
struct mgmt_cp_pin_code_neg_reply ncp;
struct hci_cp_pin_code_reply reply;
struct pending_cmd *cmd;
BT_DBG("");
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_INVALID_PARAMS);
goto failed;
}
- cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, len);
+ cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data,
+ len);
if (!cmd) {
err = -ENOMEM;
goto failed;
return err;
}
-static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int pin_code_neg_reply(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_pin_code_neg_reply *cp;
+ struct mgmt_cp_pin_code_neg_reply *cp = data;
int err;
BT_DBG("");
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
MGMT_STATUS_INVALID_PARAMS);
return err;
}
-static int set_io_capability(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int set_io_capability(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_set_io_capability *cp;
+ struct mgmt_cp_set_io_capability *cp = data;
BT_DBG("");
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY,
MGMT_STATUS_INVALID_PARAMS);
pairing_complete(cmd, status);
}
-static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
+static int pair_device(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_pair_device *cp;
+ struct mgmt_cp_pair_device *cp = data;
struct mgmt_rp_pair_device rp;
struct pending_cmd *cmd;
u8 sec_level, auth_type;
BT_DBG("");
- cp = (void *) data;
-
if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS);
static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_cp_user_confirm_reply *cp = (void *) data;
+ struct mgmt_cp_user_confirm_reply *cp = data;
BT_DBG("");
static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_cp_user_passkey_reply *cp = (void *) data;
+ struct mgmt_cp_user_passkey_reply *cp = data;
BT_DBG("");
static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data,
u16 len)
{
- struct mgmt_cp_user_passkey_neg_reply *cp = (void *) data;
+ struct mgmt_cp_user_passkey_neg_reply *cp = data;
BT_DBG("");
HCI_OP_USER_PASSKEY_NEG_REPLY, 0);
}
-static int set_local_name(struct sock *sk, u16 index, unsigned char *data,
+static int set_local_name(struct sock *sk, u16 index, void *data,
u16 len)
{
- struct mgmt_cp_set_local_name *mgmt_cp = (void *) data;
+ struct mgmt_cp_set_local_name *mgmt_cp = data;
struct hci_cp_write_local_name hci_cp;
struct hci_dev *hdev;
struct pending_cmd *cmd;
hci_dev_lock(hdev);
- cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len);
+ cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data,
+ len);
if (!cmd) {
err = -ENOMEM;
goto failed;
return err;
}
-static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int add_remote_oob_data(struct sock *sk, u16 index, void *data,
+ u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_add_remote_oob_data *cp = (void *) data;
+ struct mgmt_cp_add_remote_oob_data *cp = data;
int err;
BT_DBG("hci%u ", index);
}
static int remove_remote_oob_data(struct sock *sk, u16 index,
- unsigned char *data, u16 len)
+ void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_remove_remote_oob_data *cp = (void *) data;
+ struct mgmt_cp_remove_remote_oob_data *cp = data;
int err;
BT_DBG("hci%u ", index);
}
static int start_discovery(struct sock *sk, u16 index,
- unsigned char *data, u16 len)
+ void *data, u16 len)
{
- struct mgmt_cp_start_discovery *cp = (void *) data;
+ struct mgmt_cp_start_discovery *cp = data;
struct pending_cmd *cmd;
struct hci_dev *hdev;
int err;
return err;
}
-static int confirm_name(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int confirm_name(struct sock *sk, u16 index, void *data, u16 len)
{
- struct mgmt_cp_confirm_name *cp = (void *) data;
+ struct mgmt_cp_confirm_name *cp = data;
struct inquiry_entry *e;
struct hci_dev *hdev;
int err;
return err;
}
-static int block_device(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int block_device(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_block_device *cp = (void *) data;
+ struct mgmt_cp_block_device *cp = data;
int err;
BT_DBG("hci%u", index);
return err;
}
-static int unblock_device(struct sock *sk, u16 index, unsigned char *data,
- u16 len)
+static int unblock_device(struct sock *sk, u16 index, void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_cp_unblock_device *cp = (void *) data;
+ struct mgmt_cp_unblock_device *cp = data;
int err;
BT_DBG("hci%u", index);
}
static int set_fast_connectable(struct sock *sk, u16 index,
- unsigned char *data, u16 len)
+ void *data, u16 len)
{
struct hci_dev *hdev;
- struct mgmt_mode *cp = (void *) data;
+ struct mgmt_mode *cp = data;
struct hci_cp_write_page_scan_activity acp;
u8 type;
int err;
int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
{
- unsigned char *buf;
+ void *buf;
+ u8 *cp;
struct mgmt_hdr *hdr;
u16 opcode, index, len;
int err;
goto done;
}
- hdr = (struct mgmt_hdr *) buf;
+ hdr = buf;
opcode = get_unaligned_le16(&hdr->opcode);
index = get_unaligned_le16(&hdr->index);
len = get_unaligned_le16(&hdr->len);
goto done;
}
+ cp = buf + sizeof(*hdr);
+
switch (opcode) {
case MGMT_OP_READ_VERSION:
err = read_version(sk);
err = read_controller_info(sk, index);
break;
case MGMT_OP_SET_POWERED:
- err = set_powered(sk, index, buf + sizeof(*hdr), len);
+ err = set_powered(sk, index, cp, len);
break;
case MGMT_OP_SET_DISCOVERABLE:
- err = set_discoverable(sk, index, buf + sizeof(*hdr), len);
+ err = set_discoverable(sk, index, cp, len);
break;
case MGMT_OP_SET_CONNECTABLE:
- err = set_connectable(sk, index, buf + sizeof(*hdr), len);
+ err = set_connectable(sk, index, cp, len);
break;
case MGMT_OP_SET_FAST_CONNECTABLE:
- err = set_fast_connectable(sk, index, buf + sizeof(*hdr),
- len);
+ err = set_fast_connectable(sk, index, cp, len);
break;
case MGMT_OP_SET_PAIRABLE:
- err = set_pairable(sk, index, buf + sizeof(*hdr), len);
+ err = set_pairable(sk, index, cp, len);
break;
case MGMT_OP_ADD_UUID:
- err = add_uuid(sk, index, buf + sizeof(*hdr), len);
+ err = add_uuid(sk, index, cp, len);
break;
case MGMT_OP_REMOVE_UUID:
- err = remove_uuid(sk, index, buf + sizeof(*hdr), len);
+ err = remove_uuid(sk, index, cp, len);
break;
case MGMT_OP_SET_DEV_CLASS:
- err = set_dev_class(sk, index, buf + sizeof(*hdr), len);
+ err = set_dev_class(sk, index, cp, len);
break;
case MGMT_OP_LOAD_LINK_KEYS:
- err = load_link_keys(sk, index, buf + sizeof(*hdr), len);
+ err = load_link_keys(sk, index, cp, len);
break;
case MGMT_OP_REMOVE_KEYS:
- err = remove_keys(sk, index, buf + sizeof(*hdr), len);
+ err = remove_keys(sk, index, cp, len);
break;
case MGMT_OP_DISCONNECT:
- err = disconnect(sk, index, buf + sizeof(*hdr), len);
+ err = disconnect(sk, index, cp, len);
break;
case MGMT_OP_GET_CONNECTIONS:
err = get_connections(sk, index);
break;
case MGMT_OP_PIN_CODE_REPLY:
- err = pin_code_reply(sk, index, buf + sizeof(*hdr), len);
+ err = pin_code_reply(sk, index, cp, len);
break;
case MGMT_OP_PIN_CODE_NEG_REPLY:
- err = pin_code_neg_reply(sk, index, buf + sizeof(*hdr), len);
+ err = pin_code_neg_reply(sk, index, cp, len);
break;
case MGMT_OP_SET_IO_CAPABILITY:
- err = set_io_capability(sk, index, buf + sizeof(*hdr), len);
+ err = set_io_capability(sk, index, cp, len);
break;
case MGMT_OP_PAIR_DEVICE:
- err = pair_device(sk, index, buf + sizeof(*hdr), len);
+ err = pair_device(sk, index, cp, len);
break;
case MGMT_OP_CANCEL_PAIR_DEVICE:
err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len);
break;
case MGMT_OP_USER_CONFIRM_REPLY:
- err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len);
+ err = user_confirm_reply(sk, index, cp, len);
break;
case MGMT_OP_USER_CONFIRM_NEG_REPLY:
- err = user_confirm_neg_reply(sk, index, buf + sizeof(*hdr),
- len);
+ err = user_confirm_neg_reply(sk, index, cp, len);
break;
case MGMT_OP_USER_PASSKEY_REPLY:
- err = user_passkey_reply(sk, index, buf + sizeof(*hdr), len);
+ err = user_passkey_reply(sk, index, cp, len);
break;
case MGMT_OP_USER_PASSKEY_NEG_REPLY:
- err = user_passkey_neg_reply(sk, index, buf + sizeof(*hdr),
- len);
+ err = user_passkey_neg_reply(sk, index, cp, len);
break;
case MGMT_OP_SET_LOCAL_NAME:
- err = set_local_name(sk, index, buf + sizeof(*hdr), len);
+ err = set_local_name(sk, index, cp, len);
break;
case MGMT_OP_READ_LOCAL_OOB_DATA:
err = read_local_oob_data(sk, index);
break;
case MGMT_OP_ADD_REMOTE_OOB_DATA:
- err = add_remote_oob_data(sk, index, buf + sizeof(*hdr), len);
+ err = add_remote_oob_data(sk, index, cp, len);
break;
case MGMT_OP_REMOVE_REMOTE_OOB_DATA:
- err = remove_remote_oob_data(sk, index, buf + sizeof(*hdr),
- len);
+ err = remove_remote_oob_data(sk, index, cp, len);
break;
case MGMT_OP_START_DISCOVERY:
- err = start_discovery(sk, index, buf + sizeof(*hdr), len);
+ err = start_discovery(sk, index, cp, len);
break;
case MGMT_OP_STOP_DISCOVERY:
err = stop_discovery(sk, index);
break;
case MGMT_OP_CONFIRM_NAME:
- err = confirm_name(sk, index, buf + sizeof(*hdr), len);
+ err = confirm_name(sk, index, cp, len);
break;
case MGMT_OP_BLOCK_DEVICE:
- err = block_device(sk, index, buf + sizeof(*hdr), len);
+ err = block_device(sk, index, cp, len);
break;
case MGMT_OP_UNBLOCK_DEVICE:
- err = unblock_device(sk, index, buf + sizeof(*hdr), len);
+ err = unblock_device(sk, index, cp, len);
break;
default:
BT_DBG("Unknown op %u", opcode);