Commit Graph

26634 Commits

Author SHA1 Message Date
Christian Eggers
ee750bbaf6 client/gatt: proxy_property_changed: check for NULL iterator
The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
   proxy->prop_func(..., ..., iter=NULL, ...)
   +--client/gatt.c::proxy_property_changed(..., ..., iter, ...);
      +--dbus_message_iter_get_arg_type(iter);
...
2022-09-23 13:42:49 -07:00
Christian Eggers
47346e5390 advertising: parse_tx_power: reset value if iter is NULL
Set property to its default value (as done in all other methods listed
in parsers[]).
2022-09-23 13:34:24 -07:00
Christian Eggers
a18d66862d advertising: parse_[min|max]_interval: reset value if iter is NULL
Set property to its default value (as done in all other methods listed
in parsers[]).
2022-09-23 13:34:24 -07:00
Christian Eggers
abfb3a807c advertising: parse_min_interval: reset min_interval if iter is NULL
Set property to its default value (as done in all other methods listed
in parsers[]).
2022-09-23 13:34:24 -07:00
Christian Eggers
732eaa7ccf advertising: parse_secondary: check for NULL iterator
The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
   proxy->prop_func(..., ..., iter=NULL, ...)
   +--src/advertising.c::properties_changed(..., ..., iter, ...);
      +--parse_secondary(iter, ...);
...
2022-09-23 13:34:24 -07:00
Christian Eggers
2e43278165 advertising: parse_secondary: fix mask value
It looks like a wrong mask value is used here as only the bits mentioned
in adv_secondary::flag can be set again within the loop.

Replace magic number by preprocessor macro.
2022-09-23 13:34:23 -07:00
Christian Eggers
47821c4731 advertising: parse_secondary: fix loop condition
"secondary" isn't an array of pointers, so the iterator can never be
NULL.
2022-09-23 13:34:23 -07:00
Isak Westin
95d9dc6764 mesh: Reply error if appkey added for wrong netkey
If a known appkey is added for a different netkey, the status reply
should be Invalid NetKey.
2022-09-23 10:06:37 -07:00
Isak Westin
32d866b4df mesh: Clear addr field if virt sub failed
If processing failed for a Config Model Subscription Virtual Address
Add/Delete/Overwrite message, the address field in the status reply
should be set to zero. See MshPRFv1.0.1 section 4.4.1.2.8.
2022-09-23 10:06:37 -07:00
Brian Gix
721d5a8ae8 lib: Add defines of new MGMT opcodes and events
Populated new opcodes and events into static mgmt_ev and mgmt_op string
arrays.
2022-09-22 14:09:09 -07:00
Brian Gix
0454e2d095 mgmt: Add support for Mesh in the kernel
These commands and events allow User space apps to test for Mesh
support, and request incoming mesh packets be delivered and request
outbound mesh packets to be sent. This is the basis for sharing
one controller between the legacy bluetoothd daemon and the mesh
bluetooth-meshd daemon.
2022-09-22 14:09:08 -07:00
Isak Westin
c9fadca7eb mesh: Remove RFU check for publication set
It is not stated in the mesh profile that the RFU bits in a Model
Publication Set message have to be zero. In fact, PTS test
MESH/NODE/CFG/MP/BV-01-C is sending that command with non-zero RFU and
expects a reply.
2022-09-22 14:02:38 -07:00
Isak Westin
b72edcc5ca mesh: Do not accept publication for unbound appkey
If a user tries to configure publication of a model with an appkey that
is not bound to that model, an error should be returned.
2022-09-22 14:02:38 -07:00
Isak Westin
a76ff5879b mesh: Add interface output filter
According to the mesh profile (3.4.5.2), if TTL is set to 1 for an
outgoing message, that message shall be dropped.
2022-09-22 14:02:38 -07:00
Brian Gix
75ba186a9c mesh: Fix potential memory leak
This memory leak will never happen, however since we added a new
return from function that malloc'd memory, the free should still be
done.
2022-09-22 14:02:38 -07:00
Tedd Ho-Jeong An
0da759f1a3 tools/ioctl-tester - Add ioctl-tester
This patch adds ioctl-tester which tests the IOCTL commands.

HCI Down
Device List
Device List - Invalid Param 1
Device Info
Reset Stat
Set Link Mode - ACCEPT
Set Link Mode - MASTER
Set Pkt Type - DM
Set Pkt Type - DH
Set Pkt Type - HV
Set Pkt Type - 2-DH
Set Pkt Type - 2-DH
Set Pkt Type - ALL
Set ACL MTU - 1
Set ACL MTU - 2
Set SCO MTU - 1
Set SCO MTU - 2
Block BDADDR - Success
Block BDADDR - Fail
Unblock BDADDR - Success
Unblock BDADDR - Fail
Connection List - No Conn
Connection List
Connection Info
Connection Info - No Connection
Connection Info - Wrong Type
Authentication Info - No Connection
Authentication Info
2022-09-21 16:37:35 -07:00
Sathish Narasimman
7233b50f41 Profiles: Enable bt_vcp_set_debug
Set bt_vcp_set_debug to be used for VCP.
2022-09-21 16:37:35 -07:00
Sathish Narasimman
89ac7b8265 shared/vcp: Add bt_vcp_set_debug
Add support for bt_vcp_set_debug and replace the exisiting DBG.
2022-09-21 16:37:35 -07:00
Luiz Augusto von Dentz
40a90f4e98 shared/gatt-db: Fix scan-build warnings
This fixes the following warnings:

src/shared/gatt-db.c:1339:2: warning: Undefined or garbage value
returned to caller [core.uninitialized.UndefReturn]
        return data.num_of_res;
        ^~~~~~~~~~~~~~~~~~~~~~

src/shared/gatt-db.c:725:5: warning: Access to field 'handle' results
in a dereference of a null pointer
        service->attributes[0]->handle == handle)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-09-21 16:36:23 -07:00
Luiz Augusto von Dentz
31b32daf52 gatt: Fix scan-build warnings
This fixes the following warnings:

src/gatt-database.c:3541:14: warning: Value stored to 'iface' during
its initialization is never read [deadcode.DeadStores]
        const char *iface = g_dbus_proxy_get_interface(proxy);
                    ^~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gatt-database.c:3542:14: warning: Value stored to 'path' during
its initialization is never read [deadcode.DeadStores]
        const char *path = g_dbus_proxy_get_path(proxy);
                    ^~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-09-21 14:49:48 -07:00
Luiz Augusto von Dentz
c2734c41f7 client/gatt: Fix notification enabled/disabled output
When notifications are enabled/disable the output was not print a new
line.
2022-09-21 14:45:03 -07:00
Luiz Augusto von Dentz
50782b0eeb gatt-db: Check if permissions are set when adding CCC
CCC shall always have some permission set.
2022-09-21 14:43:24 -07:00
Luiz Augusto von Dentz
fbf17ac497 gatt: Fix not setting permissions for CCC
CCC shall always have both Read and Write permissions set in addition to
what application set.

Fixes: https://github.com/bluez/bluez/issues/399
2022-09-21 14:40:14 -07:00
Sathish Narasimman
115514d85a monitor/att: Add decoding support for Volume Control Serice
This adds decoding support for VCS attributes

> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0017 Type: Volume State (0x2b7d)
< ACL Data TX: Handle 3585 flags 0x00 dlen 8
      ATT: Read Response (0x0b) len 3
        Value: 000000
        Handle: 0x0017 Type: Volume State (0x2b7d)
            Volume Setting: 0
            Not Muted: 0
            Change Counter: 0
> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 3585 Address: 49:71:FC:C0:66:C6 (Resolvable)
        Count: 1
> ACL Data RX: Handle 3585 flags 0x02 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x001c Type: Volume Flags (0x2b7f)
< ACL Data TX: Handle 3585 flags 0x00 dlen 6
      ATT: Read Response (0x0b) len 1
        Value: 01
        Handle: 0x001c Type: Volume Flags (0x2b7f)
            Volume Falg: 1
2022-09-19 15:31:37 -07:00
Sathish Narasimman
a96ede87c6 profiles: Add initial code for vcp plugin
This adds initial code for vcp plugin which handles Volume Control
Profile and Volume Control Service.
2022-09-19 15:31:19 -07:00
Sathish Narasimman
b8a113ecba shared/vcp: Add initial code for handling VCP
This adds initial code for Volume Control Profile.
2022-09-19 15:22:32 -07:00
Luiz Augusto von Dentz
f6ac0886f0 shared/gatt-client: Make use of gatt_db_attribute_get_ccc
This makes use of gatt_db_attribute_get_ccc to locate a CCC of a given
attribute.
2022-09-16 16:41:53 -07:00
Luiz Augusto von Dentz
b7023510c9 a2dp: Fix not detecting transport connection collision
Some headsets appears to attempt to connect back after receiving
AVDTP_Open which would cause unexpected transitions since setup->io
and stream->io would not be in sync:

> ACL Data RX: Handle 70 flags 0x02 dlen 6
      Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
      AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 2 nosp 0
< ACL Data TX: Handle 70 flags 0x00 dlen 12
      L2CAP: Connection Request (0x02) ident 6 len 4
        PSM: 25 (0x0019)
        Source CID: 67
> ACL Data RX: Handle 70 flags 0x02 dlen 12
      L2CAP: Connection Request (0x02) ident 10 len 4
        PSM: 25 (0x0019)
        Source CID: 68
< ACL Data TX: Handle 70 flags 0x00 dlen 16
      L2CAP: Connection Response (0x03) ident 10 len 8
        Destination CID: 68
        Source CID: 68
        Result: Connection pending (0x0001)
        Status: Authorization pending (0x0002)
< ACL Data TX: Handle 70 flags 0x00 dlen 16
      L2CAP: Connection Response (0x03) ident 10 len 8
        Destination CID: 68
        Source CID: 68
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
> ACL Data RX: Handle 70 flags 0x02 dlen 16
      L2CAP: Connection Response (0x03) ident 6 len 8
        Destination CID: 69
        Source CID: 67
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)

Fixes: https://github.com/bluez/bluez/issues/327
2022-09-16 14:41:06 -07:00
Luiz Augusto von Dentz
68adb4d1b7 shared/tester: Remove include to io.h
Users of tester.h shall also include io.h, including io.h by default may
cause errors if has been previously included.
2022-09-15 17:21:28 -07:00
Luiz Augusto von Dentz
de0a366833 shared/bap: Remove include to io.h
Users of bap.h shall also include io.h, including io.h by default may
cause errors if has been previously included.
2022-09-15 17:14:39 -07:00
Sathish Narasimman
af1bfbb470 lib/uuid: Add VCS UUIDs
This adds Volume Control Service UUIDs which will be used by
Volume Control Profile.
2022-09-15 14:11:36 -07:00
Luiz Augusto von Dentz
b632ec3f32 rfcomm-tester: Add test to close socket while connecting
This adds Basic RFCOMM Socket Client - Close test which attempt to close
socket while connecting.
2022-09-13 16:32:38 -07:00
Luiz Augusto von Dentz
877b88c5f2 shared/bap: Fix attempting to disable stream when it is idle
If the stream is already in idle state do not attempt to disable it
again.
2022-09-12 14:41:33 -07:00
Brian Gix
9d8fd3c28b monitor: Add mesh MGMT cmds/events to btmon parser
Sample Output:
@ MGMT Command: Read Mesh Features (0x0058) plen 0
@ MGMT Event: Command Complete (0x0001) plen 7
      Read Mesh Features (0x0058) plen 4
        Status: Success (0x00)
        Index: 0
        Max Handles: 3
        Used Handles: 0

@ MGMT Command: Set Mesh Receiver (0x0057) plen 9
        Enable: 1
        Window: 4096
        Period: 4096
        Num AD Types: 3
          AD Type: 42
          AD Type: 43
          AD Type: 41
@ MGMT Event: Command Complete (0x0001) plen 3
      Set Mesh Receiver (0x0057) plen 0
        Status: Success (0x00)

@ MGMT Command: Mesh Send (0x0059) plen 43
        Address: 00:00:00:00:00:00 (OUI 00-00-00)
        Addr Type: 2
        Instant: 0x0000000000000000
        Delay: 0
        Count: 1
        Data Length: 24
        Data: 172b01002dda0c2491537ae2000000009de2120a725038b2
@ MGMT Event: Command Complete (0x0001) plen 4
      Mesh Send (0x0059) plen 1
        Status: Success (0x00)
        Handle: 3

@ MGMT Event: Mesh Packet Complete (0x0032) plen 1
        Handle: 3
2022-09-08 14:36:34 -07:00
Brian Gix
0940cba003 monitor: Add ADV Monitor events to btmon parser
Add missing ADV Monitor MGMT events
2022-09-08 14:36:34 -07:00
Luiz Augusto von Dentz
4c8a6ba5ec shared/bap: Fix not unregistering disconnect callback
bt_bap_detach shall always unregister the disconnect callback otherwise
the session pointer may still be accessible.
2022-09-06 13:13:01 -07:00
Luiz Augusto von Dentz
3d3b1ceab9 rfcomm-tester: Use latest Bluetooth version
This makes rfcomm-tester use the latest Bluetooth supported by the
emulator which is useful the detect regression related to ACL data
transfer.
2022-09-02 13:54:05 -07:00
Brian Gix
c96629bedb mgmt-tester: Adds turning on Mesh Experimental feature
Turns on experimental Mesh feature, and expects it in report when
querying which experimental features are supported and have been
enabled.
2022-09-01 14:34:34 -07:00
Brian Gix
da4b654834 tools: Add mesh-tester to test Kernel mesh support
Ever growing set of tests for Mesh kernel support
2022-09-01 11:52:08 -07:00
Brian Gix
4f452c7753 lib: Add mgmt opcodes and events for Mesh 2022-09-01 11:52:06 -07:00
Bastien Nocera
61f4f28958 adapter: Fix typo in function name 2022-09-01 11:43:49 -07:00
Bastien Nocera
6e49216ad4 adapter-api: Add PowerState property documentation 2022-09-01 11:43:44 -07:00
Bastien Nocera
48992da64f client: Print the PowerState property 2022-09-01 11:43:41 -07:00
Bastien Nocera
58021a665b adapter: Implement PowerState property
This property should allow any program to show whether an adapter is in
the process of being turned on.

As turning on an adapter isn't instantaneous, it's important that the UI
reflects the transitional state of the adapter's power, and doesn't
assume the device is already turned on but not yet working, or still off
despite having requested for it to be turned on, in both cases making
the UI feel unresponsive.

This can also not be implemented in front-ends directly as, then,
the status of an adapter wouldn't be reflected correctly in the Settings
window if it's turned on in the system menu. Implementing it in the
front-ends would also preclude from having feedback about the state of
the adapter when bluetoothd is the one powering up the adapter after the
rfkill was unblocked.

See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121
and the original https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773
2022-09-01 11:43:35 -07:00
Bastien Nocera
abf5ba6b80 adapter: Keep track of whether the adapter is rfkill'ed
Instead of only replying to D-Bus requests with an error saying the
adapter is blocked, keep track of the rfkill being enabled or disabled
so we know the rfkill state of the adapter at all times.
2022-09-01 11:43:35 -07:00
Luiz Augusto von Dentz
49b8c59015 media: Fix scan-build warnings
This fixes the following warnings:

profiles/audio/media.c:1465:6: warning: 8th function call argument
is an uninitialized value
        if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3012:3: warning: Use of memory after it is freed
                release_endpoint(adapter->endpoints->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
profiles/audio/media.c:3015:3: warning: Use of memory after it is freed
                media_player_destroy(adapter->players->data);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-08-31 15:24:39 -07:00
Luiz Augusto von Dentz
a84aa0e6e5 media: Fix registering PAC endpoints if ISO socket are not supported
If adapter don't support ISO sockets the PAC UUIDs shall not be allowed
to be registered as they depend on ISO sockets to work properly.
2022-08-30 17:03:34 -07:00
Luiz Augusto von Dentz
f8c3a38e4f shared/shell: Fix scan-build error
This fixes the following error:

src/shared/shell.c:1135:19: warning: Null pointer passed to 1st
parameter expecting 'nonnull'
                        data.timeout = atoi(optarg);
                                       ^~~~~~~~~~~~
2022-08-30 17:03:31 -07:00
Luiz Augusto von Dentz
d8febc76a4 client/player: Fix checkpatch warning
This fixes the following checkpatch warning:

WARNING:LINE_SPACING: Missing a blank line after declarations
216: FILE: client/player.c:625:
+               GDBusProxy *proxy = l->data;
+               print_player(proxy, NULL);
2022-08-30 14:24:08 -07:00
Frédéric Danis
d04b64003d profiles: Fix function definition style
This was found by checkpatch in previous commit:
WARNING:SPACING: Unnecessary space before function pointer arguments
124: FILE: src/shared/bap.h:123:
+	int (*select) (struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,

Do the same for (*config) and (*clear) for consistence.
2022-08-30 13:31:05 -07:00