Commit Graph

27982 Commits

Author SHA1 Message Date
Prathibha Madugonde
385f0f357d advertising: Fix for broadcaster role
src/advertising.c
Include check for broadcast mode:
AD flags shall never be set for broadcast

Test steps:
From DUT, bluetoothctl go to menu advertise
advertise.secondary 1M/2M
advertise.name on
advertise broadcast
2024-11-20 15:57:53 -05:00
Iulia Tanasescu
e59a915db9 bap: Remove PA idle timer logic
This removes BAP support for long-lived PA sync (added for Scan Delegator
support), since it is now handled inside the BASS plugin. This also
removes the PA idle timer logic, since PA/BIG sync requests are now
ordered inside the kernel.
2024-11-20 10:13:14 -05:00
Iulia Tanasescu
e618932b96 bap: Remove API to probe device from BASS
This removes the BAP API to probe broadcasters from BASS, since BASS is
now directly adding the Broadcast Audio Announcement Service UUID to the
broadcaster device, and it will internally handle the probe.
2024-11-20 10:10:28 -05:00
Iulia Tanasescu
ac56526b7e bass: Rework Scan Delegator to handle BAP streams
This updates the Scan Delegator implementation to be handled internally in
BASS: The BASS Server is responsible to handle Write Commands for the Add
Source operation by creating long-lived PA sync, parsing the BASE,
creating and configuring BAP streams, as well as enabling them.
2024-11-20 10:07:58 -05:00
Iulia Tanasescu
3babeefa17 bap: Make default PA sync QoS public
This make the default BAP QoS parameters for PA Create Sync public,
to be available to other plugins that might need to listen for
Broadcasters (like BASS).
2024-11-20 10:05:04 -05:00
Iulia Tanasescu
66a83fde5c bap: Rework BASE parsing
This replaces the internal parse_base with bt_bap_parse_base from
shared/bap. A bis callback is added to handle parsed streams.

The Broadcast Assistant implementation in the BASS plugin is also
updated to use bap qos instead of iso qos, since the BISes are
now parsed along with bap qos structure.
2024-11-20 10:02:15 -05:00
Iulia Tanasescu
8054693b0c bap: Add helpers to convert iso_qos to/from bap_qos
This adds public BAP helpers to convert iso_qos to bap_qos and reversed.
This is needed for the BASS plugin to handle the Scan Delegator (BASS
Server) role internally (to create/handle BAP streams when receiving the
Add Source command from a Broadcast Assistant).
2024-11-20 09:59:26 -05:00
Iulia Tanasescu
a0aee49df1 shared/bap: Add helper to parse BASE
This adds a shared/bap helper to parse BASE. Any plugin that wishes to
parse a BASE structure can call this helper and provide a callback to
process each BIS.
2024-11-20 09:56:28 -05:00
Rudi Heitbaum
6f3111eb68 shared/gatt-helpers: fix -std=c23 build failure
gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result `bluez` fails the build as:

    src/shared/gatt-helpers.c:1136:24: error: incompatible types when returning type '_Bool' but 'struct bt_gatt_request *' was expected
     1136 |                 return false;
          |                        ^~~~~
    src/shared/gatt-helpers.c:1250:24: error: incompatible types when returning type '_Bool' but 'struct bt_gatt_request *' was expected
     1250 |                 return false;
          |                        ^~~~~
    src/shared/gatt-helpers.c:1478:24: error: incompatible types when returning type '_Bool' but 'struct bt_gatt_request *' was expected
     1478 |                 return false;
          |                        ^~~~~
2024-11-20 09:50:50 -05:00
Rudi Heitbaum
4d60826865 shared/shell: fix -std=c23 build failure
gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result `bluez` fails the build as:

    src/shared/shell.c:365:24: error: incompatible types when returning type '_Bool' but 'struct input *' was expected
      365 |                 return false;
          |                        ^~~~~
2024-11-20 09:47:42 -05:00
Rudi Heitbaum
da5b5b0ecb shared/ad: fix -std=c23 build failure
gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result `bluez` fails the build as:

    src/shared/ad.c:1090:24: error: incompatible types when returning type '_Bool' but 'const char *' was expected
     1090 |                 return false;
          |                        ^~~~~
