2011-02-21 14:36:53

by Bruna Moreira

[permalink] [raw]
Subject: [PATCH 1/2] Fix Find by Type Response with start == end grp handle

Find by type value response in attribute server was in loop when the
start/end grp handles from a primary service had same values.

Initializing end grp handle with start handle makes the special check
when end grp handle was zero unnecessary so it was removed.
---
src/attrib-server.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 4285f6e..2eb800f 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -469,6 +469,9 @@ static int find_by_type(uint16_t start, uint16_t end, uuid_t *uuid,

range = g_new0(struct att_range, 1);
range->start = a->handle;
+ /* It is allowed to have end group handle the same as
+ * start handle, for groups with only one attribute. */
+ range->end = a->handle;

matches = g_slist_append(matches, range);
} else if (range) {
@@ -487,12 +490,6 @@ static int find_by_type(uint16_t start, uint16_t end, uuid_t *uuid,
if (l == NULL) {
/* Avoids another iteration */
range->end = 0xFFFF;
- } else if (range->end == 0) {
- /* Broken requests: requested End Handle is not
- * 0xFFFF. Given handle is in the middle of a
- * service definition. */
- matches = g_slist_remove(matches, range);
- g_free(range);
}
}

--
1.7.0.4



2011-02-21 16:57:46

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/2] Fix Find by Type Response with start == end grp handle

Hi Bruna,

On Mon, Feb 21, 2011, Bruna Moreira wrote:
> Find by type value response in attribute server was in loop when the
> start/end grp handles from a primary service had same values.
>
> Initializing end grp handle with start handle makes the special check
> when end grp handle was zero unnecessary so it was removed.
> ---
> src/attrib-server.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)

Both patches have been pushed upstream. Thanks.

Johan

2011-02-21 14:36:54

by Bruna Moreira

[permalink] [raw]
Subject: [PATCH 2/2] Fix end grp handle on Find By Type response

The attribute server was incorrectly setting the end group handle of the
last attribute to 0xFFFF on Find By Type response (used by Discover
Primary Service by UUID).
---
src/attrib-server.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2eb800f..7ec0f56 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -486,13 +486,6 @@ static int find_by_type(uint16_t start, uint16_t end, uuid_t *uuid,
}
}

- if (range) {
- if (l == NULL) {
- /* Avoids another iteration */
- range->end = 0xFFFF;
- }
- }
-
if (matches == NULL)
return enc_error_resp(ATT_OP_FIND_BY_TYPE_REQ, start,
ATT_ECODE_ATTR_NOT_FOUND, opdu, mtu);
--
1.7.0.4