Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ v4 1/4] client: Fix reading long values
Date: Wed, 21 Mar 2018 11:34:08 +0100	[thread overview]
Message-ID: <1945037.y6NqV2LbZ1@ix> (raw)
In-Reply-To: <20180320140519.6285-1-grzegorz.kolodziejczyk@codecoup.pl>

Hi Grzegorz,

On Tuesday, 20 March 2018 15:05:16 CET Grzegorz Kolodziejczyk wrote:
> While value has more than single MTU can carry long read procedure will
> be triggered. In such cases offset need to bo considered while getting
> value from storage.
> ---
>  client/gatt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 47 insertions(+), 2 deletions(-)
> 
> diff --git a/client/gatt.c b/client/gatt.c
> index 8c818d8c1..7a6035ac1 100644
> --- a/client/gatt.c
> +++ b/client/gatt.c
> @@ -1412,6 +1412,39 @@ static const GDBusPropertyTable chrc_properties[] = {
> { }
>  };
> 
> +static int parse_offset(DBusMessageIter *iter, uint16_t *offset)
> +{
> +	DBusMessageIter dict;
> +
> +	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
> +		return -EINVAL;
> +
> +	dbus_message_iter_recurse(iter, &dict);
> +
> +	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
> +		const char *key;
> +		DBusMessageIter value, entry;
> +		int var;
> +
> +		dbus_message_iter_recurse(&dict, &entry);
> +		dbus_message_iter_get_basic(&entry, &key);
> +
> +		dbus_message_iter_next(&entry);
> +		dbus_message_iter_recurse(&entry, &value);
> +
> +		var = dbus_message_iter_get_arg_type(&value);
> +		if (strcasecmp(key, "offset") == 0) {
> +			if (var != DBUS_TYPE_UINT16)
> +				return -EINVAL;
> +			dbus_message_iter_get_basic(&value, offset);
> +		}
> +
> +		dbus_message_iter_next(&dict);
> +	}
> +
> +	return 0;
> +}
> +
>  static DBusMessage *read_value(DBusMessage *msg, uint8_t *value,
>  						uint16_t value_len)
>  {
> @@ -1433,8 +1466,14 @@ static DBusMessage *chrc_read_value(DBusConnection
> *conn, DBusMessage *msg, void *user_data)
>  {
>  	struct chrc *chrc = user_data;
> +	DBusMessageIter iter;
> +	uint16_t offset = 0;
> +
> +	dbus_message_iter_init(msg, &iter);
> +
> +	parse_offset(&iter, &offset);
> 
> -	return read_value(msg, chrc->value, chrc->value_len);
> +	return read_value(msg, &chrc->value[offset], chrc->value_len - offset);
>  }
> 
>  static int parse_value_arg(DBusMessageIter *iter, uint8_t **value, int
> *len) @@ -1785,8 +1824,14 @@ static DBusMessage
> *desc_read_value(DBusConnection *conn, DBusMessage *msg, void *user_data)
>  {
>  	struct desc *desc = user_data;
> +	DBusMessageIter iter;
> +	uint16_t offset = 0;
> +
> +	dbus_message_iter_init(msg, &iter);
> +
> +	parse_offset(&iter, &offset);
> 
> -	return read_value(msg, desc->value, desc->value_len);
> +	return read_value(msg, &desc->value[offset], desc->value_len - offset);
>  }
> 
>  static DBusMessage *desc_write_value(DBusConnection *conn, DBusMessage
> *msg,

All patches applied, thanks.
As discussed, I changed authz parameter to authorize.


-- 
pozdrawiam
Szymon Janc



      parent reply	other threads:[~2018-03-21 10:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20 14:05 [PATCH BlueZ v4 1/4] client: Fix reading long values Grzegorz Kolodziejczyk
2018-03-20 14:05 ` [PATCH BlueZ v4 2/4] gatt: Add org.bluez.Error.InvalidOffset for long read procedure Grzegorz Kolodziejczyk
2018-03-20 14:05 ` [PATCH BlueZ v4 3/4] client: Update read callbacks with invalid offset error handlers Grzegorz Kolodziejczyk
2018-03-20 14:05 ` [PATCH BlueZ v4 4/4] client: Add authorization request handling for attribute operations Grzegorz Kolodziejczyk
2018-03-21 10:34 ` Szymon Janc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1945037.y6NqV2LbZ1@ix \
    --to=szymon.janc@codecoup.pl \
    --cc=grzegorz.kolodziejczyk@codecoup.pl \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox