Commit Graph

14346 Commits

Author SHA1 Message Date
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
Marcel Holtmann
a2dc0a4d57 core: Parse the TX power level from EIR data 2013-01-27 05:18:16 +01:00
João Paulo Rechi Vita
bd416e95d5 avctp: Handle Vol Up/Down operations
The AVRCP spec mandates to support 'volume up' and 'volume down'
operations when claiming support for Category 2 TG.
2013-01-27 01:03:19 +02:00
Johan Hedberg
c491db263f emulator: Add support for LE Read White List Size command 2013-01-26 19:14:35 +02:00
Johan Hedberg
9551f312c1 tools: Add mgmt_set_le test cases 2013-01-26 19:06:58 +02:00
Johan Hedberg
ea9dcf75a0 tools: Add mgmt_set_ssp test cases 2013-01-26 18:55:14 +02:00
Johan Hedberg
6586030489 tools: Rename setup_ssp to match its true function 2013-01-26 18:47:39 +02:00
Johan Hedberg
dcfedc3dc3 tools: Add another mgmt_set_link_security success test case 2013-01-26 18:12:09 +02:00
Johan Hedberg
4f514c0237 tools: Add basic mgmt_set_link_security(off) test cases 2013-01-26 18:12:09 +02:00
Johan Hedberg
64e3b99df3 tools: Fix mgmt-tester setup function logs 2013-01-26 18:12:08 +02:00
Johan Hedberg
9ba5514c95 tools: Add basic set connectable off test cases 2013-01-26 18:12:08 +02:00
Johan Hedberg
a4ad707f10 tools: Add invalid params test cases for mgmt_set_powered(off) 2013-01-26 18:12:08 +02:00
Johan Hedberg
18dbb638b1 tools: Add mgmt_read_version success test case 2013-01-26 18:12:08 +02:00
Vinicius Costa Gomes
20160ae61b adapter: Fix not removing a device when the adapter is down
It is a documented error that MGMT_UNPAIR_DEVICE should return an error
if the controller is not powered.

This error is being ignored, and if the user asks for a device to be
removed while the controller is powered down, the keys associated with
that device will still be in the kernel side.

The solution is to return the user an error when it is asked to remove a
device and the controller is not powered.
2013-01-25 18:30:15 +02:00