summaryrefslogtreecommitdiff
path: root/plugins/bluetooth.c
Commit message (Collapse)AuthorAgeFilesLines
* tethering: Reduce the number of parameters of tech_set_tetheringMichael Trimarchi2021-10-151-1/+0
| | | | | | connman_technology is an opaque type but has all the parameters to handle the connection. Those parameters are only used in wifi tethering one and not in other technologies
* bluetooth: Move DBG statement after initial checksDaniel Wagner2020-10-231-2/+2
| | | | | | | gcc complains with format-overflow for the DBG statement for the bridge argument. Let's move the DBG after the initial checks to avoid the complain and also make the output more helpful. If we see it in the log, the bridge has been created.
* bluetooth: Check for network in callbacksPatrik Flykt2017-03-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is an ongoing connect or disconnect when the system is suspended, the Bluetooth PAN device might be gone when the system resumes. This can cause the network being removed before the connect or disconnect callback is called. As the connect or disconnect callback do not re-check for an existing pan->network, a crash will happen as a NULL network is accessed. Fix this by verifying that pan->network exists when the callback is called. connmand[9153]: src/network.c:__connman_network_disconnect() network 0x563544e6ca30 connmand[9153]: plugins/bluetooth.c:bluetooth_pan_disconnect() network 0x563544e6ca30 connmand[9153]: src/network.c:connman_network_unref_debug() 0x563544e6ca30 name phone ref 3 by src/service.c:4687:service_free() connmand[9153]: src/ipconfig.c:__connman_ipconfig_unref_debug() 0x563544e58330 ref 0 by src/service.c:4697:service_free() connmand[9153]: src/ipconfig.c:__connman_ipconfig_disable() ipconfig 0x563544e58330 connmand[9153]: src/ipconfig.c:__connman_ipconfig_unref_debug() 0x563544e81fd0 ref 0 by src/service.c:4704:service_free() connmand[9153]: src/ipconfig.c:__connman_ipconfig_disable() ipconfig 0x563544e81fd0 connmand[9153]: plugins/bluetooth.c:bluetooth_pan_remove() network 0x563544e6ca30 pan 0x563544e580b0 connmand[9153]: plugins/bluetooth.c:pan_remove_nap() network 0x563544e6ca30 pan 0x563544e580b0 connmand[9153]: src/device.c:connman_device_remove_network() device 0x563544e630d0 network 0x563544e6ca30 connmand[9153]: src/device.c:free_network() network 0x563544e6ca30 connmand[9153]: src/network.c:network_remove() network 0x563544e6ca30 name phone connmand[9153]: plugins/bluetooth.c:bluetooth_pan_remove() network 0x563544e6ca30 pan (nil) connmand[9153]: src/network.c:connman_network_unref_debug() 0x563544e6ca30 name phone ref 2 by src/device.c:378:free_network() connmand[9153]: src/network.c:connman_network_unref_debug() 0x563544e6ca30 name phone ref 1 by plugins/bluetooth.c:160:pan_remove_nap() connmand[9153]: src/network.c:connman_network_unref_debug() 0x563544e6ca30 name phone ref 0 by src/device.c:378:free_network() connmand[9153]: src/network.c:network_destruct() network 0x563544e6ca30 name phone connmand[9153]: plugins/bluetooth.c:pan_connect_cb() network (nil) org.bluez.Error.Failed connmand[9153]: src/network.c:connman_network_set_associating() network (nil) associating 0 connmand[9153]: Aborting (signal 11) [src/connmand] connmand[9153]: ++++++++ backtrace ++++++++
* Bluetooth: Change state before disconnectingFrédéric Dalleau2016-09-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | When bluetooth PAN connection fails, ConnMan can start looping endlessly. This can happen when trying to connect to a device out of reach or when trying to reconnect just after disconnect. The debug output will look like the following: plugins/bluetooth.c:bluetooth_pan_disconnect() network 0xfb8510 plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510 org.bluez.Error.NotConnected plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510 src/network.c:connman_network_set_connected() network 0xfb8510 connected 0/0 connecting 0 associating 1 src/network.c:connman_network_set_error() network 0xfb8510 error 4 src/service.c:__connman_service_indicate_error() service 0xfb88e0 error 4 src/network.c:__connman_network_disconnect() network 0xfb8510 plugins/bluetooth.c:bluetooth_pan_disconnect() network 0xfb8510 plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510 org.bluez.Error.NotConnected ... Fix this by setting network associating to false in the bluetooth plugin.
* bluetooth: Change function return value to booleanRavi Prasad RK2016-04-131-1/+1
|
* bluetooth: Fix Memory LeakNiraj Kumar Goit2016-01-281-2/+6
| | | | Tethering struct is allocated memory but not freed in case of error.
* bluetooth: Fix crash when adapter is NULLHarish Jenny K N2015-11-251-2/+7
| | | | | | | | | | | | | | | | | This fixes a crash in pan_create_nap function when proxy_get_string returns NULL for "Adapter". The Backtrace: update_properties ->add_property -->pan_create_nap --->g_hash_table_lookup ---->g_str_hash R0: 00000000 indicating NULL is passed to g_str_hash This patch handles the crash by adding NULL check before passing it to g_hash_table_lookup.
* bluetooth: Clean up gdbus client on exitHannu Mallat2015-01-211-0/+2
| | | | | | Gdbus client for BlueZ was created on plugin initialization, but not cleaned up on plugin exit. Fixed by adding a g_dbus_client_unref() to bluetooth_exit().
* bluetooth: Fix bluetooth plugin returning error on technology_setDavid Lechner2015-01-211-1/+1
| | | | | | | | | | | | | | The technology_set implementation in the bluetooth plugin returns -EINPROGRESS which causes problems. 1. When setting the Tethering property via D-Bus, D-Bus returns an error instead of completing successfuly. 2. When using the PersistentTetheringMode option, bluetooth tethering is not remembered. This is because /var/lib/connman/settings is not updated if technology_set returns an error. This fixes the issue by returning 0 when bluetooth_tech_set_tethering completes successfully.
* Fix crash when role is NULL.David Lechner2014-11-101-5/+7
| | | | | | This fixes a crash that was introduced in commit 6f6927236fc35429eecb1b1459ea5e20ab667db8. It is possible for the role to be NULL, which caused a crash in strcmp.
* Fix preferred bluetooth role matching.David Lechner2014-11-101-8/+9
| | | | | | | | | This fixes an error in the proxy_get_role fuction in commit 6f6927236fc35429eecb1b1459ea5e20ab667db8. The comment was correct as to what we want to accomplish here, however the programming logic did not match what the comment says. Now it correctly returns the most preferred role instead of just the first matching role.
* Support connecting to bluetooth GN and PANU rolesDavid Lechner2014-11-031-18/+34
| | | | | | | | | | | | Bluetooth PAN specifies three different roles for different types of network connections, PANU, NAP and GN. ConnMan currently supports NAP but ignores the other roles. This patch adds support for the GN and PANU roles so that we can connect to devices that don't offer NAP. In the case that a device provides more than one role, we prefer NAP over GN and GN over PANU. ConnMan will only use the most preferred role and ignore the others so that we don't have duplicate services in ConnMan.
* bluetooth: Create and remove PAN networks also on adapter changePatrik Flykt2014-03-271-32/+47
| | | | | | | | | | | | | | | | Once a Bluetooth adapter changes its Powered property, PAN networks need to be created or removed. Factor out device and PAN creation and removal in order to call it when the adapter changes in addition to the normal device enabling and disabling. PAN network creation and removal on adapter change needs to be done explicitely as the Bluetooth adapter has already changed state and thus the bluetooth plugin will not make a D-Bus call to Bluez nor will the callback be called where PAN network enabling and disabling was happening. Thanks to Krzysztof Wilk for reporting and pointing out the issue and for the initial quick test of this fix.
* bluetooth: Do not derefernce NULL pointerDaniel Wagner2014-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When hypernating following can happen: systemd[1]: Service bluetooth.target is not needed anymore. Stopping. systemd[1]: Stopping Bluetooth. systemd[1]: Stopped target Bluetooth. systemd-sleep[10271]: System resumed. systemd[1]: Starting Bluetooth. systemd[1]: Reached target Bluetooth. ConnMan receives the D-Bus messages that the Network objects are gone (during the resume phase): connmand[13571]: plugins/bluetooth.c:object_removed() org.bluez.Network1 /org/bluez/hci0/dev_98_0D_2E_54_B7_50 connmand[13571]: plugins/bluetooth.c:pan_remove_nap() network 0xccfe30 pan 0xccfd50 This sequence sets pan->network to NULL. Then the we get the D-Bus message that the device have gone too: connmand[13571]: Aborting (signal 11) [/usr/sbin/connmand] connmand[13571]: ++++++++ backtrace ++++++++ connmand[13571]: #0 0x3bbec35cb0 in /lib64/libc.so.6 connmand[13571]: #1 0x44b4be in connman_network_get_device() at ome/wagi/src/connman/src/network.c:2052 connmand[13571]: #2 0x4301e3 in device_disable_cb() at ome/wagi/src/connman/plugins/bluetooth.c:554 connmand[13571]: #3 0x4a3709 in set_property_reply() at ome/wagi/src/connman/gdbus/client.c:657 connmand[13571]: #4 0x3bca40cad2 in /lib64/libdbus-1.so.3 connmand[13571]: #5 0x3bca40fdc1 in /lib64/libdbus-1.so.3 connmand[13571]: #6 0x49ce5f in message_dispatch() at ome/wagi/src/connman/gdbus/mainloop.c:72 (discriminator 1) connmand[13571]: #7 0x3bc0c492a6 in /lib64/libglib-2.0.so.0 connmand[13571]: #8 0x3bc0c49628 in /lib64/libglib-2.0.so.0 connmand[13571]: #9 0x3bc0c49a3a in /lib64/libglib-2.0.so.0 connmand[13571]: #10 0x4435a2 in main() at ome/wagi/src/connman/src/main.c:695 connmand[13571]: #11 0x3bbec21d65 in /lib64/libc.so.6 connmand[13571]: +++++++++++++++++++++++++++ device_disable_cb() blindly passes a NULL pointer to connman_network_get_device().
* bluetooth: Fix failure when enabling Bluez 5.x adapterZhang zhengguang2013-12-171-7/+2
| | | | | | | | | | | | | | | | | | | | | | | Root cause: When ConnMan tries to enable bluetooth technology, first it will send RFkill unblock event to kernel, then call dbus method to enable bluetooth device. When bluez receives the RFkill event, it will power on the device immediately, and sends PropertyChanged message to ConnMan. In ConnMan, the device powered state is updated in device enable dbus reply callback function, but ConnMan receives PropertyChanged message before device enable dbus reply. In current ConnMan Bluez 5.x bluetooth plugin, when handling PropertyChanged message, it finds the adapter state(enabled) is different with the device state ConnMan stores(disabled), it will disable the bluetooth device. Solution: In ConnMan bluetooth plugin for Bluez 5.x, when ConnMan finds the adapter state is different with the device state ConnMan stores, update device state in ConnMan to the adapter state.
* bluetooth: Do not turn off hci device when ConnMan stopsJukka Rissanen2013-11-211-0/+6
| | | | | We only disconnect PAN connections when ConnMan stops and leave other BT connections running.
* bluetooth: Leading whitespace fixPatrik Flykt2013-09-021-2/+2
|
* bluetooth: Use dbus_bool_t when accessing a D-Bus booleanPatrik Flykt2013-09-021-1/+4
|
* plugins: Do not compare expression against NULLDaniel Wagner2013-08-071-37/+37
| | | | | | | | | | | | | | | | This patch generate via coccinelle with: @ disable is_null,isnt_null1 @ expression E; @@ ( - E == NULL + !E | - E != NULL + E )
* bluetooth: Check pointer for null before passing to strcmp()Jukka Rissanen2013-08-061-0/+10
|
* bluetooth: Address pointer might be null when creating napJukka Rissanen2013-08-061-0/+5
| | | | Check pointer for null before dereferencing it.
* plugins: Whitespace cleanupDaniel Wagner2013-07-231-4/+8
| | | | | The coccinelle patch introduces some whitespace violiacense. Fix up most errors and warnings reported by checkpatch.
* plugins: Convert to stdbool with coccinelleDaniel Wagner2013-07-231-60/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is completely generated by set of coccille rules and containts zero manual changes. The rule set is not really beautiful but it does the job. We might miss a few conversions but there should be none accidently wrong converted bool here. The rules are as following: //// Do not compare boolean expressions @@ expression E; symbol TRUE; symbol FALSE; @@ ( E - == TRUE | - TRUE == E + E | - E != TRUE + !E | - TRUE != E + !E | - E == FALSE + !E | - FALSE == E + !E | E - != FALSE | - FALSE != E + E ) //// Convert connman_bool_t to stdbool @@ connman_bool_t x; @@ x = ( - TRUE + true | - FALSE + false ) @@ identifier f; @@ connman_bool_t f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ connman_bool_t f(...) { <... - return FALSE; + return false; ...> } @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, connman_bool_t i, ...) { ... } @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, connman_bool_t i, ...); @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @@ typedef bool; @@ - connman_bool_t + bool //// Convert gboolean to stdbool @@ gboolean x; @@ x = ( - TRUE + true | - FALSE + false ) // Figure out which function signature will to be fixed... // when we have the defitition @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, gboolean i, ...) { ... } // ... and now convert all call sites @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // Figure out which function signature will to be fixed... // when we have the declaration only @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, gboolean i, ...); // ... and now convert all call sites @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // A handfull of the GLib hooks we can't change. Let's remember // all ther positions. // 1. timeouts @k1@ identifier f; position p; typedef gpointer; identifier ptr; @@ static gboolean@p f(gpointer ptr); @k2@ identifier f; position p; identifier ptr; @@ static gboolean@p f(gpointer ptr) { ... } // hash map iterator functions @k3@ identifier f; position p; identifier p1, p2, p3; @@ static gboolean@p f(gpointer p1, gpointer p2, gpointer p3) { ... } // 2. GIOChannel @k4@ identifier f; position p; typedef GIOChannel, GIOCondition; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr); @k5@ identifier f; position p; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr) { ... } // 3. GSourceFuncs @k6@ identifier f; position p; typedef GSource; identifier src; @@ static gboolean@p f(GSource *src, ...) { ... } // gdbus functions @k7@ identifier f; position p; typedef DBusConnection; identifier con; @@ static gboolean@p f(DBusConnection *con, ...) { ... } // Now convert all gboolean which are are not used for interactin // with GLib // Note here happens the magic! @@ typedef bool; position p != {k1.p,k2.p,k3.p,k4.p,k5.p,k6.p,k7.p}; @@ - gboolean@p + bool // Update all return types @@ identifier f; @@ bool f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ bool f(...) { <... - return FALSE; + return false; ...> } //// Last last rule is to fixup all missed call sites. In theory we should //// fixed them with some rules above but somehow coccinelle does not //// match. @@ identifier f =~ "^(__)?connman_.*" ; @@ f(..., ( - FALSE + false | - TRUE + true ) ,...)
* plugins: Use dbus_bool_t with D-Bus functionsDaniel Wagner2013-07-231-3/+3
| | | | | | | When we start using stdbool, the size of the stdbool does not match with dbus_bool_t which is important. Therefore fix all places where we use currently connman_bool_t instead of dbus_bool_t to access D-Bus layer.
* bluetooth: Implement tethering for the Bluez 5 bluetooth pluginPatrik Flykt2013-01-301-0/+117
|
* bluetooth: Connect and disconnect a PAN NAP networkPatrik Flykt2013-01-301-5/+137
| | | | | | Implement connect and disconnect functionality for a ConnMan network. On network creation check the connection status of the Bluez 5 Network1 object and set the network to connected when needed.
* bluetooth: Expose Bluez 5 org.bluez.Network1 objects as networksPatrik Flykt2013-01-301-4/+133
| | | | | | | | | | Create ConnMan networks for those Bluez 5 org.bluez.Network1/Device1 objects that support PAN NAP. A network is created or removed in response to the Network1/Device1 being created or when the Device1 object's UUID changed. The ConnMan network struct is added to and removed from the ConnMan device when the device is created, enabled or disabled.
* bluetooth: Keep track of Bluez 5 org.bluez.Network1 objectsPatrik Flykt2013-01-301-0/+172
| | | | | | | Set up functions monitoring Bluez 5 org.bluez.Network1 objects being added and removed. Add a GDBusProxy for the org.bluez.Device1 object that corresponds to the Network1 object. Set up functions monitoring Network1 'Connected' and Device1 'UUID' properties.
* bluetooth: Expose Bluez 5 adapters as ConnMan devicesPatrik Flykt2013-01-301-0/+308
| | | | | | | | | | Set up functions monitoring Bluez 5 objects being added and removed using GDBusProxy. When an adapter appears, create a new device for it and set up a watch function for the adapter's 'Powered' property. Keep the adapter 'Powered' property in sync with the device state and if they differ reset the adapter to the device state. Also update the Bluez 5 adapter 'Powered' property when the device is enabled or disabled.
* bluetooth: Register technology driverPatrik Flykt2013-01-301-1/+31
|
* bluetooth: Add new bluetooth pluginPatrik Flykt2013-01-301-0/+49
|
* bluetooth: Rename bluetooth plugin to bluetooth_legacyPatrik Flykt2013-01-301-1350/+0
| | | | | | Set the plugin priority to CONNMAN_PLUGIN_PRIORITY_LOW and the technology priority to -10. Update strings to "bluetooth_legacy" and use ordinary string instead of ident.
* Use g_slist_prepend() where appropriatePatrik Flykt2012-09-041-1/+1
| | | | | | Convert usage of g_slist_append() to g_slist_prepend() where appropriate. gdbus, dnsproxy, resolver, rtnl, session and session unit test have ordering requirements and thus not touched.
* bluetooth: Add the device into hash table when relevantTomasz Bursztyka2012-08-161-2/+2
| | | | Fixes BMC#25215
* bluetooth: Defer add_networks() if adapter is not powered yetDaniel Wagner2012-08-141-3/+63
| | | | | | | | | | | In the case we add a new adapter and the adapter is powered off we would ignore the reported devices. Later when the adapter was powered on it would just not add those networks. Instead silently ignoring the devices, store the D-Bus paths in a hash table and process them as soon the adapter is powered. Fixes BMC#25322
* bluetooth: Remove unused argument in check_networks()Daniel Wagner2012-08-141-4/+3
|
* bluetooth: Remove unused argument in add_network()Daniel Wagner2012-08-141-3/+3
|
* bluetooth: Add device to hash before registrationGustavo Padovan2012-08-101-2/+3
| | | | | | | | | | | | | During the connman_device_register() procedure a lookup to the bluetooth_devices hash table happens, however the device is not on the hash at this point and the look out fails. If the registration fails, technology_disable() returns the Failed message on D-Bus with the error status zero. That happens because we don't have any device registered. This patch moves the insertion of the device to before the device registration.
* plugins: Avoid shadowing connection variableMarcel Holtmann2012-07-151-18/+18
|
* bluetooth: Watch for signals only on BLUEZ_SERVICELucas De Marchi2012-06-301-8/+9
|
* bluetooth: Check ownership of deviceDaniel Wagner2012-06-041-1/+16
| | | | | We have two drivers for the CONNMAN_DEVICE_TYPE_BLUETOOTH and therefore check owner ship in probe function.
* plugins: Update copyright informationMarcel Holtmann2012-04-291-1/+1
|
* bluetooth: use g_hash_table_replace instead of insert functionTomasz Bursztyka2012-04-171-1/+1
|
* bluetooth: Cleanup if technology driver register failsDaniel Wagner2011-11-101-1/+1
|
* bluetooth: Fix remove device/networkDaniel Wagner2011-07-261-0/+35
|
* bluetooth: Unref network objectsDaniel Wagner2011-07-261-3/+15
| | | | | The bluetooth plugin creates the network object therefore it should also unref (destroy) it.
* device: Change signature of connman_device_remove_network()Daniel Wagner2011-07-261-4/+2
|
* network: Remove connman_network_register/unregister()Daniel Wagner2011-07-261-3/+0
| | | | | | | | Since the service object doesn't take a reference the intermediate step of having a connman_network_register/unregister is not needed. This function are only there to have an additional step where probe()/remove() will be called. This is the job of connman_device_add_network()/connman_device_remove_network().
* element: Remove network codeDaniel Wagner2011-06-161-0/+3
|
* bluetooth: Set service state to IDLE when PAN connection failsSamuel Ortiz2011-03-031-4/+13
|