smp.c (d22ef0bc83c5a4e7ca9f2791e658dc8949d31ff4) smp.c (f01ead315785768cdb6e928646f90a47640bcdd9)
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation;
8

--- 173 unchanged lines hidden (view full) ---

182}
183
184static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
185{
186 struct smp_cmd_pairing *rp = (void *) skb->data;
187
188 BT_DBG("conn %p", conn);
189
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation;
8

--- 173 unchanged lines hidden (view full) ---

182}
183
184static void smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
185{
186 struct smp_cmd_pairing *rp = (void *) skb->data;
187
188 BT_DBG("conn %p", conn);
189
190 conn->preq[0] = SMP_CMD_PAIRING_REQ;
191 memcpy(&conn->preq[1], rp, sizeof(*rp));
190 skb_pull(skb, sizeof(*rp));
191
192 rp->io_capability = 0x00;
193 rp->oob_flag = 0x00;
194 rp->max_key_size = 16;
195 rp->init_key_dist = 0x00;
196 rp->resp_key_dist = 0x00;
197 rp->auth_req &= (SMP_AUTH_BONDING | SMP_AUTH_MITM);
198
192 skb_pull(skb, sizeof(*rp));
193
194 rp->io_capability = 0x00;
195 rp->oob_flag = 0x00;
196 rp->max_key_size = 16;
197 rp->init_key_dist = 0x00;
198 rp->resp_key_dist = 0x00;
199 rp->auth_req &= (SMP_AUTH_BONDING | SMP_AUTH_MITM);
200
201 conn->prsp[0] = SMP_CMD_PAIRING_RSP;
202 memcpy(&conn->prsp[1], rp, sizeof(*rp));
203
199 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp);
200}
201
202static void smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
203{
204 smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp);
205}
206
207static void smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
208{
209 struct smp_cmd_pairing *rp = (void *) skb->data;
204 struct smp_cmd_pairing_confirm cp;
205
206 BT_DBG("conn %p", conn);
207
208 memset(&cp, 0, sizeof(cp));
209
210 struct smp_cmd_pairing_confirm cp;
211
212 BT_DBG("conn %p", conn);
213
214 memset(&cp, 0, sizeof(cp));
215
216 conn->prsp[0] = SMP_CMD_PAIRING_RSP;
217 memcpy(&conn->prsp[1], rp, sizeof(*rp));
218 skb_pull(skb, sizeof(*rp));
219
210 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp);
211}
212
213static void smp_cmd_pairing_confirm(struct l2cap_conn *conn,
214 struct sk_buff *skb)
215{
216 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
217

--- 43 unchanged lines hidden (view full) ---

261
262 cp.io_capability = 0x00;
263 cp.oob_flag = 0x00;
264 cp.max_key_size = 16;
265 cp.init_key_dist = 0x00;
266 cp.resp_key_dist = 0x00;
267 cp.auth_req = rp->auth_req & (SMP_AUTH_BONDING | SMP_AUTH_MITM);
268
220 smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp);
221}
222
223static void smp_cmd_pairing_confirm(struct l2cap_conn *conn,
224 struct sk_buff *skb)
225{
226 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
227

--- 43 unchanged lines hidden (view full) ---

271
272 cp.io_capability = 0x00;
273 cp.oob_flag = 0x00;
274 cp.max_key_size = 16;
275 cp.init_key_dist = 0x00;
276 cp.resp_key_dist = 0x00;
277 cp.auth_req = rp->auth_req & (SMP_AUTH_BONDING | SMP_AUTH_MITM);
278
279 conn->preq[0] = SMP_CMD_PAIRING_REQ;
280 memcpy(&conn->preq[1], &cp, sizeof(cp));
281
269 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
270}
271
272int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
273{
274 struct hci_conn *hcon = conn->hcon;
275 __u8 authreq;
276

--- 21 unchanged lines hidden (view full) ---

298 if (hcon->link_mode & HCI_LM_MASTER) {
299 struct smp_cmd_pairing cp;
300 cp.io_capability = 0x00;
301 cp.oob_flag = 0x00;
302 cp.max_key_size = 16;
303 cp.init_key_dist = 0x00;
304 cp.resp_key_dist = 0x00;
305 cp.auth_req = authreq;
282 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
283}
284
285int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
286{
287 struct hci_conn *hcon = conn->hcon;
288 __u8 authreq;
289

--- 21 unchanged lines hidden (view full) ---

311 if (hcon->link_mode & HCI_LM_MASTER) {
312 struct smp_cmd_pairing cp;
313 cp.io_capability = 0x00;
314 cp.oob_flag = 0x00;
315 cp.max_key_size = 16;
316 cp.init_key_dist = 0x00;
317 cp.resp_key_dist = 0x00;
318 cp.auth_req = authreq;
319
320 conn->preq[0] = SMP_CMD_PAIRING_REQ;
321 memcpy(&conn->preq[1], &cp, sizeof(cp));
322
306 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
307 } else {
308 struct smp_cmd_security_req cp;
309 cp.auth_req = authreq;
310 smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp);
311 }
312
313 return 0;

--- 61 unchanged lines hidden ---
323 smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
324 } else {
325 struct smp_cmd_security_req cp;
326 cp.auth_req = authreq;
327 smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp);
328 }
329
330 return 0;

--- 61 unchanged lines hidden ---