Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH -v2 5/5] Bluetooth: Remove parent socket usage from l2cap_core.c
From: Gustavo Padovan @ 2013-10-21 16:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1382372501-28562-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

The parent socket is not used inside the L2CAP core anymore. We only lock
it to indirect access through the new_connection() callback. The hold of
the socket lock was moved to the new_connection() callback.

Inside L2CAP core the channel lock is now used in l2cap_le_conn_ready()
and l2cap_conn_ready() to protect the execution of these two functions
during the handling of new incoming connections.

This change remove the socket lock usage from L2CAP core while keeping
the code safe against race conditions.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 14 ++++----------
 net/bluetooth/l2cap_sock.c |  4 ++++
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c65ddc8..bb6d35e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1362,7 +1362,6 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
 static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 {
 	struct hci_conn *hcon = conn->hcon;
-	struct sock *parent;
 	struct l2cap_chan *chan, *pchan;
 	u8 dst_type;
 
@@ -1384,9 +1383,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 	if (hci_blacklist_lookup(hcon->hdev, &hcon->dst, dst_type))
 		return;
 
-	parent = pchan->sk;
-
-	lock_sock(parent);
+	l2cap_chan_lock(pchan);
 
 	chan = pchan->ops->new_connection(pchan);
 	if (!chan)
@@ -1402,7 +1399,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 	__l2cap_chan_add(conn, chan);
 
 clean:
-	release_sock(parent);
+	l2cap_chan_unlock(pchan);
 }
 
 static void l2cap_conn_ready(struct l2cap_conn *conn)
@@ -3705,7 +3702,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
 	struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
 	struct l2cap_conn_rsp rsp;
 	struct l2cap_chan *chan = NULL, *pchan;
-	struct sock *parent;
 	int result, status = L2CAP_CS_NO_INFO;
 
 	u16 dcid = 0, scid = __le16_to_cpu(req->scid);
@@ -3721,10 +3717,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
 		goto sendresp;
 	}
 
-	parent = pchan->sk;
-
 	mutex_lock(&conn->chan_lock);
-	lock_sock(parent);
+	l2cap_chan_lock(pchan);
 
 	/* Check if the ACL is secure enough (if not SDP) */
 	if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) &&
@@ -3800,7 +3794,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
 	}
 
 response:
-	release_sock(parent);
+	l2cap_chan_unlock(pchan);
 	mutex_unlock(&conn->chan_lock);
 
 sendresp:
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index e559992..a159b0e 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1042,6 +1042,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
 {
 	struct sock *sk, *parent = chan->data;
 
+	lock_sock(parent);
+
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(parent)) {
 		BT_DBG("backlog full %d", parent->sk_ack_backlog);
@@ -1059,6 +1061,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
 
 	bt_accept_enqueue(parent, sk);
 
+	release_sock(parent);
+
 	return l2cap_pi(sk)->chan;
 }
 
-- 
1.8.3.1


^ permalink raw reply related

* Review about Linux Kernel Bluetooth subsystem in a new Linux Kernel Networking book.
From: Rami Rosen @ 2013-10-21 16:47 UTC (permalink / raw)
  To: linux-bluetooth

Hello, all,

I am looking for reviewers for a section about the Linux Kernel
Bluetooth subsystem. It is only 9 pages.

Please reply privately off list.

-- 
regards,
Rami Rosen

^ permalink raw reply

* Re: Issue with the kernel  bluetooth  HCI_Delete_Stored_Link_Key command patch
From: Pavel Machek @ 2013-10-21 18:48 UTC (permalink / raw)
  To: alexandre@maloteaux.net, marcel, gustavo, johan.hedberg,
	linux-bluetooth
  Cc: johan.hedberg
In-Reply-To: <413864804.130358.1382295198929.open-xchange@oxwebmail.registrar-servers.com>

Hi!

Bouncing to right people.

And yes, my thinkpad was hit by something similar, but this one was
subsequently fixed.

									Pavel

On Sun 2013-10-20 14:53:18, alexandre@maloteaux.net wrote:
>  Hi
> I bought recently an old blutooth dongle in Gabon/Africa. I guess it is a pretty
> old 2.0 as it was written "Vista Compatible" on the box : Bus 004 Device 004: ID
> 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
> 
> When trying to use it on ubuntu 13.10 - 3.11.0-12-generic, i got the same issue 
> with hcitool :
> Can't init device hci0: Operation not supported (95)
> 
> The main issue is that the bit7 of octet 6 is set in the supported command
> response (see attached hcidump).
> 
> i tried to recompile the kernel by commenting this code :
> 
> +       if (hdev->commands[6] & 0x80) {
> +               struct hci_cp_delete_stored_link_key cp;
> +
> +               bacpy(&cp.bdaddr, BDADDR_ANY);
> +               cp.delete_all = 0x01;
> +               hci_req_add(req, HCI_OP_DELETE_STORED_LINK_KEY,
> +                           sizeof(cp), &cp);
> +       }
> 
> and it worked.
> 
> Are you sure about the flag position in the supported command ?
> If so , is not possible on fail just to continue the init process as this
> command seems obsolete.
> 
> Best Regards

> hcidump -X
> HCI sniffer - Bluetooth packet analyzer ver 2.5
> device: hci0 snap_len: 1500 filter: 0xffffffff
> < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
> > HCI Event: Command Complete (0x0e) plen 12
>     Read Local Supported Features (0x04|0x0003) ncmd 1
>     status 0x00
>     Features: 0xff 0xff 0x8d 0xfe 0x9b 0xf9 0x00 0x80
> < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> > HCI Event: Command Complete (0x0e) plen 12
>     Read Local Version Information (0x04|0x0001) ncmd 1
>     status 0x00
>     HCI Version: 2.0 (0x3) HCI Revision: 0x3000
>     LMP Version: 2.0 (0x3) LMP Subversion: 0x420b
>     Manufacturer: Broadcom Corporation (15)
> < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> > HCI Event: Command Complete (0x0e) plen 10
>     Read BD ADDR (0x04|0x0009) ncmd 1
>     status 0x00 bdaddr 00:19:86:00:19:C2
> < HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> > HCI Event: Command Complete (0x0e) plen 11
>     Read Buffer Size (0x04|0x0005) ncmd 1
>     status 0x00
>     ACL MTU 1017:8 SCO MTU 64:0
> < HCI Command: Read Class of Device (0x03|0x0023) plen 0
> > HCI Event: Command Complete (0x0e) plen 7
>     Read Class of Device (0x03|0x0023) ncmd 1
>     status 0x00 class 0x000000
> < HCI Command: Read Local Name (0x03|0x0014) plen 0
> > HCI Event: Command Complete (0x0e) plen 252
>     Read Local Name (0x03|0x0014) ncmd 1
>     status 0x00 name 'BCM2045B'
> < HCI Command: Read Voice Setting (0x03|0x0025) plen 0
> > HCI Event: Command Complete (0x0e) plen 6
>     Read Voice Setting (0x03|0x0025) ncmd 1
>     status 0x00 voice setting 0x0060
> < HCI Command: Set Event Filter (0x03|0x0005) plen 1
>     type 0 condition 0
>     Clear all filters
> > HCI Event: Command Complete (0x0e) plen 4
>     Set Event Filter (0x03|0x0005) ncmd 1
>     status 0x00
> < HCI Command: Write Connection Accept Timeout (0x03|0x0016) plen 2
>     timeout 32000
> > HCI Event: Command Complete (0x0e) plen 4
>     Write Connection Accept Timeout (0x03|0x0016) ncmd 1
>     status 0x00
> < HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0
> > HCI Event: Command Complete (0x0e) plen 8
>     Read Page Scan Activity (0x03|0x001b) ncmd 1
>     status 0x00 interval 2048 window 18
> < HCI Command: Read Page Scan Type (0x03|0x0046) plen 0
> > HCI Event: Command Complete (0x0e) plen 5
>     Read Page Scan Type (0x03|0x0046) ncmd 1
>     0000: 00 00                                             ..
> < HCI Command: Set Event Mask (0x03|0x0001) plen 8
>     Mask: 0xfffffbff07180000
> > HCI Event: Command Complete (0x0e) plen 4
>     Set Event Mask (0x03|0x0001) ncmd 1
>     status 0x00
> < HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0
> > HCI Event: Command Complete (0x0e) plen 68
>     Read Local Supported Commands (0x04|0x0002) ncmd 1
>     status 0x00
>     Commands: ffffffffffffcfffffffffff0300ffff07
> < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1
>     mode 1
> > HCI Event: Command Complete (0x0e) plen 4
>     Write Inquiry Mode (0x03|0x0045) ncmd 1
>     status 0x00
> < HCI Command: Read Local Extended Features (0x04|0x0004) plen 1
>     page 1
> > HCI Event: Command Complete (0x0e) plen 14
>     Read Local Extended Features (0x04|0x0004) ncmd 1
>     status 0x00 page 1 max 0
>     Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> < HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7
>     bdaddr 00:00:00:00:00:00 all 1
> > HCI Event: Command Complete (0x0e) plen 4
>     Delete Stored Link Key (0x03|0x0012) ncmd 1
>     status 0x11 deleted 0
>     Error: Unsupported Feature or Parameter Value
> 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* [PATCH v3 01/11] android/hal: Move IPC and sockets related code to separate file
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

hal-ipc will provide functionality related to IPC initialization and
sockets handling (including upcoming callbacks thread).

This allow to remove code from bluetooth HAL not related to adapter.
---
 Makefile.android        |   3 +-
 android/Android.mk      |   1 +
 android/hal-bluetooth.c | 118 ++---------------------------------------
 android/hal-ipc.c       | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/hal-ipc.h       |  19 +++++++
 5 files changed, 163 insertions(+), 115 deletions(-)
 create mode 100644 android/hal-ipc.c
 create mode 100644 android/hal-ipc.h

diff --git a/Makefile.android b/Makefile.android
index f5a5834..c2010b3 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -33,7 +33,8 @@ android_libhal_internal_la_SOURCES = android/hal.h android/hal-bluetooth.c \
 					android/hardware/bt_sock.h \
 					android/hardware/hardware.h \
 					android/cutils/properties.h \
-					android/hal-log.h
+					android/hal-log.h \
+					android/hal-ipc.h android/hal-ipc.c
 
 android_libhal_internal_la_CPPFLAGS = -I$(srcdir)/android
 
diff --git a/android/Android.mk b/android/Android.mk
index 87445ed..bd3d48a 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -51,6 +51,7 @@ include $(BUILD_EXECUTABLE)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
+	hal-ipc.c \
 	hal-bluetooth.c \
 	hal-sock.c \
 	hal-hidhost.c \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 589cb1b..b9a78b6 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -17,136 +17,26 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <stdbool.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <poll.h>
+#include <string.h>
 
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 #include <hardware/bt_hh.h>
 #include <hardware/bt_pan.h>
 
-#include <cutils/properties.h>
-
 #include "hal-log.h"
 #include "hal.h"
 #include "hal-msg.h"
-
-#define SERVICE_NAME "bluetoothd"
-#define CONNECT_TIMEOUT (5 * 1000)
+#include "hal-ipc.h"
 
 bt_callbacks_t *bt_hal_cbacks = NULL;
 
-static int cmd_sk = -1;
-static int notif_sk = -1;
-
 static bool interface_ready(void)
 {
 	return bt_hal_cbacks != NULL;
 }
 
-static int accept_connection(int sk)
-{
-	int err;
-	struct pollfd pfd;
-	int new_sk;
-
-	memset(&pfd, 0 , sizeof(pfd));
-	pfd.fd = sk;
-	pfd.events = POLLIN;
-
-	err = poll(&pfd, 1, CONNECT_TIMEOUT);
-	if (err < 0) {
-		err = errno;
-		error("Failed to poll: %d (%s)", err, strerror(err));
-		return -1;
-	}
-
-	if (err == 0) {
-		error("bluetoothd connect timeout");
-		return -1;
-	}
-
-	new_sk = accept(sk, NULL, NULL);
-	if (new_sk < 0) {
-		err = errno;
-		error("Failed to accept socket: %d (%s)", err, strerror(err));
-		return -1;
-	}
-
-	return new_sk;
-}
-
-static bool start_daemon(void)
-{
-	struct sockaddr_un addr;
-	int sk;
-	int err;
-
-	sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
-	if (sk < 0) {
-		err = errno;
-		error("Failed to create socket: %d (%s)", err,
-							strerror(err));
-		return false;
-	}
-
-	memset(&addr, 0, sizeof(addr));
-	addr.sun_family = AF_UNIX;
-
-	memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
-
-	if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-		err = errno;
-		error("Failed to bind socket: %d (%s)", err, strerror(err));
-		close(sk);
-		return false;
-	}
-
-	if (listen(sk, 2) < 0) {
-		err = errno;
-		error("Failed to listen on socket: %d (%s)", err,
-								strerror(err));
-		close(sk);
-		return false;
-	}
-
-	/* Start Android Bluetooth daemon service */
-	property_set("ctl.start", SERVICE_NAME);
-
-	cmd_sk = accept_connection(sk);
-	if (cmd_sk < 0) {
-		close(sk);
-		return false;
-	}
-
-	notif_sk = accept_connection(sk);
-	if (notif_sk < 0) {
-		close(sk);
-		close(cmd_sk);
-		cmd_sk = -1;
-		return false;
-	}
-
-	info("bluetoothd connected");
-
-	close(sk);
-
-	return true;
-}
-
-static void stop_daemon(void)
-{
-	close(cmd_sk);
-	cmd_sk = -1;
-
-	close(notif_sk);
-	notif_sk = -1;
-}
-
 static int init(bt_callbacks_t *callbacks)
 {
 	DBG("");
@@ -154,7 +44,7 @@ static int init(bt_callbacks_t *callbacks)
 	if (interface_ready())
 		return BT_STATUS_SUCCESS;
 
-	if (!start_daemon())
+	if (!hal_ipc_init())
 		return BT_STATUS_FAIL;
 
 	bt_hal_cbacks = callbacks;
@@ -186,7 +76,7 @@ static void cleanup(void)
 	if (!interface_ready())
 		return;
 
-	stop_daemon();
+	hal_ipc_cleanup();
 
 	bt_hal_cbacks = NULL;
 }
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
new file mode 100644
index 0000000..6db67f2
--- /dev/null
+++ b/android/hal-ipc.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <pthread.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <poll.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#include <cutils/properties.h>
+
+#include "hal-msg.h"
+#include "hal-log.h"
+#include "hal-ipc.h"
+
+#define CONNECT_TIMEOUT (5 * 1000)
+#define SERVICE_NAME "bluetoothd"
+
+static int cmd_sk = -1;
+static int notif_sk = -1;
+
+static int accept_connection(int sk)
+{
+	int err;
+	struct pollfd pfd;
+	int new_sk;
+
+	memset(&pfd, 0 , sizeof(pfd));
+	pfd.fd = sk;
+	pfd.events = POLLIN;
+
+	err = poll(&pfd, 1, CONNECT_TIMEOUT);
+	if (err < 0) {
+		err = errno;
+		error("Failed to poll: %d (%s)", err, strerror(err));
+		return -1;
+	}
+
+	if (err == 0) {
+		error("bluetoothd connect timeout");
+		return -1;
+	}
+
+	new_sk = accept(sk, NULL, NULL);
+	if (new_sk < 0) {
+		err = errno;
+		error("Failed to accept socket: %d (%s)", err, strerror(err));
+		return -1;
+	}
+
+	return new_sk;
+}
+
+bool hal_ipc_init(void)
+{
+	struct sockaddr_un addr;
+	int sk;
+	int err;
+
+	sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
+	if (sk < 0) {
+		err = errno;
+		error("Failed to create socket: %d (%s)", err,
+							strerror(err));
+		return false;
+	}
+
+	memset(&addr, 0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+
+	memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
+
+	if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+		err = errno;
+		error("Failed to bind socket: %d (%s)", err, strerror(err));
+		close(sk);
+		return false;
+	}
+
+	if (listen(sk, 2) < 0) {
+		err = errno;
+		error("Failed to listen on socket: %d (%s)", err,
+								strerror(err));
+		close(sk);
+		return false;
+	}
+
+	/* Start Android Bluetooth daemon service */
+	property_set("ctl.start", SERVICE_NAME);
+
+	cmd_sk = accept_connection(sk);
+	if (cmd_sk < 0) {
+		close(sk);
+		return false;
+	}
+
+	notif_sk = accept_connection(sk);
+	if (notif_sk < 0) {
+		close(sk);
+		close(cmd_sk);
+		cmd_sk = -1;
+		return false;
+	}
+
+	info("bluetoothd connected");
+
+	close(sk);
+
+	return true;
+}
+
+void hal_ipc_cleanup(void)
+{
+	close(cmd_sk);
+	cmd_sk = -1;
+
+	close(notif_sk);
+	notif_sk = -1;
+}
diff --git a/android/hal-ipc.h b/android/hal-ipc.h
new file mode 100644
index 0000000..2f71668
--- /dev/null
+++ b/android/hal-ipc.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+bool hal_ipc_init(void);
+void hal_ipc_cleanup(void);
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 02/11] android/hal: Add initial code for sending commands
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This will be used by all HAL modules to send commands and get response
from daemon. In case of any protocol error abort.

