Lines Matching +full:ext +full:- +full:address +full:- +full:match
1 /* gap.c - Bluetooth GAP Tester */
4 * Copyright (c) 2015-2016 Intel Corporation
6 * SPDX-License-Identifier: Apache-2.0
120 bt_addr_le_copy(&ev.address, info.le.dst); in le_connected()
145 bt_addr_le_copy(&ev.address, addr); in le_disconnected()
155 bt_addr_le_copy(&ev.address, rpa); in le_identity_resolved()
167 bt_addr_le_copy(&ev.address, addr); in le_param_updated()
177 /* reject update if all parameters match reject pattern */ in le_param_req()
178 if ((param->interval_min == REJECT_INTERVAL_MIN) && in le_param_req()
179 (param->interval_max == REJECT_INTERVAL_MAX) && in le_param_req()
180 (param->latency == REJECT_LATENCY) && in le_param_req()
181 (param->timeout == REJECT_SUPERVISION_TIMEOUT)) { in le_param_req()
198 bt_addr_le_copy(&sec_ev.address, addr); in le_security_changed()
209 * This means bond is lost and we restart pairing to re-bond in le_security_changed()
215 bt_addr_le_copy(&bond_ev.address, addr); in le_security_changed()
243 tester_set_bit(rp->data, BTP_GAP_READ_SUPPORTED_COMMANDS); in supported_commands()
244 tester_set_bit(rp->data, BTP_GAP_READ_CONTROLLER_INDEX_LIST); in supported_commands()
245 tester_set_bit(rp->data, BTP_GAP_READ_CONTROLLER_INFO); in supported_commands()
246 tester_set_bit(rp->data, BTP_GAP_SET_POWERED); in supported_commands()
247 tester_set_bit(rp->data, BTP_GAP_SET_CONNECTABLE); in supported_commands()
250 tester_set_bit(rp->data, BTP_GAP_SET_DISCOVERABLE); in supported_commands()
251 tester_set_bit(rp->data, BTP_GAP_SET_BONDABLE); in supported_commands()
252 tester_set_bit(rp->data, BTP_GAP_START_ADVERTISING); in supported_commands()
253 tester_set_bit(rp->data, BTP_GAP_STOP_ADVERTISING); in supported_commands()
254 tester_set_bit(rp->data, BTP_GAP_START_DISCOVERY); in supported_commands()
255 tester_set_bit(rp->data, BTP_GAP_STOP_DISCOVERY); in supported_commands()
256 tester_set_bit(rp->data, BTP_GAP_CONNECT); in supported_commands()
257 tester_set_bit(rp->data, BTP_GAP_DISCONNECT); in supported_commands()
260 tester_set_bit(rp->data, BTP_GAP_SET_IO_CAP); in supported_commands()
261 tester_set_bit(rp->data, BTP_GAP_PAIR); in supported_commands()
262 tester_set_bit(rp->data, BTP_GAP_PASSKEY_ENTRY); in supported_commands()
263 tester_set_bit(rp->data, BTP_GAP_PASSKEY_CONFIRM); in supported_commands()
264 tester_set_bit(rp->data, BTP_GAP_START_DIRECTED_ADV); in supported_commands()
265 tester_set_bit(rp->data, BTP_GAP_CONN_PARAM_UPDATE); in supported_commands()
268 tester_set_bit(rp->data, BTP_GAP_OOB_LEGACY_SET_DATA); in supported_commands()
270 tester_set_bit(rp->data, BTP_GAP_OOB_SC_GET_LOCAL_DATA); in supported_commands()
271 tester_set_bit(rp->data, BTP_GAP_OOB_SC_SET_REMOTE_DATA); in supported_commands()
273 tester_set_bit(rp->data, BTP_GAP_SET_MITM); in supported_commands()
274 tester_set_bit(rp->data, BTP_GAP_SET_FILTER_LIST); in supported_commands()
276 tester_set_bit(rp->data, BTP_GAP_SET_EXTENDED_ADVERTISING); in supported_commands()
289 rp->num = 1U; in controller_index_list()
290 rp->index[0] = BTP_INDEX; in controller_index_list()
306 bt_addr_copy(&rp->address, &oob_local.addr.a); in controller_info()
309 * Re-use the oob data read here in get_oob_sc_local_data() in controller_info()
316 * If privacy is used, the device uses random type address, otherwise in controller_info()
317 * static random or public type address is used. in controller_info()
332 rp->supported_settings = sys_cpu_to_le32(supported_settings); in controller_info()
333 rp->current_settings = sys_cpu_to_le32(current_settings); in controller_info()
335 memcpy(rp->name, CONTROLLER_NAME, sizeof(CONTROLLER_NAME)); in controller_info()
373 switch (oob_info->type) { in oob_data_request()
378 oob_config_str(oob_info->lesc.oob_config), in oob_data_request()
382 oob_info->lesc.oob_config != BT_CONN_OOB_REMOTE_ONLY ? in oob_data_request()
387 oob_info->lesc.oob_config != BT_CONN_OOB_LOCAL_ONLY ? in oob_data_request()
428 LOG_ERR("Unhandled OOB type %d", oob_info->type); in oob_data_request()
441 memcpy(rp->conf, &oob_sc_local.le_sc_data.c[0], sizeof(rp->conf)); in get_oob_sc_local_data()
442 memcpy(rp->rand, &oob_sc_local.le_sc_data.r[0], sizeof(rp->rand)); in get_oob_sc_local_data()
459 memcpy(&oob_sc_remote.le_sc_data.r[0], cp->rand, in set_oob_sc_remote_data()
461 memcpy(&oob_sc_remote.le_sc_data.c[0], cp->conf, in set_oob_sc_remote_data()
475 if (cp->powered) { in set_powered()
492 rp->current_settings = sys_cpu_to_le32(current_settings); in set_powered()
505 if (cp->connectable) { in set_connectable()
511 rp->current_settings = sys_cpu_to_le32(current_settings); in set_connectable()
540 return -EINVAL; in tester_gap_start_ext_adv()
556 return -EINVAL; in tester_gap_stop_ext_adv()
571 switch (cp->discoverable) { in set_discoverable()
590 rp->current_settings = sys_cpu_to_le32(current_settings); in set_discoverable()
602 LOG_DBG("bondable: %d", cp->bondable); in set_bondable()
604 if (cp->bondable) { in set_bondable()
610 bt_set_bondable(cp->bondable); in set_bondable()
612 rp->current_settings = sys_cpu_to_le32(current_settings); in set_bondable()
629 param->options |= BT_LE_ADV_OPT_CONN; in tester_gap_create_adv_instance()
632 param->options |= BT_LE_ADV_OPT_FILTER_CONN; in tester_gap_create_adv_instance()
637 param->options |= BT_LE_ADV_OPT_FILTER_SCAN_REQ; in tester_gap_create_adv_instance()
642 param->options |= BT_LE_ADV_OPT_USE_IDENTITY; in tester_gap_create_adv_instance()
648 return -EINVAL; in tester_gap_create_adv_instance()
652 /* NRPA is used only for non-connectable advertising */ in tester_gap_create_adv_instance()
654 return -EINVAL; in tester_gap_create_adv_instance()
659 return -EINVAL; in tester_gap_create_adv_instance()
664 param->options |= BT_LE_ADV_OPT_EXT_ADV; in tester_gap_create_adv_instance()
705 * additional 5 bytes (4 bytes for duration, 1 byte for own address
709 (cmd_len != sizeof(*cp) + cp->adv_data_len + cp->scan_rsp_len +
715 duration = sys_get_le32(cp->adv_sr_data + cp->adv_data_len + cp->scan_rsp_len);
717 own_addr_type = cp->adv_sr_data[cp->adv_data_len + cp->scan_rsp_len + sizeof(duration)];
719 for (i = 0, adv_len = 1U; i < cp->adv_data_len; adv_len++) {
725 ad[adv_len].type = cp->adv_sr_data[i++];
726 ad[adv_len].data_len = cp->adv_sr_data[i++];
727 ad[adv_len].data = &cp->adv_sr_data[i];
731 for (sd_len = 0U; i < cp->adv_data_len + cp->scan_rsp_len; sd_len++) {
737 sd[sd_len].type = cp->adv_sr_data[i++];
738 sd[sd_len].data_len = cp->adv_sr_data[i++];
739 sd[sd_len].data = &cp->adv_sr_data[i];
766 rp->current_settings = sys_cpu_to_le32(current_settings);
778 uint16_t options = sys_le16_to_cpu(cp->options);
780 adv_param = *BT_LE_ADV_CONN_DIR(&cp->address);
790 /* check if peer supports Central Address Resolution */
792 if (bt_addr_le_eq(&cp->address, &cars[i].addr)) {
807 rp->current_settings = sys_cpu_to_le32(current_settings);
827 rp->current_settings = sys_cpu_to_le32(current_settings);
838 for (i = 0U; i < buf_ad->len; i += len - 1) {
839 len = buf_ad->data[i++];
845 if (len > (buf_ad->len - i) || (buf_ad->len - i) < 1) {
849 switch (buf_ad->data[i++]) {
851 return buf_ad->data[i];
873 bt_addr_le_copy(&ev->address, addr);
874 ev->rssi = rssi;
875 ev->flags = BTP_GAP_DEVICE_FOUND_FLAG_AD | BTP_GAP_DEVICE_FOUND_FLAG_RSSI;
876 ev->eir_data_len = buf_ad->len;
877 memcpy(net_buf_simple_add(adv_buf, buf_ad->len), buf_ad->data, buf_ad->len);
883 /* if General/Limited Discovery - parse Advertising data to get flags */
888 /* ignore non-discoverable devices */
894 /* if Limited Discovery - ignore general discoverable devices */
908 if (!adv_buf->len) {
913 ev = (void *) adv_buf->data;
915 bt_addr_le_copy(&a, &ev->address);
923 LOG_INF("Address does not match, skipping");
927 ev->eir_data_len += buf_ad->len;
928 ev->flags |= BTP_GAP_DEVICE_FOUND_FLAG_SD;
930 memcpy(net_buf_simple_add(adv_buf, buf_ad->len), buf_ad->data, buf_ad->len);
939 if (adv_buf->len) {
941 adv_buf->data, adv_buf->len);
947 /* if Active Scan and scannable event - wait for Scan Response */
956 adv_buf->data, adv_buf->len);
966 if (cp->flags & BTP_GAP_DISCOVERY_FLAG_BREDR) {
971 if (bt_le_scan_start(cp->flags & BTP_GAP_DISCOVERY_FLAG_LE_ACTIVE_SCAN ?
979 discovery_flags = cp->flags;
1011 if (!bt_addr_le_eq(&cp->address, BT_ADDR_LE_ANY)) {
1014 err = bt_conn_le_create(&cp->address, BT_CONN_LE_CREATE_CONN, conn_param, &conn);
1039 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1062 bt_addr_le_copy(&ev.address, addr);
1073 bt_addr_le_copy(&ev.address, addr);
1083 bt_addr_le_copy(&ev.address, addr);
1109 bt_addr_le_copy(&ev.address, addr);
1121 bt_addr_le_copy(&ev.address, addr);
1130 /* Read peer's Central Address Resolution if bonded */
1151 LOG_DBG("io_cap: %d", cp->io_cap);
1153 switch (cp->io_cap) {
1177 LOG_WRN("Unhandled io_cap: 0x%x", cp->io_cap);
1197 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1221 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1236 err = bt_unpair(BT_ID_DEFAULT, &cp->address);
1251 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1257 err = bt_conn_auth_passkey_entry(conn, sys_le32_to_cpu(cp->passkey));
1275 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1281 if (cp->match) {
1307 .interval_min = sys_le16_to_cpu(cp->interval_min),
1308 .interval_max = sys_le16_to_cpu(cp->interval_max),
1309 .latency = sys_le16_to_cpu(cp->latency),
1310 .timeout = sys_le16_to_cpu(cp->timeout),
1315 conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address);
1345 memcpy(oob_legacy_tk, cp->oob_data, 16);
1360 (cmd_len != sizeof(*cp) + (cp->cnt * sizeof(cp->addr[0])))) {
1366 for (int i = 0; i < cp->cnt; i++) {
1367 err = bt_le_filter_accept_list_add(&cp->addr[i]);
1373 filter_list_in_use = cp->cnt != 0;
1384 LOG_DBG("ext adv settings: %u", cp->settings);
1386 if (cp->settings != 0) {
1394 rp->current_settings = sys_cpu_to_le32(current_settings);
1417 bt_addr_le_copy(&ev.address, info->addr);
1418 ev.sync_handle = sys_cpu_to_le16(sync->handle);
1434 LOG_DBG("PA sync lost with reason %u", info->reason);
1437 ev.sync_handle = sys_cpu_to_le16(sync->handle);
1438 ev.reason = info->reason;
1454 BT_LE_ADV_PARAM_INIT(0, param->interval_min, param->interval_max, NULL);
1462 return -EINVAL;
1485 if (cp->flags & BTP_GAP_PADV_INCLUDE_TX_POWER) {
1489 err = tester_gap_padv_configure(BT_LE_PER_ADV_PARAM(sys_le16_to_cpu(cp->interval_min),
1490 sys_le16_to_cpu(cp->interval_max),
1496 rp->current_settings = sys_cpu_to_le32(current_settings);
1508 return -EINVAL;
1514 return -EINVAL;
1539 rp->current_settings = sys_cpu_to_le32(current_settings);
1551 /* Ext adv not yet created */
1552 return -ESRCH;
1576 rp->current_settings = sys_cpu_to_le32(current_settings);
1588 return -EINVAL;
1607 for (uint8_t i = 0; i < cp->data_len; padv_len++) {
1613 padv[padv_len].data_len = cp->data[i++] - 1;
1614 padv[padv_len].type = cp->data[i++];
1615 padv[padv_len].data = &cp->data[i];
1629 return -EBUSY;
1646 return -EALREADY;
1664 bt_addr_le_copy(&create_params.addr, &cp->address);
1666 create_params.sid = cp->advertiser_sid;
1667 create_params.skip = sys_le16_to_cpu(cp->skip);
1668 create_params.timeout = sys_le16_to_cpu(cp->sync_timeout);
1670 if (cp->flags & BTP_GAP_PADV_CREATE_SYNC_FLAG_REPORTS_DISABLED) {
1674 if (cp->flags & BTP_GAP_PADV_CREATE_SYNC_FLAG_FILTER_DUPLICATES) {