summaryrefslogtreecommitdiff
path: root/emulator/btdev.c
Commit message (Collapse)AuthorAgeFilesLines
* tools/iso-tester: Add Broadcast tests for encrypted BIGIulia Tanasescu2023-04-191-0/+8
| | | | | | | This adds the following tests for encrypted broadcast: ISO Broadcaster Encrypted - Success ISO Broadcaster Receiver Encrypted - Success
* btdev: Fix not setting CIS parameters properlyLuiz Augusto von Dentz2023-04-121-5/+6
| | | | | The code was assuming only index 0 was to be used which doesn't work when there are multiple CIS being programmed with different parameters.
* btdev: Add support for setting bdaddrLuiz Augusto von Dentz2022-10-101-0/+10
| | | | | This adds btdev_set_bdaddr so it is possible to set an arbritrary address.
* btdev: Fix not checking if a CIG has any active CISLuiz Augusto von Dentz2022-07-111-0/+17
| | | | | | | | | | | Bluetooth Core specification says the CIG must be in configurable state in order to accept the SetCIGParameters: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2553: 'If the Host issues this command when the CIG is not in the configurable state, the Controller shall return the error code Command Disallowed (0x0C).'
* btdev: Fix not removing connection and advertising set on resetLuiz Augusto von Dentz2022-05-021-36/+40
| | | | | This makes sure that all connections and advertising sets are cleanup on reset.
* btdev: Fix CIS EstablishedLuiz Augusto von Dentz2022-04-141-4/+4
| | | | | CIS Established was using the ISO latency instead of SDU interval for transport latency.
* bthost: Add support for Create CISLuiz Augusto von Dentz2022-04-141-1/+1
| | | | This introduces bthost_set_cig_params and bthost_create_cis.
* btdev: Fix not cleanup ssp_status and ssp_auto_completeLuiz Augusto von Dentz2022-04-131-0/+5
| | | | This resets ssp_status and ssp_auto_complete flags on auth_complete.
* btdev: Fix BIG Create SyncLuiz Augusto von Dentz2022-04-061-7/+10
| | | | This fixes status return to BIG Create Sync command.
* btdev: Add support for sending LE BIG Info Adv ReportsLuiz Augusto von Dentz2022-04-061-1/+39
| | | | | This adds support for sending LE BIG Info Adv Reports if LE Create BIG has been called.
* btdev: Check parameter for CIG related commandsLuiz Augusto von Dentz2022-04-011-1/+59
| | | | | This checks if the parameters given to Set CIG Parameters and Remove CIG are in the valid range.
* btdev: Fix response to LE Set Extended Advertising ParametersLuiz Augusto von Dentz2022-03-081-8/+9
| | | | | The response should both the status and TX Power regardless if the command succeeds or not.
* btdev: Implements BT_HCI_CMD_LE_BIG_TERM_SYNCLuiz Augusto von Dentz2022-03-071-2/+37
| | | | | This sends BT_HCI_EVT_DISCONNECT_COMPLETE when handling BT_HCI_CMD_LE_BIG_TERM_SYNC.
* btdev: Implements BT_HCI_CMD_LE_BIG_CREATE_SYNCLuiz Augusto von Dentz2022-03-071-9/+149
| | | | | This sends BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED when handling BT_HCI_CMD_LE_BIG_CREATE_SYNC.
* monitor: Rename Periodic Advertising terms to PA/paLuiz Augusto von Dentz2022-03-071-88/+80
| | | | This renames the use of Periodic Advertising in the API to just PA.
* btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote start paLuiz Augusto von Dentz2022-03-071-66/+78
| | | | | | This sends BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote device start to periodic advertise when BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC is pending.
* btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED when scan is initiatedLuiz Augusto von Dentz2022-03-071-66/+86
| | | | | This sends BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if scan is initiated while BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC is pending.
* btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNCLuiz Augusto von Dentz2022-03-071-2/+15
| | | | This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC.
* btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCELLuiz Augusto von Dentz2022-03-071-3/+27
| | | | | | This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL generating BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if necessary.
* btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNCLuiz Augusto von Dentz2022-03-071-3/+96
| | | | | | This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC generating BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED and BT_HCI_EVT_LE_PER_ADV_REPORT.
* monitor: Fix Create BIG PDULuiz Augusto von Dentz2022-03-071-1/+1
| | | | | | The PDU of Create BIG is actually fixed size as the num_bis is related to the number of indexes to be connected and not the BIS parameters.
* btdev: Fix response to BT_HCI_CMD_LE_REMOVE_CIGLuiz Augusto von Dentz2022-01-311-1/+2
| | | | | BT_HCI_CMD_LE_REMOVE_CIG should respond with the CIG ID from the command instead of always responding with 0x00.
* btdev: Fix command status of BT_HCI_CMD_LE_TERM_BIGLuiz Augusto von Dentz2022-01-311-1/+1
| | | | | The status was reporting BT_HCI_CMD_DISCONNECT instead of BT_HCI_CMD_LE_TERM_BIG.
* btdev: Add implementation for BT_HCI_CMD_LE_TERM_BIGLuiz Augusto von Dentz2022-01-271-3/+19
| | | | | | This adds handler for BT_HCI_CMD_LE_TERM_BIG and generate BT_HCI_EVT_LE_BIG_TERMINATE to indicate to the host stack that the BIG has been terminated.
* emulator: Add support for vendor commandsLuiz Augusto von Dentz2022-01-051-8/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for vendor commands reserving a single opcode (0xfc10) so it can be extended using subcommands, similar to how MSFT works. The first subcommand (0x00) enables the emulator to generate arbitrary events using the commands parameters: > tools/hcitool cmd 3f 10 00 22 24 d0 d0 d0 d0 d0 d0 ff ff < HCI Command: Vendor (0x3f|0x0010) plen 11 00 22 24 d0 d0 d0 d0 d0 d0 ff ff ."$........ Bluetooth: hci0: Malformed HCI Event: 0x22 > HCI Event: Inquiry Result with R.. (0x22) plen 9 Num responses: 36 Page scan repetition mode: Reserved (0xff) Page period mode: Reserved (0xff) Class: 0xffffd0 Major class: Uncategorized, specific device code not specified Minor class: 0x34 Limited Discoverable Mode invalid service class Clock offset: 0x6368 RSSI: 105 dBm (0x69) > HCI Event: Command Complete (0x0e) plen 4 Vendor (0x3f|0x0010) ncmd 1 Status: Success (0x00)
* btdev: Add support for BT_HCI_CMD_LE_CREATE_CONN_CANCELLuiz Augusto von Dentz2021-12-101-0/+14
| | | | | This adds support for BT_HCI_CMD_LE_CREATE_CONN_CANCEL so it is able to generate proper command complete.
* btdev: Add support for LE Set Privacy modeLuiz Augusto von Dentz2021-11-091-1/+46
| | | | | | | | | | | | This adds support for LE Set Privacy mode which is required when using Device Privacy mode: < HCI Command: LE Set Priva.. (0x08|0x004e) plen 8 Peer Identity address type: Public (0x00) Peer Identity address: BC:9A:78:56:34:12 (OUI BC-9A-78) Privacy Mode: Use Device Privacy (0x01) > HCI Event: Command Complete (0x0e) plen 4 LE Set Privacy Mode (0x08|0x004e) ncmd 1
* emulator: Add support to get the advertising addressTedd Ho-Jeong An2021-10-251-2/+21
| | | | | This patch add supprt emulator to get the advertising address of the central device.
* emulator: Add support to config the accept and resolve listTedd Ho-Jeong An2021-10-251-8/+29
| | | | | This patch adds interfaces to config the accept list and resolve list in the btdev.
* btdev: Fix using the callback return as command completeLuiz Augusto von Dentz2021-10-251-36/+84
| | | | | Command callback can only be used when generating a command status as command complete can carry more than just the status.
* btdev: Set Local RPA when own_addr_type is 0x03Luiz Augusto von Dentz2021-10-211-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables the emulator to properly emulate the generation of a Local RPA so it always set the random_addr when Create Connection sets 0x03 as own_addr_type 0x03: < HCI Command: LE Extended.. (0x08|0x0043) plen 26 Filter policy: Accept list is not used (0x00) Own address type: Random (0x03) Peer address type: Public (0x00) Peer address: 00:AA:01:01:00:00 (Intel Corporation) Initiating PHYs: 0x01 Entry 0: LE 1M Scan interval: 60.000 msec (0x0060) Scan window: 60.000 msec (0x0060) Min connection interval: 30.00 msec (0x0018) Max connection interval: 50.00 msec (0x0028) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Min connection length: 0.000 msec (0x0000) Max connection length: 0.000 msec (0x0000) > HCI Event: Command Status (0x0f) plen 4 LE Extended Create Connection (0x08|0x0043) ncmd 1 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 31 LE Enhanced Connection Complete (0x0a) Status: Success (0x00) Handle: 42 Role: Central (0x00) Peer address type: Public (0x00) Peer address: 00:AA:01:01:00:00 (Intel Corporation) Local resolvable private address: 60:0C:C5:B9:10:5D (Resolvable) Peer resolvable private address: 00:00:00:00:00:00 (Non-Resolvable) Connection interval: 50.00 msec (0x0028) Connection latency: 0 (0x0000) Supervision timeout: 420 msec (0x002a) Central clock accuracy: 0x00
* emulator: Add initial support for MSFT vendor commandsLuiz Augusto von Dentz2021-10-211-24/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the initial support for MSFT vendor commands and enable them when in btvirt: < HCI Command: Microsoft Ex.. (0x3f|0x001e) plen 1 Read Supported Features (0x00) > HCI Event: Command Complete (0x0e) plen 14 Microsoft Extension (0x3f|0x001e) ncmd 1 Read Supported Features (0x00) Status: Success (0x00) Features: 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 RSSI Monitoring feature for BR/EDR RSSI Monitoring feature for LE connections RSSI Monitoring of LE advertisements Advertising Monitoring of LE advertisements Verifying the validity of P-192 and P-256 keys Continuous Advertising Monitoring Event prefix length: 0 Event prefix: < HCI Command: Microsoft Ex.. (0x3f|0x001e) plen 2 LE Set Advertisement Filter Enable (0x05) Enable: All filter conditions (0x01) > HCI Event: Command Complete (0x0e) plen 5 Microsoft Extension (0x3f|0x001e) ncmd 1 LE Set Advertisement Filter Enable (0x05) Status: Success (0x00)
* btdev: Use Linux Foundation as manufacturerLuiz Augusto von Dentz2021-10-211-1/+1
| | | | | | This makes the emulator use Linux Foundation manufacturer id which shall be simpler to distinguish emulator instances since it is unlikely there will be other vendors using it.
* vhci: Add functions to interface with debugfsLuiz Augusto von Dentz2021-10-181-2/+21
| | | | This adds functions that can be used to set debugfs options.
* hciemu: Use vhci_open to instanciate a vhci btdevLuiz Augusto von Dentz2021-10-181-1/+7
| | | | | This makes use of vhci_open to isntanciate the vhci btdev since that has proper support for reading the index assigned to it.
* emulator: Inclusive language changesArchie Pusaka2021-09-211-77/+77
| | | | | | | | BT core spec 5.3 promotes the usage of inclusive languages. This CL replaces some terms with the more appropriate counterparts, such as "central", "peripheral", and "accept list". Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* monitor: Inclusive language changesArchie Pusaka2021-09-211-29/+29
| | | | | | | | BT core spec 5.3 promotes the usage of inclusive languages. This CL replaces some terms with the more appropriate counterparts, such as "central", "peripheral", "link key", and "accept list" Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* btdev: Fix removing advertising set if it was terminatedLuiz Augusto von Dentz2021-08-191-1/+1
| | | | | Consider the advertising set disabled but don't remove it as the host may still reuse it.
* btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERMLuiz Augusto von Dentz2021-08-191-6/+8
| | | | | | BT_HCI_EVT_LE_ADV_SET_TERM shall come after BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE otherwise the host doesn't know the connection handle.
* btdev: Fix sending terminate advertising event to the wrong deviceLuiz Augusto von Dentz2021-08-191-1/+1
| | | | | The device where the event should be sent is the same that had created not the connection one.
* emulator: Add support enhanced SCO connectionKiran K2021-08-171-1/+57
| | | | | Add support for enhanced_setup_synchronous_connection command in btdev
* btdev: Add proper handling for own_address_type 0x03Luiz Augusto von Dentz2021-08-061-8/+78
| | | | | | | When own_address_type is set to 0x03 the host expects the controller to generate RPAs using the stored IRK from the resolving list and in addition to that set the generated RPA as Local RPA in LE Enhanced Connection Complete.
* btdev: Fix not checking conditions for LE Set Random AddressLuiz Augusto von Dentz2021-07-191-0/+13
| | | | | | | | | | | | | The spec says LE Set Random Address cannot be used when scan is enabled or with legacy advertising: BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E page 2480 'If the Host issues this command when any of advertising (created using legacy advertising commands), scanning, or initiating are enabled, the Controller shall return the error code Command Disallowed (0x0C).'
* btdev: Add proper checks for own_addr_type for LE scan/advLuiz Augusto von Dentz2021-07-191-22/+79
| | | | | | | | | | | | | | | | | | | | | own_addr_type 0x01 and 0x03 shall check that a random address has properly been set: BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E page 2496: 'If LE_Scan_Enable is set to 0x01, the scanning parameters' Own_Address_Type parameter is set to 0x01 or 0x03, and the random ddress for the device has not been initialized, the Controller shall return the error code Invalid HCI Command Parameters (0x12).' BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E page 2614: 'If Enable is set to 0x01, the scanning parameters' Own_Address_Type parameter is set to 0x01 or 0x03, and the random address for the device has not been initialized, the Controller shall return the error code Invalid HCI Command Parameters (0x12).'
* emulator/btdev: Add support HCI_READ_CLOCK commandTedd Ho-Jeong An2021-07-161-0/+18
| | | | This patch adds support HCI_READ_CLOCK command in btdev.
* btdev: Add proper checks for own_addr_type for extended advertisingLuiz Augusto von Dentz2021-07-141-0/+44
| | | | | | | | | | | | | | | | | | | | | | | own_addr_type 0x01 and 0x03 shall check that a random address has properly been set and in case of 0x03 the resolving list actually contains the irk of the identity address: BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E page 2596 'If the advertising set's Own_Address_Type parameter is set to 0x01 and the random address for the advertising set has not been initialized, the Controller shall return the error code Invalid HCI Command Parameters (0x12).' BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E page 2597 'If the advertising set's Own_Address_Type parameter is set to 0x03, the controller's resolving list did not contain a matching entry, and the random address for the advertising set has not been initialized, the Controller shall return the error code Invalid HCI Command Parameters (0x12).'
* emulator/btdev: clean up the queue before closing the testTedd Ho-Jeong An2021-07-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch clean up the queue for connection before closing the test to prevent the potential memory leak. ==50== 32 bytes in 1 blocks are definitely lost in loss record 18 of 32 ==50== at 0x483A809: malloc (vg_replace_malloc.c:307) ==50== by 0x14A37E: btd_malloc (util.c:33) ==50== by 0x149D9D: queue_new (queue.c:47) ==50== by 0x13B3C0: btdev_create (btdev.c:6042) ==50== by 0x13178E: create_vhci (hciemu.c:229) ==50== by 0x13178E: hciemu_new_num (hciemu.c:403) ==50== by 0x130E2C: read_index_list_callback (mgmt-tester.c:357) ==50== by 0x14AD91: request_complete (mgmt.c:264) ==50== by 0x14BD34: can_read_data (mgmt.c:356) ==50== by 0x14E794: watch_callback (io-glib.c:157) ==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== ==50== 32 bytes in 1 blocks are definitely lost in loss record 19 of 32 ==50== at 0x483A809: malloc (vg_replace_malloc.c:307) ==50== by 0x14A37E: btd_malloc (util.c:33) ==50== by 0x149D9D: queue_new (queue.c:47) ==50== by 0x13B3C0: btdev_create (btdev.c:6042) ==50== by 0x1318F7: hciemu_client_new (hciemu.c:332) ==50== by 0x1318F7: hciemu_new_num (hciemu.c:412) ==50== by 0x130E2C: read_index_list_callback (mgmt-tester.c:357) ==50== by 0x14AD91: request_complete (mgmt.c:264) ==50== by 0x14BD34: can_read_data (mgmt.c:356) ==50== by 0x14E794: watch_callback (io-glib.c:157) ==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6) ==50== by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
* emulator/btdev: Add support HCI LE Adv Set Terminated eventLuiz Augusto von Dentz2021-06-231-3/+61
| | | | | This patch adds support the HCI_LE_Advertising_Set_Terminated event in btdev.
* emulator/btdev: Add support multiple instance of extended advertisingTedd Ho-Jeong An2021-06-231-96/+323
| | | | This patch adds support multiple instance of extended advertising.
* btdev: Check advertising/scanning states when changing Resolving ListLuiz Augusto von Dentz2021-06-091-0/+40
| | | | | | | | | Resolving List cannot be changed when advertising/scanning: • Advertising (other than periodic advertising) is enabled, • Scanning is enabled, or • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or HCI_LE_Periodic_Advertising_Create_Sync command is outstanding.