Commit Graph

26369 Commits

Author SHA1 Message Date
Marcel Holtmann
41f8c466f3 Release 5.64 2022-03-16 16:04:29 +01:00
Luiz Augusto von Dentz
411d63ec33 gatt-db: Fix gatt_db_attribute_notify
gatt_db_attribute_notify was only accepting passing the Characteristic
Declaration instead of accepting its value as well,
gatt_db_service_foreach_desc also have similar limitation so both have
been updated to allow working with both value and declaration.
2022-03-14 14:47:02 -07:00
Luiz Augusto von Dentz
8fb8f9e73f gatt: Print error if gatt_db_attribut_notify fails
This prints an error if gatt_db_attribut_notify fails.
2022-03-14 14:46:21 -07:00
Luiz Augusto von Dentz
42e9937158 test-runner: Update help information
This updates usage so it list -l/--emulator properly:

test-runner - Automated test execution utility
Usage:
	test-runner [options] [--] <command> [args]
Options:
	-a, --auto             Find tests and run them
	-d, --dbus             Start D-Bus daemon
	-m, --monitor          Start btmon
	-l, --emulator         Start btvirt
	-u, --unix [path]      Provide serial device
	-q, --qemu <path>      QEMU binary
	-k, --kernel <image>   Kernel image (bzImage)
	-h, --help             Show help options
2022-03-08 18:07:06 -08:00
Luiz Augusto von Dentz
55888bfd62 test-runner: Fix -l/--emulator
This fixes -l/--emulator not able to start depending on what parameters
are given as it was not setting the directory properly.
2022-03-08 18:00:49 -08:00
Luiz Augusto von Dentz
8e1892cc92 btdev: Fix response to LE Set Extended Advertising Parameters
The response should both the status and TX Power regardless if the
command succeeds or not.
2022-03-08 17:58:40 -08:00
Yun-Hao Chung
b69b5736c8 audio: Fix crash in a2dp_discover
Sample stack trace:
0x0000567c394e4c6b (bluetoothd - a2dp.c: 270) setup_cb_free
0x0000567c394e4a94 (bluetoothd - a2dp.c: 2884) a2dp_discover
0x0000567c394e3c03 (bluetoothd - sink.c: 275) sink_setup_stream
0x0000567c394e3d4f (bluetoothd - sink.c: 299) sink_connect
0x0000567c39535183 (bluetoothd - service.c: 294) btd_service_connect
0x0000567c39539f68 (bluetoothd - device.c: 2006) connect_next
0x0000567c3954086d (bluetoothd - device.c: 2060) service_state_changed
0x0000567c39534efb (bluetoothd - service.c: 111) change_state
0x0000567c3953559c (bluetoothd - service.c: 0)
btd_service_connecting_complete
0x0000567c39534a5c (bluetoothd - profile.c: 1641) record_cb
0x0000567c395197cd (bluetoothd - sdp-client.c: 298) connect_watch
0x00007b14bc8034f6 (libglib-2.0.so.0 - gmain.c: 3337)
g_main_context_dispatch
0x00007b14bc803801 (libglib-2.0.so.0 - gmain.c: 4131)
g_main_context_iterate
0x00007b14bc803a7d (libglib-2.0.so.0 - gmain.c: 4329) g_main_loop_run
0x0000567c39566af1 (bluetoothd - mainloop-glib.c: 79) mainloop_run
0x0000567c39566ddb (bluetoothd - mainloop-notify.c: 201)
mainloop_run_with_signal
0x0000567c3954bf4c (bluetoothd - main.c: 1222) main
0x00007b14bc579797 (libc.so.6 - libc-start.c: 332) __libc_start_main
0x0000567c394df449 (bluetoothd) _start
0x00007ffd70145737

This could be triggered from a2dp_discover -> avdtp_discover ->
send_request -> send_req -> l2cap_connect (return error) ->
avdtp_set_state (to disconnect state)-> channel_remove -> channel_free
-> finalize_setup_errno (discover cb is freed) -> error handling all
the way back to a2dp_discover -> a2dp_discover (discover cb is freed
again, crashed!).

The fix is to attach cb with setup after avdtp_discover success.

