summaryrefslogtreecommitdiff
path: root/attrib/gatt.c
Commit message (Collapse)AuthorAgeFilesLines
* attrib: Use local libbluetooth includesMarcel Holtmann2015-02-281-3/+5
|
* attrib/gatt: Improve robustness when searching for included servicesLukasz Rymanowski2015-02-271-1/+14
| | | | | | | | 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
* attrib/gatt: Improve robustness when searching for descriptorsLukasz Rymanowski2015-02-271-1/+14
| | | | | | | | 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.
* attrib/gatt: Minor refactor in desc_discovered_cbLukasz Rymanowski2015-02-271-2/+6
| | | | This is needed for next patch
* attrib/gatt: Improve robustness when searching for characteristicsLukasz Rymanowski2015-02-271-2/+15
| | | | | | | | | | | 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
* attrib/gatt: Minor refactor in char_discovered_cbLukasz Rymanowski2015-02-271-2/+7
| | | | This will be needed by next patch
* attrib/gatt: Improve robustness on search primary servicesLukasz Rymanowski2015-02-271-2/+27
| | | | | | | | | | | | 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
* attrib/gatt: Fix for search servicesLukasz Rymanowski2014-12-181-11/+32
| | | | | | | | | | | | | | | | 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.
* attrib/gatt: Minor coding style fixLukasz Rymanowski2014-12-101-1/+0
|
* attrib/gatt: Fix for attrib refLukasz Rymanowski2014-12-101-3/+6
| | | | | This patch makes sure that attrib instance will not disappear while reading characteristic
* attrib: Fix discovering descriptorsMarcin Kraglak2014-07-181-1/+1
| | | | | Discover all attributes in given range. In same cases we ommited last attribute in range.
* android/gatt: Fix signed write command encodingLukasz Rymanowski2014-05-301-3/+8
| | | | | | | 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
* attrib: Add wrapper to send signed write commandLukasz Rymanowski2014-05-261-0/+16
|
* gatt: Remove gatt_discover_char_descAndrzej Kaczmarek2014-05-051-15/+0
| | | | | This function is no longer used since all code is changed to use gatt_discover_desc instead.
* attrib: Add simpler call for descriptors discoveryAndrzej Kaczmarek2014-05-051-0/+146
| | | | | | | | | | | | | 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.
* attrib: Expose write executeLukasz Rymanowski2014-04-231-0/+6
| | | | This is needed to cover Android API
* attrib: Add API for reliable writeLukasz Rymanowski2014-04-231-0/+18
| | | | | Android expose to application api for reliable write. Therefore we need to add this support to gattrib
* attrib: Improve Attribute Data length checkingClaudio Takahasi2014-04-031-23/+17
| | | | | According to Core SPEC, attribute data list must be grouped in elements of the same size.
* attrib: Use const source data pointer for writeJakub Tyszkowski2014-03-281-3/+3
| | | | Source buffer for write operations should be immutable.
* attrib: Minor code optimizationClaudio Takahasi2014-03-241-3/+1
|
* Replace att_get_uuid128() by bswap_128()Claudio Takahasi2014-03-241-22/+47
| | | | | | GATT/ATT use little-endian byte order format for 128-bit UUID. No matter the system byte order representation, internally the core will handle 128-bit UUID on big-endian format.
* Replace att_get_u16() by get_le16()Claudio Takahasi2014-03-241-7/+7
|
* Replace att_get_uuid16() by get_le16()Claudio Takahasi2014-03-241-3/+8
|
* attrib: Use LE helpers defined in src/shared/util.hClaudio Takahasi2014-03-241-13/+13
|
* attrib: Fix gatt_primary leaks when a failure occursJohan Hedberg2014-03-201-1/+1
|
* attrib: Use destroy notify for included queryJohan Hedberg2014-03-191-5/+9
|
* attrib: Fix potential leaks with primary discovery contextJohan Hedberg2014-03-191-6/+24
|
* core: Fix memory leaks with struct discover_charJohan Hedberg2014-03-191-5/+18
|
* attrib: Modify gatt_cb_t signatureAnderson Lizardo2014-01-111-5/+5
| | | | | | Use standard C types instead of GLib ones (which are unnecessary here) and move the "status" parameter to the first position, so it is consistent with other callbacks.
* attrib: Reduce scope of variable declarations in char_discovered_cb()Anderson Lizardo2013-07-241-4/+5
| | | | This makes it easy to identify where variables are being used.
* attrib: Simplify prepare_write()Anderson Lizardo2013-07-241-17/+12
| | | | | All parameters can be retrieved from struct write_long_data fields, therefore there is no need to pass them separately.
* attrib: Fix coding style in prepare_write_cb()Anderson Lizardo2013-07-241-5/+5
|
* attrib: Do not use Write Command in gatt_write_char()Anderson Lizardo2013-07-241-12/+10
| | | | | | | | | | | | | Previously, if no callback was given to gatt_write_char(), it was assumed that a "Write Without Response" (which uses Write Command) should be used instead of Write Request. This "shortcut" is unnecessary (there is gatt_write_cmd() for the situations where Write Without Response is required) and just duplicates code. This commit also fixes the few places where gatt_write_cmd() should be used.
* attrib: Rename gatt_find_info() to gatt_discover_char_desc()Anderson Lizardo2013-07-241-1/+1
| | | | | | The old name referred to the underlying ATT PDU (Find Information Request and Find Information Response) and not to the actual GATT procedure (Discover All Characteristic Descriptors).
* attrib: Use GAttrib destroy callback for included searchJohan Hedberg2013-06-071-3/+1
|
* attrib: 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.
* attrib: Use gcc builtin instead of g_atomicLucas De Marchi2013-04-091-6/+6
| | | | | | | | | | | | | g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to -Wunused-local-typedefs. /usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs] #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] Most of the uses of atomic operations were wrong. They were fixed as well. If we are using atomic operations, reading the variable again later for logging is not an option, we should use the return of the atomic function used to fetch the variable.
* attrib: Fix status on memory allocation failureAnderson Lizardo2013-04-041-1/+3
| | | | | If memory allocation fails, ATT_ECODE_INSUFF_RESOURCES should be reported to the callback.
* attrib: Fix coding style in read_char_helper()Anderson Lizardo2013-04-041-3/+2
|
* attrib: Fix memory leak on low memory conditionAnderson Lizardo2013-04-041-0/+1
| | | | | If g_try_new0() fails due to low memory condition, "list" should be freed before returning from primary_all_cb().
* device: Fix invalid memory access during Find IncludedVinicius Costa Gomes2013-01-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* attrib: Fix remaining references to bluetooth/uuid.hAnderson Lizardo2013-01-101-1/+1
| | | | These headers are not public anymore, so need to use "lib/uuid.h".
* Revert "Ensure config.h is included by using CPPFLAGS"Johan Hedberg2012-12-071-0/+4
| | | | | | | | | | | | | | This reverts commit 8a03376544b046a84301847d1594f6c3674983ff. The patch needs to be split up and the gdbus/ changes were bogus compared to the original commit message. Conflicts: Makefile.am Makefile.obexd profiles/cyclingspeed/cyclingspeed.c profiles/heartrate/heartrate.c src/error.c
* Ensure config.h is included by using CPPFLAGSLucas De Marchi2012-12-051-4/+0
| | | | | | | | | | Instead of trying to include config.h in each file over the tree and possibly forgetting to include it, give a "-include config.h" argument to the compiler so it's guaranteed that a) it will be included for all source files and b) it will be the first header included. gdbus/ directory is left out, since it would break other projects using it.
* gatt: Improve characteristics discoveryPaulo Borges2012-12-011-1/+1
| | | | | | | | | | | | | | | | | | In the Discover Characteristics by UUID sub-procedure, if a fetched characteristic doesn't matches with the target UUID, all others characteristics in that response were discarded. Because of this, the procedure will make a new request to possibly rediscover the characteristics in the range beyond this last characteristic. At present, this procedure works because the gatt library will send a Read by Type Request starting at the first attribute after the non matching characteristic. This commit makes the rest of the characteristics to be checked for a matching type, which should reduce the number of requests sent during the discovery of characteristics.
* gatt: Fix memory leak in characteristic discoveryPaulo Borges2012-12-011-3/+3
| | | | | | | | | If the Discover Characteristics by UUID sub-procedure has been executed and the first characteristic is not the target, a memory leak occurs. This commit fixes this leak by postponing the allocation to after the UUID verification.
* attrib: Remove opcode parameter from g_attrib_send()Vinicius Costa Gomes2012-10-091-30/+21
| | | | | | In all uses of g_attrib_send() the opcode of the command/event is already clear because of the att.h functions used to build the ATT PDU.
* gatt: Add support for find included servicesVinicius Costa Gomes2012-10-091-0/+192
| | | | | | | | Some services like HID over LE can reference another service using included services. See Vol 3, Part G, section 2.6.3 of Core specification for more details.
* gatt: Remove offset parameter from gatt_read_charJefferson Delfes2012-10-011-11/+4
| | | | | | The Core spec allows to implement Read Long Characteristic Value as a Read Request, followed by zero or more Read Blob Requests, therefore the offset parameter is unnecessary and is always 0 for normal use.
* gatt: Don't raise error if declaration was foundClaudio Takahasi2012-08-201-4/+4
| | | | | | | This patch avoids raising errors to the upper layer if at least one characteristic declaration has been found. According to the Core SPEC Characteristic declarations shall be read without authentication or authorization.