~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to net/bluetooth/hci_event.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        if (status)
57
57
                return;
58
58
 
59
 
        clear_bit(HCI_INQUIRY, &hdev->flags);
 
59
        if (test_bit(HCI_MGMT, &hdev->flags) &&
 
60
                                test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
 
61
                mgmt_discovering(hdev->id, 0);
60
62
 
61
63
        hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
62
64
 
72
74
        if (status)
73
75
                return;
74
76
 
75
 
        clear_bit(HCI_INQUIRY, &hdev->flags);
 
77
        if (test_bit(HCI_MGMT, &hdev->flags) &&
 
78
                                test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
 
79
                mgmt_discovering(hdev->id, 0);
76
80
 
77
81
        hci_conn_check_pending(hdev);
78
82
}
195
199
 
196
200
        BT_DBG("%s status 0x%x", hdev->name, status);
197
201
 
198
 
        if (status)
199
 
                return;
200
 
 
201
202
        sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
202
203
        if (!sent)
203
204
                return;
204
205
 
205
 
        memcpy(hdev->dev_name, sent, 248);
 
206
        if (test_bit(HCI_MGMT, &hdev->flags))
 
207
                mgmt_set_local_name_complete(hdev->id, sent, status);
 
208
 
 
209
        if (status)
 
210
                return;
 
211
 
 
212
        memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
206
213
}
207
214
 
208
215
static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
214
221
        if (rp->status)
215
222
                return;
216
223
 
217
 
        memcpy(hdev->dev_name, rp->name, 248);
 
224
        memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH);
218
225
}
219
226
 
220
227
static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
470
477
         * command otherwise */
471
478
        u8 events[8] = { 0xff, 0xff, 0xfb, 0xff, 0x00, 0x00, 0x00, 0x00 };
472
479
 
473
 
        /* Events for 1.2 and newer controllers */
474
 
        if (hdev->lmp_ver > 1) {
475
 
                events[4] |= 0x01; /* Flow Specification Complete */
476
 
                events[4] |= 0x02; /* Inquiry Result with RSSI */
477
 
                events[4] |= 0x04; /* Read Remote Extended Features Complete */
478
 
                events[5] |= 0x08; /* Synchronous Connection Complete */
479
 
                events[5] |= 0x10; /* Synchronous Connection Changed */
480
 
        }
 
480
        /* CSR 1.1 dongles does not accept any bitfield so don't try to set
 
481
         * any event mask for pre 1.2 devices */
 
482
        if (hdev->lmp_ver <= 1)
 
483
                return;
 
484
 
 
485
        events[4] |= 0x01; /* Flow Specification Complete */
 
486
        events[4] |= 0x02; /* Inquiry Result with RSSI */
 
487
        events[4] |= 0x04; /* Read Remote Extended Features Complete */
 
488
        events[5] |= 0x08; /* Synchronous Connection Complete */
 
489
        events[5] |= 0x10; /* Synchronous Connection Changed */
481
490
 
482
491
        if (hdev->features[3] & LMP_RSSI_INQ)
483
492
                events[4] |= 0x04; /* Inquiry Result with RSSI */
821
830
                                                                rp->status);
822
831
}
823
832
 
 
833
static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
 
834
                                                        struct sk_buff *skb)
 
835
{
 
836
        struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
 
837
 
 
838
        BT_DBG("%s status 0x%x", hdev->name, rp->status);
 
839
 
 
840
        mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash,
 
841
                                                rp->randomizer, rp->status);
 
842
}
 
843
 
824
844
static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
825
845
{
826
846
        BT_DBG("%s status 0x%x", hdev->name, status);
827
847
 
828
848
        if (status) {
829
849
                hci_req_complete(hdev, HCI_OP_INQUIRY, status);
830
 
 
831
850
                hci_conn_check_pending(hdev);
832
 
        } else
833
 
                set_bit(HCI_INQUIRY, &hdev->flags);
 
851
                return;
 
852
        }
 
853
 
 
854
        if (test_bit(HCI_MGMT, &hdev->flags) &&
 
855
                                        !test_and_set_bit(HCI_INQUIRY,
 
856
                                                        &hdev->flags))
 
857
                mgmt_discovering(hdev->id, 1);
834
858
}
835
859
 
836
860
static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
999
1023
        hci_dev_lock(hdev);
1000
1024
 
1001
1025
        conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
1002
 
        if (conn && hci_outgoing_auth_needed(hdev, conn)) {
 
1026
        if (!conn)
 
1027
                goto unlock;
 
1028
 
 
1029
        if (!hci_outgoing_auth_needed(hdev, conn))
 
1030
                goto unlock;
 
1031
 
 
1032
        if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
1003
1033
                struct hci_cp_auth_requested cp;
1004
1034
                cp.handle = __cpu_to_le16(conn->handle);
1005
1035
                hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
1006
1036
        }
1007
1037
 
 
1038
unlock:
1008
1039
        hci_dev_unlock(hdev);
1009
1040
}
1010
1041
 
1194
1225
 
1195
1226
        BT_DBG("%s status %d", hdev->name, status);
1196
1227
 
1197
 
        clear_bit(HCI_INQUIRY, &hdev->flags);
 
1228
        if (test_bit(HCI_MGMT, &hdev->flags) &&
 
1229
                                test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
 
1230
                mgmt_discovering(hdev->id, 0);
1198
1231
 
1199
1232
        hci_req_complete(hdev, HCI_OP_INQUIRY, status);
1200
1233
 
1214
1247
 
1215
1248
        hci_dev_lock(hdev);
1216
1249
 
1217
 
        for (; num_rsp; num_rsp--) {
 
1250
        if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
 
1251
 
 
1252
                if (test_bit(HCI_MGMT, &hdev->flags))
 
1253
                        mgmt_discovering(hdev->id, 1);
 
1254
        }
 
1255
 
 
1256
        for (; num_rsp; num_rsp--, info++) {
1218
1257
                bacpy(&data.bdaddr, &info->bdaddr);
1219
1258
                data.pscan_rep_mode     = info->pscan_rep_mode;
1220
1259
                data.pscan_period_mode  = info->pscan_period_mode;
1223
1262
                data.clock_offset       = info->clock_offset;
1224
1263
                data.rssi               = 0x00;
1225
1264
                data.ssp_mode           = 0x00;
1226
 
                info++;
1227
1265
                hci_inquiry_cache_update(hdev, &data);
 
1266
                mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 0,
 
1267
                                                                        NULL);
1228
1268
        }
1229
1269
 
1230
1270
        hci_dev_unlock(hdev);
1402
1442
 
1403
1443
        conn->state = BT_CLOSED;
1404
1444
 
1405
 
        if (conn->type == ACL_LINK)
 
1445
        if (conn->type == ACL_LINK || conn->type == LE_LINK)
1406
1446
                mgmt_disconnected(hdev->id, &conn->dst);
1407
1447
 
1408
1448
        hci_proto_disconn_cfm(conn, ev->reason);
1428
1468
                        conn->sec_level = conn->pending_sec_level;
1429
1469
                } else {
1430
1470
                        mgmt_auth_failed(hdev->id, &conn->dst, ev->status);
1431
 
                        conn->sec_level = BT_SECURITY_LOW;
1432
1471
                }
1433
1472
 
1434
1473
                clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
1482
1521
 
1483
1522
        hci_dev_lock(hdev);
1484
1523
 
 
1524
        if (ev->status == 0 && test_bit(HCI_MGMT, &hdev->flags))
 
1525
                mgmt_remote_name(hdev->id, &ev->bdaddr, ev->name);
 
1526
 
1485
1527
        conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
1486
 
        if (conn && hci_outgoing_auth_needed(hdev, conn)) {
 
1528
        if (!conn)
 
1529
                goto unlock;
 
1530
 
 
1531
        if (!hci_outgoing_auth_needed(hdev, conn))
 
1532
                goto unlock;
 
1533
 
 
1534
        if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
1487
1535
                struct hci_cp_auth_requested cp;
1488
1536
                cp.handle = __cpu_to_le16(conn->handle);
1489
1537
                hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
1490
1538
        }
1491
1539
 
 
1540
unlock:
1492
1541
        hci_dev_unlock(hdev);
1493
1542
}
1494
1543
 
1751
1800
                hci_cc_pin_code_neg_reply(hdev, skb);
1752
1801
                break;
1753
1802
 
 
1803
        case HCI_OP_READ_LOCAL_OOB_DATA:
 
1804
                hci_cc_read_local_oob_data_reply(hdev, skb);
 
1805
                break;
 
1806
 
1754
1807
        case HCI_OP_LE_READ_BUFFER_SIZE:
1755
1808
                hci_cc_le_read_buffer_size(hdev, skb);
1756
1809
                break;
1984
2037
        if (!test_bit(HCI_PAIRABLE, &hdev->flags))
1985
2038
                hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
1986
2039
                                        sizeof(ev->bdaddr), &ev->bdaddr);
1987
 
 
1988
 
        if (test_bit(HCI_MGMT, &hdev->flags))
1989
 
                mgmt_pin_code_request(hdev->id, &ev->bdaddr);
 
2040
        else if (test_bit(HCI_MGMT, &hdev->flags)) {
 
2041
                u8 secure;
 
2042
 
 
2043
                if (conn->pending_sec_level == BT_SECURITY_HIGH)
 
2044
                        secure = 1;
 
2045
                else
 
2046
                        secure = 0;
 
2047
 
 
2048
                mgmt_pin_code_request(hdev->id, &ev->bdaddr, secure);
 
2049
        }
1990
2050
 
1991
2051
        hci_dev_unlock(hdev);
1992
2052
}
2015
2075
        BT_DBG("%s found key type %u for %s", hdev->name, key->type,
2016
2076
                                                        batostr(&ev->bdaddr));
2017
2077
 
2018
 
        if (!test_bit(HCI_DEBUG_KEYS, &hdev->flags) && key->type == 0x03) {
 
2078
        if (!test_bit(HCI_DEBUG_KEYS, &hdev->flags) &&
 
2079
                                key->type == HCI_LK_DEBUG_COMBINATION) {
2019
2080
                BT_DBG("%s ignoring debug key", hdev->name);
2020
2081
                goto not_found;
2021
2082
        }
2022
2083
 
2023
2084
        conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
2024
 
 
2025
 
        if (key->type == 0x04 && conn && conn->auth_type != 0xff &&
2026
 
                                                (conn->auth_type & 0x01)) {
2027
 
                BT_DBG("%s ignoring unauthenticated key", hdev->name);
2028
 
                goto not_found;
 
2085
        if (conn) {
 
2086
                if (key->type == HCI_LK_UNAUTH_COMBINATION &&
 
2087
                                conn->auth_type != 0xff &&
 
2088
                                (conn->auth_type & 0x01)) {
 
2089
                        BT_DBG("%s ignoring unauthenticated key", hdev->name);
 
2090
                        goto not_found;
 
2091
                }
 
2092
 
 
2093
                if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 &&
 
2094
                                conn->pending_sec_level == BT_SECURITY_HIGH) {
 
2095
                        BT_DBG("%s ignoring key unauthenticated for high \
 
2096
                                                        security", hdev->name);
 
2097
                        goto not_found;
 
2098
                }
 
2099
 
 
2100
                conn->key_type = key->type;
 
2101
                conn->pin_length = key->pin_len;
2029
2102
        }
2030
2103
 
2031
2104
        bacpy(&cp.bdaddr, &ev->bdaddr);
2057
2130
                hci_conn_hold(conn);
2058
2131
                conn->disc_timeout = HCI_DISCONN_TIMEOUT;
2059
2132
                pin_len = conn->pin_length;
 
2133
 
 
2134
                if (ev->key_type != HCI_LK_CHANGED_COMBINATION)
 
2135
                        conn->key_type = ev->key_type;
 
2136
 
2060
2137
                hci_conn_put(conn);
2061
2138
        }
2062
2139
 
2063
2140
        if (test_bit(HCI_LINK_KEYS, &hdev->flags))
2064
 
                hci_add_link_key(hdev, 1, &ev->bdaddr, ev->link_key,
 
2141
                hci_add_link_key(hdev, conn, 1, &ev->bdaddr, ev->link_key,
2065
2142
                                                        ev->key_type, pin_len);
2066
2143
 
2067
2144
        hci_dev_unlock(hdev);
2136
2213
 
2137
2214
        hci_dev_lock(hdev);
2138
2215
 
 
2216
        if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
 
2217
 
 
2218
                if (test_bit(HCI_MGMT, &hdev->flags))
 
2219
                        mgmt_discovering(hdev->id, 1);
 
2220
        }
 
2221
 
2139
2222
        if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
2140
2223
                struct inquiry_info_with_rssi_and_pscan_mode *info;
2141
2224
                info = (void *) (skb->data + 1);
2142
2225
 
2143
 
                for (; num_rsp; num_rsp--) {
 
2226
                for (; num_rsp; num_rsp--, info++) {
2144
2227
                        bacpy(&data.bdaddr, &info->bdaddr);
2145
2228
                        data.pscan_rep_mode     = info->pscan_rep_mode;
2146
2229
                        data.pscan_period_mode  = info->pscan_period_mode;
2149
2232
                        data.clock_offset       = info->clock_offset;
2150
2233
                        data.rssi               = info->rssi;
2151
2234
                        data.ssp_mode           = 0x00;
2152
 
                        info++;
2153
2235
                        hci_inquiry_cache_update(hdev, &data);
 
2236
                        mgmt_device_found(hdev->id, &info->bdaddr,
 
2237
                                                info->dev_class, info->rssi,
 
2238
                                                NULL);
2154
2239
                }
2155
2240
        } else {
2156
2241
                struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
2157
2242
 
2158
 
                for (; num_rsp; num_rsp--) {
 
2243
                for (; num_rsp; num_rsp--, info++) {
2159
2244
                        bacpy(&data.bdaddr, &info->bdaddr);
2160
2245
                        data.pscan_rep_mode     = info->pscan_rep_mode;
2161
2246
                        data.pscan_period_mode  = info->pscan_period_mode;
2164
2249
                        data.clock_offset       = info->clock_offset;
2165
2250
                        data.rssi               = info->rssi;
2166
2251
                        data.ssp_mode           = 0x00;
2167
 
                        info++;
2168
2252
                        hci_inquiry_cache_update(hdev, &data);
 
2253
                        mgmt_device_found(hdev->id, &info->bdaddr,
 
2254
                                                info->dev_class, info->rssi,
 
2255
                                                NULL);
2169
2256
                }
2170
2257
        }
2171
2258
 
2294
2381
        if (!num_rsp)
2295
2382
                return;
2296
2383
 
 
2384
        if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
 
2385
 
 
2386
                if (test_bit(HCI_MGMT, &hdev->flags))
 
2387
                        mgmt_discovering(hdev->id, 1);
 
2388
        }
 
2389
 
2297
2390
        hci_dev_lock(hdev);
2298
2391
 
2299
 
        for (; num_rsp; num_rsp--) {
 
2392
        for (; num_rsp; num_rsp--, info++) {
2300
2393
                bacpy(&data.bdaddr, &info->bdaddr);
2301
2394
                data.pscan_rep_mode     = info->pscan_rep_mode;
2302
2395
                data.pscan_period_mode  = info->pscan_period_mode;
2305
2398
                data.clock_offset       = info->clock_offset;
2306
2399
                data.rssi               = info->rssi;
2307
2400
                data.ssp_mode           = 0x01;
2308
 
                info++;
2309
2401
                hci_inquiry_cache_update(hdev, &data);
 
2402
                mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class,
 
2403
                                                info->rssi, info->data);
2310
2404
        }
2311
2405
 
2312
2406
        hci_dev_unlock(hdev);
2326
2420
 
2327
2421
        /* If remote requests no-bonding follow that lead */
2328
2422
        if (conn->remote_auth == 0x00 || conn->remote_auth == 0x01)
2329
 
                return 0x00;
 
2423
                return conn->remote_auth | (conn->auth_type & 0x01);
2330
2424
 
2331
2425
        return conn->auth_type;
2332
2426
}
2355
2449
 
2356
2450
                bacpy(&cp.bdaddr, &ev->bdaddr);
2357
2451
                cp.capability = conn->io_capability;
2358
 
                cp.oob_data = 0;
2359
 
                cp.authentication = hci_get_auth_req(conn);
 
2452
                conn->auth_type = hci_get_auth_req(conn);
 
2453
                cp.authentication = conn->auth_type;
 
2454
 
 
2455
                if ((conn->out == 0x01 || conn->remote_oob == 0x01) &&
 
2456
                                hci_find_remote_oob_data(hdev, &conn->dst))
 
2457
                        cp.oob_data = 0x01;
 
2458
                else
 
2459
                        cp.oob_data = 0x00;
2360
2460
 
2361
2461
                hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_REPLY,
2362
2462
                                                        sizeof(cp), &cp);
2364
2464
                struct hci_cp_io_capability_neg_reply cp;
2365
2465
 
2366
2466
                bacpy(&cp.bdaddr, &ev->bdaddr);
2367
 
                cp.reason = 0x16; /* Pairing not allowed */
 
2467
                cp.reason = 0x18; /* Pairing not allowed */
2368
2468
 
2369
2469
                hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY,
2370
2470
                                                        sizeof(cp), &cp);
2399
2499
                                                        struct sk_buff *skb)
2400
2500
{
2401
2501
        struct hci_ev_user_confirm_req *ev = (void *) skb->data;
 
2502
        int loc_mitm, rem_mitm, confirm_hint = 0;
 
2503
        struct hci_conn *conn;
2402
2504
 
2403
2505
        BT_DBG("%s", hdev->name);
2404
2506
 
2405
2507
        hci_dev_lock(hdev);
2406
2508
 
2407
 
        if (test_bit(HCI_MGMT, &hdev->flags))
2408
 
                mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey);
2409
 
 
 
2509
        if (!test_bit(HCI_MGMT, &hdev->flags))
 
2510
                goto unlock;
 
2511
 
 
2512
        conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
 
2513
        if (!conn)
 
2514
                goto unlock;
 
2515
 
 
2516
        loc_mitm = (conn->auth_type & 0x01);
 
2517
        rem_mitm = (conn->remote_auth & 0x01);
 
2518
 
 
2519
        /* If we require MITM but the remote device can't provide that
 
2520
         * (it has NoInputNoOutput) then reject the confirmation
 
2521
         * request. The only exception is when we're dedicated bonding
 
2522
         * initiators (connect_cfm_cb set) since then we always have the MITM
 
2523
         * bit set. */
 
2524
        if (!conn->connect_cfm_cb && loc_mitm && conn->remote_cap == 0x03) {
 
2525
                BT_DBG("Rejecting request: remote device can't provide MITM");
 
2526
                hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
 
2527
                                        sizeof(ev->bdaddr), &ev->bdaddr);
 
2528
                goto unlock;
 
2529
        }
 
2530
 
 
2531
        /* If no side requires MITM protection; auto-accept */
 
2532
        if ((!loc_mitm || conn->remote_cap == 0x03) &&
 
2533
                                (!rem_mitm || conn->io_capability == 0x03)) {
 
2534
 
 
2535
                /* If we're not the initiators request authorization to
 
2536
                 * proceed from user space (mgmt_user_confirm with
 
2537
                 * confirm_hint set to 1). */
 
2538
                if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
 
2539
                        BT_DBG("Confirming auto-accept as acceptor");
 
2540
                        confirm_hint = 1;
 
2541
                        goto confirm;
 
2542
                }
 