Suggested-by: luiz.dentz@gmail.com
Reviewed-by: Archie Pusaka <apusaka@chromium.org>
2022-03-08 11:22:50 -08:00
Luiz Augusto von Dentz
554fcb7d89 bthost: Add support for Create BIG
This adds bthost_create_big
2022-03-07 17:21:57 -08:00
Luiz Augusto von Dentz
f040ba43d1 bthost: Add support for Periodic Advertising
This adds bthost_set_pa_params and bthost_set_pa_enable.
2022-03-07 17:21:57 -08:00
Luiz Augusto von Dentz
a473a5a47c bthost: Add support for BT_H4_ISO_PKT
This adds sending and receiving BT_H4_ISO_PKT packets.
2022-03-07 17:21:56 -08:00
Luiz Augusto von Dentz
9cbc6fc1b2 btdev: Implements BT_HCI_CMD_LE_BIG_TERM_SYNC
This sends BT_HCI_EVT_DISCONNECT_COMPLETE when handling
BT_HCI_CMD_LE_BIG_TERM_SYNC.
2022-03-07 17:18:39 -08:00
Luiz Augusto von Dentz
40bacfff0c btdev: Implements BT_HCI_CMD_LE_BIG_CREATE_SYNC
This sends BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED when handling
BT_HCI_CMD_LE_BIG_CREATE_SYNC.
2022-03-07 17:18:38 -08:00
Luiz Augusto von Dentz
9d7f4405df monitor: Rename Periodic Advertising terms to PA/pa
This renames the use of Periodic Advertising in the API to just PA.
2022-03-07 17:18:38 -08:00
Luiz Augusto von Dentz
306bc0ca76 btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote start pa
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.
2022-03-07 17:18:37 -08:00
Luiz Augusto von Dentz
d07185ff4e btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED when scan is initiated
This sends BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if scan is initiated
while BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC is pending.
2022-03-07 17:18:37 -08:00
Luiz Augusto von Dentz
942a73daca btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC
This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC.
2022-03-07 17:18:37 -08:00
Luiz Augusto von Dentz
3250d7f938 btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL
This adds implementation of
BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL generating
BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if necessary.
2022-03-07 17:18:37 -08:00
Luiz Augusto von Dentz
ea501af91c btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC
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.
2022-03-07 17:18:36 -08:00
Luiz Augusto von Dentz
b5ab5eee3a monitor: Fix Create BIG PDU
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.
2022-03-07 17:18:36 -08:00
ihsinme
2f4368de81 device: Fix writing out of bounds array
%32s expect a buffer of at least 33 bytes since it is a string it needs
to be NULL terminated.
2022-03-07 16:14:23 -08:00
Andreas Kemnade
5e9342ee34 gatt: sanitize input at profile registration
Check whether type of UUIDs property of GattProfile1 object
is correct.
2022-03-07 16:12:35 -08:00
Luiz Augusto von Dentz
18af5f4faf client: Add support for scan <le/bredr>
This adds support for entering the transport directly as an scan
argument rather than having to first set it scan.transport.
2022-03-02 16:30:11 -08:00
Luiz Augusto von Dentz
b9f27b814d test-runner: Fix parsing of command line
Instead of parsing the command line, which can contain a shell script,
run using /bin/sh so it allows more complex command line to be tested:

sudo tools/test-runner -l -d -k <pathto/bzImage> --
'client/bluetoothctl power on && sleep 2 && client/bluetoothctl power
off'
2022-03-01 15:26:14 -08:00
Luiz Augusto von Dentz
ab943bf833 shared/shell: Introduce bt_shell_exec
This introduces bt_shell_exec which can be used to inject commands into
a bt_shell without using stdin/user input.
2022-02-28 15:58:29 -08:00
Luiz Augusto von Dentz
850003734a test-runner: Add option to start emulator
This adds an option (-l/--emulator) to start btvirt before processing
the command which is convenient to runs tools like bluetoothctl:

  sudo tools/test-runner -l -d -k <pathto/bzImage> --
  client/bluetoothctl power on
2022-02-28 15:26:02 -08:00
Luiz Augusto von Dentz
d91fe6994f hog-lib: Fix not waiting for UHID_START
With use of UHID_CREATE2 the code needs to wait for UHID_START in order
to know if the reports are numbered or not.

Fixes: https://github.com/bluez/bluez/issues/298
2022-02-25 15:35:04 -08:00
Luiz Augusto von Dentz
2ae3ce9e6d btproxy: Attempt to bind the next index
If no specific index is given attempt to bind the next index if the
current one is already in use.
2022-02-25 15:35:03 -08:00
Nicolas Fella
bf09e1f048 neard: Fix reading State message
dbus_message_iter_recurse only makese sense for container types, this is a string.

Fixes: https://github.com/bluez/bluez/issues/300
2022-02-24 13:57:59 -08:00
Fabrice Fontaine
58dec00edc src/shared/util.h: include sys/types.h
Include sys/types.h to avoid the following build failure on musl raised
since commit fb57ad9b9d:

In file included from src/shared/queue.c:15:
./src/shared/util.h:106:1: error: unknown type name 'ssize_t';
did you mean 'size_t'?
  106 | ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags);
      | ^~~~~~~
      | size_t

Fixes:
 - http://autobuild.buildroot.org/results/83eaeb3863040645409f5787fdbdde79385c5257
2022-02-24 13:56:30 -08:00
Fabrice Delliaux
65302d98e1 error: Fix typo
s/suuported/supported
2022-02-24 13:55:40 -08:00
Joseph Hwang
d89af9acb7 monitor: fix division by zero about conn->tx_pkt_med
In a connection without outgoing traffic, conn->tx_num will remain 0.
In this case, conn->tx_pkt_med should be simply 0 without calculating
"conn->tx_bytes / conn->tx_num".

This was likely to happen, for example, when "btmon -w btsnoop.log"
was launched in the middle of a LE mouse connection, and a number of
incoming ACL Data RX were received as the mouse movements.  When
running "btmon -a btsnoop.log", it would encounter this error.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
2022-02-23 08:57:33 -08:00
Bastien Nocera
b086260ac6 adapter-api: Document per-client discovery sessions
The fact that each client can start its own discovery wasn't clear from
the documentation and only becomes obvious when reading the sources.
2022-02-23 08:57:23 -08:00
Luiz Augusto von Dentz
2e4627c3c9 player: Fix Track being emitted with empty metadata
This sometimes causes the Track to be schedule while some metadata are
still pending, also don't remove the Duration from track when updating
its metadata since Duration is typically updated by player status rather
than metadata.

Fixes: https://github.com/bluez/bluez/issues/291
2022-02-22 11:38:19 -08:00
Tedd Ho-Jeong An
8fe1e5e165 gobex: Fix read from pointer after free
This patch sets the pointer to null after free since the g_free(p)
doesn't set the pointer to NULL.

This is reported by the Coverity.

Fixes: 7e7d826aa1 ("gobex: Print error if data cannot be written")
2022-02-18 13:25:57 -08:00
Michael Nosthoff
51c34da9d6 Makefile.tools: remove duplicate link entry 2022-02-18 13:25:43 -08:00
Tedd Ho-Jeong An
840ca1e7f1 shared: Fix the incorrect type with bit shift
This patch fixes the following runtime error:

$ sudo ./monitor/btmon -w test.btsnoop
  Bluetooth monitor ver 5.63
  src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'
2022-02-18 13:25:31 -08:00
Luiz Augusto von Dentz
afefbb4872 main.conf: Fix parsing of mode options
This replace the use of g_key_file_get_integer, which is limited to
only decimal values, to g_key_file_get_string and then use strtol to
convert the string value to integer.

Fixes: https://github.com/bluez/bluez/issues/293
2022-02-18 13:17:00 -08:00
Luiz Augusto von Dentz
d96c2fd877 adapter: Fix allowing multiple adapters with the same address
The bdaddr of an adapter is used for its unique storage path so having
multiple adapters with the same address would likely cause problems
with its storage as they would be shared.
2022-02-16 15:16:48 -08:00
Luiz Augusto von Dentz
a1cdd683df main.conf: Introduce MaxControllers
This introduces MaxControllers which can be used to limit the number of
adapters exposed in the system.
2022-02-16 15:16:29 -08:00
Michael Nosthoff
ec8c8f22ef tools/mesh-cfgtest: include limits.h
mesh-cfgtest.c uses MAX_PATH so it should include limits.h.