If non-null fd pointer is passed auxiliary data with passed FD will be
received as part of response.
---
 android/hal-ipc.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/hal-ipc.h |   3 ++
 2 files changed, 110 insertions(+)

diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 6db67f2..5b77adf 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -37,6 +37,8 @@
 static int cmd_sk = -1;
 static int notif_sk = -1;
 
+static pthread_mutex_t cmd_sk_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 static int accept_connection(int sk)
 {
 	int err;
@@ -135,3 +137,108 @@ void hal_ipc_cleanup(void)
 	close(notif_sk);
 	notif_sk = -1;
 }
+
+int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
+					size_t rsp_len, void *rsp, int *fd)
+{
+	ssize_t ret;
+	struct msghdr msg;
+	struct iovec iv[2];
+	struct hal_msg_hdr hal_msg;
+	char cmsgbuf[CMSG_SPACE(sizeof(int))];
+
+	if (cmd_sk < 0)
+		return -EBADF;
+
+	memset(&msg, 0, sizeof(msg));
+	memset(&hal_msg, 0, sizeof(hal_msg));
+
+	hal_msg.service_id = service_id;
+	hal_msg.opcode = opcode;
+	hal_msg.len = len;
+
+	iv[0].iov_base = &hal_msg;
+	iv[0].iov_len = sizeof(hal_msg);
+
+	iv[1].iov_base = param;
+	iv[1].iov_len = len;
+
+	msg.msg_iov = iv;
+	msg.msg_iovlen = 2;
+
+	pthread_mutex_lock(&cmd_sk_mutex);
+
+	ret = sendmsg(cmd_sk, &msg, 0);
+	if (ret < 0) {
+		error("Sending command failed, aborting :%s", strerror(errno));
+		pthread_mutex_unlock(&cmd_sk_mutex);
+		exit(EXIT_FAILURE);
+	}
+
+	memset(&msg, 0, sizeof(msg));
+	memset(&hal_msg, 0, sizeof(hal_msg));
+
+	iv[0].iov_base = &hal_msg;
+	iv[0].iov_len = sizeof(hal_msg);
+
+	iv[1].iov_base = rsp;
+	iv[1].iov_len = rsp_len;
+
+	msg.msg_iov = iv;
+	msg.msg_iovlen = 2;
+
+	if (fd) {
+		memset(cmsgbuf, 0, sizeof(cmsgbuf));
+		msg.msg_control = cmsgbuf;
+		msg.msg_controllen = sizeof(cmsgbuf);
+	}
+
+	ret = recvmsg(cmd_sk, &msg, 0);
+	if (ret < 0) {
+		error("Receiving command response failed, aborting :%s",
+							strerror(errno));
+		pthread_mutex_unlock(&cmd_sk_mutex);
+		exit(EXIT_FAILURE);
+	}
+
+	pthread_mutex_unlock(&cmd_sk_mutex);
+
+	if (ret < (ssize_t) sizeof(hal_msg)) {
+		error("Too small response received(%zd bytes), aborting", ret);
+		exit(EXIT_FAILURE);
+	}
+
+	if (ret != (ssize_t) (sizeof(hal_msg) + hal_msg.len)) {
+		error("Malformed response received(%zd bytes), aborting", ret);
+		exit(EXIT_FAILURE);
+	}
+
+	if (hal_msg.opcode != opcode && hal_msg.opcode != HAL_MSG_OP_ERROR) {
+		error("Invalid opcode received (%u vs %u), aborting",
+						hal_msg.opcode, opcode);
+		exit(EXIT_FAILURE);
+	}
+
+	if (hal_msg.opcode == HAL_MSG_OP_ERROR) {
+		struct hal_msg_rsp_error *err = rsp;
+		return -err->status;
+	}
+
+	/* Receive auxiliary data in msg */
+	if (fd) {
+		struct cmsghdr *cmsg;
+
+		*fd = -1;
+
+		for (cmsg = CMSG_FIRSTHDR(&msg); !cmsg;
+					cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+			if (cmsg->cmsg_level == SOL_SOCKET
+					&& cmsg->cmsg_type == SCM_RIGHTS) {
+				memcpy(fd, CMSG_DATA(cmsg), sizeof(int));
+				break;
+			}
+		}
+	}
+
+	return hal_msg.len;
+}
diff --git a/android/hal-ipc.h b/android/hal-ipc.h
index 2f71668..3834e7d 100644
--- a/android/hal-ipc.h
+++ b/android/hal-ipc.h
@@ -17,3 +17,6 @@
 
 bool hal_ipc_init(void);
 void hal_ipc_cleanup(void);
+
+int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
+					size_t rsp_len, void *rsp, int *fd);
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 03/11] android/hal: Register adapter and socket interface on HAL init
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

After daemon is started HAL needs to register those two interfaces
to performe initialization procedure as described in IPC documentation.
---
 android/hal-bluetooth.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index b9a78b6..f408a7d 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -39,6 +39,9 @@ static bool interface_ready(void)
 
 static int init(bt_callbacks_t *callbacks)
 {
+	struct hal_msg_cmd_register_module cmd;
+	struct hal_msg_rsp_error rsp;
+
 	DBG("");
 
 	if (interface_ready())
@@ -49,7 +52,32 @@ static int init(bt_callbacks_t *callbacks)
 
 	bt_hal_cbacks = callbacks;
 
+	cmd.service_id = HAL_SERVICE_ID_BLUETOOTH;
+
+	if (hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE,
+						sizeof(cmd), &cmd,
+						sizeof(rsp), &rsp, NULL) < 0) {
+		error("Failed to register 'bluetooth' service");
+		goto fail;
+	}
+
+	cmd.service_id = HAL_SERVICE_ID_SOCK;
+
+	if (hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE,
+						sizeof(cmd), &cmd,
+						sizeof(rsp), &rsp, NULL) < 0) {
+		error("Failed to register 'socket' service");
+		goto fail;
+	}
+
 	return BT_STATUS_SUCCESS;
+
+fail:
+
+	hal_ipc_cleanup();
+	bt_hal_cbacks = NULL;
+	return BT_STATUS_FAIL;
+
 }
 
 static int enable(void)
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 04/11] android: Split command and notification socket watch
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

---
 android/main.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/android/main.c b/android/main.c
index fac1003..b24451e 100644
--- a/android/main.c
+++ b/android/main.c
@@ -62,10 +62,19 @@ static GIOChannel *hal_notif_io = NULL;
 
 static volatile sig_atomic_t __terminated = 0;
 
-static gboolean watch_cb(GIOChannel *io, GIOCondition cond,
+static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
-	info("HAL socket closed, terminating");
+	info("HAL command socket closed, terminating");
+	g_main_loop_quit(event_loop);
+
+	return FALSE;
+}
+
+static gboolean notif_watch_cb(GIOChannel *io, GIOCondition cond,
+							gpointer user_data)
+{
+	info("HAL notification socket closed, terminating");
 	g_main_loop_quit(event_loop);
 
 	return FALSE;
@@ -123,7 +132,7 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
 
 	cond = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
 
-	g_io_add_watch(io, cond, watch_cb, NULL);
+	g_io_add_watch(io, cond, notif_watch_cb, NULL);
 
 	info("Successfully connected to HAL");
 
@@ -144,7 +153,7 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 
 	cond = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
 
-	g_io_add_watch(io, cond, watch_cb, NULL);
+	g_io_add_watch(io, cond, cmd_watch_cb, NULL);
 
 	hal_notif_io = connect_hal(notif_connect_cb);
 	if (!hal_notif_io) {
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 05/11] android: Define IPC MTU size
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This defines buffer size big enough to hold the largest possible IPC
message.
---
 android/hal-msg.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4440fc8..58fff4d 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -21,6 +21,8 @@
  *
  */
 
+#define BLUEZ_HAL_MTU 1024
+
 static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
 
 struct hal_msg_hdr {
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 06/11] android: Add HAL_SERVICE_ID_MAX define
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

---
 android/hal-msg.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 58fff4d..f19d0d0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -42,6 +42,8 @@ struct hal_msg_hdr {
 #define HAL_SERVICE_ID_AVRCP		8
 #define HAL_SERVICE_ID_GATT		9
 
+#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_GATT
+
 /* Core Service */
 
 #define HAL_MSG_OP_ERROR		0x00
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 07/11] android: Add main_quit function
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This will allow to stop mainloop from outside of main.c.
---
 android/main.c |  6 ++++++
 android/main.h | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 android/main.h

diff --git a/android/main.c b/android/main.c
index b24451e..04e8a48 100644
--- a/android/main.c
+++ b/android/main.c
@@ -48,6 +48,7 @@
 
 #include "adapter.h"
 #include "hal-msg.h"
+#include "main.h"
 
 static GMainLoop *event_loop;
 static struct mgmt *mgmt_if = NULL;
@@ -418,6 +419,11 @@ static void cleanup_hal_connection(void)
 	}
 }
 
+void main_quit(void)
+{
+	g_main_loop_quit(event_loop);
+}
+
 int main(int argc, char *argv[])
 {
 	GOptionContext *context;
diff --git a/android/main.h b/android/main.h
new file mode 100644
index 0000000..4aa2557
--- /dev/null
+++ b/android/main.h
@@ -0,0 +1,24 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+void main_quit(void);
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 08/11] android: Add IPC helper for sending command responses and notification
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

If send failed mainloop is stopped.
---
 Makefile.android   |  3 +-
 android/Android.mk |  1 +
 android/ipc.c      | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/ipc.h      | 25 +++++++++++++++++
 4 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 android/ipc.c
 create mode 100644 android/ipc.h

diff --git a/Makefile.android b/Makefile.android
index c2010b3..aebc715 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -8,7 +8,8 @@ android_bluetoothd_SOURCES =	android/main.c \
 				src/sdpd-service.c src/sdpd-request.c \
 				src/shared/util.h src/shared/util.c \
 				src/shared/mgmt.h src/shared/mgmt.c \
-				android/adapter.h android/adapter.c
+				android/adapter.h android/adapter.c \
+				android/ipc.h android/ipc.c
 
 android_bluetoothd_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
 
diff --git a/android/Android.mk b/android/Android.mk
index bd3d48a..679c12b 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -16,6 +16,7 @@ LOCAL_SRC_FILES := \
 	main.c \
 	log.c \
 	adapter.c \
+	ipc.c ipc.h \
 	../src/shared/mgmt.c \
 	../src/shared/util.c \
 	../src/sdpd-database.c \
diff --git a/android/ipc.c b/android/ipc.c
new file mode 100644
index 0000000..449ba23
--- /dev/null
+++ b/android/ipc.c
@@ -0,0 +1,80 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <stddef.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/socket.h>
+
+#include <glib.h>
+
+#include "hal-msg.h"
+#include "ipc.h"
+#include "log.h"
+#include "main.h"
+
+void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
+							void *param, int fd)
+{
+	struct msghdr msg;
+	struct iovec iv[2];
+	struct hal_msg_hdr hal_msg;
+	char cmsgbuf[CMSG_SPACE(sizeof(int))];
+	struct cmsghdr *cmsg;
+
+
+	memset(&msg, 0, sizeof(msg));
+	memset(&hal_msg, 0, sizeof(hal_msg));
+
+	hal_msg.service_id = service_id;
+	hal_msg.opcode = opcode;
+	hal_msg.len = len;
+
+	iv[0].iov_base = &hal_msg;
+	iv[0].iov_len = sizeof(hal_msg);
+
+	iv[1].iov_base = param;
+	iv[1].iov_len = len;
+
+	msg.msg_iov = iv;
+	msg.msg_iovlen = 2;
+
+	if (fd >= 0) {
+		cmsg = CMSG_FIRSTHDR(&msg);
+		cmsg->cmsg_level = SOL_SOCKET;
+		cmsg->cmsg_type = SCM_RIGHTS;
+		cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+
+		/* Initialize the payload */
+		memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
+
+		msg.msg_control = cmsgbuf;
+		msg.msg_controllen = sizeof(cmsgbuf);
+	}
+
+	if (sendmsg(g_io_channel_unix_get_fd(io), &msg, 0) < 0) {
+		error("IPC send failed, terminating :%s", strerror(errno));
+		main_quit();
+	}
+}
diff --git a/android/ipc.h b/android/ipc.h
new file mode 100644
index 0000000..db92c97
--- /dev/null
+++ b/android/ipc.h
@@ -0,0 +1,25 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
+							void *param, int fd);
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 09/11] android: Add IPC helper for convenient error sending
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This simple helper will simplify error paths in code.
---
 android/ipc.c | 9 +++++++++
 android/ipc.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/android/ipc.c b/android/ipc.c
index 449ba23..406a19b 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -78,3 +78,12 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
 		main_quit();
 	}
 }
+
+void ipc_send_error(GIOChannel *io, uint8_t service_id, uint8_t status)
+{
+	struct hal_msg_rsp_error err;
+
+	err.status = status;
+
+	ipc_send(io, service_id, HAL_MSG_OP_ERROR, sizeof(err), &err, -1);
+}
diff --git a/android/ipc.h b/android/ipc.h
index db92c97..4b0ee2a 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -23,3 +23,4 @@
 
 void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
 							void *param, int fd);
+void ipc_send_error(GIOChannel *io, uint8_t service_id, uint8_t status);
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 10/11] android: Add initial code for handling HAL commands
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This enable watch for input and do basic sanity checks on received
command. If there is protocol error mainloop is stopped and daemon
exits.
---
 android/main.c | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/android/main.c b/android/main.c
index 04e8a48..72a1272 100644
--- a/android/main.c
+++ b/android/main.c
@@ -48,6 +48,7 @@
 
 #include "adapter.h"
 #include "hal-msg.h"
+#include "ipc.h"
 #include "main.h"
 
 static GMainLoop *event_loop;
@@ -66,9 +67,45 @@ static volatile sig_atomic_t __terminated = 0;
 static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
-	info("HAL command socket closed, terminating");
-	g_main_loop_quit(event_loop);
+	int fd;
+	ssize_t ret;
+	char buf[BLUEZ_HAL_MTU];
+	struct hal_msg_hdr *msg = (void *) buf;
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+		info("HAL command socket closed, terminating");
+		goto fail;
+	}
+
+	fd = g_io_channel_unix_get_fd(io);
+
+	ret = read(fd, buf, sizeof(buf));
+	if (ret < 0) {
+		error("HAL command read failed, terminating (%s)",
+							strerror(errno));
+		goto fail;
+	}
+
+	if (ret < (ssize_t) sizeof(*msg)) {
+		error("HAL command too small, terminating (%zd)", ret);
+		goto fail;
+	}
+
+	if (ret != (ssize_t) (sizeof(*msg) + msg->len)) {
+		error("Malformed HAL command (%zd bytes), terminating", ret);
+		goto fail;
+	}
+
+	switch (msg->service_id) {
+	default:
+		ipc_send_error(hal_cmd_io, msg->service_id, 0x01);
+		break;
+	}
+
+	return TRUE;
 
+fail:
+	g_main_loop_quit(event_loop);
 	return FALSE;
 }
 
@@ -152,7 +189,7 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
-	cond = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+	cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
 
 	g_io_add_watch(io, cond, cmd_watch_cb, NULL);
 
-- 
1.8.4


^ permalink raw reply related

* [PATCH v3 11/11] android: Implement core service functionality
From: Szymon Janc @ 2013-10-21 18:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

This allows HAL to register and unregister of services.
---
 android/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/android/main.c b/android/main.c
index 72a1272..9bf2aea 100644
--- a/android/main.c
+++ b/android/main.c
@@ -64,6 +64,57 @@ static GIOChannel *hal_notif_io = NULL;
 
 static volatile sig_atomic_t __terminated = 0;
 
+static bool services[HAL_SERVICE_ID_MAX + 1] = {false};
+
+static void service_register(void *buf, uint16_t len)
+{
+	struct hal_msg_cmd_register_module *m = buf;
+
+	if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id]) {
+		ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+		return;
+	}
+
+	services[m->service_id] = true;
+
+	ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE, 0,
+								NULL, -1);
+
+	info("Service ID=%u registered", m->service_id);
+}
+
+static void service_unregister(void *buf, uint16_t len)
+{
+	struct hal_msg_cmd_unregister_module *m = buf;
+
+	if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id]) {
+		ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+		return;
+	}
+
+	services[m->service_id] = false;
+
+	ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_UNREGISTER_MODULE,
+								0, NULL, -1);
+
+	info("Service ID=%u unregistered", m->service_id);
+}
+
+static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
+{
+	switch (opcode) {
+	case HAL_MSG_OP_REGISTER_MODULE:
+		service_register(buf, len);
+		break;
+	case HAL_MSG_OP_UNREGISTER_MODULE:
+		service_unregister(buf, len);
+		break;
+	default:
+		ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+		break;
+	}
+}
+
 static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -97,6 +148,9 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 	}
 
 	switch (msg->service_id) {
+	case HAL_SERVICE_ID_CORE:
+		handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
+		break;
 	default:
 		ipc_send_error(hal_cmd_io, msg->service_id, 0x01);
 		break;
-- 
1.8.4


^ permalink raw reply related

* Re: Issue with the kernel  bluetooth  HCI_Delete_Stored_Link_Key command patch
From: Johan Hedberg @ 2013-10-21 19:20 UTC (permalink / raw)
  To: Pavel Machek; +Cc: alexandre@maloteaux.net, marcel, gustavo, linux-bluetooth
In-Reply-To: <20131021184839.GA10592@amd.pavel.ucw.cz>

Hi,

On Mon, Oct 21, 2013, Pavel Machek wrote:
> > old 2.0 as it was written "Vista Compatible" on the box : Bus 004
> > Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth
> > Dongle (HCI mode)
<snip>
> > < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> > > HCI Event: Command Complete (0x0e) plen 12
> >     Read Local Version Information (0x04|0x0001) ncmd 1
> >     status 0x00
> >     HCI Version: 2.0 (0x3) HCI Revision: 0x3000
> >     LMP Version: 2.0 (0x3) LMP Subversion: 0x420b
> >     Manufacturer: Broadcom Corporation (15)
> > < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> > > HCI Event: Command Complete (0x0e) plen 10
> >     Read BD ADDR (0x04|0x0009) ncmd 1
> >     status 0x00 bdaddr 00:19:86:00:19:C2
> > < HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> > > HCI Event: Command Complete (0x0e) plen 11
> >     Read Buffer Size (0x04|0x0005) ncmd 1
> >     status 0x00
> >     ACL MTU 1017:8 SCO MTU 64:0
> > < HCI Command: Read Class of Device (0x03|0x0023) plen 0
> > > HCI Event: Command Complete (0x0e) plen 7
> >     Read Class of Device (0x03|0x0023) ncmd 1
> >     status 0x00 class 0x000000
> > < HCI Command: Read Local Name (0x03|0x0014) plen 0
> > > HCI Event: Command Complete (0x0e) plen 252
> >     Read Local Name (0x03|0x0014) ncmd 1
> >     status 0x00 name 'BCM2045B'

There is something very strange in this hardware if it's reporting
Broadcom on HCI but CSR over USB. Considering that these two companies
are competitors I'd be inclined to think this HW is by neither one, i.e.
possibly counterfeit. This, combined with the fact that it's not
compliant with the Bluetooth specification, is not very likely to
inspire efforts to get it fixed.

Johan

^ permalink raw reply

* [PATCH] android: Add README file with instructions
From: Szymon Janc @ 2013-10-21 19:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This file cotains help on how BlueZ for Android should be build, run
and test.
---
 Makefile.android |  2 +-
 android/README   | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 android/README

diff --git a/Makefile.android b/Makefile.android
index f5a5834..1252682 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -79,7 +79,7 @@ EXTRA_DIST += android/client/terminal.c \
 		android/client/history.h \
 		android/client/terminal.h
 
-EXTRA_DIST += android/hal-ipc-api.txt
+EXTRA_DIST += android/hal-ipc-api.txt android/README
 
 EXTRA_DIST += android/hardware/bluetooth.h \
 		android/hardware/bt_av.h \
diff --git a/android/README b/android/README
new file mode 100644
index 0000000..21690d4
--- /dev/null
+++ b/android/README
@@ -0,0 +1,83 @@
+BlueZ for Android
+*****************
+
+Since Android 4.2 there exists a well standardized HAL interface that the
+Bluetooth stack is expected to provide and which enables the easy replacement
+of the stack of choice on Android. Android BlueZ is intended as a drop-in
+replacement to Android provided Bluetooth stack.
+
+More details about BlueZ for Android architecture and components can be found
+in android/hal-apc-api.txt file.
+
+===============================
+Building and running on Android
+===============================
+
+Build requirements
+==================
+
+- GLib - Android 4.2 or later don't provide GLib and one must provide it in
+'external/bluetooth/glib' folder of Android tree. Sample Android GLib port
+is available at https://code.google.com/p/android-bluez.glib/
+
+- Bionic support - BlueZ requires signalfd and timerfd APIs to be provided
+by libc library. Currently only 'master' branch available at
+https://android.googlesource.com/platform/bionic provides all required
+functionality and running BlueZ on older branch requires backporting missing
+features. Sample Bionic for Android on Intel Architecture (Android-IA) with all
+required features backported is available at
+https://code.google.com/p/android-bluez.bionic/
+
+Runtime requirements
+====================
+
+BlueZ HAL library requires 'bluetoothd' service to be available on Android
+system. This can be done by defining service in init.rc file of targeted board:
+
+service bluetoothd logwrapper /system/bin/bluetoothd
+  class main
+  group bluetooth net_bt_stack
+  disabled
+  oneshot
+
+Sample can be found at https://code.google.com/p/android-bluez.system-core/
+
+Downloading and building
+========================
+
+Building for Android requires full Android AOSP source tree. Sample Android-IA
+tree with all required components present is available at
+http://code.google.com/p/android-bluez/
+
+Downloading:
+repo init -u https://code.google.com/p/android-bluez.manifest/ -m topics/bluez
+repo sync
+
+Build for Intel ultrabook:
+'source build/envsetup.sh'
+'lunch core_mesa-eng'
+'make allimages -j8'
+
+After full build is done it is possible to rebuild only BlueZ:
+'cd external/bluetooth/bluez/android/'
+'mm' (or 'mm -B' to force rebuilding of all files)
+'adb sync' to update target device.
+
+=============================
+Building and running on Linux
+=============================
+It is possible to build and test BlueZ for Android daemon on Linux (eg. PC).
+Simply follow instructions available at README file in BlueZ top directory.
+Android daemon binary is located at android/bluetoothd.
+
+=======
+Testing
+=======
+
+BT HAL test tools located in android/haltest is provided for HAL level testing
+of both Android daemon and HAL library. Start it and type 'adapter init' in
+prompt to initialize HAL library. On Android required bluetoothd service will
+be started automatically. On Linux it is required to start android/bluetoothd
+manually before init command timeout. To deinitialize HAL library and stop
+daemon type 'adapter cleanup'. Type 'help' for more information. Tab completion
+is also supported.
\ No newline at end of file
-- 
1.8.4


^ permalink raw reply related

* Re: [PATCH v3 01/11] android/hal: Move IPC and sockets related code to separate file
From: Johan Hedberg @ 2013-10-21 19:58 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1382381811-28123-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Mon, Oct 21, 2013, Szymon Janc wrote:
> hal-ipc will provide functionality related to IPC initialization and
> sockets handling (including upcoming callbacks thread).
> 
> This allow to remove code from bluetooth HAL not related to adapter.
> ---
>  Makefile.android        |   3 +-
>  android/Android.mk      |   1 +
>  android/hal-bluetooth.c | 118 ++---------------------------------------
>  android/hal-ipc.c       | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
>  android/hal-ipc.h       |  19 +++++++
>  5 files changed, 163 insertions(+), 115 deletions(-)
>  create mode 100644 android/hal-ipc.c
>  create mode 100644 android/hal-ipc.h

All patches, except 5/11 (which was unnecessary) have been applied along
with minor fixes. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH -v2 1/5] Bluetooth: Remove not used struct sock
From: Marcel Holtmann @ 2013-10-21 20:01 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1382372501-28562-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> It is a leftover from the recent effort of remove sk usage from L2CAP
> core.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> net/bluetooth/l2cap_core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)

all 5 patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: Issue with the kernel bluetooth HCI_Delete_Stored_Link_Key command patch
From: alexandre @ 2013-10-21 20:06 UTC (permalink / raw)
  To: Pavel Machek, Johan Hedberg; +Cc: gustavo, marcel, linux-bluetooth
In-Reply-To: <20131021192021.GA19575@x220.p-661hnu-f1>

[-- Attachment #1: Type: text/plain, Size: 2033 bytes --]

Hi

It seems that i m not the only one in this situation and i managed to fix it by
applying this pending patch :
https://bugzilla.kernel.org/show_bug.cgi?id=60824

Thanks for your answer and time.


> On October 21, 2013 at 3:20 PM Johan Hedberg <johan.hedberg@gmail.com> wrote:
>
>
> Hi,
>
> On Mon, Oct 21, 2013, Pavel Machek wrote:
> > > old 2.0 as it was written "Vista Compatible" on the box : Bus 004
> > > Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth
> > > Dongle (HCI mode)
> <snip>
> > > < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 12
> > > Read Local Version Information (0x04|0x0001) ncmd 1
> > > status 0x00
> > > HCI Version: 2.0 (0x3) HCI Revision: 0x3000
> > > LMP Version: 2.0 (0x3) LMP Subversion: 0x420b
> > > Manufacturer: Broadcom Corporation (15)
> > > < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 10
> > > Read BD ADDR (0x04|0x0009) ncmd 1
> > > status 0x00 bdaddr 00:19:86:00:19:C2
> > > < HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 11
> > > Read Buffer Size (0x04|0x0005) ncmd 1
> > > status 0x00
> > > ACL MTU 1017:8 SCO MTU 64:0
> > > < HCI Command: Read Class of Device (0x03|0x0023) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 7
> > > Read Class of Device (0x03|0x0023) ncmd 1
> > > status 0x00 class 0x000000
> > > < HCI Command: Read Local Name (0x03|0x0014) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 252
> > > Read Local Name (0x03|0x0014) ncmd 1
> > > status 0x00 name 'BCM2045B'
>
> There is something very strange in this hardware if it's reporting
> Broadcom on HCI but CSR over USB. Considering that these two companies
> are competitors I'd be inclined to think this HW is by neither one, i.e.
> possibly counterfeit. This, combined with the fact that it's not
> compliant with the Bluetooth specification, is not very likely to
> inspire efforts to get it fixed.
>
> Johan

[-- Attachment #2: Type: text/html, Size: 3721 bytes --]

^ permalink raw reply

* [PATCH 1/3] Bluetooth: Add L2CAP channel to skb private data
From: Gustavo Padovan @ 2013-10-21 20:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Adding the channel to the skb private data makes possible to us know which
channel the skb we have came from.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk
---
 include/net/bluetooth/bluetooth.h | 1 +
 net/bluetooth/l2cap_sock.c        | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index bf2ddff..a707a02 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -282,6 +282,7 @@ struct bt_skb_cb {
 	__u8 incoming;
 	__u16 expect;
 	__u8 force_active;
+	struct l2cap_chan *chan;
 	struct l2cap_ctrl control;
 	struct hci_req_ctrl req;
 	bdaddr_t bdaddr;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index a159b0e..cba3162 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1174,6 +1174,8 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
 	if (!skb)
 		return ERR_PTR(err);
 
+	bt_cb(skb)->chan = chan;
+
 	return skb;
 }
 
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 2/3] Bluetooth: Use bt_cb(skb)->chan to send raw data back
From: Gustavo Padovan @ 2013-10-21 20:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1382386946-19797-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Instead of accessing skb->sk in L2CAP core we now compare the channel
a skb belongs to and not send it back if the channel is same. This change
removes another struct socket usage from L2CAP core.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index bb6d35e..0cef677 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2813,17 +2813,16 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
 	mutex_lock(&conn->chan_lock);
 
 	list_for_each_entry(chan, &conn->chan_l, list) {
-		struct sock *sk = chan->sk;
 		if (chan->chan_type != L2CAP_CHAN_RAW)
 			continue;
 
-		/* Don't send frame to the socket it came from */
-		if (skb->sk == sk)
+		/* Don't send frame to the channel it came from */
+		if (bt_cb(skb)->chan == chan)
 			continue;
+
 		nskb = skb_clone(skb, GFP_KERNEL);
 		if (!nskb)
 			continue;
-
 		if (chan->ops->recv(chan, nskb))
 			kfree_skb(nskb);
 	}
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 3/3] Bluetooth: Remove sk member from struct l2cap_chan
From: Gustavo Padovan @ 2013-10-21 20:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1382386946-19797-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

There is no access to chan->sk in L2CAP core now. This change marks the
end of the task of splitting L2CAP between Core and Socket, thus sk is now
gone from struct l2cap_chan.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 include/net/bluetooth/l2cap.h | 2 --
 net/bluetooth/l2cap_sock.c    | 2 --
 2 files changed, 4 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 3d922b9..5132990 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -435,8 +435,6 @@ struct l2cap_seq_list {
 #define L2CAP_SEQ_LIST_TAIL	0x8000
 
 struct l2cap_chan {
-	struct sock *sk;
-
 	struct l2cap_conn	*conn;
 	struct hci_conn		*hs_hcon;
 	struct hci_chan		*hs_hchan;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index cba3162..7cc24d2 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1374,8 +1374,6 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
 
 	l2cap_chan_hold(chan);
 
-	chan->sk = sk;
-
 	l2cap_pi(sk)->chan = chan;
 
 	return sk;
-- 
1.8.3.1


^ permalink raw reply related

* Re: [PATCH 1/3] Bluetooth: Add L2CAP channel to skb private data
From: Marcel Holtmann @ 2013-10-21 20:53 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1382386946-19797-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> Adding the channel to the skb private data makes possible to us know which
> channel the skb we have came from.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk
> ---
> include/net/bluetooth/bluetooth.h | 1 +
> net/bluetooth/l2cap_sock.c        | 2 ++
> 2 files changed, 3 insertions(+)

all 3 patches have been applied bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: Issue with the kernel  bluetooth  HCI_Delete_Stored_Link_Key command patch
From: Pavel Machek @ 2013-10-21 21:58 UTC (permalink / raw)
  To: alexandre@maloteaux.net, marcel, gustavo, linux-bluetooth
In-Reply-To: <20131021192021.GA19575@x220.p-661hnu-f1>

Hi!

> > > old 2.0 as it was written "Vista Compatible" on the box : Bus 004
> > > Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth
> > > Dongle (HCI mode)
> <snip>
> > > < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 12
> > >     Read Local Version Information (0x04|0x0001) ncmd 1
> > >     status 0x00
> > >     HCI Version: 2.0 (0x3) HCI Revision: 0x3000
> > >     LMP Version: 2.0 (0x3) LMP Subversion: 0x420b
> > >     Manufacturer: Broadcom Corporation (15)
> > > < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 10
> > >     Read BD ADDR (0x04|0x0009) ncmd 1
> > >     status 0x00 bdaddr 00:19:86:00:19:C2
> > > < HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 11
> > >     Read Buffer Size (0x04|0x0005) ncmd 1
> > >     status 0x00
> > >     ACL MTU 1017:8 SCO MTU 64:0
> > > < HCI Command: Read Class of Device (0x03|0x0023) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 7
> > >     Read Class of Device (0x03|0x0023) ncmd 1
> > >     status 0x00 class 0x000000
> > > < HCI Command: Read Local Name (0x03|0x0014) plen 0
> > > > HCI Event: Command Complete (0x0e) plen 252
> > >     Read Local Name (0x03|0x0014) ncmd 1
> > >     status 0x00 name 'BCM2045B'
> 
> There is something very strange in this hardware if it's reporting
> Broadcom on HCI but CSR over USB. Considering that these two companies
> are competitors I'd be inclined to think this HW is by neither one, i.e.
> possibly counterfeit. This, combined with the fact that it's not
> compliant with the Bluetooth specification, is not very likely to
> inspire efforts to get it fixed.

Actually, could you verify that it worked ok in some older kernel? If
so, it definitely _needs_ to be fixed.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* pull request: bluetooth-next 2013-10-21
From: Gustavo Padovan @ 2013-10-21 22:37 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 8588 bytes --]

Hi John,

One more big pull request for 3.13. These are the patches we queued during
last week. Here you will find a lot of improvements to the HCI and L2CAP and
MGMT layers with the main ones being a better debugfs support and end of work
of splitting L2CAP into Core and Socket parts.

Please pull!

	Gustavo

---
The following changes since commit 4b836f393bd8ed111857a6ee1865e44627266ec6:

  Bluetooth: Read current IAC LAP on controller setup (2013-10-14 19:31:18 -0300)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next for-upstream

for you to fetch changes up to d78a32a8fcf775111ccc9ba611a08ca5c29784b6:

  Bluetooth: Remove sk member from struct l2cap_chan (2013-10-21 13:50:56 -0700)

----------------------------------------------------------------
Gustavo Padovan (14):
      Bluetooth: Extend state_change() call to report errors too
      Bluetooth: Add l2cap_state_change_and_error()
      Bluetooth: Access sk_sndtimeo indirectly in l2cap_core.c
      Bluetooth: Add chan->ops->set_shutdown()
      Bluetooth: Move l2cap_wait_ack() to l2cap_sock.c
      Bluetooth: use l2cap_chan_ready() instead of duplicate code
      Bluetooth: Remove not used struct sock
      Bluetooth: Do not access chan->sk directly
      Bluetooth: Hold socket in defer callback in L2CAP socket
      Bluetooth: Remove socket lock from l2cap_state_change()
      Bluetooth: Remove parent socket usage from l2cap_core.c
      Bluetooth: Add L2CAP channel to skb private data
      Bluetooth: Use bt_cb(skb)->chan to send raw data back
      Bluetooth: Remove sk member from struct l2cap_chan

Johan Hedberg (20):
      Bluetooth: Fix L2CAP "Command Reject: Invalid CID" response
      Bluetooth: Remove unused command reject mapping for EMSGSIZE
      Bluetooth: Remove useless l2cap_err_to_reason function
      Bluetooth: Ignore A2MP data on non-BR/EDR links
      Bluetooth: Ignore SMP data on non-LE links
      Bluetooth: Fix updating the right variable in update_scan_rsp_data()
      Bluetooth: Reintroduce socket restrictions for LE sockets
      Bluetooth: Convert auto accept timer to use delayed work
      Bluetooth: Convert idle timer to use delayed work
      Bluetooth: Fix ATT socket backwards compatibility with user space
      Bluetooth: Check for flag instead of features in update_scan_rsp_data()
      Bluetooth: Check for flag instead of features in update_adv_data()
      Bluetooth: Add missing check for BREDR_ENABLED flag in update_class()
      Bluetooth: Refactor set_connectable settings update to separate function
      Bluetooth: Fix updating settings when there are no HCI commands to send
      Bluetooth: Move mgmt_pending_find to avoid forward declarations
      Bluetooth: Fix sending write_scan_enable when BR/EDR is disabled
      Bluetooth: Move HCI_LIMITED_DISCOVERABLE changes to a general place
      Bluetooth: Update Set Discoverable to support LE
      Bluetooth: Fix enabling fast connectable on LE-only controllers

Marcel Holtmann (71):
      Bluetooth: Fix minor coding style issue in set_connectable()
      Bluetooth: Use hci_request for discoverable timeout handling
      Bluetooth: Update advertising data based on management commands
      Bluetooth: Introduce flag for limited discoverable mode
      Bluetooth: Make mgmt_discoverable() return void
      Bluetooth: Make mgmt_connectable() return void
      Bluetooth: Make mgmt_write_scan_failed() return void
      Bluetooth: Update class of device after changing discoverable mode
      Bluetooth: Move arming of discoverable timeout to complete handler
      Bluetooth: Simplify the code for re-arming discoverable timeout
      Bluetooth: Add HCI command structure for writing current IAC LAP
      Bluetooth: Add support for entering limited discoverable mode
      Bluetooth: Make mgmt_new_link_key() return void
      Bluetooth: Move eir_append_data() function into mgmt.c
      Bluetooth: Move eir_get_length() function into hci_event.c
      Bluetooth: Update class of device on discoverable timeout
      Bluetooth: Add l2cap_chan_no_resume stub for A2MP
      Bluetooth: Make mgmt_pin_code_request() return void
      Bluetooth: Make mgmt_pin_code_reply_complete() return void
      Bluetooth: Make mgmt_pin_code_neg_reply_complete() return void
      Bluetooth: Make mgmt_auth_failed() return void
      Bluetooth: Make mgmt_auth_enable_complete() return void
      Bluetooth: Make mgmt_ssp_enable_complete() return void
      Bluetooth: Make mgmt_set_class_of_dev_complete() return void
      Bluetooth: Make mgmt_set_local_name_complete() return void
      Bluetooth: Make mgmt_read_local_oob_data_reply_complete() return void
      Bluetooth: Make mgmt_new_ltk() return void
      Bluetooth: Rename create_ad into create_adv_data
      Bluetooth: Store scan response data in HCI device
      Bluetooth: Set the scan response data when needed
      Bluetooth: Store device name in scan response data
      Bluetooth: Rename update_ad into update_adv_data
      Bluetooth: Remove duplicate definitions for advertising event types
      Bluetooth: Remove enable_hs declaration
      Bluetooth: Socket address parameter for CID is in little endian
      Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
      Bluetooth: Expose auto_accept_delay debugfs only when SSP is supported
      Bluetooth: Expose static address value for LE capable controllers
      Bluetooth: Expose current voice setting in debugfs
      Bluetooth: Add address type to device blacklist table
      Bluetooth: Move blacklist debugfs entry creation into hci_core.c
      Bluetooth: Move uuids debugfs entry creation into hci_core.c
      Bluetooth: Use IS_ERR_OR_NULL for checking bt_debugfs
      Bluetooth: Create HCI device debugfs directory in hci_register_dev
      Bluetooth: Create root debugfs directory during module init
      Bluetooth: Move device_add handling into hci_register_dev
      Bluetooth: Include address type in blacklist debugfs data
      Bluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c
      Bluetooth: Use BDADDR_BREDR type for old blacklist ioctl interface
      Bluetooth: Use hcon directly instead of conn->hcon where possible
      Bluetooth: Block ATT connection on LE when device is blocked
      Bluetooth: Move HCI device features into hci_core.c
      Bluetooth: Add workaround for buggy max_page features page value
      Bluetooth: Remove debug entry for connection features
      Bluetooth: Move manufacturer, hci_ver and hci_rev into hci_core.c
      Bluetooth: Store local version information only during setup phase
      Bluetooth: Move export of class of device information into hci_core.c
      Bluetooth: Expose current list of link keys via debugfs
      Bluetooth: Remove bus attribute in favor of hierarchy
      Bluetooth: Expose white list size information in debugfs
      Bluetooth: Expose current list of long term keys via debugfs
      Bluetooth: Select the own address type during initial setup phase
      Bluetooth: Expose debugfs entry read/write own address type
      Bluetooth: Expose setting if debug keys are used or not
      Bluetooth: Add LE features to debugfs if available
      Bluetooth: Remove interval parameter from HCI connection
      Bluetooth: Add support for setting SSP debug mode
      Bluetooth: Expose debugfs settings for LE connection interval
      Bluetooth: Add support for setting DUT mode
      Bluetooth: Fix UUID values in debugfs file
      Bluetooth: Fix minor coding style issue in hci_core.c

 include/net/bluetooth/bluetooth.h |   1 +
 include/net/bluetooth/hci.h       |  35 ++-
 include/net/bluetooth/hci_core.h  |  89 +++----
 include/net/bluetooth/l2cap.h     |  20 +-
 net/bluetooth/a2mp.c              |   9 +-
 net/bluetooth/af_bluetooth.c      |   9 +-
 net/bluetooth/hci_conn.c          |  48 ++--
 net/bluetooth/hci_core.c          | 803 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 net/bluetooth/hci_event.c         |  59 +++--
 net/bluetooth/hci_sock.c          |   4 +-
 net/bluetooth/hci_sysfs.c         | 373 ---------------------------
 net/bluetooth/l2cap_core.c        | 227 ++++++----------
 net/bluetooth/l2cap_sock.c        | 120 ++++++++-
 net/bluetooth/mgmt.c              | 637 ++++++++++++++++++++++++++++++++-------------
 net/bluetooth/rfcomm/core.c       |  14 +-
 net/bluetooth/rfcomm/sock.c       |  14 +-
 net/bluetooth/sco.c               |  13 +-
 net/bluetooth/smp.c               |   4 +-
 18 files changed, 1506 insertions(+), 973 deletions(-)


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox