From: Johan Hedberg <johan.hedberg@gmail.com>
To: Mikel Astiz <mikel.astiz.oss@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: Re: [RFC BlueZ v2] mgmt-api: Add reason to device disconnect event
Date: Thu, 16 Aug 2012 15:25:10 +0300 [thread overview]
Message-ID: <20120816122510.GA23760@x220> (raw)
In-Reply-To: <1344498980-2829-1-git-send-email-mikel.astiz.oss@gmail.com>
Hi Mikel,
On Thu, Aug 09, 2012, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>
> Extend the management API with the disconnect reason, as now reported
> by the Kernel in MGMT_EV_DEVICE_DISCONNECTED.
> ---
> Updated userland patch to test the recently submitted Kernel patches regarding ACL disconnect reason.
>
> doc/mgmt-api.txt | 16 ++++++++++++++++
> lib/mgmt.h | 6 ++++++
> monitor/control.c | 19 +++++++++++++++----
> src/mgmt.c | 13 ++++++++-----
> 4 files changed, 45 insertions(+), 9 deletions(-)
Seems like you're missing an update to tools/btmgmt.c?
> --- a/monitor/control.c
> +++ b/monitor/control.c
> @@ -226,18 +226,29 @@ static void mgmt_device_disconnected(uint16_t len, const void *buf)
> {
> const struct mgmt_ev_device_disconnected *ev = buf;
> char str[18];
> + uint8_t reason;
> + uint16_t l;
I suppose size_t would be more appropriate instead of uint16_t as that's
the return type of sizeof(). The variable name is also a bit
uninformative and I'd have used something like consumed_len or
parsed_len, but if this the convention in rest of the btmon code then I
wont object to it.
> --- a/src/mgmt.c
> +++ b/src/mgmt.c
> @@ -510,18 +510,21 @@ static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
> static void mgmt_device_disconnected(int sk, uint16_t index, void *buf,
> size_t len)
> {
> - struct mgmt_addr_info *ev = buf;
> + struct mgmt_ev_device_disconnected *ev = buf;
> struct controller_info *info;
> char addr[18];
>
> - if (len < sizeof(*ev)) {
> + if (len < sizeof(struct mgmt_addr_info)) {
> error("Too small device_disconnected event");
> return;
> }
>
> - ba2str(&ev->bdaddr, addr);
> + if (len < sizeof(*ev))
> + memset((char *) buf + len, 0, sizeof(*ev) - len);
I don't like how this assumes that there is usable space after the end
of the buffer given to this function. Could you instead use a temporary
"uint8_t reason" variable like you do for btmon?
Johan
next prev parent reply other threads:[~2012-08-16 12:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 7:56 [RFC BlueZ v2] mgmt-api: Add reason to device disconnect event Mikel Astiz
2012-08-16 12:25 ` Johan Hedberg [this message]
2012-08-17 9:07 ` Mikel Astiz
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=20120816122510.GA23760@x220 \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mikel.astiz.oss@gmail.com \
--cc=mikel.astiz@bmw-carit.de \
/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;
as well as URLs for NNTP newsgroup(s).