fixes compilation error with musl-based toolchains.
2022-02-16 10:30:12 -08:00
Daniel Trnka
e6b7d537d7 adapter: battery provider for non-LE controllers
Enable battery provider dbus interface BatteryProviderManager1 for
non-LE controllers, so external clients like pipewire can provide
battery information for bluetooth headsets on non-LE controllers.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
2022-02-15 13:54:39 -08:00
Fabrice Fontaine
fb57ad9b9d build: Fix errors with glibc < 2.25
getrandom and sys/random.h are only available since glibc 2.25:
https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html
resulting in the following build failures since version 5.63 and
https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom:

plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory
 #include <sys/random.h>
                        ^

To fix this build failure, add util_getrandom and a fallback (borrowed
from pipewire and licensed under MIT):
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c

Fixes:
 - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
2022-02-15 13:36:35 -08:00
Yun-Hao Chung
b5ff08b267 lib: fix hci_strtolm crash
|str| can be NULL in the case of reading lm value. Calling strcasestr
could lead to a crash.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
2022-02-15 13:31:42 -08:00
Luiz Augusto von Dentz
6c9c4b7c3a rfcomm-tester: Increase amount of data from 8k to 32k
This forces the behavior where not all data can be written at once so it
is able to reproduce the from [1].

[1]https://bugzilla.kernel.org/show_bug.cgi?id=215594
2022-02-14 17:47:13 -08:00
Luiz Augusto von Dentz
7e7d826aa1 gobex: Print error if data cannot be written
This makes sure that if the data cannot be written it fails and the
error is properly printed.
2022-02-14 15:40:40 -08:00
Luiz Augusto von Dentz
47bea5418c obexctl: Add optional argument channel to connect command
This adds a third argument to connect command so a channel can be passed
to CreateSession which is useful since it possible to force a specific
RFCOMM channel.
2022-02-14 15:15:20 -08:00
Tedd Ho-Jeong An
002c0c9eda profiles: Fix the reusing gerror without re-initialization
When the GError variable is freeed with g_error_free(), it is not set to
NULL and reusing the same variable again can cause the seg_fault because
it is still pointing the old memory address which is freed.

This patch relaces the g_error_free() to g_clear_error() which frees the
variable and set it to NULL if the variable is used in the function
again.

Fixes: 4ad622d592 ("profiles/a2dp: Fix unchecked return value")
2022-02-11 14:17:27 -08:00
Tedd Ho-Jeong An
8b69a634f4 device: Fix the reusing gerror without re-initialization
When the GError variable is freeed with g_error_free(), it is not set to
NULL and reusing the same variable again can cause the seg_fault because
it is still pointing the old memory address which is freed.

This patch relaces the g_error_free() to g_clear_error() which frees the
variable and set it to NULL if the variable is used in the function
again.

Fixes: 6a154cd080 ("device: Fix unchecked return value")
2022-02-11 14:17:27 -08:00
Tedd Ho-Jeong An
b4e74f7bd0 adapter: Fix the reusing gerror without re-initialization
When the GError variable is freeed with g_error_free(), it is not set to
NULL and reusing the same variable again can cause the seg_fault because
it is still pointing the old memory address which is freed.

This patch relaces the g_error_free() to g_clear_error() which frees the
variable and set it to NULL if the variable is used in the function
again.

Fixes: 2287c517ca ("adapter: Fix unchecked return value")
Fixes: https://github.com/bluez/bluez/issues/276
2022-02-11 14:17:27 -08:00
Luiz Augusto von Dentz
24d986e72d device: Fix crash when removing device
Calling btd_adapter_remove_device from device_remove_connection can
cause a crash, so instead of removing it immediatelly this set a the
temporary timeout to 0.

Fixes: https://github.com/bluez/bluez/issues/290
2022-02-10 14:55:20 -08:00