Commit Graph

549 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
cfab569484 build: Replace use of g_memdup with util_memdup
This replaces the uses of g_memdup with util_memdup since the former has
been deprecated:

  warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead
  [-Wdeprecated-declarations]

g_memdup2 requires bumping glib version which would likely have its
own problems thus why util_memdup was introduced.
2022-01-06 12:58:39 -08:00
Luiz Augusto von Dentz
3a53b27e4d attrib: Remove gatt-service.{c,h} and attrib-server.{c,h}
These files are not longer needed since this functionality has been
moved to gatt-db.{c,h}.
2022-01-06 12:55:12 -08:00
Luiz Augusto von Dentz
401643e5c5 gattrib: Fix passing NULL to memcpy
This fixes the following runtime error:

  attrib/gattrib.c:198:2: runtime error: null pointer passed as
  argument 2, which is declared to never be null
2021-12-23 11:47:03 -08:00
Luiz Augusto von Dentz
ac2c2e10b3 attrib: Make use of bt_att_resend
If the id != 0 that means that a proceedure that needs multiple PDUs is
in progress so use bt_att_resend with its id that way the bt_att id and
gattrib shall always be the same.
2021-10-06 14:36:50 -07:00
Tedd Ho-Jeong An
4284184d00 attrib: Add SPDX License Identifier
This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     13

License: GPL-2.0-or-later
   attrib/att-database.h
   attrib/gattrib.h
   attrib/gatttool.h
   attrib/gatt-service.c
   attrib/interactive.c
   attrib/utils.c
   attrib/gatt.c
   attrib/gattrib.c
   attrib/gatt-service.h
   attrib/att.c
   attrib/gatt.h
   attrib/att.h
   attrib/gatttool.c
2020-09-21 16:19:33 -07:00
Luiz Augusto von Dentz
76d63c91b2 shared/gatt-client: Add support for EATT features
This enables EATT in the Client Features if the EATT characteristic is
present in the database.
2020-03-02 14:42:32 -08:00
Marcel Holtmann
261948090e build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
Mariusz Skamra
b576fa4d33 shared/att: Add ext_signed flag to be able to use external crypto
Due to the issues with CSRK tests ext_signed flag has been added to
allow android/gatt handle signed write operations.

This patch fixes following tests:
GAP__TC_SEC_CSIGN_BV_02_C
GAP__TC_SEC_CSIGN_BI_01_C
GAP__TC_SEC_CSIGN_BI_02_C
GAP__TC_SEC_CSIGN_BI_03_C
GAP__TC_SEC_CSIGN_BI_04_C
SM__TC_SIGN_BV_03_C
2015-05-19 16:42:43 +02:00
Luiz Augusto von Dentz
64f8641733 attrib: Fix not honoring MTU
If MTU has changed, by bt_gatt_client for example, the code should be
able to figure it out without waiting g_attrib_set_mtu to be called.
2015-03-15 09:01:36 +02:00
Marcel Holtmann
8c1a878f33 attrib: Fix local libbluetooth includes order 2015-02-28 23:34:40 -08:00
Marcel Holtmann
571124ffdb attrib: Use local libbluetooth includes 2015-02-28 22:40:14 -08:00
Lukasz Rymanowski
92218dc7bb attrib/gatt: Improve robustness when searching for included services
Without this patch it is possible to enter infinite loop when
searching included services on remote device. This patch fixes that.

Issue happens when remote device replies with ending handle which is
lower than start handle we use for search
2015-02-27 16:33:56 +01:00
Lukasz Rymanowski
028afb638f attrib/gatt: Improve robustness when searching for descriptors
Without this patch it is possible to enter infinite loop when
searching descriptors on remote device. This patch fixes that.

Issue happens when remote device replies with ending handle which is
lower than start handle we use for search.
2015-02-27 16:33:56 +01:00
Lukasz Rymanowski
beec19a736 attrib/gatt: Minor refactor in desc_discovered_cb
This is needed for next patch
2015-02-27 16:33:56 +01:00
Lukasz Rymanowski
1998daa85d attrib/gatt: Improve robustness when searching for characteristics
Without this patch it is possible to enter infinite loop when searching
characteristics on remote device.
This patch fixes that.

Issue happens when remote device replies with ending handle which is
lower than start handle we use for search.

