* [RFCv1 8/9] android/hal-sock: Implement accept signal over Android fd
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Android expects to get accept signal over file descriptor which was
set during listen HAL call.
---
android/socket.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index a962cdc..20f4e38 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -36,6 +36,7 @@
#include "hal-ipc.h"
#include "ipc.h"
#include "adapter.h"
+#include "utils.h"
#include "socket.h"
/* Simple list of RFCOMM server sockets */
@@ -68,6 +69,45 @@ static struct rfcomm_slot *create_rfslot(int sock)
return rfslot;
}
+static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
+{
+ ssize_t ret;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+ struct iovec iv;
+ char msgbuf[CMSG_SPACE(1)];
+
+ DBG("len %d sock_fd %d send_fd %d", len, sock_fd, send_fd);
+
+ if (sock_fd == -1 || send_fd == -1)
+ return -1;
+
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = msgbuf;
+ msg.msg_controllen = sizeof(msgbuf);
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd));
+ memcpy(CMSG_DATA(cmsg), &send_fd, sizeof(send_fd));
+
+ iv.iov_base = (unsigned char *) buf;
+ iv.iov_len = len;
+
+ msg.msg_iov = &iv;
+ msg.msg_iovlen = 1;
+
+ ret = sendmsg(sock_fd, &msg, MSG_NOSIGNAL);
+ if (ret < 0) {
+ error("sendmsg(): sock_fd %d send_fd %d: %s",
+ sock_fd, send_fd, strerror(errno));
+ return ret;
+ }
+
+ return ret;
+}
+
static const uint8_t UUID_PBAP[] = {
0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
@@ -161,6 +201,21 @@ static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
return TRUE;
}
+static void socket_send_accept(struct rfcomm_slot *rfslot, bdaddr_t *bdaddr,
+ int fd_accepted)
+{
+ struct hal_sock_connect_signal cmd;
+
+ DBG("");
+
+ cmd.size = sizeof(cmd);
+ bdaddr2android(bdaddr, cmd.bdaddr);
+ cmd.channel = rfslot->channel;
+ cmd.status = 0;
+
+ bt_sock_send_fd(rfslot->fd, &cmd, sizeof(cmd), fd_accepted);
+}
+
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
struct rfcomm_slot *rfslot = user_data;
@@ -190,6 +245,8 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
rfslot_acc = create_rfslot(sock_acc);
rfcomm_accepted_list = g_list_append(rfcomm_accepted_list, rfslot_acc);
+ socket_send_accept(rfslot, &dst, rfslot_acc->hal_fd);
+
/* Handle events from Android */
io_stack = g_io_channel_unix_new(rfslot_acc->fd);
g_io_add_watch(io_stack, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 7/9] android/hal-sock: Implement RFCOMM events
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Copy data from RFCOMM socket to Android framework.
---
android/socket.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index dfad9da..a962cdc 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -129,6 +129,35 @@ static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
gpointer data)
{
+ struct rfcomm_slot *rfslot = data;
+ unsigned char buf[1024] = { 0 };
+ int len;
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ error("Socket error: sock %d cond %d",
+ g_io_channel_unix_get_fd(io), cond);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return FALSE;
+ }
+
+ /* FIXME check real_sock vs sock(io) */
+ len = recv(rfslot->real_sock, buf, sizeof(buf), 0);
+ if (len <= 0) {
+ error("recv(): %s sock %d", strerror(errno), rfslot->real_sock);
+ return FALSE;
+ }
+
+ DBG("read %d bytes, write to fd %d", len, rfslot->fd);
+
+ if (send(rfslot->fd, buf, len, MSG_DONTWAIT) < 0) {
+ error("send(): %s sock %d", strerror(errno), rfslot->fd);
+ return FALSE;
+ }
+
return TRUE;
}
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 6/9] android/hal-sock: Implement Android RFCOMM stack events
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Handle events from Android framework. Write everything to real RFCOMM
socket.
---
android/socket.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 0ee53ba..dfad9da 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -94,6 +94,35 @@ static int get_rfcomm_chan(const uint8_t *uuid)
static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
gpointer data)
{
+ struct rfcomm_slot *rfslot = data;
+ unsigned char buf[1024] = { 0 };
+ int len;
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ error("Socket error: sock %d cond %d",
+ g_io_channel_unix_get_fd(io), cond);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return FALSE;
+ }
+
+ /* FIXME check fd vs sock(io) */
+ len = recv(rfslot->fd, buf, sizeof(buf), 0);
+ if (len <= 0) {
+ error("recv(): %s", strerror(errno));
+ return FALSE;
+ }
+
+ DBG("read %d bytes write to %d", len, rfslot->real_sock);
+
+ if (send(rfslot->real_sock, buf, len, 0) < 0) {
+ error("send(): %s", strerror(errno));
+ return FALSE;
+ }
+
return TRUE;
}
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 5/9] android/hal-sock: Implement socket accepted event
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
When we get accepted event we create rfcomm slot and start listening
for events from Android framework and from RFCOMM real socket.
---
android/socket.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 80cb39e..0ee53ba 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -91,8 +91,58 @@ static int get_rfcomm_chan(const uint8_t *uuid)
return -1;
}
+static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
+ gpointer data)
+{
+ return TRUE;
+}
+
+static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
+ gpointer data)
+{
+ return TRUE;
+}
+
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
+ struct rfcomm_slot *rfslot = user_data;
+ struct rfcomm_slot *rfslot_acc;
+ GIOChannel *io_stack;
+ bdaddr_t dst;
+ char address[18];
+ int sock_acc;
+
+ bt_io_get(io, &err,
+ BT_IO_OPT_DEST_BDADDR, &dst,
+ BT_IO_OPT_INVALID);
+ if (err) {
+ error("%s", err->message);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return;
+ }
+
+ ba2str(&dst, address);
+ DBG("Incoming connection from %s rfslot %p", address, rfslot);
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ sock_acc = g_io_channel_unix_get_fd(io);
+ rfslot_acc = create_rfslot(sock_acc);
+ rfcomm_accepted_list = g_list_append(rfcomm_accepted_list, rfslot_acc);
+
+ /* Handle events from Android */
+ io_stack = g_io_channel_unix_new(rfslot_acc->fd);
+ g_io_add_watch(io_stack, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ sock_stack_event_cb, rfslot_acc);
+ g_io_channel_unref(io_stack);
+
+ /* Handle rfcomm events */
+ g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ sock_rfcomm_event_cb, rfslot_acc);
+
+ DBG("rfslot %p rfslot_acc %p", rfslot, rfslot_acc);
}
static int handle_listen(void *buf)
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 4/9] android/hal-sock: Initial listen handle
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Handle HAL socket listen call. Create RFCOMM socket and wait for events.
---
android/socket.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 92 insertions(+), 2 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index c283c5f..80cb39e 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -27,22 +27,112 @@
#include <glib.h>
#include <stdbool.h>
+#include <errno.h>
#include "lib/bluetooth.h"
+#include "btio/btio.h"
#include "log.h"
#include "hal-msg.h"
#include "hal-ipc.h"
#include "ipc.h"
+#include "adapter.h"
#include "socket.h"
+/* Simple list of RFCOMM server sockets */
+GList *rfcomm_srv_list = NULL;
+/* Simple list of RFCOMM accepted sockets */
+GList *rfcomm_accepted_list = NULL;
-static int handle_listen(void *buf)
+struct rfcomm_slot {
+ int fd;
+ int hal_fd;
+ int real_sock;
+ uint32_t channel;
+};
+
+static struct rfcomm_slot *create_rfslot(int sock)
{
- DBG("Not implemented");
+ int fds[2] = {-1, -1};
+ struct rfcomm_slot *rfslot;
+
+ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0) {
+ error("socketpair(): %s", strerror(errno));
+ return NULL;
+ }
+
+ rfslot = g_malloc0(sizeof(*rfslot));
+ rfslot->fd = fds[0];
+ rfslot->hal_fd = fds[1];
+ rfslot->real_sock = sock;
+
+ return rfslot;
+}
+
+static const uint8_t UUID_PBAP[] = {
+ 0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+};
+#define RFCOMM_CHAN_PBAP 19
+
+static const uint8_t UUID_OPP[] = {
+ 0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+};
+#define RFCOMM_CHAN_OPP 12
+
+static int get_rfcomm_chan(const uint8_t *uuid)
+{
+ if (!memcmp(UUID_PBAP, uuid, sizeof(UUID_PBAP)))
+ return RFCOMM_CHAN_PBAP;
+
+ if (!memcmp(UUID_OPP, uuid, sizeof(UUID_OPP)))
+ return RFCOMM_CHAN_OPP;
return -1;
}
+static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
+{
+}
+
+static int handle_listen(void *buf)
+{
+ struct hal_cmd_sock_listen *cmd = buf;
+ const bdaddr_t *src = bt_adapter_get_address();
+ struct rfcomm_slot *rfslot;
+ GIOChannel *io;
+ GError *err = NULL;
+ int ch;
+
+ DBG("");
+
+ ch = get_rfcomm_chan(cmd->uuid);
+ if (ch < 0)
+ return -1;
+
+ DBG("rfcomm channel %u", ch);
+
+ rfslot = create_rfslot(-1);
+
+ io = bt_io_listen(connect_cb, NULL, rfslot, NULL, &err,
+ BT_IO_OPT_SOURCE_BDADDR, src,
+ BT_IO_OPT_CHANNEL, ch,
+ BT_IO_OPT_INVALID);
+ if (!io) {
+ error("Failed listen: %s", err->message);
+ g_error_free(err);
+ return -1;
+ }
+
+ rfslot->real_sock = g_io_channel_unix_get_fd(io);
+ rfcomm_srv_list = g_list_append(rfcomm_srv_list, rfslot);
+
+ DBG("real_sock %d fd %d hal_fd %d",
+ rfslot->real_sock, rfslot->fd, rfslot->hal_fd);
+
+ return rfslot->hal_fd;
+}
+
static int handle_connect(void *buf)
{
DBG("Not implemented");
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 3/9] android/ahl-sock: Add connect signal to socket
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Connect signal is used to pass information to framework that socket
is accepted.
---
android/hal-msg.h | 2 ++
android/socket.h | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 569c8ea..68cc8ed 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -232,6 +232,8 @@ struct hal_cmd_sock_connect {
uint8_t flags;
} __attribute__((packed));
+/* Bluetooth Hidhost HAL api */
+
#define HAL_OP_HIDHOST_CONNECT 0x01
struct hal_cmd_hidhost_connect {
uint8_t bdaddr[6];
diff --git a/android/socket.h b/android/socket.h
index 7aa5574..ba56c9b 100644
--- a/android/socket.h
+++ b/android/socket.h
@@ -21,6 +21,13 @@
*
*/
+struct hal_sock_connect_signal {
+ short size;
+ uint8_t bdaddr[6];
+ int channel;
+ int status;
+} __attribute__((packed));
+
void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
bool bt_socket_register(int sk, const bdaddr_t *addr);
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 2/9] android: Avoid unneeded includes
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Declare struct mgmt in adapter.h. This avoids including mgmt.h in
every file using adapter functions like socket and hid.
---
android/adapter.h | 2 ++
android/hidhost.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/adapter.h b/android/adapter.h
index c62b859..3bda9d9 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -23,6 +23,8 @@
typedef void (*bt_adapter_ready)(int err);
+struct mgmt;
+
void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
bt_adapter_ready cb);
diff --git a/android/hidhost.c b/android/hidhost.c
index 683938f..8c3e9f6 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -38,7 +38,6 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "lib/uuid.h"
-#include "src/shared/mgmt.h"
#include "src/sdp-client.h"
#include "src/glib-helper.h"
#include "profiles/input/uhid_copy.h"
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 1/9] android/hal-sock: Add debug flag printing
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384178627-25991-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-sock.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index b7bc88e..eafa451 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -55,8 +55,8 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %s chan %d sock %p type %d service_name %s",
- btuuid2str(uuid), chan, sock, type, service_name);
+ DBG("uuid %s chan %d sock %p type %d service_name %s flags 0x%02x",
+ btuuid2str(uuid), chan, sock, type, service_name, flags);
switch (type) {
case BTSOCK_RFCOMM:
@@ -82,8 +82,8 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %s chan %d sock %p type %d", btuuid2str(uuid), chan, sock,
- type);
+ DBG("uuid %s chan %d sock %p type %d flags 0x%02x",
+ btuuid2str(uuid), chan, sock, type, flags);
if (type != BTSOCK_RFCOMM) {
error("Socket type %u not supported", type);
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 0/9] Socket HAL
From: Andrei Emeltchenko @ 2013-11-11 14:03 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This is initial code implementing socket HAL. Receiving files
through OPP currently working somehow.
For tracking rfcomm sockets I use structure rfslot which has following
fields:
- real_sock - real RFCOMM socket
- fd - fd to communicate with Android framework
- hal_fd - fd passed to Android framework with CMSG
Andrei Emeltchenko (9):
android/hal-sock: Add debug flag printing
android: Avoid unneeded includes
android/ahl-sock: Add connect signal to socket
android/hal-sock: Initial listen handle
android/hal-sock: Implement socket accepted event
android/hal-sock: Implement Android RFCOMM stack events
android/hal-sock: Implement RFCOMM events
android/hal-sock: Implement accept signal over Android fd
android/hal-sock: Write channel to Android fd
android/adapter.h | 2 +
android/hal-msg.h | 2 +
android/hal-sock.c | 8 +-
android/hidhost.c | 1 -
android/socket.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++-
android/socket.h | 7 ++
6 files changed, 277 insertions(+), 7 deletions(-)
--
1.7.10.4
^ permalink raw reply
* Re: [RFCv1 2/9] android: Avoid unneeded includes
From: Szymon Janc @ 2013-11-11 13:31 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Andrei Emeltchenko, linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJMGQHVog9cPDqqLfe7ocdBy4UTrW+T9a6SjWWE=qd6=w@mail.gmail.com>
Hi Luiz,
On Monday 11 November 2013 15:20:21 Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Mon, Nov 11, 2013 at 2:37 PM, Andrei Emeltchenko
>
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > Declare struct mgmt in adapter.h. This avoids including mgmt.h in
> > every file using adapter functions like socket and hid.
> > ---
> >
> > android/adapter.h | 2 ++
> > android/hidhost.c | 1 -
> > 2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/android/adapter.h b/android/adapter.h
> > index c62b859..3bda9d9 100644
> > --- a/android/adapter.h
> > +++ b/android/adapter.h
> > @@ -23,6 +23,8 @@
> >
> > typedef void (*bt_adapter_ready)(int err);
> >
> > +struct mgmt;
> > +
> >
> > void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
> >
> > bt_adapter_ready
> > cb);
> >
> > diff --git a/android/hidhost.c b/android/hidhost.c
> > index 683938f..8c3e9f6 100644
> > --- a/android/hidhost.c
> > +++ b/android/hidhost.c
> > @@ -38,7 +38,6 @@
> >
> > #include "lib/sdp.h"
> > #include "lib/sdp_lib.h"
> > #include "lib/uuid.h"
> >
> > -#include "src/shared/mgmt.h"
> >
> > #include "src/sdp-client.h"
> > #include "src/glib-helper.h"
> > #include "profiles/input/uhid_copy.h"
> >
> > --
> > 1.7.10.4
>
> Well it looks like we need to find a proper place for the mgmt
> interaction, or then perhaps pass the fd and use mgmt_new on adapter
> but that seems to require some work as it does create a different mgmt
> objects with different queues which I don't think is safe to use.
I've some patches that try to address this issue. Should be able to send them
soon.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [RFCv1 2/9] android: Avoid unneeded includes
From: Luiz Augusto von Dentz @ 2013-11-11 13:20 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384173438-21708-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Mon, Nov 11, 2013 at 2:37 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Declare struct mgmt in adapter.h. This avoids including mgmt.h in
> every file using adapter functions like socket and hid.
> ---
> android/adapter.h | 2 ++
> android/hidhost.c | 1 -
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/android/adapter.h b/android/adapter.h
> index c62b859..3bda9d9 100644
> --- a/android/adapter.h
> +++ b/android/adapter.h
> @@ -23,6 +23,8 @@
>
> typedef void (*bt_adapter_ready)(int err);
>
> +struct mgmt;
> +
> void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
> bt_adapter_ready cb);
>
> diff --git a/android/hidhost.c b/android/hidhost.c
> index 683938f..8c3e9f6 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -38,7 +38,6 @@
> #include "lib/sdp.h"
> #include "lib/sdp_lib.h"
> #include "lib/uuid.h"
> -#include "src/shared/mgmt.h"
> #include "src/sdp-client.h"
> #include "src/glib-helper.h"
> #include "profiles/input/uhid_copy.h"
> --
> 1.7.10.4
Well it looks like we need to find a proper place for the mgmt
interaction, or then perhaps pass the fd and use mgmt_new on adapter
but that seems to require some work as it does create a different mgmt
objects with different queues which I don't think is safe to use.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 3/3] obex: Use XDG_RUNTIME_DIR as a default root
From: Luiz Augusto von Dentz @ 2013-11-11 13:01 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384173342.1898.8.camel@nuvo>
Hi Bastien,
On Mon, Nov 11, 2013 at 2:35 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Mon, 2013-11-11 at 11:00 +0200, Luiz Augusto von Dentz wrote:
>> Hi Bastien,
>>
>> On Sun, Nov 10, 2013 at 3:46 PM, Bastien Nocera <hadess@hadess.net> wrote:
>> > On Sat, 2013-11-09 at 18:03 +0100, Bastien Nocera wrote:
>> >> It's per-user, so we won't try to overwrite somebody else's
>> >> files in /tmp when that happens.
>> >
>> > There might be another useful directory instead. We could use
>> > g_get_user_cache_dir() instead of the run-time dir. This would save
>> > cross-partition moves by default, making the move to the Downloads dir
>> > atomic (a single rename, which can fail, iterate until we find a "free"
>> > filename).
>> >
>> > Is that better for you?
>>
>> Yep, it sounds better. Regarding renaming that is up the agent, if you
>> really want to do that its probably fine but Im still not convinced
>> this is absolutely necessary if obexd is running with the same user as
>> the agent can just create the file while authorizing so you wouldn't
>> need to move after completed, but again this is completely up to the
>> agent to decide where the files should go.
>
> You seem to think that all the application/services running under one
> user would have the same rights. That's currently the case, but won't be
> in the future.
Interesting that would cause some problems for sure...
>> Btw, what about fd passing? In theory we can create a different
>> version of the agent interface to enable passing fd directly, and in
>> fact we were thinking about this already as for some services you
>> wanted them to be dynamic so we were thinking on having this set by
>> the agent when it registers.
>
> I'm fine with a file descriptor as well, but obex push server is
> currently broken in GNOME 3.10. I'm happy doing the changes in GNOME
> 3.12 (due in 6 months).
>
> Can we get the cache dir change in, and make the API change later on?
Yep, lets use the cache dir and then think about the API change.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [RFCv1 9/9] android/hal-sock: Write channel to Android fd
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 20f4e38..0188646 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -27,6 +27,7 @@
#include <glib.h>
#include <stdbool.h>
+#include <unistd.h>
#include <errno.h>
#include "lib/bluetooth.h"
@@ -292,6 +293,10 @@ static int handle_listen(void *buf)
rfslot->real_sock = g_io_channel_unix_get_fd(io);
rfcomm_srv_list = g_list_append(rfcomm_srv_list, rfslot);
+ /* TODO: Check this */
+ if (write(rfslot->fd, &ch, sizeof(ch)) < 0)
+ return -1;
+
DBG("real_sock %d fd %d hal_fd %d",
rfslot->real_sock, rfslot->fd, rfslot->hal_fd);
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 8/9] android/hal-sock: Implement accept signal over Android fd
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Android expects to get accept signal over file descriptor which was
set during listen HAL call.
---
android/socket.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index a962cdc..20f4e38 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -36,6 +36,7 @@
#include "hal-ipc.h"
#include "ipc.h"
#include "adapter.h"
+#include "utils.h"
#include "socket.h"
/* Simple list of RFCOMM server sockets */
@@ -68,6 +69,45 @@ static struct rfcomm_slot *create_rfslot(int sock)
return rfslot;
}
+static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
+{
+ ssize_t ret;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+ struct iovec iv;
+ char msgbuf[CMSG_SPACE(1)];
+
+ DBG("len %d sock_fd %d send_fd %d", len, sock_fd, send_fd);
+
+ if (sock_fd == -1 || send_fd == -1)
+ return -1;
+
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = msgbuf;
+ msg.msg_controllen = sizeof(msgbuf);
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd));
+ memcpy(CMSG_DATA(cmsg), &send_fd, sizeof(send_fd));
+
+ iv.iov_base = (unsigned char *) buf;
+ iv.iov_len = len;
+
+ msg.msg_iov = &iv;
+ msg.msg_iovlen = 1;
+
+ ret = sendmsg(sock_fd, &msg, MSG_NOSIGNAL);
+ if (ret < 0) {
+ error("sendmsg(): sock_fd %d send_fd %d: %s",
+ sock_fd, send_fd, strerror(errno));
+ return ret;
+ }
+
+ return ret;
+}
+
static const uint8_t UUID_PBAP[] = {
0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
@@ -161,6 +201,21 @@ static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
return TRUE;
}
+static void socket_send_accept(struct rfcomm_slot *rfslot, bdaddr_t *bdaddr,
+ int fd_accepted)
+{
+ struct hal_sock_connect_signal cmd;
+
+ DBG("");
+
+ cmd.size = sizeof(cmd);
+ bdaddr2android(bdaddr, cmd.bdaddr);
+ cmd.channel = rfslot->channel;
+ cmd.status = 0;
+
+ bt_sock_send_fd(rfslot->fd, &cmd, sizeof(cmd), fd_accepted);
+}
+
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
struct rfcomm_slot *rfslot = user_data;
@@ -190,6 +245,8 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
rfslot_acc = create_rfslot(sock_acc);
rfcomm_accepted_list = g_list_append(rfcomm_accepted_list, rfslot_acc);
+ socket_send_accept(rfslot, &dst, rfslot_acc->hal_fd);
+
/* Handle events from Android */
io_stack = g_io_channel_unix_new(rfslot_acc->fd);
g_io_add_watch(io_stack, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 7/9] android/hal-sock: Implement RFCOMM events
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Copy data from RFCOMM socket to Android framework.
---
android/socket.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index dfad9da..a962cdc 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -129,6 +129,35 @@ static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
gpointer data)
{
+ struct rfcomm_slot *rfslot = data;
+ unsigned char buf[1024] = { 0 };
+ int len;
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ error("Socket error: sock %d cond %d",
+ g_io_channel_unix_get_fd(io), cond);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return FALSE;
+ }
+
+ /* FIXME check real_sock vs sock(io) */
+ len = recv(rfslot->real_sock, buf, sizeof(buf), 0);
+ if (len <= 0) {
+ error("recv(): %s sock %d", strerror(errno), rfslot->real_sock);
+ return FALSE;
+ }
+
+ DBG("read %d bytes, write to fd %d", len, rfslot->fd);
+
+ if (send(rfslot->fd, buf, len, MSG_DONTWAIT) < 0) {
+ error("send(): %s sock %d", strerror(errno), rfslot->fd);
+ return FALSE;
+ }
+
return TRUE;
}
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 6/9] android/hal-sock: Implement Android RFCOMM stack events
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Handle events from Android framework. Write everything to real RFCOMM
socket.
---
android/socket.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 0ee53ba..dfad9da 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -94,6 +94,35 @@ static int get_rfcomm_chan(const uint8_t *uuid)
static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
gpointer data)
{
+ struct rfcomm_slot *rfslot = data;
+ unsigned char buf[1024] = { 0 };
+ int len;
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ error("Socket error: sock %d cond %d",
+ g_io_channel_unix_get_fd(io), cond);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return FALSE;
+ }
+
+ /* FIXME check fd vs sock(io) */
+ len = recv(rfslot->fd, buf, sizeof(buf), 0);
+ if (len <= 0) {
+ error("recv(): %s", strerror(errno));
+ return FALSE;
+ }
+
+ DBG("read %d bytes write to %d", len, rfslot->real_sock);
+
+ if (send(rfslot->real_sock, buf, len, 0) < 0) {
+ error("send(): %s", strerror(errno));
+ return FALSE;
+ }
+
return TRUE;
}
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 5/9] android/hal-sock: Implement socket accepted event
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
When we get accepted event we create rfcomm slot and start listening
for events from Android framework and from RFCOMM real socket.
---
android/socket.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 80cb39e..0ee53ba 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -91,8 +91,58 @@ static int get_rfcomm_chan(const uint8_t *uuid)
return -1;
}
+static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
+ gpointer data)
+{
+ return TRUE;
+}
+
+static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
+ gpointer data)
+{
+ return TRUE;
+}
+
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
+ struct rfcomm_slot *rfslot = user_data;
+ struct rfcomm_slot *rfslot_acc;
+ GIOChannel *io_stack;
+ bdaddr_t dst;
+ char address[18];
+ int sock_acc;
+
+ bt_io_get(io, &err,
+ BT_IO_OPT_DEST_BDADDR, &dst,
+ BT_IO_OPT_INVALID);
+ if (err) {
+ error("%s", err->message);
+ g_io_channel_shutdown(io, TRUE, NULL);
+ return;
+ }
+
+ ba2str(&dst, address);
+ DBG("Incoming connection from %s rfslot %p", address, rfslot);
+
+ DBG("rfslot: fd %d hal_fd %d real_sock %d chan %u sock %d",
+ rfslot->fd, rfslot->hal_fd, rfslot->real_sock, rfslot->channel,
+ g_io_channel_unix_get_fd(io));
+
+ sock_acc = g_io_channel_unix_get_fd(io);
+ rfslot_acc = create_rfslot(sock_acc);
+ rfcomm_accepted_list = g_list_append(rfcomm_accepted_list, rfslot_acc);
+
+ /* Handle events from Android */
+ io_stack = g_io_channel_unix_new(rfslot_acc->fd);
+ g_io_add_watch(io_stack, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ sock_stack_event_cb, rfslot_acc);
+ g_io_channel_unref(io_stack);
+
+ /* Handle rfcomm events */
+ g_io_add_watch(io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ sock_rfcomm_event_cb, rfslot_acc);
+
+ DBG("rfslot %p rfslot_acc %p", rfslot, rfslot_acc);
}
static int handle_listen(void *buf)
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 4/9] android/hal-sock: Initial listen handle
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Handle HAL socket listen call. Create RFCOMM socket and wait for events.
---
android/socket.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 92 insertions(+), 2 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index c283c5f..80cb39e 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -27,22 +27,112 @@
#include <glib.h>
#include <stdbool.h>
+#include <errno.h>
#include "lib/bluetooth.h"
+#include "btio/btio.h"
#include "log.h"
#include "hal-msg.h"
#include "hal-ipc.h"
#include "ipc.h"
+#include "adapter.h"
#include "socket.h"
+/* Simple list of RFCOMM server sockets */
+GList *rfcomm_srv_list = NULL;
+/* Simple list of RFCOMM accepted sockets */
+GList *rfcomm_accepted_list = NULL;
-static int handle_listen(void *buf)
+struct rfcomm_slot {
+ int fd;
+ int hal_fd;
+ int real_sock;
+ uint32_t channel;
+};
+
+static struct rfcomm_slot *create_rfslot(int sock)
{
- DBG("Not implemented");
+ int fds[2] = {-1, -1};
+ struct rfcomm_slot *rfslot;
+
+ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0) {
+ error("socketpair(): %s", strerror(errno));
+ return NULL;
+ }
+
+ rfslot = g_malloc0(sizeof(*rfslot));
+ rfslot->fd = fds[0];
+ rfslot->hal_fd = fds[1];
+ rfslot->real_sock = sock;
+
+ return rfslot;
+}
+
+static const uint8_t UUID_PBAP[] = {
+ 0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+};
+#define RFCOMM_CHAN_PBAP 19
+
+static const uint8_t UUID_OPP[] = {
+ 0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+};
+#define RFCOMM_CHAN_OPP 12
+
+static int get_rfcomm_chan(const uint8_t *uuid)
+{
+ if (!memcmp(UUID_PBAP, uuid, sizeof(UUID_PBAP)))
+ return RFCOMM_CHAN_PBAP;
+
+ if (!memcmp(UUID_OPP, uuid, sizeof(UUID_OPP)))
+ return RFCOMM_CHAN_OPP;
return -1;
}
+static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
+{
+}
+
+static int handle_listen(void *buf)
+{
+ struct hal_cmd_sock_listen *cmd = buf;
+ const bdaddr_t *src = bt_adapter_get_address();
+ struct rfcomm_slot *rfslot;
+ GIOChannel *io;
+ GError *err = NULL;
+ int ch;
+
+ DBG("");
+
+ ch = get_rfcomm_chan(cmd->uuid);
+ if (ch < 0)
+ return -1;
+
+ DBG("rfcomm channel %u", ch);
+
+ rfslot = create_rfslot(-1);
+
+ io = bt_io_listen(connect_cb, NULL, rfslot, NULL, &err,
+ BT_IO_OPT_SOURCE_BDADDR, src,
+ BT_IO_OPT_CHANNEL, ch,
+ BT_IO_OPT_INVALID);
+ if (!io) {
+ error("Failed listen: %s", err->message);
+ g_error_free(err);
+ return -1;
+ }
+
+ rfslot->real_sock = g_io_channel_unix_get_fd(io);
+ rfcomm_srv_list = g_list_append(rfcomm_srv_list, rfslot);
+
+ DBG("real_sock %d fd %d hal_fd %d",
+ rfslot->real_sock, rfslot->fd, rfslot->hal_fd);
+
+ return rfslot->hal_fd;
+}
+
static int handle_connect(void *buf)
{
DBG("Not implemented");
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 3/9] android/ahl-sock: Add connect signal to socket
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Connect signal is used to pass information to framework that socket
is accepted.
---
android/hal-msg.h | 2 ++
android/socket.h | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 569c8ea..68cc8ed 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -232,6 +232,8 @@ struct hal_cmd_sock_connect {
uint8_t flags;
} __attribute__((packed));
+/* Bluetooth Hidhost HAL api */
+
#define HAL_OP_HIDHOST_CONNECT 0x01
struct hal_cmd_hidhost_connect {
uint8_t bdaddr[6];
diff --git a/android/socket.h b/android/socket.h
index 7aa5574..ba56c9b 100644
--- a/android/socket.h
+++ b/android/socket.h
@@ -21,6 +21,13 @@
*
*/
+struct hal_sock_connect_signal {
+ short size;
+ uint8_t bdaddr[6];
+ int channel;
+ int status;
+} __attribute__((packed));
+
void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
bool bt_socket_register(int sk, const bdaddr_t *addr);
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 2/9] android: Avoid unneeded includes
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Declare struct mgmt in adapter.h. This avoids including mgmt.h in
every file using adapter functions like socket and hid.
---
android/adapter.h | 2 ++
android/hidhost.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/adapter.h b/android/adapter.h
index c62b859..3bda9d9 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -23,6 +23,8 @@
typedef void (*bt_adapter_ready)(int err);
+struct mgmt;
+
void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
bt_adapter_ready cb);
diff --git a/android/hidhost.c b/android/hidhost.c
index 683938f..8c3e9f6 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -38,7 +38,6 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "lib/uuid.h"
-#include "src/shared/mgmt.h"
#include "src/sdp-client.h"
#include "src/glib-helper.h"
#include "profiles/input/uhid_copy.h"
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 1/9] android/hal-sock: Add debug flag printing
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1384173438-21708-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-sock.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index b7bc88e..eafa451 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -55,8 +55,8 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %s chan %d sock %p type %d service_name %s",
- btuuid2str(uuid), chan, sock, type, service_name);
+ DBG("uuid %s chan %d sock %p type %d service_name %s flags 0x%02x",
+ btuuid2str(uuid), chan, sock, type, service_name, flags);
switch (type) {
case BTSOCK_RFCOMM:
@@ -82,8 +82,8 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %s chan %d sock %p type %d", btuuid2str(uuid), chan, sock,
- type);
+ DBG("uuid %s chan %d sock %p type %d flags 0x%02x",
+ btuuid2str(uuid), chan, sock, type, flags);
if (type != BTSOCK_RFCOMM) {
error("Socket type %u not supported", type);
--
1.7.10.4
^ permalink raw reply related
* [RFCv1 0/9] Socket HAL
From: Andrei Emeltchenko @ 2013-11-11 12:37 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This is initial code implementing socket HAL. Receiving files
through OPP currently working somehow.
For tracking rfcomm sockets I use structure rfslot which has following
fields:
- real_sock - real RFCOMM socket
- fd - fd to communicate with Android framework
- hal_fd - fd passed to Android framework with CMSG
Andrei Emeltchenko (9):
android/hal-sock: Add debug flag printing
android: Avoid unneeded includes
android/ahl-sock: Add connect signal to socket
android/hal-sock: Initial listen handle
android/hal-sock: Implement socket accepted event
android/hal-sock: Implement Android RFCOMM stack events
android/hal-sock: Implement RFCOMM events
android/hal-sock: Implement accept signal over Android fd
android/hal-sock: Write channel to Android fd
android/adapter.h | 2 +
android/hal-msg.h | 2 +
android/hal-sock.c | 8 +-
android/hidhost.c | 1 -
android/socket.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++-
android/socket.h | 7 ++
6 files changed, 277 insertions(+), 7 deletions(-)
--
1.7.10.4
^ permalink raw reply
* Re: [PATCH 3/3] obex: Use XDG_RUNTIME_DIR as a default root
From: Bastien Nocera @ 2013-11-11 12:35 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZK4m11-41ShyWO+LS3VqoUuqWbX8d2C9JssvGuKxJMiDA@mail.gmail.com>
On Mon, 2013-11-11 at 11:00 +0200, Luiz Augusto von Dentz wrote:
> Hi Bastien,
>
> On Sun, Nov 10, 2013 at 3:46 PM, Bastien Nocera <hadess@hadess.net> wrote:
> > On Sat, 2013-11-09 at 18:03 +0100, Bastien Nocera wrote:
> >> It's per-user, so we won't try to overwrite somebody else's
> >> files in /tmp when that happens.
> >
> > There might be another useful directory instead. We could use
> > g_get_user_cache_dir() instead of the run-time dir. This would save
> > cross-partition moves by default, making the move to the Downloads dir
> > atomic (a single rename, which can fail, iterate until we find a "free"
> > filename).
> >
> > Is that better for you?
>
> Yep, it sounds better. Regarding renaming that is up the agent, if you
> really want to do that its probably fine but Im still not convinced
> this is absolutely necessary if obexd is running with the same user as
> the agent can just create the file while authorizing so you wouldn't
> need to move after completed, but again this is completely up to the
> agent to decide where the files should go.
You seem to think that all the application/services running under one
user would have the same rights. That's currently the case, but won't be
in the future.
> Btw, what about fd passing? In theory we can create a different
> version of the agent interface to enable passing fd directly, and in
> fact we were thinking about this already as for some services you
> wanted them to be dynamic so we were thinking on having this set by
> the agent when it registers.
I'm fine with a file descriptor as well, but obex push server is
currently broken in GNOME 3.10. I'm happy doing the changes in GNOME
3.12 (due in 6 months).
Can we get the cache dir change in, and make the API change later on?
Cheers
^ permalink raw reply
* [PATCH 3/3] android/hidhost: Set info request from HAL is not supported
From: Ravi kumar Veeramally @ 2013-11-11 12:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1384172130-29837-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Data from hal_cmd_hidhost_set_info is usefull only when we create
UHID device. Once device is created all the transactions will be
done through the fd. There is no way to use this information
once device is created with HID internals.
---
android/hidhost.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 816fe3e..6579ff3 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -857,7 +857,11 @@ static uint8_t bt_hid_virtual_unplug(struct hal_cmd_hidhost_virtual_unplug *cmd,
static uint8_t bt_hid_info(struct hal_cmd_hidhost_set_info *cmd, uint16_t len)
{
- DBG("Not Implemented");
+ /* Data from hal_cmd_hidhost_set_info is usefull only when we create
+ * UHID device. Once device is created all the transactions will be
+ * done through the fd. There is no way to use this information
+ * once device is created with HID internals. */
+ DBG("Not supported");
return HAL_STATUS_FAILED;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/3] android/hidhost: Remove deprecated idle opcode from ipc document
From: Ravi kumar Veeramally @ 2013-11-11 12:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1384172130-29837-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Idle time is deprecated in HID 1_1. So remove it from ipc document
and update GET_REPORT and VIRTUAL_UNPLUG opcode values.
---
android/hal-ipc-api.txt | 10 ++--------
android/hal-msg.h | 4 ++--
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 91ea280..57f4c13 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -614,20 +614,14 @@ Notifications:
0x01 = Boot
0xff = Unsupported
- Opcode 0x84 - Idle Time notification
-
- Notification parameters: Remote address (6 octets)
- Status (1 octet)
- Idle time (2 octets)
-
- Opcode 0x85 - Get Report notification
+ Opcode 0x84 - Get Report notification
Notification parameters: Remote address (6 octets)
Status (1 octet)
Report length (2 octets)
Report data (variable)
- Opcode 0x86 - Virtual Unplug notification
+ Opcode 0x85 - Virtual Unplug notification
Notification parameters: Remote address (6 octets)
Status (1 octet)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 569c8ea..1d20afd 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -472,7 +472,7 @@ struct hal_ev_hidhost_proto_mode {
uint8_t mode;
} __attribute__((packed));
-#define HAL_EV_HIDHOST_GET_REPORT 0x85
+#define HAL_EV_HIDHOST_GET_REPORT 0x84
struct hal_ev_hidhost_get_report {
uint8_t bdaddr[6];
uint8_t status;
@@ -480,7 +480,7 @@ struct hal_ev_hidhost_get_report {
uint8_t data[0];
} __attribute__((packed));
-#define HAL_EV_HIDHOST_VIRTUAL_UNPLUG 0x86
+#define HAL_EV_HIDHOST_VIRTUAL_UNPLUG 0x85
struct hal_ev_hidhost_virtual_unplug {
uint8_t bdaddr[6];
uint8_t status;
--
1.8.3.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox