Skip to content

Commit

Permalink
Bluetooth: Use defined link key size
Browse files Browse the repository at this point in the history
Remove magic number with defined link key size.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Andrei Emeltchenko authored and Johan Hedberg committed Jun 5, 2012
1 parent a6c511c commit 9b3b446
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define HCI_MAX_EVENT_SIZE 260
#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4)

#define HCI_LINK_KEY_SIZE 16

/* HCI dev events */
#define HCI_DEV_REG 1
#define HCI_DEV_UNREG 2
Expand Down Expand Up @@ -371,7 +373,7 @@ struct hci_cp_reject_conn_req {
#define HCI_OP_LINK_KEY_REPLY 0x040b
struct hci_cp_link_key_reply {
bdaddr_t bdaddr;
__u8 link_key[16];
__u8 link_key[HCI_LINK_KEY_SIZE];
} __packed;

#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
Expand Down Expand Up @@ -1048,7 +1050,7 @@ struct hci_ev_link_key_req {
#define HCI_EV_LINK_KEY_NOTIFY 0x18
struct hci_ev_link_key_notify {
bdaddr_t bdaddr;
__u8 link_key[16];
__u8 link_key[HCI_LINK_KEY_SIZE];
__u8 key_type;
} __packed;

Expand Down
2 changes: 1 addition & 1 deletion include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct link_key {
struct list_head list;
bdaddr_t bdaddr;
u8 type;
u8 val[16];
u8 val[HCI_LINK_KEY_SIZE];
u8 pin_len;
};

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
}

bacpy(&key->bdaddr, bdaddr);
memcpy(key->val, val, 16);
memcpy(key->val, val, HCI_LINK_KEY_SIZE);
key->pin_len = pin_len;

if (type == HCI_LK_CHANGED_COMBINATION)
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,7 +2739,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev,
}

bacpy(&cp.bdaddr, &ev->bdaddr);
memcpy(cp.link_key, key->val, 16);
memcpy(cp.link_key, key->val, HCI_LINK_KEY_SIZE);

hci_send_cmd(hdev, HCI_OP_LINK_KEY_REPLY, sizeof(cp), &cp);

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,7 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
ev.key.addr.type = BDADDR_BREDR;
ev.key.type = key->type;
memcpy(ev.key.val, key->val, 16);
memcpy(ev.key.val, key->val, HCI_LINK_KEY_SIZE);
ev.key.pin_len = key->pin_len;

return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL);
Expand Down

0 comments on commit 9b3b446

Please sign in to comment.