* [RFC v0] Bluetooth: mgmt: Add device disconnect reason
@ 2012-05-14 15:34 Mikel Astiz
2012-05-15 14:15 ` Anderson Lizardo
0 siblings, 1 reply; 4+ messages in thread
From: Mikel Astiz @ 2012-05-14 15:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
MGMT_EV_DEVICE_DISCONNECTED should expose the disconnection reason to
userland.
Signed-off-by: Mikel Astiz <mikel.astiz@bmw-carit.de>
---
include/net/bluetooth/hci_core.h | 2 +-
include/net/bluetooth/mgmt.h | 4 ++++
net/bluetooth/hci_event.c | 2 +-
net/bluetooth/mgmt.c | 9 +++++----
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index b60d2c8..4c7252c 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -974,7 +974,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u32 flags, u8 *name, u8 name_len,
u8 *dev_class);
int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
- u8 link_type, u8 addr_type);
+ u8 link_type, u8 addr_type, u8 reason);
int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type, u8 status);
int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 23fd054..5845af9 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -406,6 +406,10 @@ struct mgmt_ev_device_connected {
} __packed;
#define MGMT_EV_DEVICE_DISCONNECTED 0x000C
+struct mgmt_ev_device_disconnected {
+ struct mgmt_addr_info addr;
+ __u8 reason;
+} __packed;
#define MGMT_EV_CONNECT_FAILED 0x000D
struct mgmt_ev_connect_failed {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d81262a..e33dbeb 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1920,7 +1920,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
conn->dst_type, ev->status);
else
mgmt_device_disconnected(hdev, &conn->dst, conn->type,
- conn->dst_type);
+ conn->dst_type, ev->reason);
}
if (ev->status == 0) {
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 25d2207..89af7c6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3047,16 +3047,17 @@ static void unpair_device_rsp(struct pending_cmd *cmd, void *data)
}
int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
- u8 link_type, u8 addr_type)
+ u8 link_type, u8 addr_type, u8 reason)
{
- struct mgmt_addr_info ev;
+ struct mgmt_ev_device_disconnected ev;
struct sock *sk = NULL;
int err;
mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk);
- bacpy(&ev.bdaddr, bdaddr);
- ev.type = link_to_bdaddr(link_type, addr_type);
+ bacpy(&ev.addr.bdaddr, bdaddr);
+ ev.addr.type = link_to_bdaddr(link_type, addr_type);
+ ev.reason = reason;
err = mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev),
sk);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [RFC v0] Bluetooth: mgmt: Add device disconnect reason
2012-05-14 15:34 [RFC v0] Bluetooth: mgmt: Add device disconnect reason Mikel Astiz
@ 2012-05-15 14:15 ` Anderson Lizardo
2012-05-15 15:03 ` Mikel Astiz
0 siblings, 1 reply; 4+ messages in thread
From: Anderson Lizardo @ 2012-05-15 14:15 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
Hi Mikel,
On Mon, May 14, 2012 at 11:34 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>
> MGMT_EV_DEVICE_DISCONNECTED should expose the disconnection reason to
> userland.
There is "getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len)". Why
is it not enough?
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC v0] Bluetooth: mgmt: Add device disconnect reason
2012-05-15 14:15 ` Anderson Lizardo
@ 2012-05-15 15:03 ` Mikel Astiz
2012-05-15 15:24 ` Anderson Lizardo
0 siblings, 1 reply; 4+ messages in thread
From: Mikel Astiz @ 2012-05-15 15:03 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth, Mikel Astiz
Hi Lizardo,
On Tue, May 15, 2012 at 4:15 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Mikel,
>
> On Mon, May 14, 2012 at 11:34 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
>> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>>
>> MGMT_EV_DEVICE_DISCONNECTED should expose the disconnection reason to
>> userland.
>
> There is "getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len)". Why
> is it not enough?
Could you please be more specific? Which socket type exposes this
disconnect reason?
That would be the second approach explained in the cover-letter
(userspace part), but AFAIK it's not been set by the Kernel right now.
We would probably have to set the option for all RFCOMM, L2CAP and SCO
sockets associated to the ACL link.
Cheers,
Mikel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC v0] Bluetooth: mgmt: Add device disconnect reason
2012-05-15 15:03 ` Mikel Astiz
@ 2012-05-15 15:24 ` Anderson Lizardo
0 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2012-05-15 15:24 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
Hi Mikel,
On Tue, May 15, 2012 at 11:03 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
> Hi Lizardo,
>
> On Tue, May 15, 2012 at 4:15 PM, Anderson Lizardo
> <anderson.lizardo@openbossa.org> wrote:
>> Hi Mikel,
>>
>> On Mon, May 14, 2012 at 11:34 AM, Mikel Astiz <mikel.astiz.oss@gmail.com> wrote:
>>> From: Mikel Astiz <mikel.astiz@bmw-carit.de>
>>>
>>> MGMT_EV_DEVICE_DISCONNECTED should expose the disconnection reason to
>>> userland.
>>
>> There is "getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len)". Why
>> is it not enough?
>
> Could you please be more specific? Which socket type exposes this
> disconnect reason?
It's L2CAP. Not sure about other socket types (I didn't check them).
BlueZ already uses it in some places (grep for "SO_ERROR"), and we use
it on GATT code for exactly the same reason you describe (many GATT
profiles describe specific behavior depending on disconnect reason
being timeout or not)
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-15 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-14 15:34 [RFC v0] Bluetooth: mgmt: Add device disconnect reason Mikel Astiz
2012-05-15 14:15 ` Anderson Lizardo
2012-05-15 15:03 ` Mikel Astiz
2012-05-15 15:24 ` Anderson Lizardo
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).