summaryrefslogtreecommitdiff
path: root/src/service.c
Commit message (Collapse)AuthorAgeFilesLines
* service: Add initiator argument to service_acceptLuiz Augusto von Dentz2022-05-121-1/+3
| | | | | | This adds initiator argument to service_accept so profiles accepting the connection can use btd_service_is_initiator to determine if the connection was initiated locally (central) or remotely (peripheral).
* service: Add btd_service_is_initiatorLuiz Augusto von Dentz2021-09-171-0/+10
| | | | | | | | Since BTD_SERVICE_STATE_CONNECTING is being used for both initiator and responder case it is no longer possible to use the state distint when the service connection was initiated locally or not, so to fix this a new flag is introduce to track when btd_service_connect has been called.
* core: add is_allowed property in btd_serviceYun-Hao Chung2021-08-041-0/+33
| | | | | | | | This adds is_allowed property in btd_service. When is_allowed is set to false, calling btd_service_connect and service_accept will fail and the existing service connection gets disconnected. Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
* service: add adapter powered check before connectingArchie Pusaka2020-11-051-0/+3
| | | | | | When policy_connect() is called, there might be a case where the power is just turned off, hence the adapter is down. Add a check in btd_service_connect to detect such condition.
* src: Add SPDX License IdentifierTedd Ho-Jeong An2020-09-211-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds SPDX License Identifier and removes the license text. ------------------------------------- License COUNT ------------------------------------- LGPL-2.1-or-later : 62 GPL-2.0-or-later : 51 BSD-2-Clause : 2 License: LGPL-2.1-or-later src/adv_monitor.c src/adv_monitor.h src/shared/mainloop-glib.c src/shared/btp.c src/shared/tester.c src/shared/btsnoop.c src/shared/gatt-helpers.h src/shared/log.h src/shared/util.h src/shared/mainloop-ell.c src/shared/hci-crypto.c src/shared/mainloop.c src/shared/hfp.h src/shared/mainloop-notify.c src/shared/io-mainloop.c src/shared/btsnoop.h src/shared/uhid.h src/shared/util.c src/shared/ringbuf.c src/shared/btp.h src/shared/shell.h src/shared/io-glib.c src/shared/queue.h src/shared/gatt-server.h src/shared/crypto.c src/shared/crypto.h src/shared/io-ell.c src/shared/timeout-glib.c src/shared/mgmt.c src/shared/gatt-db.c src/shared/mainloop-notify.h src/shared/hfp.c src/shared/timeout-ell.c src/shared/shell.c src/shared/hci.c src/shared/log.c src/shared/ringbuf.h src/shared/gatt-helpers.c src/shared/queue.c src/shared/tty.h src/shared/timeout-mainloop.c src/shared/tester.h src/shared/gap.h src/shared/mgmt.h src/shared/gatt-db.h src/shared/uhid.c src/shared/mainloop.h src/shared/timeout.h src/shared/att-types.h src/shared/pcap.c src/shared/gap.c src/shared/att.c src/shared/pcap.h src/shared/hci.h src/shared/gatt-client.h src/shared/io.h src/shared/gatt-client.c src/shared/ad.c src/shared/att.h src/shared/gatt-server.c src/shared/hci-crypto.h src/shared/ad.h License: GPL-2.0-or-later src/attrib-server.h src/advertising.h src/textfile.c src/attrib-server.c src/uinput.h src/log.h src/eir.h src/sdpd.h src/sdpd-request.c src/service.h src/sdpd-database.c src/adapter.h src/plugin.h src/uuid-helper.h src/plugin.c src/main.c src/sdp-xml.c src/error.h src/oui.c src/device.c src/agent.h src/sdp-client.c src/oui.h src/device.h src/gatt-database.c src/error.c src/backtrace.c src/sdpd-server.c src/adapter.c src/log.c src/agent.c src/backtrace.h src/sdp-xml.h src/hcid.h src/dbus-common.h src/uuid-helper.c src/storage.c src/profile.c src/advertising.c src/storage.h src/dbus-common.c src/profile.h src/sdpd-service.c src/eir.c src/sdp-client.h src/gatt-database.h src/gatt-client.h src/rfkill.c src/gatt-client.c src/service.c src/textfile.h License: BSD-2-Clause src/shared/ecc.h src/shared/ecc.c
* device: Fix reply of DisconnectProfilePali Rohár2020-04-281-1/+2
| | | | | | When DisconnectProfile is called with disconnected UUID, bluetooth daemon often returned error "Operation already in progress". This change fixed it and no error message is returned for this case.
* service: Remove unnecessary btd_assertLuiz Augusto von Dentz2017-11-241-1/+0
| | | | | | btd_service_set_user_data shall be allowed to be called when the state is unavailable since device_probe is called with that state the callback attempt to set its user_data.
* core/profile: Fix calling service_acceptLuiz Augusto von Dentz2016-10-241-0/+19
| | | | | | service_accept shall only be used with profiles that implement .accept callback, to set connecting state directly use service_set_connecting which does not require .accept to be implemented.
* core/service: Fix setting wrong state after calling acceptLuiz Augusto von Dentz2016-09-081-1/+2
| | | | | | The accept calback may transit the state to connected on the call itself since most of the time it is just a matter of selecting the attributes in case of GATT profiles.
* core/service: Fix setting connecting stateLuiz Augusto von Dentz2016-08-091-1/+1
| | | | | | | If the profile don't implement .accept callback it means it cannot connect in this mode, which is normally used for GATT profiles, so the code shall not assume the service will start connecting and instead just return an error.
* core/service: Allow disconnected -> connected state changeMiroslav Koskar2016-06-131-1/+2
| | | | | | | | | | By ignoring case where service->state == BTD_SERVICE_STATE_DISCONNECTED in btd_service_connecting_complete(), state_callbacks don't get executed. Such case occurs when e.g., phone using a2dp-source profile connects to the bluez. Because no state_callbacks are executed (including one added by policy plugin) no reconnection is attempted after connection timeout, although if situation is reversed (bluez connects to the phone) reconnection works.
* core: Fix replying with an error for connected profileLuiz Augusto von Dentz2015-11-231-0/+1
| | | | | If the profile(s) is already connected don't reply with an error, if the profile is in fact connecting already just wait until it completes.
* core: Use local assert function where possibleMarcel Holtmann2015-11-081-5/+5
|
* core/service: Fix failing to connect external profileLuiz Augusto von Dentz2015-11-021-1/+1
| | | | | | | | When initiating a connection to a external profile btd_service_connect will be called which will change the service state to BTD_SERVICE_STATE_CONNECTING but then once the connection completes service_accept is called but since it now checks the state it would return -EALREADY to prevent driver accept to be called more than once.
* core/service: Fix calling driver .accept multiple timesLuiz Augusto von Dentz2015-10-261-0/+12
| | | | service_accept shall not call driver .accept callback multiple times.
* src/profile: Set service to connecting in ext_connectHsin-Yu Chao2015-04-271-4/+7
| | | | | | | | | | | | | | | | | | | For the profile connection initiated by remote device, ext_connect() function is triggered without advance the state of device's service to BTD_SERVICE_STATE_CONNECTING. This is causing a problems when the later 'NewConnection' dbus method call is made to registered application. If the remote device gets disconnected during the period of time waiting for the reply of 'NewConnection' method, the btd_service_disconnect() call will fail at the service state check and never handle the profile disconnection due to that state was incorrectly left as BTD_SERVICE_STATE_DISCONNECTED. Fix the problem by use service_accept() call in ext_connect() to assure the service state has changed. Also modify the logic of service state check in btd_service_connecting_complete() to prevent the problem when the 'NewConnect' reply changes service state to BTD_SERVICE_STATE_CONNECTED while the device has already disconnected before it arrives.
* core: Use local libbluetooth includesMarcel Holtmann2015-02-281-2/+3
|
* core: Fix crash on device removalLuiz Augusto von Dentz2015-02-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following crash happen when attempting to remove a device while it is connecting, this will turn all services to unavailable without first setting it to disconnected causing the backtrace: Invalid read of size 8 at 0x495BF8: btd_service_connect (service.c:200) by 0x49D942: connect_next.isra.7 (device.c:1283) by 0x4A2B82: device_profile_connected (device.c:1328) by 0x4A2B82: service_state_changed (device.c:5325) by 0x4957A9: change_state (service.c:108) by 0x495AF4: service_remove (service.c:173) by 0x4A4BD9: device_remove (device.c:3207) by 0x48AAC1: btd_adapter_remove_device (adapter.c:1135) by 0x48B536: remove_device (adapter.c:2270) by 0x4BF4CB: process_message.isra.3 (object.c:259) by 0x4BFD12: generic_message (object.c:1070) by 0x518C5CE: ??? (in /usr/lib64/libdbus-1.so.3.8.10) by 0x517E193: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.8.10) Address 0x7a22e60 is 16 bytes inside a block of size 40 free'd at 0x4C2ACE9: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E847FE: g_free (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x495988: btd_service_unref (service.c:130) by 0x495B26: service_remove (service.c:177) by 0x4A4BD9: device_remove (device.c:3207) by 0x48AAC1: btd_adapter_remove_device (adapter.c:1135) by 0x48B536: remove_device (adapter.c:2270) by 0x4BF4CB: process_message.isra.3 (object.c:259) by 0x4BFD12: generic_message (object.c:1070) by 0x518C5CE: ??? (in /usr/lib64/libdbus-1.so.3.8.10) by 0x517E193: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.8.10) by 0x4BA45F: message_dispatch (mainloop.c:72)
* core/service: Remove GATT handle logicArman Uguray2015-01-161-38/+0
| | | | | This patch reverts the recent addition of GATT service handles to btd_service.
* core: profile: Add accept functionArman Uguray2014-12-171-0/+18
| | | | | | | | | This patch introduces the "accept" function to btd_profile. The purpose of this function is to notify a profile when a btd_service is ready to interact with and will be called by btd_device when a bt_gatt_client becomes ready (MTU exchange and discovery has been completed). This is initially meant to be optional for non-GATT based profiles but could be generalized for them in the future.
* core: service: Add start & end handle fieldsArman Uguray2014-12-171-0/+38
| | | | | | | | | | When GATT services are discovered, added, and removed, profiles will be notified using btd_profile device_probe and device_remove functions. Since a single profile may handle multiple services from the same device, it is useful to distinguish each btd_service by its service handle range. This patch adds the start_handle and end_handle fields to btd_service and an accessor for getting them, which reports failure if the service was initialized without handles.
* core: Do not change service state in btd_service_connect if it failsLuiz Augusto von Dentz2013-11-141-5/+3
| | | | | | If .connect fails and the service state changes it may re-enter connect_next, inverting the order and messing up the error of each connect request.
* core/service: Rename service_shutdown to service_removeLuiz Augusto von Dentz2013-07-101-1/+2
| | | | | | This rename service_shutdown to service_remove to make it more similar to other internal APIs such as device_remove which only do object cleanup/free and do not have any disconnect logic.
* core: Fix not been able to cancel Device.Connect with Device.DisconnectLuiz Augusto von Dentz2013-06-111-0/+5
| | | | | Device.Disconnect should be able to interrupt the connection attempt started by Device.Connect.
* core: Get rid of gintLucas De Marchi2013-05-011-1/+1
| | | | | Use plain int instead of gint. In glib gint is always a typedef to int, so it's safe to use it even for callbacks with glib.
* profile: Use btd_service for connect/disconnectMikel Astiz2013-04-261-2/+2
| | | | | | | | | | | | | | Change the btd_profile connect/disconnect callbacks to receive a btd_service pointer. This should make it possible to handle multiple instances of the same profile in a specific device. The patch strongly influences how the profiles should interact with the core. The state transitions, previously reported using the device.h API (device_profile_connected() and device_profile_disconnected()), have now been replaced by the btd_service API. The transitions will then be propagated to device.c by means of the conventional state-changed callback mechanism.
* service: Add callbacks to track state changesMikel Astiz2013-04-261-0/+47
| | | | Extend the btd_service API to support state observers.
* service: Add error-code btd_serviceMikel Astiz2013-04-261-0/+7
| | | | | The error-code represents the result of a connection/disconnection procedure and can be useful when a state transition is detected.
* core: Add user_data to btd_serviceMikel Astiz2013-04-261-0/+12
| | | | | Profile implementations can benefit from a user_data associated to a service, which will typically be set during probe.
* profile: Use btd_service for probing profilesMikel Astiz2013-04-261-2/+2
| | | | | | | | | | | | | | Change the profile probe mechanism in order to pass the btd_service instance representing the remote service. This object is bound to a btd_profile and a btd_device, thus replacing the previous parameters. The probe callback is allowed to hold a reference to the btd_service by means of btd_service_ref(), which should be unreferenced during removal. Keeping such a reference of the btd_service allows supporting multiple instances of the same UUID, since the reference can serve as a handle during the interactions between the profile implementation and the core.
* core: Add a state enum to btd_serviceMikel Astiz2013-04-261-1/+106
| | | | | Add a state to btd_service in order to distinguish which operations are allowed in a certain point in time.
* core: Add connect/disconnect API to btd_serviceMikel Astiz2013-04-261-0/+40
| | | | | Make use of the btd_profile connect/disconnect callbacks directly within service.c instead of doing it inside device.c.
* core: Add probe API to btd_serviceMikel Astiz2013-04-261-0/+22
| | | | | Make use of the btd_profile callbacks directly within service.c instead of doing it inside device.c.
* core: Add btd_service to represent device servicesMikel Astiz2013-04-261-0/+102
Add a new object to centralize all data corresponding to a service provided by a remote device, coupling a pair of btd_profile and btd_device pointers.