2024-11-20 09:45:23 -05:00
Luiz Augusto von Dentz
5c65356cae shared/att: Fix failing to set security level
bt_att_chan_set_security attempts to set BT_SECURITY without first
checking what is the current security level which may cause errors
since the kernel does actually return -EINVAL when the security doesn't
change.
2024-11-19 11:36:46 -05:00
Luiz Augusto von Dentz
da0253959e org.bluez.GattCharacteristic: Update documentation of AcquireNotify
This updates the documentation of AcquireNotify adding that indicate
flag also allows the usage of AcquireNotify.
2024-11-18 10:03:55 -05:00
Benedek Kupper
f863d0116d gatt-client: allow AcquireNotify when characteristic has indicate flag
StartNotify / StopNotify already correctly allows usage when the
characteristic indicate is present (simplify this check though),
apply the same to AcquireNotify.

Fixes: https://github.com/bluez/bluez/issues/1022
2024-11-18 10:03:33 -05:00
Luiz Augusto von Dentz
95e89cd2e4 client/mgmt: Add hci-cmd command
This adds hci-cmd command which uses the MGMT_OP_HCI_CMD_SYNC:

bluetoothctl> mgmt.hci-send 0xffff
bluetoothctl[44]: @ MGMT Com..nd (0x005b) plen 6  {0x0002}
        Opcode: 0xffff
        Event: 0x00
        Timeout: 0 seconds
        Parameters Length: 0
        Parameters[0]:
< HCI Command: Vendor (0x3f|0x03ff) plen 0
> HCI Event: Command Status (0x0f) plen 4
      Vendor (0x3f|0x03ff) ncmd 1
        Status: Unknown HCI Command (0x01)
@ MGMT Event: Command Status (0x0002) plen 3    {0x0002}
      Send HCI command and wait for event (0x005b)
        Status: Failed (0x03)
2024-11-14 13:46:31 -05:00
Luiz Augusto von Dentz
0580dc4bb6 lib/mgmt: Add definitions of MGMT_OP_HCI_CMD_SYNC
This adds the definition of MGMT_OP_HCI_CMD_SYNC and its packet
structure.
2024-11-14 13:46:30 -05:00
Luiz Augusto von Dentz
d395c6b1c7 monitor: Add decoding of MGMT_OP_HCI_CMD_SYNC
@ MGMT Com..nd (0x005b) plen 6  {0x0002}
        Opcode: 0xffff
        Event: 0x00
        Timeout: 0 seconds
        Parameters Length: 0
        Parameters[0]:
@ MGMT Event: Command Status (0x0002) plen 3    {0x0002}
        Send HCI command and wait for event (0x005b)
          Status: Failed (0x03)
2024-11-14 13:46:29 -05:00
Luiz Augusto von Dentz
2e981e1a94 monitor: Fix opcode for MGMT_OP_MESH_SEND_CANCEL
MGMT_OP_MESH_SEND_CANCEL opcode is 0x005A not 0x0056.
2024-11-14 13:46:29 -05:00
Luiz Augusto von Dentz
fe1296cb11 mgmt-api: Add Send HCI command and wait for event Command
This adds Send HCI command and wait for event Command initial
documentation.
2024-11-14 13:46:27 -05:00
Marcus Prebble
63f1ab560c rfkill: Do not log errors for missing device path
In the case of our products, we lack a physical RFKILL switch and do
not have the rfkill module enabled in the kernel which resulted in an
error message each time bluetoothd was started.

This commit looks at the errno code after failing to open the RFKILL
device and only logs an error if it is something other than ENOENT
(No such file or directory).

Fixes: https://github.com/bluez/bluez/issues/792
2024-11-13 11:21:24 -05:00
Amisha Jain
f0302d90a1 obex: Update the FTP version to 1.3 in SDP record
This change is required in below PTS testcase:
1. FTP/SR/SGSIT/ATTR/BV-02-C
Attribute GSIT - Bluetooth Profile Descriptor List

Current FTP version 1.2 is being deprecated and withdrawn
from BT Sig, so it is mandatory to update the version to 1.3.

No additional changes are needed for supporting the new version.
2024-11-11 10:09:15 -05:00
Amisha Jain
b22bbf873f obex: Fix the PBAP GET request in PTS testing
This change is required for passing below PTS testcases:
1. PBAP/PSE/PBD/BV-02-C
2. PBAP/PSE/PBD/BV-03-C
3. PBAP/PSE/PBD/BI-01-C
4. PBAP/PSE/PBD/BV-13-C
5. PBAP/PSE/PBD/BV-14-C
6. PBAP/PSE/PBD/BV-17-C

PTS sends all the GET phonebook requests without extra params.
Therefore, the PBAP server is rejecting the requests with a
'Bad Request' response.
So append 'maxlistcount' as default param in GET request to
avoid testcase failure.
2024-11-11 10:09:14 -05:00
Amisha Jain
486aeafd87 obex: Check for supported features bit value for legacy server
This fix is required for below PTS testcase:

1. PBAP/PCE/SSM/BV-10-C
Description - Verify that the PCE does not share its
PbapSupportedFeatures bits with a legacy server.

Incase of legacy server, check for 'supported features bit'
uint_32_t value instead of directly checking the pointer
holding the attribute.
As pointer 'data' won't be null as PbapSupportedFeatures
attribute is present in SDP record but it's value is zero.
2024-11-11 10:09:13 -05:00
Amisha Jain
639fb80032 obex: Add Newmissedcalls tag in PBAP GET response
This fix is required for passing below PTS testcases:

1. PBAP/PSE/PBD/BV-05-C
2. PBAP/PSE/PBD/BV-17-C
3. PBAP/PSE/PBB/BV-11-C

Even if the new missed calls value is zero, send it in GET response.
As per the PBAP spec, it is mandatory to include Newmissedcalls
tag in response incase of object name is 'mch.vcf' or 'cch.vcf'.
It will be better to include it in all GET response.
2024-11-11 10:09:13 -05:00
Pauli Virtanen
774ad9fdd9 transport: fix AVRCP volume in reconfigured transports
We no longer reconnect AVRCP session on AVDTP transport reconfiguration.
This breaks AVRCP volume after reconfiguration, since there's no volume
update event incoming.

Fix by keeping track of the latest volume in btd_device volume.  It was
introduced to track volume changes that arrive when there are no
transports/players, but we should track all volume changes otherwise the
value can be out of date when we want to use it.

Fixes: 469a75ae18 ("sink: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle")
2024-11-11 10:09:12 -05:00
Luiz Augusto von Dentz
de1b3a5ac3 avrcp: Fix not marking AVRCP_EVENT_VOLUME_CHANGED as supported
If avrcp_volume_supported return true then AVRCP_EVENT_VOLUME_CHANGED
shall be marked as supported.

Fixes: https://github.com/bluez/bluez/issues/1007
2024-11-08 13:15:10 -05:00
Luiz Augusto von Dentz
34cfee7ed0 test-runner: Fix using removed options
-no-acpi and -no-hpet are not longer available on most recent release
(e.g. fc41).
2024-11-08 13:13:00 -05:00
Luiz Augusto von Dentz
aa118e965b a2dp: Don't wait to reconfigure
If the stream has been confirmed to be closed it should be safe to
attempt to send SetConfiguration without having to wait for a period
since the remote end can assume no new stream would be created it may
end up disconnecting the session.
2024-11-06 10:43:29 -05:00
Luiz Augusto von Dentz
2aade568ce source: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle
If the stream transition to AVDTP_STATE_IDLE it means the stream has
been disconnected, not the session, therefore
btd_service_disconnecting_complete shall not be called otherwise it may
trigger the policy plugin to disconnect AVRCP in cases like codec
reconfiguration.
2024-11-06 10:41:48 -05:00
Luiz Augusto von Dentz
469a75ae18 sink: Fix transitioning to BTD_SERVICE_STATE_DISCONNECTED on idle
If the stream transition to AVDTP_STATE_IDLE it means the stream has
been disconnected, not the session, therefore
btd_service_disconnecting_complete shall not be called otherwise it may
trigger the policy plugin to disconnect AVRCP in cases like codec
reconfiguration.

Fixes: https://github.com/bluez/bluez/issues/1003
2024-11-06 10:22:21 -05:00
Luiz Augusto von Dentz
0025cdd0c1 lib: Add IPC bus type
Zephyr(1) has been using the same bus defines as Linux so tools likes of
btmon, etc, are able to decode the bus under HCI, so this attempts to
synchronize the definitions by adding the missing bus type IPC(11) and its
decoding string.

