platform/upstream/bluez.git
17 months agodevice: Fix enabling wake support without RPA Resolution
Luiz Augusto von Dentz [Thu, 12 May 2022 23:40:49 +0000 (16:40 -0700)]
device: Fix enabling wake support without RPA Resolution

If device uses RPA it shall only enable wakeup if RPA Resolution has
been enabled otherwise it cannot be programmed in the acceptlist which
can cause suspend to fail.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=215768
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data
Luiz Augusto von Dentz [Thu, 12 May 2022 00:55:14 +0000 (17:55 -0700)]
gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data

This makes gatt_db_attribute_get_char_data work with Characteristic
Value rather than only with Characteristic Declaration.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoservice: Add initiator argument to service_accept
Luiz Augusto von Dentz [Thu, 12 May 2022 00:55:15 +0000 (17:55 -0700)]
service: Add initiator argument to service_accept

This adds initiator argument to service_accept so profiles accepting
the connection can use btd_service_is_initiator to determine if the
connection was initiated locally (central) or remotely (peripheral).

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Fix pairing has failed due to the error of Already Paired (0x13)
wangyouwan [Tue, 10 May 2022 01:27:35 +0000 (09:27 +0800)]
device: Fix pairing has failed due to the error of Already Paired (0x13)

After connect the Bluetooth mouse, open two Bluetoothctl at the same time,
when remove the mouse, quickly go to power off,
try to paired the mouse again when I was power on,
found that the error 0x13 was always reported.
try to connect directly,can connect successfully.
but use the info command to query the information of the mouse
and find that the pairing status of the mouse is No.
so I try to delete the paired information in the kernel
through the "* cancel_pairing()" interface.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Fix uninitialized value usage
Ildar Kamaletdinov [Sat, 7 May 2022 17:35:05 +0000 (20:35 +0300)]
device: Fix uninitialized value usage

Definitely `dbus_bool_t b;` must be initialized before comparing it
with current value.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix handle leak in rfcomm
Ildar Kamaletdinov [Sat, 7 May 2022 17:35:04 +0000 (20:35 +0300)]
tools: Fix handle leak in rfcomm

Some branches of execution can make handle (socket) leakage.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix memory leaks in btgatt-server/client
Ildar Kamaletdinov [Sat, 7 May 2022 17:35:03 +0000 (20:35 +0300)]
tools: Fix memory leaks in btgatt-server/client

According to man buffer allocated by getline() should be freed by
the user program even if getline() failed.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix memory leak in hciconfig
Ildar Kamaletdinov [Sat, 7 May 2022 17:35:02 +0000 (20:35 +0300)]
tools: Fix memory leak in hciconfig

printf() was using function that return dynamic allocated memory as
a parameter.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoadvertising: Treat empty LocalName the same as omitting it
Luiz Augusto von Dentz [Fri, 6 May 2022 23:05:14 +0000 (16:05 -0700)]
advertising: Treat empty LocalName the same as omitting it

This treats empty LocalName ("") the same as omitting it so not name is
set in the advertising data since some D-Bus binding seems to have
problems to omit properties at runtime.

Fixes: https://github.com/bluez/bluez/issues/337
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice-api: Clarify Paired/Bonded documentation
Luiz Augusto von Dentz [Wed, 4 May 2022 23:39:30 +0000 (16:39 -0700)]
device-api: Clarify Paired/Bonded documentation

This attempt to clarify the distinction of Paired and Bonded
properties.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient: Add filter to devices and show Bonded in info
Zhengping Jiang [Wed, 4 May 2022 21:09:48 +0000 (14:09 -0700)]
client: Add filter to devices and show Bonded in info

Use the property name as optional filters to the command "devices" and
show the "Bonded" property for the command "info".

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Add "Bonded" flag to dbus property
Zhengping Jiang [Wed, 4 May 2022 21:09:46 +0000 (14:09 -0700)]
device: Add "Bonded" flag to dbus property

Add "Bonded" to dbus device property table. When setting the "Bonded
flag, check the status of the Bonded property first. If the Bonded
property is changed, send property changed signal.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodoc: add "Bonded" flag to dbus property
Zhengping Jiang [Wed, 4 May 2022 21:09:47 +0000 (14:09 -0700)]
doc: add "Bonded" flag to dbus property

Bonded flag is used to indicate the link key or ltk of the remote
device has been stored.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Fix parsing of LE Terminate BIG Complete event
Luiz Augusto von Dentz [Mon, 2 May 2022 21:43:20 +0000 (14:43 -0700)]
monitor: Fix parsing of LE Terminate BIG Complete event

LE Terminate BIG Complete event format Subevent_Code, BIG_Handle and
Reason but the last two were swapped.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Decode LTV fields of Basic Audio Announcements
Luiz Augusto von Dentz [Mon, 2 May 2022 20:02:46 +0000 (13:02 -0700)]
monitor: Decode LTV fields of Basic Audio Announcements

This decodes the LTV fields of Basic Audio Announcements:

< HCI Command: LE Set Periodic Advertising Data (0x08|0x003f) plen 41
        Handle: 0
        Operation: Complete ext advertising data (0x03)
        Data length: 0x26
        Service Data: Basic Audio Announcement (0x1851)
          Presetation Delay: 40000
          Number of Subgroups: 1
            Subgroup #0:
            Number of BIS(s): 1
            Codec: LC3 (0x06)
            Codec Specific Configuration #0: len 0x02 type 0x01
            Codec Specific Configuration: 03
            Codec Specific Configuration #1: len 0x02 type 0x02
            Codec Specific Configuration: 01
            Codec Specific Configuration #2: len 0x05 type 0x03
            Codec Specific Configuration: 01000000
            Codec Specific Configuration #3: len 0x03 type 0x04
            Codec Specific Configuration: 2800
            Metadata #0: len 0x03 type 0x02
            Metadata: 0200
              BIS #0:
              Index: 1
              Codec Specific Configuration:

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Fix not removing connection and advertising set on reset
Luiz Augusto von Dentz [Mon, 2 May 2022 19:59:50 +0000 (12:59 -0700)]
btdev: Fix not removing connection and advertising set on reset

This makes sure that all connections and advertising sets are cleanup
on reset.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotransport: Fix not being able to initialize volume properly
Luiz Augusto von Dentz [Wed, 27 Apr 2022 20:14:19 +0000 (13:14 -0700)]
transport: Fix not being able to initialize volume properly

In case AVRCP is connected first and
media_transport_update_device_volume is called without any media_player
being available the volume setting would be lost and Transport.Volume
won't be available, so this introduces btd_device_{set,get}_volume
helpers which is used to store the volume temporarely so
media_player_get_device_volume is able to restore it when the transport
is created.

Fixes: https://github.com/bluez/bluez/issues/335
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtmon: Fix not decoding LC3 id
Luiz Augusto von Dentz [Tue, 26 Apr 2022 23:02:54 +0000 (16:02 -0700)]
btmon: Fix not decoding LC3 id

This enablind decoding LC3 codec id (0x06).

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtmon: Add support for decoding Basic Audio Annoucements
Luiz Augusto von Dentz [Tue, 26 Apr 2022 22:57:15 +0000 (15:57 -0700)]
btmon: Add support for decoding Basic Audio Annoucements

This adds support for decoding Basic Audio Announcements as shown
on:

Basic Audio Profile / Profile Specification
Page 36 of 146

Table 3.15: Format of BASE used in Basic Audio Announcements

< HCI Command: LE Set Periodic Advertising Data (0x08|0x003f) plen 36
        Handle: 0
        Operation: Complete ext advertising data (0x03)
        Data length: 0x21
        Service Data: Basic Audio Announcement (0x1851)
          Presetation Delay: 40000
          Number of Subgroups: 1
            Subgroup #0:
            Number of BIS(s): 1
            Codec: Reserved (0x06)
            Codec Specific Configuration: 010101020403010000020428
            Metadata: 020202
              BIS #0:
              Index: 1
              Codec Specific Configuration:

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtmon: Add support for decoding Broadcast Audio Annoucements
Luiz Augusto von Dentz [Tue, 26 Apr 2022 20:22:03 +0000 (13:22 -0700)]
btmon: Add support for decoding Broadcast Audio Annoucements

This adds support for decoding Broadcast Audio Announcements as shown
on:

Basic Audio Profile / Profile Specification
Page 34 of 146

Table 3.14: Broadcast Source AD format when transmitting Broadcast
Audio Announcements

< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 36
        Handle: 0x00
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x20
        Service Data: Broadcast Audio Announcement (0x1852)
        Broadcast ID: 904177 (0x0dcbf1)
        Name (complete): Broadcast Audio Source

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtmon: Add proper decoding to Service Data UUID
Luiz Augusto von Dentz [Tue, 26 Apr 2022 18:39:14 +0000 (11:39 -0700)]
btmon: Add proper decoding to Service Data UUID

This adds proper decoding for Service Data UUID:

        Service Data: Apple, Inc. (0xfd6f)
          Data: e6b07e19815e902100b8b2f4a55255fd18f0c6be

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient/player: Add transport.receive command
Luiz Augusto von Dentz [Mon, 25 Apr 2022 23:58:54 +0000 (16:58 -0700)]
client/player: Add transport.receive command

This adds transport.receive command:

Get/Set file to receive
Usage:
 receive [filename]

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient/player: Add transport.volume command
Luiz Augusto von Dentz [Fri, 22 Apr 2022 23:01:29 +0000 (16:01 -0700)]
client/player: Add transport.volume command

This adds transport.volume command:

Get/Set transport volume
Usage:
 volume <transport> [value]

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtmon: Fix decoding of Enhanced Credit Connection Request
Luiz Augusto von Dentz [Wed, 20 Apr 2022 23:43:31 +0000 (16:43 -0700)]
btmon: Fix decoding of Enhanced Credit Connection Request

This fixes the decoding of Enhanced Credit Connection Request which was
not accounting the fields correctly causing 2 extra Source CID to be
printed.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agohog-lib: Check if Report ID is set before prepending it
Luiz Augusto von Dentz [Wed, 20 Apr 2022 20:08:59 +0000 (13:08 -0700)]
hog-lib: Check if Report ID is set before prepending it

Before prepending the Report ID check if it is non-zero:

BLUETOOTH SPECIFICATION Page 16 of 26
HID Service Specification

Report ID shall be nonzero in a Report Reference characteristic
descriptor where there is more than one instance of the Report
characteristic for any given Report Type.

Fixes: https://www.spinics.net/lists/linux-bluetooth/msg97262.html
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest: changes for Python3
Diego Rondini [Tue, 19 Apr 2022 15:09:49 +0000 (17:09 +0200)]
test: changes for Python3

Remove some leftover usage of Python2 code. In particular replace
iteritems() with items() to fix the following error:

AttributeError: 'dbus.Dictionary' object has no attribute 'iteritems'
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agosettings-storage: Document use of StateDirectory
Luiz Augusto von Dentz [Tue, 19 Apr 2022 18:30:16 +0000 (11:30 -0700)]
settings-storage: Document use of StateDirectory

This documents the use of StateDirecory environment variable which
overwrites the default storage diretory when set.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient/player: Fix use of unsupported config_qos
Luiz Augusto von Dentz [Mon, 18 Apr 2022 23:56:48 +0000 (16:56 -0700)]
client/player: Fix use of unsupported config_qos

QoS is not yet supported by bluetoothd so remove them.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest-runner: Add dedicated option to start D-Bus
Luiz Augusto von Dentz [Sat, 16 Apr 2022 00:17:04 +0000 (17:17 -0700)]
test-runner: Add dedicated option to start D-Bus

This adds a dedicated option to start D-Bus alone which can be useful
when testing the bluetoothd with the likes of valgrind.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomain: Add support for CONFIGURATION_DIRECTORY environment variable
Luiz Augusto von Dentz [Fri, 15 Apr 2022 21:18:09 +0000 (14:18 -0700)]
main: Add support for CONFIGURATION_DIRECTORY environment variable

When running as a systemd service the CONFIGURATION_DIRECTORY
environment variable maybe set:

https://www.freedesktop.org/software/systemd/man/systemd.exec.html
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agostorage: Add support for STATE_DIRECTORY environment variable
Luiz Augusto von Dentz [Fri, 15 Apr 2022 20:48:39 +0000 (13:48 -0700)]
storage: Add support for STATE_DIRECTORY environment variable

When running as a systemd service the STATE_DIRECTORY environment
variable maybe set:

https://www.freedesktop.org/software/systemd/man/systemd.exec.html
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agopolicy: Change AutoEnable default to true
Luiz Augusto von Dentz [Wed, 13 Apr 2022 22:21:00 +0000 (15:21 -0700)]
policy: Change AutoEnable default to true

This changes the default of AutoEnable to true so controllers are power
up by default.

Fixes: https://github.com/bluez/bluez/issues/328
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient/player: Add transport menu
Luiz Augusto von Dentz [Mon, 11 Apr 2022 23:53:56 +0000 (16:53 -0700)]
client/player: Add transport menu

This adds transport menu:

[bluetooth]# menu transport
Menu transport:
Available commands:
-------------------
list                                              List available transports
show <transport>                                  Transport information
acquire <transport>                               Acquire Transport
release <transport>                               Release Transport
send <filename>                                   Send contents of a file

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient/player: Add endpoint menu
Luiz Augusto von Dentz [Mon, 11 Apr 2022 23:51:12 +0000 (16:51 -0700)]
client/player: Add endpoint menu

This adds endpoint menu:

[bluetooth]# menu endpoint
Menu endpoint:
Available commands:
-------------------
list [local]                                      List available endpoints
show <endpoint>                                   Endpoint information
register <UUID> <codec> [capabilities...]         Register Endpoint
unregister <UUID/object>                          Register Endpoint
config <endpoint> <local endpoint> [preset]       Configure Endpoint
presets <UUID> [default]                          List available presets

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Fix CIS Established
Luiz Augusto von Dentz [Fri, 11 Mar 2022 21:12:33 +0000 (13:12 -0800)]
btdev: Fix CIS Established

CIS Established was using the ISO latency instead of SDU interval for
transport latency.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobthost: Fix not setting all parameters when using Create BIG cmd
Luiz Augusto von Dentz [Fri, 11 Mar 2022 21:10:33 +0000 (13:10 -0800)]
bthost: Fix not setting all parameters when using Create BIG cmd

Create BIG shall set proper values for interval, latency, rtn and phy.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobthost: Add support for Create CIS
Luiz Augusto von Dentz [Thu, 10 Mar 2022 23:20:49 +0000 (15:20 -0800)]
bthost: Add support for Create CIS

This introduces bthost_set_cig_params and bthost_create_cis.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Fix not cleanup ssp_status and ssp_auto_complete
Luiz Augusto von Dentz [Mon, 11 Apr 2022 21:50:23 +0000 (14:50 -0700)]
btdev: Fix not cleanup ssp_status and ssp_auto_complete

This resets ssp_status and ssp_auto_complete flags on auth_complete.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoadapter: Fix check of DISCOVERABLE setting
Jakob hilmer [Sat, 9 Apr 2022 10:01:30 +0000 (12:01 +0200)]
adapter: Fix check of DISCOVERABLE setting

The test for `DISCOVERABLE` should be done with
`MGMT_SETTING_DISCOVERABLE` instead of `MGMT_OP_SET_DISCOVERABLE`.
Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoshell: Fix not able to auto complete commands with submenu prefix
Luiz Augusto von Dentz [Thu, 7 Apr 2022 23:41:34 +0000 (16:41 -0700)]
shell: Fix not able to auto complete commands with submenu prefix

If the command was given with submenu prefix the code wasn't able to
detect the command to be able to generate the auto complete for its
arguments.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoshell: Fix not being able to auto complete submenus
Luiz Augusto von Dentz [Thu, 7 Apr 2022 23:19:26 +0000 (16:19 -0700)]
shell: Fix not being able to auto complete submenus

submenus should be part of the list of possible auto completes just as
other commands.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Fix BIG Create Sync
Luiz Augusto von Dentz [Wed, 6 Apr 2022 20:01:03 +0000 (13:01 -0700)]
btdev: Fix BIG Create Sync

This fixes status return to BIG Create Sync command.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Add support for sending LE BIG Info Adv Reports
Luiz Augusto von Dentz [Tue, 5 Apr 2022 00:41:06 +0000 (17:41 -0700)]
btdev: Add support for sending LE BIG Info Adv Reports

This adds support for sending LE BIG Info Adv Reports if LE Create BIG
has been called.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Add support for LE BIG Info Adverting Report
Luiz Augusto von Dentz [Mon, 4 Apr 2022 23:20:33 +0000 (16:20 -0700)]
monitor: Add support for LE BIG Info Adverting Report

This adds support for LE BIG Info Advertising Report.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogap: Don't attempt to read the appearance if already set
Luiz Augusto von Dentz [Mon, 4 Apr 2022 20:15:18 +0000 (13:15 -0700)]
gap: Don't attempt to read the appearance if already set

Devices are unlikely to change appearance over time which is the reason
why we cache then on the storage so this skips reading it on every
reconnection.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt: Fix double free and freed memory dereference
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:47 +0000 (15:16 +0300)]
gatt: Fix double free and freed memory dereference

If device is no longer exists or not paired when notifications send it
is possible to get double free and dereference of already freed memory.

To avoid this we need to recheck the state of device after sending
notification.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Limit width of fields in sscanf
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:46 +0000 (15:16 +0300)]
device: Limit width of fields in sscanf

In src/device.c few sscanf does not limit width of uuid field. This
could lead to static overflow and stack corruption.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Limit width of fields in sscanf
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:45 +0000 (15:16 +0300)]
tools: Limit width of fields in sscanf

In tools/btmgmt.c and tools/hex2hcd.c few sscanf does not limit width
of fields. This could lead to static overflow and stack corruption.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix signed integer overflow in btsnoop.c
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:44 +0000 (15:16 +0300)]
tools: Fix signed integer overflow in btsnoop.c

If malformed packet is proceed with zero 'size' field we will face with
wrong behaviour of write() call. Value 'toread - 1' gives wrong sign
for value 'written' (-1) in write() call. To prevent this we should
check that 'toread' is not equal to zero.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix buffer overflow in hciattach_tialt.c
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:43 +0000 (15:16 +0300)]
tools: Fix buffer overflow in hciattach_tialt.c

Array 'c_brf_chip' of size 8 could be accessed by index > 7. We should
limit array access like in previous check at line 221.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Fix out-of-bound read in print_le_states
Ildar Kamaletdinov [Fri, 1 Apr 2022 12:16:42 +0000 (15:16 +0300)]
monitor: Fix out-of-bound read in print_le_states

Accessing le_states_desc_table array with value 15 can cause
out-of-bound read because current size of array is 14.

Currently this cannot lead to any problems becase we do no have such
state in le_states_comb_table but this could be changed in future and
raise described problem.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotools: Fix g_dbus_setup_private connection check in mpris-proxy
Frédéric Danis [Wed, 30 Mar 2022 09:47:40 +0000 (11:47 +0200)]
tools: Fix g_dbus_setup_private connection check in mpris-proxy

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoshared/gatt-db: Fix gatt_db_attribute_get_index
Luiz Augusto von Dentz [Fri, 1 Apr 2022 21:32:53 +0000 (14:32 -0700)]
shared/gatt-db: Fix gatt_db_attribute_get_index

gatt_db_attribute_get_index was calculating the index based on
attrib->handle - service->attributes[0]->handle which doesn't work when
there are gaps in between handles.

Fixes: https://github.com/bluez/bluez/issues/326
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Check parameter for CIG related commands
Luiz Augusto von Dentz [Thu, 31 Mar 2022 22:25:10 +0000 (15:25 -0700)]
btdev: Check parameter for CIG related commands

This checks if the parameters given to Set CIG Parameters and Remove CIG
are in the valid range.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomesh: use explicit uint32_t when bit shifting left
Inga Stotland [Wed, 30 Mar 2022 21:17:47 +0000 (14:17 -0700)]
mesh: use explicit uint32_t when bit shifting left

This addresses a situation when a boolean type is represented by
an integer and performing a left shift on a boolean causes
an integer overflow.

This fixes the following runtime error:
"left shift of 1 by 31 places cannot be represented in type 'int'"

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoa2dp: Fix crash when SEP codec has not been initialized
Frédéric Danis [Wed, 30 Mar 2022 09:28:44 +0000 (11:28 +0200)]
a2dp: Fix crash when SEP codec has not been initialized

If SEP has not been properly discovered avdtp_get_codec may return NULL
thus causing crashes such as when running AVRCP/TG/VLH/BI-01-C after
AVRCP/TG/RCR/BV-04-C.

Prevent remote endpoint registration if its codec is not available.

Remove queue_isempty check from store_remote_seps since that prevents
cleaning up if no seps could be registered.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient: Add support for player submenu
Luiz Augusto von Dentz [Mon, 28 Mar 2022 21:18:07 +0000 (14:18 -0700)]
client: Add support for player submenu

This moves adds the functionality of bluetooth-player into
bluetoothctl.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoshell: Make bt_shell_add_submenu set main menu if none has been set
Luiz Augusto von Dentz [Mon, 28 Mar 2022 20:56:58 +0000 (13:56 -0700)]
shell: Make bt_shell_add_submenu set main menu if none has been set

If not main menu has been set when calling bt_shell_add_submenu then
turns it on it main menu.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomgmt: Remove mgmt_set_verbose
Luiz Augusto von Dentz [Fri, 25 Mar 2022 18:11:47 +0000 (11:11 -0700)]
mgmt: Remove mgmt_set_verbose

The likes of btmon already decode the commands/events so there is no
need to have the code hexdump their contents.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoa2dp: Always invalidate the cache if its configuration fails
Luiz Augusto von Dentz [Thu, 24 Mar 2022 22:14:34 +0000 (15:14 -0700)]
a2dp: Always invalidate the cache if its configuration fails

When a configuration had been restored from last_used cache but it
fails invalidate it so another sep can be used.

Fixes: https://github.com/bluez/bluez/issues/313
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoa2dp: Don't initialize a2dp_sep->destroy until properly registered
Luiz Augusto von Dentz [Thu, 24 Mar 2022 21:32:11 +0000 (14:32 -0700)]
a2dp: Don't initialize a2dp_sep->destroy until properly registered

On a2dp_add_sep if the record cannot be properly registred
a2dp_unregister_sep would be called which would attempt to destroy the
user_data causing the following backtrace:

Invalid write of size 8
   at 0x2F41EB: endpoint_init_a2dp_source (media.c:687)
   by 0x2F41EB: media_endpoint_create (media.c:1030)
   by 0x2F6713: register_endpoint (media.c:1155)
   by 0x46983F: process_message (object.c:246)
   by 0x4A574A8: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.14)
   by 0x45F0BF: message_dispatch (mainloop.c:59)
   by 0x495239A: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x495605E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x49AB2A7: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x4955772: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x4CA924: mainloop_run (mainloop-glib.c:66)
   by 0x4CAE1B: mainloop_run_with_signal (mainloop-notify.c:188)
   by 0x2AE791: main (main.c:1258)
 Address 0x6e47a30 is 0 bytes inside a block of size 112 free'd
   at 0x48470E4: free (vg_replace_malloc.c:872)
   by 0x4957CDC: g_free (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x2C2D57: a2dp_unregister_sep (a2dp.c:2588)
   by 0x2D124C: a2dp_add_sep (a2dp.c:2697)
   by 0x2F41D5: endpoint_init_a2dp_source (media.c:687)
   by 0x2F41D5: media_endpoint_create (media.c:1030)
   by 0x2F6713: register_endpoint (media.c:1155)
   by 0x46983F: process_message (object.c:246)
   by 0x4A574A8: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.14)
   by 0x45F0BF: message_dispatch (mainloop.c:59)
   by 0x495239A: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x495605E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x49AB2A7: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoadapter: Fix adding SDP records when operating on LE only mode
Luiz Augusto von Dentz [Thu, 24 Mar 2022 21:24:12 +0000 (14:24 -0700)]
adapter: Fix adding SDP records when operating on LE only mode

If mode is set to BT_MODE_LE SDP protocol won't be operational so it is
useless to attempt to add records.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomesh: Fix address overrun error in rx filter
Inga Stotland [Fri, 25 Mar 2022 23:46:25 +0000 (16:46 -0700)]
mesh: Fix address overrun error in rx filter

This fixes the following error for invalid read access when registering
filter for incoming messages:

140632==ERROR: AddressSanitizer: stack-buffer-overflow on address...
 #0 0x7f60c185741d in MemcmpInterceptorCommon(...
    #1 0x7f60c1857af8 in __interceptor_memcmp (/lib64/libasan.so...
    #2 0x55a10101536e in find_by_filter mesh/mesh-io-unit.c:494
    #3 0x55a1010d8c46 in l_queue_remove_if ell/queue.c:517
    #4 0x55a101014ebd in recv_register mesh/mesh-io-unit.c:506
    #5 0x55a10102946f in mesh_net_attach mesh/net.c:2885
    #6 0x55a101086f64 in send_reply mesh/dbus.c:153
    #7 0x55a101124c3d in handle_method_return ell/dbus.c:216
    #8 0x55a10112c8ef in message_read_handler ell/dbus.c:276
    #9 0x55a1010dae20 in io_callback ell/io.c:120
    #10 0x55a1010dff7e in l_main_iterate ell/main.c:478
    #11 0x55a1010e06e3 in l_main_run ell/main.c:525
    #12 0x55a1010e06e3 in l_main_run ell/main.c:507
    #13 0x55a1010e0bfc in l_main_run_with_signal ell/main.c:647
    #14 0x55a10100316e in main mesh/main.c:292
    #15 0x7f60c0c6855f in __libc_start_call_main (/lib64/libc.so.6+...
    #16 0x7f60c0c6860b in __libc_start_main_alias_1 (/lib64/libc.so.6+...
    #17 0x55a101003ce4 in _start (/home/istotlan/bluez/mesh/bluetooth-m...

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Don't use DBG in gatt_debug
Luiz Augusto von Dentz [Mon, 21 Mar 2022 20:04:33 +0000 (13:04 -0700)]
device: Don't use DBG in gatt_debug

gatt_debug callback is used to print debug strings from bt_att which
includes the file and function names so using DBG would add yet another
set of file and function prefixes which makes the logs confusing.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoatt: Rename att_debug and att_verbose to DBG and VERBOSE
Luiz Augusto von Dentz [Mon, 21 Mar 2022 20:36:52 +0000 (13:36 -0700)]
att: Rename att_debug and att_verbose to DBG and VERBOSE

att_debug and att_verbose are macros which are more common to be
used as uppercase, this also change them to use DBG like other parts of
the code.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt-server: Add DBG macro
Luiz Augusto von Dentz [Mon, 21 Mar 2022 20:29:48 +0000 (13:29 -0700)]
gatt-server: Add DBG macro

This adds gatt_log wrapper for util_debug and DBG so file and function
names are printed with the logs.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt-client: Add DBG macro
Luiz Augusto von Dentz [Mon, 21 Mar 2022 20:21:16 +0000 (13:21 -0700)]
gatt-client: Add DBG macro

This adds gatt_log wrapper for util_debug and DBG macro so file and
function names are printed which is more consistent with other parts of
the daemon code.

Change-Id: I802443ecd6bd249c174c1dcf0d1f8ed246425427
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoatt: Log file and function names
Luiz Augusto von Dentz [Mon, 21 Mar 2022 20:01:37 +0000 (13:01 -0700)]
att: Log file and function names

This adds logging of file and function names.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoadapter: Don't use DBG in mgmt_debug
Luiz Augusto von Dentz [Tue, 22 Mar 2022 22:57:53 +0000 (15:57 -0700)]
adapter: Don't use DBG in mgmt_debug

mgmt_debug callback is used to print debug strings from mgmt instances
which includes the file and function names so using DBG would add yet
another set of file and function prefixes which makes the logs
confusing.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomgmt: Introduce mgmt_set_verbose
Luiz Augusto von Dentz [Tue, 22 Mar 2022 23:20:10 +0000 (16:20 -0700)]
mgmt: Introduce mgmt_set_verbose

This introduces mgmt_set_verbose which can be used to enable printing
the the likes hexdump of packets, by default it is disabled since in
most cases the hexdump is not very useful and there are better tools
to collect the hexdumo like btmon.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomgmt: Add DBG macro
Luiz Augusto von Dentz [Tue, 22 Mar 2022 21:48:06 +0000 (14:48 -0700)]
mgmt: Add DBG macro

This adds mgmt_log wrapper for util_debug and DBG so file and function
names are printed with the logs.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agolog: Don't log __FILE__ and __func__ with DBG_IDX
Luiz Augusto von Dentz [Tue, 22 Mar 2022 22:51:17 +0000 (15:51 -0700)]
log: Don't log __FILE__ and __func__ with DBG_IDX

This removes __FILE__ and __func__ from DBG_IDX since users of it may
already contain such information embedded in the format.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoRelease 5.64
Marcel Holtmann [Wed, 16 Mar 2022 15:04:29 +0000 (16:04 +0100)]
Release 5.64

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt-db: Fix gatt_db_attribute_notify
Luiz Augusto von Dentz [Mon, 14 Mar 2022 21:47:02 +0000 (14:47 -0700)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt: Print error if gatt_db_attribut_notify fails
Luiz Augusto von Dentz [Mon, 14 Mar 2022 21:46:21 +0000 (14:46 -0700)]
gatt: Print error if gatt_db_attribut_notify fails

This prints an error if gatt_db_attribut_notify fails.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest-runner: Update help information
Luiz Augusto von Dentz [Wed, 9 Mar 2022 02:04:41 +0000 (18:04 -0800)]
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

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest-runner: Fix -l/--emulator
Luiz Augusto von Dentz [Wed, 9 Mar 2022 02:00:49 +0000 (18:00 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Fix response to LE Set Extended Advertising Parameters
Luiz Augusto von Dentz [Wed, 9 Mar 2022 01:58:40 +0000 (17:58 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoaudio: Fix crash in a2dp_discover
Yun-Hao Chung [Tue, 8 Mar 2022 09:43:48 +0000 (17:43 +0800)]
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>
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobthost: Add support for Create BIG
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:29 +0000 (17:22 -0800)]
bthost: Add support for Create BIG

This adds bthost_create_big

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobthost: Add support for Periodic Advertising
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:28 +0000 (17:22 -0800)]
bthost: Add support for Periodic Advertising

This adds bthost_set_pa_params and bthost_set_pa_enable.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobthost: Add support for BT_H4_ISO_PKT
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:27 +0000 (17:22 -0800)]
bthost: Add support for BT_H4_ISO_PKT

This adds sending and receiving BT_H4_ISO_PKT packets.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Implements BT_HCI_CMD_LE_BIG_TERM_SYNC
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:26 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Implements BT_HCI_CMD_LE_BIG_CREATE_SYNC
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:25 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Rename Periodic Advertising terms to PA/pa
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:24 +0000 (17:22 -0800)]
monitor: Rename Periodic Advertising terms to PA/pa

This renames the use of Periodic Advertising in the API to just PA.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote start pa
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:23 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED when scan is initiated
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:22 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:21 +0000 (17:22 -0800)]
btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC

This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:20 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:19 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agomonitor: Fix Create BIG PDU
Luiz Augusto von Dentz [Sat, 5 Mar 2022 01:22:18 +0000 (17:22 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agodevice: Fix writing out of bounds array
ihsinme [Tue, 1 Mar 2022 06:14:45 +0000 (06:14 +0000)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agogatt: sanitize input at profile registration
Andreas Kemnade [Sat, 26 Feb 2022 10:08:36 +0000 (11:08 +0100)]
gatt: sanitize input at profile registration

Check whether type of UUIDs property of GattProfile1 object
is correct.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoclient: Add support for scan <le/bredr>
Luiz Augusto von Dentz [Thu, 3 Mar 2022 00:30:11 +0000 (16:30 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest-runner: Fix parsing of command line
Luiz Augusto von Dentz [Tue, 1 Mar 2022 23:26:14 +0000 (15:26 -0800)]
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'

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoshared/shell: Introduce bt_shell_exec
Luiz Augusto von Dentz [Mon, 28 Feb 2022 23:58:29 +0000 (15:58 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agotest-runner: Add option to start emulator
Luiz Augusto von Dentz [Mon, 28 Feb 2022 23:23:37 +0000 (15:23 -0800)]
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

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agohog-lib: Fix not waiting for UHID_START
Luiz Augusto von Dentz [Fri, 25 Feb 2022 22:18:47 +0000 (14:18 -0800)]
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
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agobtproxy: Attempt to bind the next index
Luiz Augusto von Dentz [Fri, 25 Feb 2022 21:53:19 +0000 (13:53 -0800)]
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
17 months agoneard: Fix reading State message
Nicolas Fella [Wed, 23 Feb 2022 21:56:17 +0000 (22:56 +0100)]
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
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>