aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-17 07:24:57 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-17 07:39:16 -0500
commitd8457698e7f23a05055396a15ec72ba663282867 (patch)
treea3e5e0b749cbdbf19e1224aebc6c8cabd32397cb
parentd753fdc40f60da2eef03b4816392081a552fea5a (diff)
Bluetooth: mgmt: Add address type to PIN code messages
The latest mgmt API includes address types for all messages containing an address. This patch updates the PIN code messages to match this. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/bluetooth/mgmt.h8
-rw-r--r--net/bluetooth/mgmt.c22
2 files changed, 17 insertions, 13 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 5aafe929d011..eb584cc287d6 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -199,18 +199,18 @@ struct mgmt_rp_get_connections {
199 199
200#define MGMT_OP_PIN_CODE_REPLY 0x0016 200#define MGMT_OP_PIN_CODE_REPLY 0x0016
201struct mgmt_cp_pin_code_reply { 201struct mgmt_cp_pin_code_reply {
202 bdaddr_t bdaddr; 202 struct mgmt_addr_info addr;
203 __u8 pin_len; 203 __u8 pin_len;
204 __u8 pin_code[16]; 204 __u8 pin_code[16];
205} __packed; 205} __packed;
206struct mgmt_rp_pin_code_reply { 206struct mgmt_rp_pin_code_reply {
207 bdaddr_t bdaddr; 207 struct mgmt_addr_info addr;
208 uint8_t status; 208 uint8_t status;
209} __packed; 209} __packed;
210 210
211#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 211#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017
212struct mgmt_cp_pin_code_neg_reply { 212struct mgmt_cp_pin_code_neg_reply {
213 bdaddr_t bdaddr; 213 struct mgmt_addr_info addr;
214} __packed; 214} __packed;
215 215
216#define MGMT_OP_SET_IO_CAPABILITY 0x0018 216#define MGMT_OP_SET_IO_CAPABILITY 0x0018
@@ -377,7 +377,7 @@ struct mgmt_ev_connect_failed {
377 377
378#define MGMT_EV_PIN_CODE_REQUEST 0x000E 378#define MGMT_EV_PIN_CODE_REQUEST 0x000E
379struct mgmt_ev_pin_code_request { 379struct mgmt_ev_pin_code_request {
380 bdaddr_t bdaddr; 380 struct mgmt_addr_info addr;
381 __u8 secure; 381 __u8 secure;
382} __packed; 382} __packed;
383 383
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b0de7194249e..68623401933f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1528,8 +1528,8 @@ static int send_pin_code_neg_reply(struct sock *sk, u16 index,
1528 if (!cmd) 1528 if (!cmd)
1529 return -ENOMEM; 1529 return -ENOMEM;
1530 1530
1531 err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(cp->bdaddr), 1531 err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
1532 &cp->bdaddr); 1532 sizeof(cp->addr.bdaddr), &cp->addr.bdaddr);
1533 if (err < 0) 1533 if (err < 0)
1534 mgmt_pending_remove(cmd); 1534 mgmt_pending_remove(cmd);
1535 1535
@@ -1541,7 +1541,6 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)
1541 struct hci_dev *hdev; 1541 struct hci_dev *hdev;
1542 struct hci_conn *conn; 1542 struct hci_conn *conn;
1543 struct mgmt_cp_pin_code_reply *cp = data; 1543 struct mgmt_cp_pin_code_reply *cp = data;
1544 struct mgmt_cp_pin_code_neg_reply ncp;
1545 struct hci_cp_pin_code_reply reply; 1544 struct hci_cp_pin_code_reply reply;
1546 struct pending_cmd *cmd; 1545 struct pending_cmd *cmd;
1547 int err; 1546 int err;
@@ -1565,7 +1564,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)
1565 goto failed; 1564 goto failed;
1566 } 1565 }
1567 1566
1568 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); 1567 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr);
1569 if (!conn) { 1568 if (!conn) {
1570 err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, 1569 err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY,
1571 MGMT_STATUS_NOT_CONNECTED); 1570 MGMT_STATUS_NOT_CONNECTED);
@@ -1573,7 +1572,9 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)
1573 } 1572 }
1574 1573
1575 if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) { 1574 if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) {
1576 bacpy(&ncp.bdaddr, &cp->bdaddr); 1575 struct mgmt_cp_pin_code_neg_reply ncp;
1576
1577 memcpy(&ncp.addr, &cp->addr, sizeof(ncp.addr));
1577 1578
1578 BT_ERR("PIN code is not 16 bytes long"); 1579 BT_ERR("PIN code is not 16 bytes long");
1579 1580
@@ -1592,7 +1593,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len)
1592 goto failed; 1593 goto failed;
1593 } 1594 }
1594 1595
1595 bacpy(&reply.bdaddr, &cp->bdaddr); 1596 bacpy(&reply.bdaddr, &cp->addr.bdaddr);
1596 reply.pin_len = cp->pin_len; 1597 reply.pin_len = cp->pin_len;
1597 memcpy(reply.pin_code, cp->pin_code, sizeof(reply.pin_code)); 1598 memcpy(reply.pin_code, cp->pin_code, sizeof(reply.pin_code));
1598 1599
@@ -2945,7 +2946,8 @@ int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure)
2945{ 2946{
2946 struct mgmt_ev_pin_code_request ev; 2947 struct mgmt_ev_pin_code_request ev;
2947 2948
2948 bacpy(&ev.bdaddr, bdaddr); 2949 bacpy(&ev.addr.bdaddr, bdaddr);
2950 ev.addr.type = MGMT_ADDR_BREDR;
2949 ev.secure = secure; 2951 ev.secure = secure;
2950 2952
2951 return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev), 2953 return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev),
@@ -2963,7 +2965,8 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2963 if (!cmd) 2965 if (!cmd)
2964 return -ENOENT; 2966 return -ENOENT;
2965 2967
2966 bacpy(&rp.bdaddr, bdaddr); 2968 bacpy(&rp.addr.bdaddr, bdaddr);
2969 rp.addr.type = MGMT_ADDR_BREDR;
2967 rp.status = mgmt_status(status); 2970 rp.status = mgmt_status(status);
2968 2971
2969 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp, 2972 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp,
@@ -2985,7 +2988,8 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2985 if (!cmd) 2988 if (!cmd)
2986 return -ENOENT; 2989 return -ENOENT;
2987 2990
2988 bacpy(&rp.bdaddr, bdaddr); 2991 bacpy(&rp.addr.bdaddr, bdaddr);
2992 rp.addr.type = MGMT_ADDR_BREDR;
2989 rp.status = mgmt_status(status); 2993 rp.status = mgmt_status(status);
2990 2994
2991 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, 2995 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp,