Commit Graph

25444 Commits

Author SHA1 Message Date
Denis Grigorev
7a35c12a6c gobex: Fix segfault caused by interrupted transfer
When a obex transfer is interrupted by a peer in the middle, the response
G_OBEX_RSP_FORBIDDEN comes and the transfer is freed in transfer_complete.
However gobex is still ref'ed and gobex->io continues to be writable,
so write_data() and then g_obex_abort() are called. When the abort response
comes, struct obc_transfer is already freed, which leads to the crash.

Backtrace :
__GI___pthread_mutex_lock (mutex=0x65732f74) at pthread_mutex_lock.c:67
0xecc6eeda in dbus_connection_get_object_path_data () from libdbus-1.so.3
0x000457d4 in g_dbus_emit_property_changed_full () at gdbus/object.c:1794
0x00045868 in g_dbus_emit_property_changed () at gdbus/object.c:1832
0x000367f0 in transfer_set_status () at obexd/client/transfer.c:211
0x0003681e in transfer_set_status () at obexd/client/transfer.c:206
xfer_complete () at obexd/client/transfer.c:672
0x00022df6 in transfer_complete () at gobex/gobex-transfer.c:103
0x00022f44 in transfer_abort_response () at gobex/gobex-transfer.c:124
0x00020a0e in handle_response () at gobex/gobex.c:1128
0x00020dde in incoming_data () at gobex/gobex.c:1373

This commit introduces g_obex_drop_tx_queue(), which will be called if
a transfer error detected. After the tx queue is dropped, obex shuts
down gracefully.
2020-07-01 10:49:49 -07:00
Inga Stotland
96c140c2c4 mesh: Clean up config model publication set
No functioal changes. Make code more readable, plus style fixes.
2020-06-30 10:14:09 -07:00
Alain Michaud
c178cf8df0 a2dp: Fix typo in endpoint_setconf_ind
This patch simply fixes a typo in endpoint_setconf_ind.
2020-06-29 12:52:38 -07:00
Luiz Augusto von Dentz
2579cb5aee avdtp: Fix possible unbalance ref count
It has been reported that under some unknown circuntances the reference
number of AVDTP sessions can go bellow 0 (loop around) causing a crash:

bluetoothd[5633]: profiles/audio/avdtp.c:avdtp_ref() 0x56a882b8a500: ref=-2101995743
bluetoothd[5633]: profiles/audio/a2dp.c:discover_cb() err (nil)
WARNING crash_reporter[10707]: [user] Received crash notification for bluetoothd[5633]
2020-06-26 10:32:40 -07:00
Luiz Augusto von Dentz
84ee3a8f76 shared/gatt-client: Fix freeing instance while processing notification
If CCC fails to be programmed the callback would be run without taking
a reference which may lead to freeing the client instance while there
are still notification to be processed.

To fix this handling of both success and failure to program the CCC will
now take a reference to the client, also in case of failure instead of
attempting to program the CCC once again the code now notify all the
queued requests which is consistent with how the success case is
handled.
2020-06-25 14:08:36 -07:00
Noah Pendleton
9469ea039e src/shared: update uuid16_table to latest
Update the table of 16-bit UUID to manufacturer name string to the
latest from this url:

https://www.bluetooth.com/specifications/assigned-numbers/16-bit-uuids-for-members/

I used this script to convert to the bluez format:

https://github.com/noahp/bt-sig-16-bit-uuids
2020-06-23 17:46:45 -07:00
Brian Gix
b7992c3cd5 mesh: Fix memory leak when queuing OB pkts rapidly
If a new packet for outbound delivery is queued during the last
transmission of the only other packet being sent, the prior
packet got forgotten and leaked. This fix correctly deletes the prior
packet, but also makes sure it is given the proper oportunity for
transmission.
2020-06-22 14:36:55 -07:00
Inga Stotland
e462e1c4b9 tools/mesh-cfgclient: add list of blacklisted addresses
This adds a concept of "blacklisted" addresses. that a provisioner is
not allowed to assign to newly added mesh nodes.
An address may be "blacklisted" is a node has been removed from the network
(e.g., after node reset procedure). This ensures that the addresses are not
reused for provisioning new nodes to prevent a potential communication
problem due to saved RPL entries associated with these addresses in the
rest of the mesh network. The address is "cleared", when IV index updates
at least twice.
2020-06-22 14:36:55 -07:00
Inga Stotland
c9790544ec tools/mesh-cfgclient: get/set IV index
This adds keeping track of IV index changes.
The updates are detected by observing PropertiesChanged signal
on local node's object path and reading "IvIndex" property
2020-06-22 14:36:55 -07:00
Inga Stotland
af07ca6950 mesh: Emit PropertiesChanged when IV Index changes
This adds emitting of PropertiesChanged signal whenever the
mesh IV index is updated to indicate that the vlaues of "IvIndex"
property has been modified.
2020-06-22 14:36:55 -07:00
Tedd Ho-Jeong An
3391fb4a06 checkpatch: Add configuration for checkpatch
This patch adds a configuration with basic rules for checkpatch.
2020-06-22 10:47:52 -07:00
Tedd Ho-Jeong An
c29241fe12 midi: Fix random empty timestamp_high value
The timestamp_high value is assigned from the monotonic time but there
is a chance that the value becomes zero because it reads the value
between bit8 and bit13.

This patch makes sure the timestamp_high value get a non-zero value.
2020-06-22 10:13:34 -07:00
Tedd Ho-Jeong An
b53fef5096 midi: Fix SysEx parser in MIDI plugin
The SysEx end of message parser didn't consider the fact that
timestampsLow are in the stream and it might have the EOX (F7)
byte as well.

Fix that by always assuming the first system message byte is
the timestampLow.

Future work would involve support other type of system message
bytes, such as real-time.
2020-06-22 10:13:31 -07:00
Michael Sun
3cc6624dce btmgmt: Add command "add" into "monitor" btmgmt submenu
This patch introduces a new command ‘add’ within "monitor" submenu to
allow users to add advertisement monitor filters and get back monitor
handlers. An event handler is also added to handle kernel issued
MGMT_EV_ADV_MONITOR_ADDED events. The command will work with the new
MGMT opcode MGMT_OP_ADD_ADV_MONITOR. This patch only adds support for
adding pattern based filters.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# add -p 0:1:c504 1🅰️9a55beef
Advertisement monitor with handle:0x0005 added
[mgmt]# add -p 0:1:xxxx
Failed to parse monitor patterns.
Usage: add <-p|-h> [options...]
Monitor Types:
        -p <ad_type:offset:pattern>...  Pattern Monitor
e.g.:
        add -p 0:1:c504 1🅰️9a55beef
2020-06-22 10:02:14 -07:00
Michael Sun
fbc85a5003 btmgmt: Add command "remove" into "monitor" btmgmt submenu
This patch introduces a new btmgmt command ‘remove’ wihtin "monitor"
submenu to allow users to remove previously added filters along with a
event handler to handle kernel issued MGMT_EV_ADV_MONITOR_REMOVED
event. The command will work with the new
MGMT opcode MGMT_OP_REMOVE_ADV_MONITOR.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# remove 1
Advertisement monitor with handle: 0x0001 removed
[mgmt]# remove 1234
Could not remove advertisement monitor with status 0x11 (Invalid Index)
2020-06-22 10:01:47 -07:00
Michael Sun
3f96e817fe btmgmt: Add "monitor" btmgmt submenu and command "features"
This patch introduces a new submenu "monitor" along with command
‘features’ to help user query for supported advertisement features. The
command will work with the new MGMT opcode
MGMT_OP_READ_ADV_MONITOR_FEATURES.

Tested on Atlas Chromebook with a sample stdout below:
[mgmt]# features
Supported features:
        None
Enabled features:
        None
Max number of handles: 32
Max number of patterns: 16
Handles list with 2 items:
        0x0001
        0x0002
2020-06-22 10:00:57 -07:00
Michał Lowas-Rzechonek
c341002952 mesh: Replace BeaconFlags with just IvUpdate
To import nodes, applications need just IvIndex and IvUpdate. KeyRefresh
phase in under provisioner's control, so we don't need to expose it.

Moreover, BeaconFlags property dealt just with the primary net key, and
each subnet key is refreshed separately.
2020-06-18 08:34:14 -07:00
Brian Gix
fd35323543 mesh: Add deferral of Attach() and Leave() if busy
We require the successful return of JoinComplete() method before
handling subsequent Attach() or Leave() method calls. To simplify the
construction of Applications, we will accept one of these calls up to 1
second prior to receiving the final return status of JoinComplete,
which tells us that the Application is ready to use the node.

If the node is still not ready after the deferral, Attach and/or Leave
will fail.
2020-06-18 08:34:14 -07:00
Alain Michaud
fd265a818a main: adding missing connection parameter entries
This patch adds the missing connection parameter entries for loading
connection parameters from main.conf
2020-06-17 21:39:39 -07:00
Miao-chen Chou
4e7e142b9c lib: Correct the string for a mgmt op
This corrects the string of MGMT_OP_ADD_ADV_PATTERNS_MONITOR to match
mgmt-api.txt.
2020-06-17 21:39:39 -07:00
Alain Michaud
5ad9a639cb main: Add configurable le autoconnect timeout value
This patch adds support for a configurable le autoconnect timer.
2020-06-17 21:39:04 -07:00
Alain Michaud
0a10b4f933 main: Fix logical error when loading controller params
Fix logical error when loading configuration parameters from the
config file.  Without this patch, the maximum allowable value is always
used.
2020-06-17 21:38:48 -07:00
Michał Lowas-Rzechonek
4527a8ad82 mesh: Rename IVUpdate import flag to IvUpdate
Name change for consistency with "IvIndex" property.
2020-06-16 10:39:22 -07:00
Inga Stotland
d4989cb19d mesh: Delete unused structures/functions
This deletes unused functions and structures in net.c & net.h.
Plus, some style cleanup.
2020-06-16 10:39:22 -07:00
Miao-chen Chou
ceb47ac6a9 lib: Correct the name command definition
This renames MGMT_OP_ADD_ADV_MONITOR to
MGMT_OP_ADD_ADV_PATTERNS_MONITOR as this command is only used for
patterns.
2020-06-16 10:12:57 -07:00
Manish Mandlik
6156983a58 lib: Move HOG UUID definition
HOG UUID is defined at multiple places in the code. Move that
definition to lib/uuid.h where all other UUIDs are defined.
2020-06-16 10:11:16 -07:00
Michał Lowas-Rzechonek
f34b7e0ba8 mesh: Fix updating CID, PID, VID & CRPL on node attach
In 8a38226212, we wanted to allow the
application to update certain composition fields. This patch makes it
work.
2020-06-15 12:53:45 -07:00
Marcel Holtmann
8eb993e983 doc: Fix minor typo 2020-06-12 21:49:12 +02:00
Alain Michaud
7f0166dbf0 mgmt: syncing configuration commands to the documentation.
This patch simply fixes the definition names (and corresponding
implemenation) to the adopted documentation.
2020-06-12 21:48:36 +02:00
Luiz Augusto von Dentz
c1226f79ec adapter: Fix not checking status of stop discovery command
Status needs to be checked in order to properly synchronize the states
with the controller.
2020-06-12 10:11:04 -07:00
Miao-chen Chou
c924331486 lib: Add definitions for advertisement monitor features
This adds the following command opcodes, event codes and the corresponding
structures.
- MGMT_OP_READ_ADV_MONITOR_FEATURES
- MGMT_OP_ADD_ADV_PATTERNS_MONITOR
- MGMT_OP_REMOVE_ADV_MONITOR
- MGMT_EV_ADV_MONITOR_ADDED
- MGMT_EV_ADV_MONITOR_REMOVED
2020-06-11 15:34:51 -07:00
Luiz Augusto von Dentz
0ce535ecb2 adapter: Rename watch_client to discovery_client
watch term is quite vague so this replace it with discovery which is
what is used for the filter as well.
2020-06-11 13:45:05 -07:00
Luiz Augusto von Dentz
e468284ada adapter: Fix leaking filter pattern
When a discovery client has set a pattern as filter the code allocates
the string so it needs to be freed with the filter otherwise it leads to
the following leak:

10 bytes in 2 blocks are definitely lost in loss record 19 of 265
   at 0x483980B: malloc (vg_replace_malloc.c:309)
   by 0x4D9FF7E: strdup (in /usr/lib64/libc-2.30.so)
   by 0x1FC8E7: parse_pattern (adapter.c:2454)
   by 0x1FF37B: parse_discovery_filter_entry (adapter.c:2480)
   by 0x1FF37B: parse_discovery_filter_dict (adapter.c:2538)
   by 0x2020AF: set_discovery_filter (adapter.c:2589)
   by 0x24AD63: process_message.isra.0 (object.c:259)
   by 0x24B40F: generic_message (object.c:1079)
   by 0x4A670B7: ??? (in /usr/lib64/libdbus-1.so.3.19.11)
   by 0x4A57763: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.11)
   by 0x2459CF: message_dispatch (mainloop.c:72)
   by 0x4963E8A: ??? (in /usr/lib64/libglib-2.0.so.0.6200.6)
   by 0x496756F: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6200.6)
2020-06-11 13:45:03 -07:00
Luiz Augusto von Dentz
227cfdf8e0 adapter: Track discovery client which initiate an action
This adds tracking for active clients so it can be properly
removed/freed on the callbacks.
2020-06-11 13:45:02 -07:00
Luiz Augusto von Dentz
b94e7fc4e2 adapter: Fix passing wrong pointer to stop discovery
stop_discovery_complete now expects adapter to be passed instead of
client.
2020-06-11 13:44:49 -07:00
Archie Pusaka
69d7d42e89 input: Disconnect ctrl chan only if intr chan was disconnected by us
If the intr channel was disconnected by the other party, then they
are also responsible to close the ctrl channel. Such disconnection
message would have the G_IO_ERR flag set, as opposed to it being
unset if the disconnection is initiated by us.

There doesn't seem to be an explicit rule in the specification
about this behavior, but this is enforced in the PTS qualification
tool.
2020-06-10 13:20:42 -07:00
Archie Pusaka
7155d7af19 input: disconnect intr channel before ctrl channel
According to bluetooth HID Profile spec Ver 1.0, section 7.2.2, A
host or device shall always complete the disconnection of the
interrupt channel before disconnecting the control channel.
However, the current implementation disconnects them both
simultaneously.

This patch postpone the disconnection of control channel to the
callback of interrupt watch, which shall be called upon receiving
interrupt channel disconnection response.
2020-06-10 13:20:40 -07:00
Luiz Augusto von Dentz
9dd6df753a adapter: Fix possible crash when stopping discovery
If the client disconnect/crash while MGMT_OP_STOP_DISCOVERY was pending
it would possibly cause a crash as the client pointer is passed to
mgmt_send and accessed in the callback after being freed.

To fix this the adapter itself is now passed to the callback so the
client is not accessed directly, instead the code now checks if
discovery_list has not been cleared in the meantime and only then
proceed to access the client pointer which is how
MGMT_OP_START_DISCOVERY is handled.
2020-06-10 13:20:39 -07:00
Luiz Augusto von Dentz
1b46f5410d adapter: Consolitate code for discovery reply
This consolidate code that were used to reply discovery commands in a
single function so it easier to reuse and maintain.
2020-06-10 13:20:37 -07:00
Luiz Augusto von Dentz
514191a75c adapter: Do not remove client watch directly if discovery fails
Client watch is used for both discovery and it filters so in case the
client has set the later the watch shall be perserved.
2020-06-10 13:20:34 -07:00
Luiz Augusto von Dentz
d6bc402840 a2dp: Use streaming mode when MPS is enabled
If MPS is enabled use L2CAP streaming mode for AVDTP channels.
2020-06-10 13:20:33 -07:00
Miao-chen Chou
79bd5951a8 doc: Describe the new Advertisement Monitor support
This describes the following commands and event.
- Read Advertisement Monitor Features command
- Add Advertisement Patterns Monitor command
- Remove Advertisement Monitor command
- Advertisement Monitor Added event
- Advertisement Monitor Removed event
Note that the content of a monitor can differ based on its type. For now we
introduce only pattern-based monitor, so you may find that unlike the
command of removing monitor(s), the Add command is tied to a specific type.
2020-06-10 20:01:15 +02:00
Inga Stotland
7bcb1086ab mesh: Add "node is busy" check for Leave() & Attach()
This introduces the following behavior change for those methods
on Network interface that specify node token as an input parameter

Leave() method:
If Leave method is called for a node that is being processed as a result
of a Create, Import, Join or Attach method calls in progress, node removal
is not allowed and org.bluez.mesh.Error.Busy error is returned.

Attach() method:
If Attach method is called for a node that is being processed as a result
of a Create, Import or Join method calls in progress, node attachment
is not allowed and org.bluez.mesh.Error.Busy error is returned.
2020-06-10 10:27:17 -07:00
Inga Stotland
4de95f9fbe mesh: Add timeout to GetManagedObjects call
Switch to using dbus_send_with_timeout when making a request
to get managed objects from an application.
2020-06-10 10:27:17 -07:00
Inga Stotland
65cdf6b22c mesh: Add destroy callback to dbus_send_with_timeout()
This adds a destroy callback as a function parameter to
dbus_send_with_timeout() to allow automatic release of user data
on either reply or timeout.
2020-06-10 10:27:17 -07:00
Inga Stotland
e5179f9fe5 mesh: Make "Busy" and "InProgress" to be distinct errors
This separates "Busy" and "InProgress" error codes:
MESH_ERROR_IN_PROGRESS maps to org.bluez.mesh.Error.InProgress
MESH_ERROR_BUSY maps to org.bluez.mesh.Error.Busy

Minor API change:
UpdateAppKey() returns "InProgress" error instead of "Busy"
2020-06-10 10:27:17 -07:00
Inga Stotland
29ab37c76a mesh: Delete unused function
This deletes unused function node_is_provisioned()
2020-06-10 10:27:16 -07:00
Marcel Holtmann
9ba75301d0 doc: Fix typo for Set Device Class command description 2020-06-10 19:21:57 +02:00
Marcel Holtmann
8a467cab33 doc: Add commands and event for handling device flags 2020-06-10 19:20:16 +02:00
Marcel Holtmann
fadc0fa6e8 doc: Add the event for default configuration changes 2020-06-10 16:11:18 +02:00