Commit Graph

77 Commits

Author SHA1 Message Date
Claudio Takahasi
454a30731b Replace att_put_u16() by put_le16() 2014-03-24 22:11:28 +02:00
Claudio Takahasi
e13e1abb8b Replace att_put_uuid() by util.h helpers 2014-03-24 22:10:16 +02:00
Claudio Takahasi
1a1e9b4fa9 Replace att_get_uuid128() by bswap_128()
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.
2014-03-24 22:08:54 +02:00
Claudio Takahasi
91744cb56f Replace att_get_u16() by get_le16() 2014-03-24 22:08:20 +02:00
Claudio Takahasi
3f03ab5766 Replace att_get_uuid16() by get_le16() 2014-03-24 22:08:02 +02:00
Claudio Takahasi
0461b9d99c Replace att_put_uuid16() by put_le16() 2014-03-24 22:07:53 +02:00
Anderson Lizardo
a3299e5b1e attrib: Add extra PDU checks when decoding Read by Type Response
These checks are needed to avoid invalid memory access on bogus PDUs.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
cceb59d76b attrib: Fix PDU length check for Read by Type Request
PDU length must be either 7 or 21 octets.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
88cdd5749c attrib: Reject incomplete PDU in dec_find_by_type_resp()
Otherwise, an incomplete PDU may be silently accepted (with any
remaining data discarded).
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a9249eece7 attrib: Remove unnecessary local variables from dec_find_by_type_req()
Use number instead of "min_len", which is easier to review (with help of
the documented parameter sizes).

valuelen is redundant as *vlen can be used directly.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a8b353da80 attrib: Remove unnecessary NULL checks on dec_find_by_type_req()
Just assume that the caller will pass non-NULL pointers as arguments
(which is true for the only current caller of this function).
2014-01-11 18:56:03 +02:00
Anderson Lizardo
ef97296c20 attrib: Add extra PDU checks when decoding Read by Group Type Response
These checks are needed to avoid invalid memory access on bogus PDUs.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
a5e6aafdf7 attrib: Fix PDU length check for Read by Group Type Request
PDU length must be either 7 or 21 octets.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
22cf3b76d1 attrib: Remove unnecessary checks for PDU length on ATT encoding
Both userspace and kernel enforce a minimum ATT MTU of 23 octets, which
is also used as minimum size for buffers passed to ATT encoding
functions. Therefore, it is unnecessary to perform these checks on ATT
requests that are guaranteed to fit into 23 octets.

Also document ATT parameter lengths where a constant is being used for
calculating the PDU length.
2014-01-11 18:56:03 +02:00
Anderson Lizardo
95b8a4ec80 attrib: Use att_put_u16() instead of htobs() + memcpy() 2014-01-11 18:56:03 +02:00
Anderson Lizardo
638790716f attrib: Allow dec_read_resp() to just check if PDU is valid
If a NULL "value" parameter is given, only check whether PDU is valid,
without copying attribute value to a buffer.
2013-07-24 08:43:17 -07:00
Alvaro Silva
1ed64821ac attrib: Add encode/decode execute write support
Add functions for encoding/decoding Execute Write Request PDUs.
2013-07-24 08:43:05 -07:00
Alvaro Silva
38487a9915 attrib: Add encode/decode prepare write support
Add functions for encoding/decoding Prepare Write Request PDUs.
2013-07-24 08:42:43 -07:00
Alvaro Silva
9abeec8c11 attrib: Remove unused parameter from enc_write_resp() 2013-07-24 08:42:32 -07:00
Eder Ruiz Maria
969906d6aa attrib: Fix coding style for various enc_*/dec_* functions
Fix coding style for enc_read_blob(), enc_read_blob_resp(),
dec_read_resp(), enc_error_resp(), enc_find_info_req(),
enc_find_info_resp() and enc_prep_write().
2013-07-24 08:42:22 -07:00
Anderson Lizardo
e654bdfa9a attrib: Fix compilation errors when compiled without optimization
Fix these build errors:

attrib/att.c: In function ‘dec_read_by_grp_req’:
attrib/att.c:165:10: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]
attrib/att.c:170:10: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]
attrib/att.c: In function ‘dec_read_by_type_req’:
attrib/att.c:393:10: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]
attrib/att.c:402:10: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]
2013-01-10 16:06:22 -08:00
Anderson Lizardo
5434627c4c attrib: Fix remaining references to bluetooth/uuid.h
These headers are not public anymore, so need to use "lib/uuid.h".
2013-01-10 15:11:53 +02:00
Cristian Rodríguez
2604776e91 attrib: Fix missing config.h includes 2012-12-23 18:59:48 -08:00
Vinicius Costa Gomes
f8619bef34 attrib: Fix not checking if att_data_list_alloc fails
Now that this function may fail in more usual situations (invalid
input), we have to check its return value.
2012-10-11 08:48:22 +02:00
Vinicius Costa Gomes
a48a3bac3a att: Fix sending pdu's with invalid data
When encoding an att_data_list we need to make sure that each element
lenght of the data list will not exceed 255, because that information
will be encoded as a octet later.
2012-10-11 08:48:09 +02:00
Johan Hedberg
04be4fe0c0 attrib: Use proper types for size variables
size_t/ssize_t/off_t/etc are more appropriate for variables denoting
some kind of size than simply using int.

This patch includes a couple of other related changes to avoid gcc
signedness errors resulting from it treating (for whatever reason) const
variables and integer literals as signed.
2012-08-15 12:20:51 +03:00
Eder Ruiz Maria
f5cf20bb06 att: Add encode/decode execute write support
Add functions for encoding/decoding Execute Write Request and
Response PDUs.
2012-08-15 11:58:43 +03:00
Eder Ruiz Maria
3be0d8feef att: Add prepare write support
Add functions for encoding/decoding Prepare Write Request and
Response PDUs.
2012-08-15 11:58:43 +03:00
Claudio Takahasi
2f8cd0cb7e ATT: Avoid invalid memory access for large PDU
This patch avoids invalid memory access when decoding ATT read response
PDUs. The ATT_MTU value is a per ATT Bearer value defined by the higher
layer specification.
2012-06-27 15:49:18 +03:00
Johan Hedberg
3b3e88678a gattrib: Fix command timeout handling
This patch fixes command timeout handling. Previously attrib_destroy was
explicitly called which ignored any reference holders. This patch fixes
the issue by first passing errors to command callbacks and after that
marking the GAttrib object as stale so no further operations can be
done.
2012-06-05 15:11:50 +03:00
Vinicius Costa Gomes
253f8a7c68 Fix using the attribute struct for encoding ATT pdus
The enconding and decoding of ATT pdus should be kept as much
free of dependences from other parts of the code as possible, so
it can be used in many contexts.

In this case, for encoding and decoding notifications and indications
we did have to pass an instance of an attribute instead of direct
values.
2011-10-07 19:52:32 +03:00
Anderson Lizardo
2acb6b1a3a Fix memory allocation of struct attribute
On commit 6a6da5de10 the struct
attribute "data[0]" member was replaced with a dynamically allocated
"data" pointer. This commit fixes remaining places where the old
allocation scheme was still assumed.
2011-09-22 20:01:28 +09:00
Anderson Lizardo
fef3e7c002 Remove empty line before declaration 2011-09-22 20:01:26 +09:00
Lucas De Marchi
fcb426c76a Fix common misspelled words
Accounting of misspelled words, as detected by codespell:

acording      2
ancilliary    1
appropiate    1
atribute      1
cant          1
comming       2
gracefull     1
lenght        1
mispelled     1
occured       1
occurences    1
ocurred       3
prefered      1
presense      1
reponse       1
seperate      1
succesful     1
successully   1
sucessfull    1
sucessfully   1
2011-07-03 14:36:14 +03:00
Claudio Takahasi
52727904b6 Remove "authen" and "autho" short versions for ATT constants 2011-03-30 19:38:46 +03:00
Elvis Pfützenreuter
a278db781a Use new UUID functions in GATT
This patch puts the new UUID functions into use for GATT-related
code, and adds some convenience functions to ATT API (att.h).
Example GATT server is also changed.
2011-03-15 19:36:48 +02:00
Claudio Takahasi
448456a19f Coding standard change replacing malloc by glib functions
Use glib memory allocation functions instead of malloc for attribute
data list in ATT protocol utility functions.
2011-02-24 18:35:17 -03:00
Bruna Moreira
ec141a423b Add encode/decode for write response
The encode/decode functions for Write Response operations were created
to keep consistency with the rest of GATT API.
2011-02-15 11:47:40 -03:00
Brian Gix
8648c3b198 Add READ_BLOB_REQUEST support to attribute server 2011-01-20 15:04:15 +05:30
Brian Gix
7749241702 Add enc_read_blob_req() as defined in BT Core Spec v4.0 2010-12-19 14:10:40 +02:00
Sheldon Demario
90dec87b5c Attrib server should truncate attribute value to pdu length
When the size of attribute value is greater than pdu size, it should be
truncated to the pdu length - 2
2010-11-29 19:24:07 +02:00
Claudio Takahasi
2b3f200f29 Add Find By Type Value Response encoding/decoding functions
Find by type operation is used by Discover Primary Service by Service
UUID. Find By Type Value Response shall contain one or more group handles.
2010-11-18 21:53:54 +02:00
Bruna Moreira
b0d8865493 Implement Find by Type request encode/decoding 2010-11-18 16:44:19 +02:00
Anderson Lizardo
0a70694d3a Add support for Attribute Write Request
Implement encoders/decoders for Write Request/Response and the handling
on attribute server. The attribute client still uses the Write Command
because currently SetProperty() has no means to wait for the server
response.
2010-10-09 18:22:09 +03:00
Anderson Lizardo
6352f7b918 Modify dec_read_req() to get PDU length as parameter
This is consistent with other att.h functions, and allows length checks.
2010-10-04 21:15:56 +02:00
Anderson Lizardo
dbad6fdb75 Replace hardcoded minimum length values with constants 2010-10-04 21:15:54 +02:00
Anderson Lizardo
69409f28f8 Remove typecast from att_get_u16() calls
att_get_u16() already does a cast of the void* parameter to uint16_t*.
2010-10-04 21:15:52 +02:00
Bruna Moreira
48b01d5006 Add encoders/decoders for the Write command 2010-10-04 17:06:48 +02:00
Vinicius Costa Gomes
9041deab65 Add encoders/decoders for Indication/Confirmation 2010-09-22 22:34:26 +03:00
Johan Hedberg
797f8e1491 Fix coding style issues in attribute code 2010-09-22 00:09:32 +03:00