Found on robustness session on UPF50
2015-02-27 16:33:56 +01:00
Lukasz Rymanowski
746cc864f5 attrib/gatt: Minor refactor in char_discovered_cb
This will be needed by next patch
2015-02-27 16:33:56 +01:00
Lukasz Rymanowski
746663a2c1 attrib/gatt: Improve robustness on search primary services
Without this it is possible to put BlueZ into infinite loop when
doing primary service search on remote device.

Issue happens when remote device replies with ending handle which is
lower than start handle we use for search.

This patch fixes that

Found on robustness session on UPF50
2015-02-27 16:33:56 +01:00
Marcel Holtmann
e09a8ee1af attrib: Add explicit include for lib/bluetooth.h 2015-02-18 06:23:56 +01:00
Bharat Panda
52362c5f20 attrib: Fix condition check for attr delete
Checks handle value for non-zero as well as >= 0xffff, to avoid
infinite loop and deletion of unspecified attrib handles.
2015-02-13 15:02:14 +02:00
Luiz Augusto von Dentz
25afc21cba attrib: Fix not disconnecting
The default behavior of GAttrib is to disconnect on unref but patch
0ea75ab4bb had changed that in order to
fix a warning, this return the old behavior but leaves to bt_att to do
the actual closing.
2015-01-12 10:58:16 -02:00
Luiz Augusto von Dentz
0ea75ab4bb attrib: Fix warning when closing connection
Since bt_att is used internally GAttrib should no longer close the
connection otherwise it cause the following warning:

bluetoothd[31756]: attrib/gattrib.c:g_attrib_unref() 0x610c130: g_attrib_unref=1
bluetoothd[31756]: attrib/gattrib.c:g_attrib_unref() 0x610c130: g_attrib_unref=0

(bluetoothd:31756): GLib-WARNING **: Invalid file descriptor.
2014-12-29 12:26:42 -02:00
Lukasz Rymanowski
acc2f8ebbd attrib/gattrib: Add tracking all the internal request id
With this patch gattrib track all the pending request id's to bt_att.
When doing g_attrib_cancel_all, only those own by gattrib will be
canceled.
2014-12-18 22:03:34 -02:00
Lukasz Rymanowski
e5a4abf420 attrib/gatt: Fix for search services
This patch adds means to reuse ATT request id for GATT operations
which might need more then one ATT request for complete GATT operation.
E.g discover primary\included services and discover
characteristics/descriptors

This is needed for the user of gattib, to make sure that ATT request id he
holds is valid during whole GATT operation.

So far, it could happen that gattrib did additional ATT request without
user knowledge which leads to situation that user had outdated ATT
request id.

Note that request id is used by the user for canceling request.
2014-12-18 16:35:37 -02:00
Lukasz Rymanowski
5043831f6d attrib/gattrib: Add track for request ids
If user provides req_id to the g_attrib_send, he assume that req_id
should be used for transaction.
With this patch, gattrib  keeps track on user requested req_id and
actual pending req_id which allow to e.g. cancel correct transaction
when user request it.

Note that for now specific request id is used in attrib/gatt.c for long
write. Next patch will make bigger usage of this but also only in this
helper. We do not expect other attrib clients to use that feature.
2014-12-18 16:35:25 -02:00
Arman Uguray
ebcbada186 attrib/gattrib: Add g_attrib_get_att
Added the g_attrib_get_att function which returns the underlying bt_att
structure associated with a GAttrib.
2014-12-15 17:24:14 -02:00
Lukasz Rymanowski
d840b56bae attrib/gatt: Fix minor coding style 2014-12-15 09:04:46 -02:00
Lukasz Rymanowski
d3f51cbc17 attrib/gatt: Minor coding style fix 2014-12-10 10:18:12 +02:00
Lukasz Rymanowski
1010aca560 attrib/gatt: Fix for attrib ref
This patch makes sure that attrib instance will not disappear while
reading characteristic
2014-12-10 10:18:12 +02:00
Arman Uguray
111186b3bf attrib: Check if attrib is NULL in functions
This patch adds an early return to attrib/gattrib functions if the
attrib argument is NULL.
2014-12-09 14:48:45 +02:00
Szymon Janc
372af43089 attrib: List all enum values in switch
As described in coding style M10
2014-12-08 14:00:28 +01:00
Jakub Tyszkowski
e31999cd81 gattrib: Fix not changing the buffer size when mtu is reduced
Using larger buffer than mtu resulted in not sending the message at all
as encode_pdu() in shared/att.c fails when provided data buffer is
larger than current mtu.
2014-12-03 12:46:08 +01:00
Jakub Tyszkowski
7dcd7babce gattrib: Fix not setting att's mtu size in g_attrib_new()
We were setting only the buffer in gattrib but att was left with the
default value of 23 (LE transport layer defaults). For BREDR transport
layer this may result in using smaller MTU than the minimum allowed
(48).

This was affecting cases when MTU Exchange was not supported by the
remote device and defaults were used.
2014-12-01 13:02:35 +01:00
Michael Janssen
b1c225b38d GATT shim to src/shared bt_att
This patch implements a version of GAttrib which is backed by
bt_att, which enables the simultaneous use of GAttrib and bt_att.

This should enable smooth transition of profiles from the GAttrib
API to the src/shared bt_att API.
2014-11-17 13:50:11 +02:00
Michael Janssen
c6cd3f52e4 gattrib: Remove unused GATTRIB_ALL_EVENTS
In prep to use shared stack, this is unused and not functionally
supported by bt_att.
2014-11-06 17:39:14 +02:00
Michael Janssen
aa6c286ce1 attrib: fix GATTRIB_ALL_REQS behavior
g_attrib_register(..., GATTRIB_ALL_REQS, ...) behavior would previously
include indications, this fixes it to only include requests and
commands.
2014-11-03 17:17:10 +02:00
Michael Janssen
002070cf4c attrib: remove g_attrib_is_encrypted
This function is only used in one place and encryption is the
responsibility of the channel, not the attribute.
2014-11-03 17:17:02 +02:00
Michael Janssen
566488510e attrib: Add mtu argument to g_attrib_new
Instead of using the default MTU, use one passed
in by the user, and detect it from the channel when
it is created.
2014-11-03 17:16:56 +02:00
Michael Janssen
1adcdc84d6 attrib: Remove MTU-probing code
Probing for the MTU using bt_io is problematic for
testing because you cannot impersonate AF_BLUETOOTH sockets
with a socketpair.
2014-10-31 15:49:21 +02:00
Michael Janssen
9e02ecba3e Remove unused g_attrib_set_debug function
This function is not used, and also not implemented.
2014-10-31 15:48:00 +02:00
Andrei Emeltchenko
56d9d175e3 attrib: Fix memory leak 2014-08-01 13:39:50 +03:00
Marcin Kraglak
ff797556da attrib: Fix discovering descriptors
Discover all attributes in given range. In same cases we ommited
last attribute in range.
2014-07-18 11:14:42 +02:00
Lukasz Rymanowski
514e224641 android/gatt: Fix signed write command encoding
As per spec (BT spec 4.1 Vol[3], Part F, chapter 3.4.5.4) we need to
take opcode, handle and parameters to generate signature.
In order to support it signing is moved to att.c, place where pdu is
encoded
2014-05-30 13:26:14 +03:00
Jakub Tyszkowski
111150d7e6 attrib: Fix minor whitespace issue
Replace spaces with tabs.
2014-05-27 22:46:49 +02:00
Lukasz Rymanowski
84bbaa3971 attrib: Add wrapper to send signed write command 2014-05-26 10:28:12 +02:00
Lukasz Rymanowski
d4026bb36e attrib: Add helpers to enc and dec signed write command 2014-05-26 10:27:21 +02:00
Andrzej Kaczmarek
9b9771ce8f gatt: Remove gatt_discover_char_desc
This function is no longer used since all code is changed to use
gatt_discover_desc instead.
2014-05-05 10:49:51 +03:00
Andrzej Kaczmarek
a2d69036e7 attrib: Discover descriptors using gatt_discover_desc 2014-05-05 10:48:55 +03:00
Andrzej Kaczmarek
93229d36d1 attrib: Add simpler call for descriptors discovery
This patch adds gatt_discover_desc() function which performs descriptor
discovery in a manner similar to gatt_discover_char(), i.e. it does
complete discovery procedure and returns list of descriptors found when
finished. For 16-bit UUIDs in addition to string UUID, short UUID is
provided.

It's also possible to specify single descriptor UUID to look for and
discovery procedure is interrupted as soon as UUID is found. This way
no more than one descriptor is returned which is useful when searching
for common descriptors like CCC.
2014-05-05 10:47:16 +03:00
Lukasz Rymanowski
7ecdd48ab7 attrib: Expose write execute
This is needed to cover Android API
2014-04-23 15:15:50 +02:00
Lukasz Rymanowski
a877e3a20b attrib: Add API for reliable write
Android expose to application api for reliable write. Therefore we need
to add this support to gattrib
2014-04-23 15:15:50 +02:00