Commit Graph

14359 Commits

Author SHA1 Message Date
Johan Hedberg
a5ee04e208 TODO: Remove completed passive scanning entry 2013-01-31 13:44:41 -06:00
Johan Hedberg
a403509832 core: Stop passive scanning when removing last item from connect_list 2013-01-31 13:44:20 -06:00
Johan Hedberg
b6da4c4d2b core: Refactor passive scanning stopping into its own function 2013-01-31 13:43:53 -06:00
Johan Hedberg
a9d59605ab core: Fix missing check for main_opts.reverse_sdp 2013-01-31 11:49:57 -06:00
Johan Hedberg
bc1b7a48a0 core: Fix checking for correct async operation id 2013-01-31 11:39:08 -06:00
Johan Hedberg
41ec2bd31b core: Move SDP record fetching to NewConnection sending function 2013-01-31 11:32:14 -06:00
Johan Hedberg
b163de40b4 core: Do authorization and service resolving in parallel 2013-01-31 11:24:15 -06:00
Johan Hedberg
2f4004d1a3 core: Force discovery timer to run immediately if a profile needs it 2013-01-31 10:06:04 -06:00
Johan Hedberg
a180f3e6ae core: Fix SDP resolving for incoming external profile connections
This patch ensures that the reverse SDP procedure completes before we
accept incoming profiles for external profiles.
2013-01-31 10:05:30 -06:00
Johan Hedberg
5274e6fc50 core: Add device API for waiting for SDP completion 2013-01-31 10:05:30 -06:00
Johan Hedberg
160915cc33 core: Remove unnecessary assignment to device->svc_resolved
The device_svc_resolved() function already takes care of setting
device->svc_resolved to true.
2013-01-31 09:58:18 -06:00
Johan Hedberg
7ba85583ec TODO: Add item for improving stopping passive scanning 2013-01-31 09:06:49 -06:00
Johan Hedberg
fddc263b48 core: Fix updating discovery state when stopping passive scanning 2013-01-29 22:43:41 -06:00
Johan Hedberg
b8bdb1c191 core: Remove unnecessary adapter->passive_scanning variable
The adapter->discovery_list can function equally well as an indicator of
whether normal discovery or passive scanning is in progress. Normal
discovery always overrides passive scanning so if there's one or more
entries in discovery_list we must be performing normal discovery and not
passive scanning.
2013-01-29 19:29:46 -06:00
Johan Hedberg
dad9ef1d37 core: Make device_set_auto_connect private to device.c 2013-01-29 17:34:38 -06:00
Johan Hedberg
f5dabf1874 proximity: Remove unnecessary device_set_auto_connect call 2013-01-29 17:34:26 -06:00
Johan Hedberg
1c51e12199 input: Remove unnecessary device_set_auto_connect call 2013-01-29 17:34:13 -06:00
Johan Hedberg
965c65dbc9 core: Let device_set_auto_connect do connect list adding
The device_set_auto_connect function should be the only function that
needs to call adapter_connect_list_add().
2013-01-29 17:32:52 -06:00
Johan Hedberg
b26ebf2b8d core: Make device_get_auto_connect private to device.c 2013-01-29 17:14:44 -06:00
Johan Hedberg
905032851a core: Move connect_list handling to ATT specific callbacks
This is more reliable since we're not always guaranteed to get the right
mgmt events, e.g. a socket connect timeout might not trigger those.
2013-01-29 17:13:36 -06:00
Johan Hedberg
efc515d523 core: Allow adapter_connect_list_remove to trigger LE scanning 2013-01-29 17:12:56 -06:00
Johan Hedberg
35ac5407a7 core: Fix adapter->connect_le updating in connect_list_add/remove 2013-01-29 17:12:23 -06:00
Anderson Lizardo
4cc7c23afb core: Fix g_source_remove() with zero ID while removing device
store_device_info_cb() is also used as callback for g_idle_add() and
therefore sets device->store_id to zero. During device removal it may be
called manually, which must be done only after the existing
device->store_id is removed from mainloop.

Fix this GLib error (and a bunch of invalid read/writes when
store_device_info_cb() was called after device removal due to this bug):

bluetoothd[1192]: src/device.c:device_remove() Removing device
/org/bluez/hci0/dev_12_34_12_34_12_34

(bluetoothd:1192): GLib-CRITICAL **: g_source_remove: assertion `tag >
0' failed
bluetoothd[1192]: src/device.c:btd_device_unref() Freeing device
/org/bluez/hci0/dev_12_34_12_34_12_34
bluetoothd[1192]: src/device.c:device_free() 0x463a2a0
2013-01-29 15:59:13 -06:00
Vinicius Costa Gomes
e897eaaa9f gas: Fix not sending response to indication
Even if the remote device is not bonded, we should send the response to the
indication. If we don't the remote device may disconnect.
2013-01-29 15:58:06 -06:00
Vinicius Costa Gomes
eac1dfd0e6 gas: Move all the code to only one file
Our Generic Attribute/Access Service plugin is small and simple enough
to be kept in only one file.
2013-01-29 15:57:41 -06:00
Vinicius Costa Gomes
99f609241c device: Fix invalid memory access during Find Included
When doing the Find Included Services GATT procedure, the status of the ATT
procedure was being ignored, and in the case of a timeout it is possible to
crash bluetooth with an invalid memory access.

Valgrind log:

==1755== Invalid read of size 8
==1755==    at 0x46971A: find_included_cb (device.c:2964)
==1755==    by 0x4465AE: isd_unref (gatt.c:92)
==1755==    by 0x446885: find_included_cb (gatt.c:425)
==1755==    by 0x448266: disconnect_timeout (gattrib.c:269)
==1755==    by 0x4E76BCA: g_timeout_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76044: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76377: g_main_context_iterate.isra.24 (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76771: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x40A2EE: main (main.c:583)
==1755==  Address 0x69530a8 is 8 bytes inside a block of size 64 free'd
==1755==    at 0x4C2874F: free (vg_replace_malloc.c:446)
==1755==    by 0x40BFA6: service_filter (watch.c:486)
==1755==    by 0x40BC6A: message_filter (watch.c:554)
==1755==    by 0x5160A1D: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.2)
==1755==    by 0x40AAB7: message_dispatch (mainloop.c:76)
==1755==    by 0x4E76BCA: g_timeout_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76044: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76377: g_main_context_iterate.isra.24 (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76771: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x40A2EE: main (main.c:583)
==1755==
==1755== Invalid read of size 8
==1755==    at 0x4486D5: g_attrib_get_buffer (gattrib.c:657)
==1755==    by 0x4467C5: find_included (gatt.c:363)
==1755==    by 0x4465AE: isd_unref (gatt.c:92)
==1755==    by 0x446885: find_included_cb (gatt.c:425)
==1755==    by 0x448266: disconnect_timeout (gattrib.c:269)
==1755==    by 0x4E76BCA: g_timeout_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76044: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76377: g_main_context_iterate.isra.24 (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76771: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x40A2EE: main (main.c:583)
==1755==  Address 0x18 is not stack'd, malloc'd or (recently) free'd
==1755==
==1755==
==1755== Process terminating with default action of signal 11 (SIGSEGV)
==1755==  Access not within mapped region at address 0x18
==1755==    at 0x4486D5: g_attrib_get_buffer (gattrib.c:657)
==1755==    by 0x4467C5: find_included (gatt.c:363)
==1755==    by 0x4465AE: isd_unref (gatt.c:92)
==1755==    by 0x446885: find_included_cb (gatt.c:425)
==1755==    by 0x448266: disconnect_timeout (gattrib.c:269)
==1755==    by 0x4E76BCA: g_timeout_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76044: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76377: g_main_context_iterate.isra.24 (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x4E76771: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3400.2)
==1755==    by 0x40A2EE: main (main.c:583)
2013-01-29 15:57:36 -06:00
Szymon Janc
ee9c08452c neard: Fix memory leak on registering as agent
Message reference was not dropped in register_agent. This fix following
memory leak reported by valgrind:

454 (184 direct, 270 indirect) bytes in 1 blocks are definitely lost in loss record 207 of 220
   at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x513DCF2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514222E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5149F46: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514A070: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514AA63: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514B0A5: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5149E0C: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5134D24: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5136088: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5135643: dbus_connection_send_with_reply_and_block (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5130C93: dbus_bus_register (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)

102 bytes in 1 blocks are indirectly lost in loss record 154 of 220
   at 0x4C2B7B2: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x514F02F: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514F0DD: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514F239: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514DE0A: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514E3D3: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x513C138: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x513FF4D: dbus_message_iter_append_basic (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5141790: dbus_message_new_error (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5135C70: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x40A747: message_dispatch (mainloop.c:76)
   by 0x4E7A91A: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)

168 bytes in 1 blocks are indirectly lost in loss record 185 of 220
   at 0x4C2B7B2: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x514F02F: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514F0DD: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514F239: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x513A3B3: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514228F: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5149F46: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514A070: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514AA63: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x514B0A5: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5149E0C: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
   by 0x5134D24: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8)
2013-01-29 15:57:31 -06:00
Szymon Janc
e5b216061b neard: Fix passing negative error code to strerror
error_reply expects non-negative error code.
2013-01-29 15:57:27 -06:00
Johan Hedberg
83400b1009 core: Allow Device1.Connect/Disconnect to control auto connection
This patch makes it possible to disable the LE auto connections
temporarily through Device1.Disconnect and re-enable them by calling
Device1.Connect().
2013-01-29 15:57:09 -06:00
Johan Hedberg
b501a6fab7 core: Stop passive scanning before connecting LE
Many controllers do not support creating LE connections at the same time
as doing scanning so stop the scanning before attempting to connect.
2013-01-29 15:48:07 -06:00
Johan Hedberg
5d562e5777 core: Add device_get_auto_connect() function needed for LE connections 2013-01-29 15:03:07 -06:00
Johan Hedberg
352f3ad61d core: Add a variable to track passive scanning
This patch adds a state variable to track passive scanning and ensures
that LE connections are only created through this discovery procedure
and not the normal (StartDiscovery based) discovery procedure.
2013-01-29 11:10:37 -06:00
Luiz Augusto von Dentz
667cb4c469 attrib: Don't attempt to unregister event id 0
Id 0 is considered invalid so the code should not even try to lookup for
it in the event list instead print a warning and return FALSE
immediatelly.
2013-01-28 16:02:11 -06:00
Luiz Augusto von Dentz
9c410e37f4 thermometer: Fix crash while unregistering adapter
Invalid read of size 8
   at 0x448200: g_attrib_unregister (gattrib.c:722)
   by 0x440476: destroy_thermometer (thermometer.c:167)
   by 0x40D849: remove_interface (object.c:656)
   by 0x40DAA9: g_dbus_unregister_interface (object.c:1413)
   by 0x3DF7A63C9C: g_slist_foreach (gslist.c:894)
   by 0x469656: device_remove (device.c:2200)
   by 0x45CDC1: adapter_remove (adapter.c:3884)
   by 0x45F146: index_removed (adapter.c:5442)
   by 0x46BC17: received_data (mgmt.c:252)
   by 0x3DF7A47A74: g_main_context_dispatch (gmain.c:2715)
   by 0x3DF7A47DA7: g_main_context_iterate.isra.24 (gmain.c:3290)
   by 0x3DF7A481A1: g_main_loop_run (gmain.c:3484)
 Address 0x40 is not stack'd, malloc'd or (recently) free'd
2013-01-28 16:02:11 -06:00
Vinicius Costa Gomes
ad3ceb04a0 media: Fix not finding endpoints with different case UUIDs
When multiple Endpoints are registered with different case UUIDs,
the only UUIDs found were those with matching case.
2013-01-28 14:05:01 -06:00
Johan Hedberg
f924572fa1 core: Fix LE connections based on connect_list 2013-01-28 12:21:54 -06:00
Marcel Holtmann
d3a75b7e64 monitor: Add supported commands bit numbers 2013-01-28 16:24:39 +01:00
Luiz Augusto von Dentz
47bcbd6c56 media: Fix custom property registration for multiple adapters
The function btd_profile_add_custom_prop register a custom property for
an UUID which is valid for every adapter so its user_data cannot be tied
to a single adapter.

To fix this now NULL is passed as user_data and the callbacks checks if
the adapter passed has been registered and if there is an endpoint for
the UUID requested.
2013-01-27 18:02:04 -06:00
Luiz Augusto von Dentz
cd3f438989 AVCTP: Add destroy callback to avctp_register_browsing_pdu_handler
This adds a destroy callback which is called when the PDU handler is
destroyed.
2013-01-27 18:00:02 -06:00
Luiz Augusto von Dentz
53d3fc3fad AVCTP: Fix not destroying browsing channel if disconnected
If the browsing channel is disconnected it should be destroyed
immediatelly and set to NULL otherwise it will point to invalid channel.
2013-01-27 18:00:02 -06:00
Luiz Augusto von Dentz
958a00e73c AVRCP: Fix not handling commands while browsing is connecting
With introdution of browsing channel the .init callback is called when
browsing channel connection completes, but in the meantime the remote
device can send commands over control channel.

To fix this the init callaback of control and browsing channel are now
separated into .init_control and .init_browsing so the handler can be
register as soon the respective channel connection completes.
2013-01-27 18:00:02 -06:00
Johan Hedberg
546622fd9f tools: Add mixed UUIDs test case for mgmt_add_uuid 2013-01-27 19:08:44 +02:00
Johan Hedberg
ed9ee7da43 core: Allow adding all kinds of UUID for mgmt >= 1.3
Before 1.3 the kernel wouldn't handle 32 and 128 bit UUIDs properly but
from that revision onwards any type of UUID can be safely added and
removed through mgmt.
2013-01-27 10:52:23 -06:00
Johan Hedberg
8ad1f97f41 core: Add convenience macro for comparing mgmt versions 2013-01-27 10:52:23 -06:00
Johan Hedberg
a6bbc7617f emulator: Fix LE Read White List Size response variable naming 2013-01-27 05:09:49 -06:00
Marcel Holtmann
fbd7494672 unit: Add extracted UUID string list to each test case 2013-01-27 06:04:18 +01:00
Marcel Holtmann
9553437865 unit: Compare UUID list from EIR data 2013-01-27 06:04:11 +01:00
Marcel Holtmann
d00eeba33b unit: Print UUID list from EIR parsing in verbose mode 2013-01-27 05:36:49 +01:00
Marcel Holtmann
1939c1f2d5 unit: Add inquiry data from Nokia Reaction BH-907 headset for testing 2013-01-27 05:20:57 +01:00
Marcel Holtmann
45e206e859 unit: Include tests for TX power from EIR and AD 2013-01-27 05:20:16 +01:00