[1] https://github.com/zephyrproject-rtos/zephyr/pull/80808
2024-11-06 09:45:40 -05:00
Damodar Reddy GangiReddy
002ee180b1 obexd: Add system bus support for obexd
Currently obexd uses session bus.
Distros  where session bus is not supported and still obex profiles
are required in that case use system bus instead of session bus
which can be configured at run time.

An Command line option has been added to achieve it.
{ "system-bus", 's', 0, G_OPTION_ARG_NONE, &option_system_bus,
"Use System bus "}

we can use option obexd -s to use system bus.
2024-11-05 11:04:17 -05:00
Iulia Tanasescu
bae6c32940 iso-tester: Add test for Broadcast Receiver Defer sync to 2 BIGs
This adds a new Broadcast Receiver test, for a Broadcast Sink
synchronizing to 2 Broadcasters, using defer setup.

ISO Broadcaster Receiver2 Defer - Success
2024-11-05 09:09:25 -05:00
Iulia Tanasescu
b87c3767f5 iso-tester: Add test for Broadcast Receiver sync to 2 BIGs
This adds a new Broadcast Receiver test, for a Broadcast Sink
synchronizing to 2 Broadcasters.

ISO Broadcaster Receiver2 - Success
2024-11-05 09:09:24 -05:00
Iulia Tanasescu
1a55bac559 iso-tester: Fix memory leaks in iso_accept_cb
This fixes memory leaks that appear in iso_accept_cb because a new io
channel is allocated but never unreferenced at the end of the test.

=================================================================
==20460==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7dcddc8fbb37 in malloc ../../../../src/libsanitizer/asan/
                                asan_malloc_linux.cpp:69
    #1 0x7dcddc719af9 in g_malloc (/lib/x86_64-linux-gnu/
                                   libglib-2.0.so.0+0x62af9)
    #2 0x7dcddc7722bd in g_io_channel_unix_new
                         (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0xbb2bd
    #3 0x5d3fdfe28262 in iso_accept_cb tools/iso-tester.c:3004

Indirect leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x7dcddc8fbb37 in malloc ../../../../src/libsanitizer/asan/
                                asan_malloc_linux.cpp:69
    #1 0x7dcddc719af9 in g_malloc (/lib/x86_64-linux-gnu/
                                   libglib-2.0.so.0+0x62af9)
    #2 0x7dcddc70016f in g_io_channel_init
                         (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4916f)
    #3 0x7dcddc7722c8 in g_io_channel_unix_new
                         (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0xbb2c8)
    #4 0x5d3fdfe28262 in iso_accept_cb tools/iso-tester.c:3004

SUMMARY: AddressSanitizer: 126 byte(s) leaked in 2 allocation(s).
2024-11-05 09:09:23 -05:00
Iulia Tanasescu
fb09ce5cfd btdev: Add support for syncing to multiple BIGs
This adds support for synchronizing to multiple BIGs.
2024-11-05 09:09:23 -05:00
Iulia Tanasescu
30951c983d btdev: Add support for syncing to multiple PA trains
This adds support for synchronizing to multiple PA trains.
2024-11-05 09:09:22 -05:00
Guðni Már Gilbert
9d69dba21f gdbus: define MAX_INPUT for musl
This is the same solution as was done in src/shared/util.c
2024-11-04 21:34:30 -05:00
Luiz Augusto von Dentz
7322ec38fb adapter: Fix up address type for all keys
66a8c522b64 ("adapter: Fix up address type when loading keys") didn't
fix all instances of wrong address type being loaded, so peripheral LTK
and IRK were still left with possible invalid types.
2024-11-04 15:31:27 -05:00
Pauli Virtanen
664a5d3785 a2dp: don't change setup sep when it is reconfiguring
If a2dp_resume/a2dp_suspend are called while setup is being
reconfigured, they make the reconfiguration use wrong SEP.  This occurs
if transport Acquire/Release are called while reconfiguration is waiting
for CLOSE_RSP.

Fix by failing a2dp_resume/suspend early without changing the setup, if
it is reconfiguring.

Such resume/suspend calls would in any case fail, because
avdtp_close(stream) has been done, so avdtp_suspend/resume would return
error.
2024-11-04 12:54:31 -05:00
Pauli Virtanen
a14d59725e transport: don't disconnect A2DP if canceling Acquire() with Release()
User can cancel transport acquire by calling Release() while Acquire()
is in progress. This calls a2dp_cancel() which sends AVDTP_ABORT_CMD,
forcing AVDTP state transition to IDLE, and A2DP profile disconnects.

However, Release()/Acquire() should only result to transitions between
STREAMING/OPEN.  The expected behavior is that either these calls return
error, or they block until the target state is reached.

Fix by: Release() during pending Acquire() first sends error reply to
the Acquire. Then it waits for START to complete, then sends SUSPEND,
and after that completes, then it replies.

This also fixes SetConfiguration() after canceled Acquire(), which
previously did not work due to AVDTP disconnect. Now it does
START/SUSPEND -> CLOSE -> reconfigure.
2024-11-04 12:54:30 -05:00
Marcel Holtmann
0845b8f6ef Release 5.79 2024-11-01 20:18:33 +01:00
Marcel Holtmann
665af5b7d1 build: Add tools/mpris-proxy.service to ignore list 2024-11-01 20:18:05 +01:00
Yun-Hao Chung
5573661fc2 textfile: Fix possible bad memory access in find_key
If the searched key is a prefix of the first key in the textfile,
the code will assume it's not the first line which is wrong.

The issue can be reproduced by a fuzzer. More context can be found in
https://issues.oss-fuzz.com/issues/42515619

To reproduce the issue, please kindly follow the instructions in
https://google.github.io/oss-fuzz/advanced-topics/reproducing/

Stack trace:
    #0 0x55e1c450e7ce in find_key /src/bluez/src/textfile.c:133:9
    #1 0x55e1c450e7ce in write_key /src/bluez/src/textfile.c:244:8
    #2 0x55e1c450dc33 in LLVMFuzzerTestOneInput /src/fuzz_textfile.c:61:3
    (...trace in fuzzer)
2024-11-01 10:39:35 -04:00
Luiz Augusto von Dentz
9e0bc3e63c build: Fix missing include
This fixes the following build error:

profiles/input/manager.c:102:4: error: implicit declaration of function ‘free’ [-Werror=implicit-function-declaration]
  102 |    free(uhid_enabled);
      |    ^~~~
2024-10-30 09:33:59 -04:00
Luiz Augusto von Dentz
e062a44edd main: Add call to g_dbus_set_debug
This adds a call to g_dbus_set_debug which enabled debugging of D-Bus
messages when dynamic debug is enabled for main.c:

bluetoothd[3672799]: [:1.38799:method_call] > org.bluez.Device1.Connect [#761]
bluetoothd[3672799]: [:1.38799:error] < org.bluez.Error.Failed [#761]
2024-10-30 09:28:48 -04:00
Luiz Augusto von Dentz
cbd6859612 gdbus: Add g_dbus_set_debug
This adds g_dbus_set_debug which can be used to set a debug function to
be invoked on incoming/outgoing message.
2024-10-30 09:28:47 -04:00
Arkadiusz Bokowy
e2e439156a org.bluez.MediaTransport: Document policy for setting transport delay 2024-10-29 17:35:16 -04:00
Arkadiusz Bokowy
6847b38ea3 transport: Allow to set A2DP transport delay property
In order to properly synchronize audio/video playback it is required
to report audio delay to the A2DP source. This commit allows connected
media application to update the Delay property of the A2DP transport
which will inform remote source about the playback delay.

In case when the transport is not acquired, everyone is allowed to set
the delay. However, when the transport is acquired only the owner can
modify the delay. This restriction is here to prevent interference
caused by 3rd party actors.

The functionality was tested by streaming audio between two hosts
running BlueZ Bluetooth stack.
2024-10-29 17:34:55 -04:00
Arkadiusz Bokowy
0cd34b1815 gdbus: Add g_dbus_pending_property_get_sender
This function allows to retrieve D-Bus message sender name in a property
setter callback. Message sender name might be required to limit write
access to authorized clients only.
2024-10-29 17:32:03 -04:00