2543
 
 
2544
                BT_DBG("Auto-accept of user confirmation with %ums delay",
 
2545
                                                hdev->auto_accept_delay);
 
2546
 
 
2547
                if (hdev->auto_accept_delay > 0) {
 
2548
                        int delay = msecs_to_jiffies(hdev->auto_accept_delay);
 
2549
                        mod_timer(&conn->auto_accept_timer, jiffies + delay);
 
2550
                        goto unlock;
 
2551
                }
 
2552
 
 
2553
                hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY,
 
2554
                                                sizeof(ev->bdaddr), &ev->bdaddr);
 
2555
                goto unlock;
 
2556
        }
 
2557
 
 
2558
confirm:
 
2559
        mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey,
 
2560
                                                                confirm_hint);
 
2561
 
 
2562
unlock:
2410
2563
        hci_dev_unlock(hdev);
2411
2564
}
2412
2565
 
2453
2606
        hci_dev_unlock(hdev);
2454
2607
}
2455
2608
 
 
2609
static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
 
2610
                                                        struct sk_buff *skb)
 
2611
{
 
2612
        struct hci_ev_remote_oob_data_request *ev = (void *) skb->data;
 
2613
        struct oob_data *data;
 
2614
 
 
2615
        BT_DBG("%s", hdev->name);
 
2616
 
 
2617
        hci_dev_lock(hdev);
 
2618
 
 
2619
        if (!test_bit(HCI_MGMT, &hdev->flags))
 
2620
                goto unlock;
 
2621
 
 
2622
        data = hci_find_remote_oob_data(hdev, &ev->bdaddr);
 
2623
        if (data) {
 
2624
                struct hci_cp_remote_oob_data_reply cp;
 
2625
 
 
2626
                bacpy(&cp.bdaddr, &ev->bdaddr);
 
2627
                memcpy(cp.hash, data->hash, sizeof(cp.hash));
 
2628
                memcpy(cp.randomizer, data->randomizer, sizeof(cp.randomizer));
 
2629
 
 
2630
                hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_REPLY, sizeof(cp),
 
2631
                                                                        &cp);
 
2632
        } else {
 
2633
                struct hci_cp_remote_oob_data_neg_reply cp;
 
2634
 
 
2635
                bacpy(&cp.bdaddr, &ev->bdaddr);
 
2636
                hci_send_cmd(hdev, HCI_OP_REMOTE_OOB_DATA_NEG_REPLY, sizeof(cp),
 
2637
                                                                        &cp);
 
2638
        }
 
2639
 
 
2640
unlock:
 
2641
        hci_dev_unlock(hdev);
 
2642
}
 
2643
 
2456
2644
static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
2457
2645
{
2458
2646
        struct hci_ev_le_conn_complete *ev = (void *) skb->data;
2473
2661
        }
2474
2662
 
2475
2663
        if (ev->status) {
 
2664
                mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status);
2476
2665
                hci_proto_connect_cfm(conn, ev->status);
2477
2666
                conn->state = BT_CLOSED;
2478
2667
                hci_conn_del(conn);
2479
2668
                goto unlock;
2480
2669
        }
2481
2670
 
 
2671
        mgmt_connected(hdev->id, &ev->bdaddr);
 
2672
 
2482
2673
        conn->handle = __le16_to_cpu(ev->handle);
2483
2674
        conn->state = BT_CONNECTED;
2484
2675
 
2655
2846
                hci_le_meta_evt(hdev, skb);
2656
2847
                break;
2657
2848
 
 
2849
        case HCI_EV_REMOTE_OOB_DATA_REQUEST:
 
2850
                hci_remote_oob_data_request_evt(hdev, skb);
 
2851
                break;
 
2852
 
2658
2853
        default:
2659
2854
                BT_DBG("%s event 0x%x", hdev->name, event);
2660
2855
                break;