* Re: Bluetooth high speed supported drivers or patches for kernel 3.11
From: Andrei Emeltchenko @ 2014-02-12 10:05 UTC (permalink / raw)
To: Viswanatham, RaviTeja; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <9BC883E0D59F6B4DBD525D460025714B08AE3825@deessmx03.dees.eberspaecher.com>
Hi Raviteja,
On Wed, Feb 12, 2014 at 09:58:19AM +0000, Viswanatham, RaviTeja wrote:
> Hello all,
>
> I bought a USB bluetooth 3.0 HS +Wifi dongle which I want to transfer
> data rate with 24Mbit/s. The dongle contains Realtek 8192cu and CSR
> drivers. I got to know from the bluez mailing list it contains SoftAMP.
I am afraid that the SoftAMP is supported only in Windows drivers.
Best regards
Andrei Emeltchenko
> I want to know is there any possibility to get the drivers or patches
> from the bluez which can enable the mac80211 to reach high speed.
>
> Any hints to get high speed data transfer rate.
^ permalink raw reply
* Bluetooth high speed supported drivers or patches for kernel 3.11
From: Viswanatham, RaviTeja @ 2014-02-12 9:58 UTC (permalink / raw)
To: bluez mailin list (linux-bluetooth@vger.kernel.org)
Hello all,
I bought a USB bluetooth 3.0 HS +Wifi dongle which I want to transfer data rate with 24Mbit/s. The dongle contains Realtek 8192cu and CSR drivers. I got to know from the bluez mailing list it contains SoftAMP. I want to know is there any possibility to get the drivers or patches from the bluez which can enable the mac80211 to reach high speed.
Any hints to get high speed data transfer rate.
Thanks in advance
Raviteja
^ permalink raw reply
* Re: [PATCH BlueZ 1/7] android: Use 16-bit UUID for SDP search
From: Luiz Augusto von Dentz @ 2014-02-12 9:58 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Anderson,
On Tue, Feb 11, 2014 at 8:32 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> These UUIDs are assigned by BT-SIG and therefore there is no need to
> use full 128-bit UUIDs. This also avoids unnecessary conversion from
> string representation.
> ---
> android/handsfree.c | 3 +--
> android/hidhost.c | 7 +++----
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/android/handsfree.c b/android/handsfree.c
> index 9482b2e..a869d58 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -34,7 +34,6 @@
> #include "lib/bluetooth.h"
> #include "lib/sdp.h"
> #include "lib/sdp_lib.h"
> -#include "lib/uuid.h"
> #include "src/sdp-client.h"
> #include "src/uuid-helper.h"
> #include "src/shared/hfp.h"
> @@ -294,7 +293,7 @@ static void handle_connect(const void *buf, uint16_t len)
>
> device_init(&bdaddr);
>
> - bt_string2uuid(&uuid, HFP_HS_UUID);
> + sdp_uuid16_create(&uuid, HANDSFREE_SVCLASS_ID);
> if (bt_search_service(&adapter_addr, &device.bdaddr, &uuid,
> sdp_search_cb, NULL, NULL, 0) < 0) {
> error("handsfree: SDP search failed");
> diff --git a/android/hidhost.c b/android/hidhost.c
> index 8bd3455..45fe14f 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -37,7 +37,6 @@
> #include "lib/bluetooth.h"
> #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/uuid-helper.h"
> @@ -751,7 +750,7 @@ static void hid_sdp_did_search_cb(sdp_list_t *recs, int err, gpointer data)
> dev->version = data->val.uint16;
> }
>
> - bt_string2uuid(&uuid, HID_UUID);
> + sdp_uuid16_create(&uuid, HID_SVCLASS_ID);
> if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
> hid_sdp_search_cb, dev, NULL, 0) < 0) {
> error("failed to search sdp details");
> @@ -792,7 +791,7 @@ static void bt_hid_connect(const void *buf, uint16_t len)
> ba2str(&dev->dst, addr);
> DBG("connecting to %s", addr);
>
> - bt_string2uuid(&uuid, PNP_UUID);
> + sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
> if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
> hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
> error("Failed to search DeviceID SDP details");
> @@ -1293,7 +1292,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
> dev->ctrl_io = g_io_channel_ref(chan);
> dev->uhid_fd = -1;
>
> - bt_string2uuid(&uuid, PNP_UUID);
> + sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
> if (bt_search_service(&src, &dev->dst, &uuid,
> hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
> error("failed to search did sdp details");
> --
> 1.7.9.5
Applied all except 6/7, I think we should probably return an error if
there is an attempt to register a service out of range, then the
caller can assert so we can have a proper test for it that expect an
error in such case.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 00/11] Socket HAL updates
From: Andrei Emeltchenko @ 2014-02-12 9:57 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1392137901-3403-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Tue, Feb 11, 2014 at 05:58:10PM +0100, Andrzej Kaczmarek wrote:
> Hi,
>
> Current socket HAL implementation is missing major feature which is
> ability to register RFCOMM server from application (so use some UUID
> and assign channel number dynamically). This corresponds to
> BluetoothAdapter::listenUsing(insecure)RfcommWithServiceRecord APIs
> in Android.
Support dynamic RFCOMM sockets looks god though I do not know why renaming
of socket names is really needed.
Best regards
Andrei Emeltchenko
>
> This series of patches adds this feature with other required fixes
> and also some does some minor refactoring.
>
> Andrzej Kaczmarek (11):
> android/bluetooth: Handle 128-bit UUIDs
> android/socket: Refactor socket related symbol names
> android/socket: Improve logging
> android/socket: Simplify SDP records handling
> android/socket: Make servers list as static array
> android/tester: Update test data
> android/socket: Add support for dynamic channel numbers
> android/socket: Register SDP record for application service
> android/socket: Include HF AG in built-in profiles
> android/socket: Update channel numbers
> android/socket: Fix sockets security
>
> android/android-tester.c | 2 +-
> android/bluetooth.c | 61 ++---
> android/hal-msg.h | 3 +
> android/socket.c | 658 +++++++++++++++++++++++------------------------
> 4 files changed, 349 insertions(+), 375 deletions(-)
>
> --
> 1.8.5.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH BlueZ] unit: Fix memory leaks in gobex tests
From: Luiz Augusto von Dentz @ 2014-02-12 9:53 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1392142591-10150-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Anderson,
On Tue, Feb 11, 2014 at 8:16 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> ---
> unit/test-gobex-apparam.c | 2 ++
> unit/test-gobex-transfer.c | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c
> index e6a42cc..976c541 100644
> --- a/unit/test-gobex-apparam.c
> +++ b/unit/test-gobex-apparam.c
> @@ -250,6 +250,8 @@ static void test_apparam_get_multi(void)
> g_assert(string != NULL);
> g_assert_cmpstr(string, ==, "ABC");
>
> + g_free(string);
> +
> g_obex_apparam_free(apparam);
> }
>
> diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
> index 128a467..7c9fd43 100644
> --- a/unit/test-gobex-transfer.c
> +++ b/unit/test-gobex-transfer.c
> @@ -511,6 +511,7 @@ static void test_stream_put_req_abort(void)
> g_obex_unref(obex);
>
> g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
> + g_error_free(d.err);
> }
>
> static void test_stream_put_rsp_abort(void)
> @@ -556,6 +557,7 @@ static void test_stream_put_rsp_abort(void)
> g_obex_unref(obex);
>
> g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
> + g_error_free(d.err);
> }
>
> static void handle_put_seq_wait(GObex *obex, GObexPacket *req,
> --
> 1.7.9.5
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC 0/2] Add hci_smd driver
From: Lukasz Rymanowski @ 2014-02-12 9:11 UTC (permalink / raw)
To: Kumar Gala; +Cc: linux-arm-msm, linux-bluetooth@vger.kernel.org
In-Reply-To: <2AA076F5-9C40-4449-84FB-FC68809197DF@codeaurora.org>
Hi,
On 11 February 2014 21:00, Kumar Gala <galak@codeaurora.org> wrote:
>
> On Feb 11, 2014, at 10:23 AM, Lukasz Rymanowski <lukasz.rymanowski@tieto.com> wrote:
>
>> Hi
>>
>> On 7 February 2014 12:35, Lukasz Rymanowski <lukasz.rymanowski@tieto.com> wrote:
>>> Hello,
>>>
>>> This is a try (long shoot) to upstream hci shared memory driver (hci_smd)
>>> which is used on Qualcomm platforms and BT chips.
>>>
>>> To make it build with upstream tree I had to introduce some simple SMD API.
>>> The idea here is that since SMD channel is represented by platform device
>>> (as it is done in mach-msm),
>>> then platfrom_data contains smd_data which contains API for that channel.
>>>
>>> Writing this SMD API I was inspired with MSM-SMD and since I'm not an expert
>>> in this area I'm asking for comments here.
>>>
>>> Maybe instead of SMD API I made, I should expose functions like smd_open(), smd_write()
>>> etc. something similar how sdio does, and just deliver to upstream dummy device
>>> implementing this SMD API?
>>>
>>> Other options I was considering is to implement module inside mach-msm which
>>> would handle registering SMD BT Channels and when it is done, it would register
>>> new platform device like "smd-bt". Then I could move smd.h to some bluetooth includes
>>> (althought don't now where at the moment) and hci_smd would register driver for "smd-bt"
>>> In this case I would also could rid of one static variable I have now in hci_smd
>>>
>>> Comments on those options are welcome.
>>>
>>> Anyway, Hci_smd is based on one of the older version of this driver found in msm kernel
>>> branch, so there are no wakelocks as in new version and also workqueues are used
>>> instead of takslet.
>>>
>>> Since SMD expose two channels, one for CMD/EVENT and one for ACL Data I decide to
>>> do separate worqueues for this. This is to make sure that ACL data never blocks EVENT
>>> packages
>>>
>>
>> Adding linux-arm-msm group for comments on SMD API.
>>
>> BR
>> Lukasz
>
> What chip/SoC/board are you trying to get bluetooth support on?
>
I'm already running it on Nexus 4 and 7, but for this I have also more
changes in mach-msm (smd_tty.c, smd.c) on top of msm kernel branch
for android.
\Lukasz
> - k
>
> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
>
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix channel check when binding RFCOMM sock
From: Andrzej Kaczmarek @ 2014-02-11 22:26 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <52F8F4E9-BCAF-4137-B21C-101F11DE1519@holtmann.org>
Hi Marcel,
On 11 February 2014 16:58, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Andrzej,
>
>> When binding RFCOMM socket we should only check if there is another
>> socket bound or listening on the same channel number. In other case,
>> it won't be possible to bind/listen on a channel in case we have
>> connection made to remote device on the same channel number.
>
> since this has been used for years now, you need to be more specific on when this fails.
It's quite simple: create one socket and connect on channel X, then
create another socket and try to bind on channel X. Event though we
don't have listening socket on channel X yet, it will fail with
EADDRINUSE since rfcomm_sock_bind looks for *any* socket on specified
channel and doesn't care if it's bound/listening on local channel or
just connected to remote channel (in which case it should not fail).
Is it specific enough?
>> Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
>> ---
>> net/bluetooth/rfcomm/sock.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
>> index 00573fb..9912e23 100644
>> --- a/net/bluetooth/rfcomm/sock.c
>> +++ b/net/bluetooth/rfcomm/sock.c
>> @@ -331,6 +331,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
>> {
>> struct sockaddr_rc *sa = (struct sockaddr_rc *) addr;
>> struct sock *sk = sock->sk;
>> + struct sock *sk1;
>> int err = 0;
>>
>> BT_DBG("sk %p %pMR", sk, &sa->rc_bdaddr);
>> @@ -352,7 +353,9 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
>>
>> write_lock(&rfcomm_sk_list.lock);
>>
>> - if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) {
>> + sk1 = __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr);
>> + if (sa->rc_channel && sk1 && (sk1->sk_state == BT_BOUND ||
>> + sk1->sk_state == BT_LISTEN)) {
>> err = -EADDRINUSE;
>
> can we find a better name than sk1 here.
Something like 'existing_sk'? Or just 'oldsk'? I have no clue how to
make a meaningful name here.
BR,
Andrzej
^ permalink raw reply
* Re: [RFC 0/2] Add hci_smd driver
From: Kumar Gala @ 2014-02-11 20:00 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-arm-msm, linux-bluetooth@vger.kernel.org
In-Reply-To: <CAMudyAsomuEjkpnj_2Dmqikx_t+nYsEcv_Ai0e6xzuFjG7vGbw@mail.gmail.com>
On Feb 11, 2014, at 10:23 AM, Lukasz Rymanowski <lukasz.rymanowski@tieto.com> wrote:
> Hi
>
> On 7 February 2014 12:35, Lukasz Rymanowski <lukasz.rymanowski@tieto.com> wrote:
>> Hello,
>>
>> This is a try (long shoot) to upstream hci shared memory driver (hci_smd)
>> which is used on Qualcomm platforms and BT chips.
>>
>> To make it build with upstream tree I had to introduce some simple SMD API.
>> The idea here is that since SMD channel is represented by platform device
>> (as it is done in mach-msm),
>> then platfrom_data contains smd_data which contains API for that channel.
>>
>> Writing this SMD API I was inspired with MSM-SMD and since I'm not an expert
>> in this area I'm asking for comments here.
>>
>> Maybe instead of SMD API I made, I should expose functions like smd_open(), smd_write()
>> etc. something similar how sdio does, and just deliver to upstream dummy device
>> implementing this SMD API?
>>
>> Other options I was considering is to implement module inside mach-msm which
>> would handle registering SMD BT Channels and when it is done, it would register
>> new platform device like "smd-bt". Then I could move smd.h to some bluetooth includes
>> (althought don't now where at the moment) and hci_smd would register driver for "smd-bt"
>> In this case I would also could rid of one static variable I have now in hci_smd
>>
>> Comments on those options are welcome.
>>
>> Anyway, Hci_smd is based on one of the older version of this driver found in msm kernel
>> branch, so there are no wakelocks as in new version and also workqueues are used
>> instead of takslet.
>>
>> Since SMD expose two channels, one for CMD/EVENT and one for ACL Data I decide to
>> do separate worqueues for this. This is to make sure that ACL data never blocks EVENT
>> packages
>>
>
> Adding linux-arm-msm group for comments on SMD API.
>
> BR
> Lukasz
What chip/SoC/board are you trying to get bluetooth support on?
- k
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
^ permalink raw reply
* Re: [PATCH 2/3] avrcp: Fix using incorrect buffer for SetVolume
From: Luiz Augusto von Dentz @ 2014-02-11 18:37 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth@vger.kernel.org
In-Reply-To: <20140211111504.GE8980@aemeltch-MOBL1>
Hi Andrei,
On Tue, Feb 11, 2014 at 1:15 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> On Tue, Feb 04, 2014 at 04:08:17PM +0200, Andrei Emeltchenko wrote:
>> On Thu, Jan 30, 2014 at 06:12:55PM +0200, Andrei Emeltchenko wrote:
>> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>> >
>> > The command requires one parameter.
>>
>> ping
>
> ping
>
>>
>> > ---
>> > profiles/audio/avrcp.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
>> > index 2e1a940..128f7d3 100644
>> > --- a/profiles/audio/avrcp.c
>> > +++ b/profiles/audio/avrcp.c
>> > @@ -3706,7 +3706,7 @@ int avrcp_set_volume(struct btd_device *dev, uint8_t volume)
>> > {
>> > struct avrcp_server *server;
>> > struct avrcp *session;
>> > - uint8_t buf[AVRCP_HEADER_LENGTH + 2];
>> > + uint8_t buf[AVRCP_HEADER_LENGTH + 1];
>> > struct avrcp_header *pdu = (void *) buf;
>> >
>> > server = find_server(servers, device_get_adapter(dev));
>> > --
>> > 1.8.3.2
Ive applied this one, I leave 1/3 for when we have the code properly
decoupled and patch 3/3 I end up redoing most of it to check for
invalid attributes.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/2] unit/avctp: Use pre-defined values instead of magic numbers
From: Luiz Augusto von Dentz @ 2014-02-11 18:34 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth@vger.kernel.org
In-Reply-To: <20140211111202.GC8980@aemeltch-MOBL1>
Hi Andrei,
On Tue, Feb 11, 2014 at 1:12 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> ping
>
> On Wed, Feb 05, 2014 at 05:28:21PM +0200, Andrei Emeltchenko wrote:
>> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>>
>> ---
>> unit/test-avctp.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/unit/test-avctp.c b/unit/test-avctp.c
>> index 581f88c..9d94ae0 100644
>> --- a/unit/test-avctp.c
>> +++ b/unit/test-avctp.c
>> @@ -277,8 +277,8 @@ static void test_client(gconstpointer data)
>> {
>> struct context *context = create_context(0x0100, data);
>>
>> - avctp_send_vendordep_req(context->session, 0, 0, NULL, 0,
>> - handler_response, context);
>> + avctp_send_vendordep_req(context->session, AVC_CTYPE_CONTROL, 0, NULL,
>> + 0, handler_response, context);
>>
>> execute_context(context);
>> }
>> @@ -290,8 +290,8 @@ static void test_server(gconstpointer data)
>> if (g_str_equal(context->data->test_name, "/TP/NFR/BV-03-C")) {
>> int ret;
>>
>> - ret = avctp_register_pdu_handler(context->session, 0x00,
>> - handler, NULL);
>> + ret = avctp_register_pdu_handler(context->session,
>> + AVC_OP_VENDORDEP, handler, NULL);
>> DBG("ret %d", ret);
>> g_assert_cmpint(ret, !=, 0);
>> }
>> --
>> 1.8.3.2
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH BlueZ 7/7] android: Add test-ipc to "make check"
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
---
Makefile.am | 3 ++-
android/Makefile.am | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 1a44a9f..11f2aa1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -178,6 +178,7 @@ EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
profiles/input/input.conf profiles/proximity/proximity.conf
test_scripts =
+unit_tests =
include Makefile.tools
include Makefile.obexd
@@ -222,7 +223,7 @@ AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
AM_CPPFLAGS = -I$(builddir)/lib -I$(srcdir)/gdbus
-unit_tests = unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
+unit_tests += unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
unit_test_eir_SOURCES = unit/test-eir.c src/eir.c src/uuid-helper.c
unit_test_eir_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
diff --git a/android/Makefile.am b/android/Makefile.am
index 5baa8db..1913b42 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -153,7 +153,7 @@ android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \
android/hardware/hardware.h \
android/system/audio.h
-noinst_PROGRAMS += android/test-ipc
+unit_tests += android/test-ipc
android_test_ipc_SOURCES = android/test-ipc.c \
src/shared/util.h src/shared/util.c \
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 6/7] android: Add assertion for ID parameter in ipc_register/ipc_unregister
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
It is a programming error to pass a invalid ID for these functions (i.e.
the ID is statically defined on the code). Given that this ID is used
for indexing an array, adding an assertion will ensure that improper API
usage will not cause random crashes due to memory corruption.
---
android/ipc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/android/ipc.c b/android/ipc.c
index ab0f1a4..373345c 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -336,12 +336,16 @@ void ipc_send_notif(uint8_t service_id, uint8_t opcode, uint16_t len,
void ipc_register(uint8_t service, const struct ipc_handler *handlers,
uint8_t size)
{
+ g_assert(service <= HAL_SERVICE_ID_MAX);
+
services[service].handler = handlers;
services[service].size = size;
}
void ipc_unregister(uint8_t service)
{
+ g_assert(service <= HAL_SERVICE_ID_MAX);
+
services[service].handler = NULL;
services[service].size = 0;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 5/7] android/test-ipc: Fix crash due to invalid ipc_register() parameter
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
This test checks for proper handling of invalid Service ID on a IPC
message, but it was attempting to register handlers for this invalid ID,
which on current ipc_register() implementation was causing a buffer
overrun.
The fix was to use a valid ID during registration, but still attempt to
use an invalid one when sending the message.
---
android/test-ipc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/test-ipc.c b/android/test-ipc.c
index 3a0729e..7318251 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -526,7 +526,7 @@ static const struct hal_hdr test_cmd_service_offrange_hdr = {
static const struct test_data test_cmd_service_offrange = {
.cmd = &test_cmd_service_offrange_hdr,
.cmd_size = sizeof(struct hal_hdr),
- .service = HAL_SERVICE_ID_MAX + 1,
+ .service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
.expected_signal = SIGTERM
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 4/7] android/client: Fix set_info command
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
Although this command is not implemented by BlueZ, make sure it is
callable from haltest so at least the IPC can be tested.
Also memset() the hid_info parameter to not pass uninitialized data
around.
---
android/client/if-hh.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/android/client/if-hh.c b/android/client/if-hh.c
index 56eb698..0341d25 100644
--- a/android/client/if-hh.c
+++ b/android/client/if-hh.c
@@ -229,6 +229,9 @@ static void virtual_unplug_p(int argc, const char **argv)
/* set_info */
+/* Same completion as connect_c */
+#define set_info_c connect_c
+
static void set_info_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -236,8 +239,11 @@ static void set_info_p(int argc, const char **argv)
RETURN_IF_NULL(if_hh);
VERIFY_ADDR_ARG(2, &addr);
- /* TODO: set_info does not seem to be called anywhere */
+ memset(&hid_info, 0, sizeof(hid_info));
+
+ /* This command is intentionally not supported. See comment from
+ * bt_hid_info() in android/hidhost.c */
EXEC(if_hh->set_info, &addr, hid_info);
}
@@ -416,7 +422,7 @@ static struct method methods[] = {
STD_METHODCH(connect, "<addr>"),
STD_METHODCH(disconnect, "<addr>"),
STD_METHODCH(virtual_unplug, "<addr>"),
- STD_METHOD(set_info),
+ STD_METHODCH(set_info, "<addr>"),
STD_METHODCH(get_protocol, "<addr> <mode>"),
STD_METHODCH(set_protocol, "<addr> <mode>"),
STD_METHODCH(get_report, "<addr> <type> <report_id> <size>"),
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 3/7] android/hidhost: Trivial coding style fix
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
Fix two lines over 80 columns.
---
android/hidhost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/hidhost.c b/android/hidhost.c
index 45fe14f..f54ca6d 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -793,7 +793,7 @@ static void bt_hid_connect(const void *buf, uint16_t len)
sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
- hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
+ hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
error("Failed to search DeviceID SDP details");
hid_device_remove(dev);
status = HAL_STATUS_FAILED;
@@ -1294,7 +1294,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
if (bt_search_service(&src, &dev->dst, &uuid,
- hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
+ hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
error("failed to search did sdp details");
hid_device_remove(dev);
return;
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 2/7] android/tester: Update SDP PDU after UUID change
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392143552-11395-1-git-send-email-anderson.lizardo@openbossa.org>
Now it is expected to receive a 16-bit UUID for PNP_INFO.
---
android/android-tester.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 870ad8d..d635732 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3307,16 +3307,10 @@ static void hid_ctrl_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
static const uint8_t did_req_pdu[] = { 0x06, /* PDU id */
0x00, 0x00, /* Transaction id */
- 0x00, 0x1d, /* Req length */
- 0x35, 0x11, /* Attributes length */
- 0x1c, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb, 0xff,
- 0xff, 0x35, 0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00,
- 0x06, 0x00, 0x01, 0x00, 0x1d, 0x35, 0x11, 0x1c, 0x00,
- 0x00, 0x11, 0x24, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
- 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb, 0xff, 0xff, 0x35,
- 0x05, 0x0a, 0x00, 0x0, 0xff, 0xff,
- 0x00 }; /* no continuation */
+ 0x00, 0x0f, /* Req length */
+ 0x35, 0x03, /* Attributes length */
+ 0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
+ 0x00, 0xff, 0xff, 0x00 }; /* no continuation */
static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
0x00, 0x00, /* Transaction id */
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 1/7] android: Use 16-bit UUID for SDP search
From: Anderson Lizardo @ 2014-02-11 18:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
These UUIDs are assigned by BT-SIG and therefore there is no need to
use full 128-bit UUIDs. This also avoids unnecessary conversion from
string representation.
---
android/handsfree.c | 3 +--
android/hidhost.c | 7 +++----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/android/handsfree.c b/android/handsfree.c
index 9482b2e..a869d58 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -34,7 +34,6 @@
#include "lib/bluetooth.h"
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
-#include "lib/uuid.h"
#include "src/sdp-client.h"
#include "src/uuid-helper.h"
#include "src/shared/hfp.h"
@@ -294,7 +293,7 @@ static void handle_connect(const void *buf, uint16_t len)
device_init(&bdaddr);
- bt_string2uuid(&uuid, HFP_HS_UUID);
+ sdp_uuid16_create(&uuid, HANDSFREE_SVCLASS_ID);
if (bt_search_service(&adapter_addr, &device.bdaddr, &uuid,
sdp_search_cb, NULL, NULL, 0) < 0) {
error("handsfree: SDP search failed");
diff --git a/android/hidhost.c b/android/hidhost.c
index 8bd3455..45fe14f 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -37,7 +37,6 @@
#include "lib/bluetooth.h"
#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/uuid-helper.h"
@@ -751,7 +750,7 @@ static void hid_sdp_did_search_cb(sdp_list_t *recs, int err, gpointer data)
dev->version = data->val.uint16;
}
- bt_string2uuid(&uuid, HID_UUID);
+ sdp_uuid16_create(&uuid, HID_SVCLASS_ID);
if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
hid_sdp_search_cb, dev, NULL, 0) < 0) {
error("failed to search sdp details");
@@ -792,7 +791,7 @@ static void bt_hid_connect(const void *buf, uint16_t len)
ba2str(&dev->dst, addr);
DBG("connecting to %s", addr);
- bt_string2uuid(&uuid, PNP_UUID);
+ sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
if (bt_search_service(&adapter_addr, &dev->dst, &uuid,
hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
error("Failed to search DeviceID SDP details");
@@ -1293,7 +1292,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
dev->ctrl_io = g_io_channel_ref(chan);
dev->uhid_fd = -1;
- bt_string2uuid(&uuid, PNP_UUID);
+ sdp_uuid16_create(&uuid, PNP_INFO_SVCLASS_ID);
if (bt_search_service(&src, &dev->dst, &uuid,
hid_sdp_did_search_cb, dev, NULL, 0) < 0) {
error("failed to search did sdp details");
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ] unit: Fix memory leaks in gobex tests
From: Anderson Lizardo @ 2014-02-11 18:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
---
unit/test-gobex-apparam.c | 2 ++
unit/test-gobex-transfer.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c
index e6a42cc..976c541 100644
--- a/unit/test-gobex-apparam.c
+++ b/unit/test-gobex-apparam.c
@@ -250,6 +250,8 @@ static void test_apparam_get_multi(void)
g_assert(string != NULL);
g_assert_cmpstr(string, ==, "ABC");
+ g_free(string);
+
g_obex_apparam_free(apparam);
}
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 128a467..7c9fd43 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -511,6 +511,7 @@ static void test_stream_put_req_abort(void)
g_obex_unref(obex);
g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
+ g_error_free(d.err);
}
static void test_stream_put_rsp_abort(void)
@@ -556,6 +557,7 @@ static void test_stream_put_rsp_abort(void)
g_obex_unref(obex);
g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
+ g_error_free(d.err);
}
static void handle_put_seq_wait(GObex *obex, GObexPacket *req,
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 4/6] shared: Add support for shutdown to IO
From: Marcel Holtmann @ 2014-02-11 17:02 UTC (permalink / raw)
To: Szymon Janc; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1392137346-26272-4-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
> This allows to locally shutdown IO.
> ---
> src/shared/io-glib.c | 9 +++++++++
> src/shared/io-mainloop.c | 9 +++++++++
> src/shared/io.h | 2 ++
> 3 files changed, 20 insertions(+)
>
> diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
> index a4f982d..8290745 100644
> --- a/src/shared/io-glib.c
> +++ b/src/shared/io-glib.c
> @@ -320,3 +320,12 @@ done:
>
> return true;
> }
> +
> +bool io_shutdown(struct io *io)
> +{
> + if (!io || !io->channel)
> + return false;
> +
> + return g_io_channel_shutdown(io->channel, TRUE, NULL)
> + == G_IO_STATUS_NORMAL;
> +}
> diff --git a/src/shared/io-mainloop.c b/src/shared/io-mainloop.c
> index 14ab128..f1e3b3b 100644
> --- a/src/shared/io-mainloop.c
> +++ b/src/shared/io-mainloop.c
> @@ -26,6 +26,7 @@
> #endif
>
> #include <unistd.h>
> +#include <sys/socket.h>
>
> #include "monitor/mainloop.h"
> #include "src/shared/util.h"
> @@ -294,3 +295,11 @@ bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback,
>
> return true;
> }
> +
> +bool io_shutdown(struct io *io)
> +{
> + if (!io || io->fd < 0)
> + return false;
> +
> + return shutdown(io->fd, SHUT_RDWR) == 0;
> +}
I have no problem doing this, but why is this actually needed? Is not closing the socket good enough? Or would be better also add a shutdown_on_unref option?
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 3/6] shared: Add support for disconnect handler in HFP
From: Marcel Holtmann @ 2014-02-11 17:00 UTC (permalink / raw)
To: Szymon Janc; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1392137346-26272-3-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
> It is no longer possible to send any data after disconnection.
> Extra reference is taken for disconnect watch to allow users to drop
> own reference in disconnect callback.
I am not sure that is the best way to do it. I get the feeling that we might better have an internal bool that is tracking if we are connected/disconnected. Thoughts?
Regards
Marcel
^ permalink raw reply
* Re: [RFC] android/ipc: Add AVRCP HAL message definitions
From: Szymon Janc @ 2014-02-11 16:59 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1390406788-17152-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Wednesday 22 of January 2014 18:06:28 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> ---
> android/hal-msg.h | 71
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71
> insertions(+)
>
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index d46b428..3937f07 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -338,6 +338,77 @@ struct hal_cmd_a2dp_disconnect {
> uint8_t bdaddr[6];
> } __attribute__((packed));
>
> +/* AVRCP HAL API */
> +
> +#define HAL_OP_AVRCP_GET_PLAY_STATUS_RSP 0x01
> +struct hal_cmd_avrcp_get_play_status_rsp {
> + uint8_t status;
defines for enums should be added as well (this goes for all enums)
> + uint32_t len;
> + uint32_t pos;
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_LIST_PLAYER_APP_ATTR_RSP 0x02
> +struct hal_cmd_avrcp_list_player_app_attr_rsp {
> + uint16_t len;
> + uint8_t data[0];
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_LIST_PLAYER_APP_VAL_RSP 0x03
> +struct hal_cmd_avrcp_list_player_app_val_rsp {
> + uint16_t len;
> + uint8_t data[0];
> +} __attribute__((packed));
> +
> +#define MAX_APP_SETTINGS 8
> +struct player_setting {
> + uint8_t num_attr;
> + uint8_t attr_ids[MAX_APP_SETTINGS];
> + uint8_t attr_vals[MAX_APP_SETTINGS];
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_GET_PLAYER_APP_VAL_RSP 0x04
> +struct hal_cmd_avrcp_get_player_app_val_rsp {
> + struct player_setting settings;
> +} __attribute__((packed));
> +
> +#define MAX_ATTR_STR_LEN 255
> +struct player_text {
> + uint32_t id;
> + uint8_t text[MAX_ATTR_STR_LEN];
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_GET_PLAYER_APP_ATTR_TEXT_RSP 0x05
> +#define HAL_OP_AVRCP_GET_PLAYER_APP_VAL_TEXT_RSP 0x06
> +#define HAL_OP_AVRCP_GET_ELEMENT_ATTR_RSP 0x07
> +struct hal_cmd_avrcp_get_text_rsp {
> + uint16_t len;
> + struct player_text data[0];
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_SET_PLAYER_APP_VAL_RSP 0x08
> +struct hal_cmd_avrcp_set_player_app_val_rsp {
> + uint8_t status;
> +} __attribute__((packed));
> +
> +union notification {
> + uint8_t status;
> + uint8_t uid[8];
> + uint32_t pos;
> + struct player_setting player_settings;
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_REGISTER_NOTIFICATION_RSP 0x09
> +struct hal_cmd_avrcp_register_notification_rsp {
> + uint8_t id;
> + uint8_t type;
> + union notification param;
> +} __attribute__((packed));
> +
> +#define HAL_OP_AVRCP_SET_VOLUME 0x0a
> +struct hal_cmd_avrcp_set_volume {
> + uint8_t volume;
> +} __attribute__((packed));
> +
> /* PAN HAL API */
>
> /* PAN Roles */
Please add structures for notifications. Also hal-ipc-api.txt needs to be
updated before this can go in.
--
BR
Szymon Janc
^ permalink raw reply
* [PATCH 11/11] android/socket: Fix sockets security
From: Andrzej Kaczmarek @ 2014-02-11 16:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1392137901-3403-1-git-send-email-andrzej.kaczmarek@tieto.com>
Socket security shall be based on flags passed from HAL.
Android public API uses both encrypt and auth flags for "secure"
sockets which should be mapped to high security on our side, but since
this would also trigger requirement for 16-digits pin code (which is
not used in Android) we'll ignore auth flag and use either low or
medium security based on encrypt flag value only.
---
android/hal-msg.h | 3 +++
android/socket.c | 29 +++++++++++++++++++----------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index aba98ed..6ef00f9 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -235,6 +235,9 @@ struct hal_cmd_le_test_mode {
#define HAL_SOCK_SCO 0x02
#define HAL_SOCK_L2CAP 0x03
+#define HAL_SOCK_FLAG_ENCRYPT 0x01
+#define HAL_SOCK_FLAG_AUTH 0x02
+
#define HAL_OP_SOCK_LISTEN 0x01
struct hal_cmd_sock_listen {
uint8_t type;
diff --git a/android/socket.c b/android/socket.c
index c790c24..4e9121d 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -70,6 +70,7 @@ GList *connections = NULL;
struct rfcomm_sock {
int channel; /* RFCOMM channel */
+ BtIOSecLevel sec_level;
/* for socket to BT */
int bt_sock;
@@ -84,8 +85,6 @@ struct rfcomm_sock {
uint8_t *buf;
int buf_size;
-
- const struct profile_info *profile;
};
struct rfcomm_channel {
@@ -721,6 +720,19 @@ static int find_free_channel(void)
return 0;
}
+static BtIOSecLevel get_sec_level(uint8_t flags)
+{
+ /* HAL_SOCK_FLAG_AUTH should require MITM but in our case setting
+ * security to BT_IO_SEC_HIGH would also require 16-digits PIN code
+ * for pre-2.1 devices which is not what Android expects. For this
+ * reason we ignore this flag to not break apps which use "secure"
+ * sockets (have both auth and encrypt flags set, there is no public
+ * API in Android which should provide proper high security socket).
+ */
+ return flags & HAL_SOCK_FLAG_ENCRYPT ? BT_IO_SEC_MEDIUM :
+ BT_IO_SEC_LOW;
+}
+
static uint8_t rfcomm_listen(int chan, const uint8_t *name, const uint8_t *uuid,
uint8_t flags, int *hal_sock)
{
@@ -748,7 +760,7 @@ static uint8_t rfcomm_listen(int chan, const uint8_t *name, const uint8_t *uuid,
profile = get_profile_by_uuid(uuid);
if (!profile) {
- sec_level = BT_IO_SEC_MEDIUM;
+ sec_level = get_sec_level(flags);
} else {
if (!profile->create_record)
return HAL_STATUS_INVALID;
@@ -931,20 +943,16 @@ fail:
static bool do_rfcomm_connect(struct rfcomm_sock *rfsock, int chan)
{
- BtIOSecLevel sec_level = BT_IO_SEC_MEDIUM;
GIOChannel *io;
GError *gerr = NULL;
- if (rfsock->profile)
- sec_level = rfsock->profile->sec_level;
-
- DBG("rfsock %p sec_level %d chan %d", rfsock, sec_level, chan);
+ DBG("rfsock %p sec_level %d chan %d", rfsock, rfsock->sec_level, chan);
io = bt_io_connect(connect_cb, rfsock, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
BT_IO_OPT_DEST_BDADDR, &rfsock->dst,
BT_IO_OPT_CHANNEL, chan,
- BT_IO_OPT_SEC_LEVEL, sec_level,
+ BT_IO_OPT_SEC_LEVEL, rfsock->sec_level,
BT_IO_OPT_INVALID);
if (!io) {
error("Failed connect: %s", gerr->message);
@@ -1047,13 +1055,14 @@ static uint8_t connect_rfcomm(const bdaddr_t *addr, int chan,
DBG("rfsock %p jv_sock %d hal_sock %d", rfsock, rfsock->jv_sock,
*hal_sock);
+ rfsock->sec_level = get_sec_level(flags);
+
bacpy(&rfsock->dst, addr);
if (!memcmp(uuid, zero_uuid, sizeof(zero_uuid))) {
if (!do_rfcomm_connect(rfsock, chan))
goto failed;
} else {
- rfsock->profile = get_profile_by_uuid(uuid);
if (bt_search_service(&adapter_addr, &rfsock->dst, &uu,
sdp_search_cb, rfsock, NULL, 0) < 0) {
--
1.8.5.3
^ permalink raw reply related
* [PATCH 10/11] android/socket: Update channel numbers
From: Andrzej Kaczmarek @ 2014-02-11 16:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1392137901-3403-1-git-send-email-andrzej.kaczmarek@tieto.com>
OPP and PBAP channel numbers are set to same values as in Bluedroid.
Both MAP and SPP use channel numbers assigned dynamically.
---
android/socket.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index 4dcb5fc..c790c24 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -47,11 +47,9 @@
#define RFCOMM_CHANNEL_MAX 30
-#define SPP_DEFAULT_CHANNEL 3
-#define OPP_DEFAULT_CHANNEL 9
+#define OPP_DEFAULT_CHANNEL 12
#define HFAG_DEFAULT_CHANNEL 13
-#define PBAP_DEFAULT_CHANNEL 15
-#define MAS_DEFAULT_CHANNEL 16
+#define PBAP_DEFAULT_CHANNEL 19
#define SVC_HINT_OBEX 0x10
@@ -406,7 +404,7 @@ static const struct profile_info {
0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
- .channel = MAS_DEFAULT_CHANNEL,
+ .channel = 0,
.svc_hint = SVC_HINT_OBEX,
.sec_level = BT_IO_SEC_MEDIUM,
.create_record = create_mas_record
@@ -415,7 +413,7 @@ static const struct profile_info {
0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
- .channel = SPP_DEFAULT_CHANNEL,
+ .channel = 0,
.svc_hint = 0,
.sec_level = BT_IO_SEC_MEDIUM,
.create_record = create_spp_record
--
1.8.5.3
^ permalink raw reply related
* [PATCH 09/11] android/socket: Include HF AG in built-in profiles
From: Andrzej Kaczmarek @ 2014-02-11 16:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1392137901-3403-1-git-send-email-andrzej.kaczmarek@tieto.com>
This patch adds entry for HF AG profile in built-in profiles list. This
it to reserve channel number so it's not assigned to other service
registered by application. Method for creating SDP record is not
provided so it's not possible for application to register HF AG service
by mistake (this can be only done by handsfree profile implementation).
---
android/socket.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 9175bf3..4dcb5fc 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -49,6 +49,7 @@
#define SPP_DEFAULT_CHANNEL 3
#define OPP_DEFAULT_CHANNEL 9
+#define HFAG_DEFAULT_CHANNEL 13
#define PBAP_DEFAULT_CHANNEL 15
#define MAS_DEFAULT_CHANNEL 16
@@ -375,6 +376,15 @@ static const struct profile_info {
} profiles[] = {
{
.uuid = {
+ 0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+ },
+ .channel = HFAG_DEFAULT_CHANNEL,
+ .svc_hint = 0,
+ .sec_level = BT_IO_SEC_MEDIUM,
+ .create_record = NULL
+ }, {
+ .uuid = {
0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
@@ -742,6 +752,9 @@ static uint8_t rfcomm_listen(int chan, const uint8_t *name, const uint8_t *uuid,
if (!profile) {
sec_level = BT_IO_SEC_MEDIUM;
} else {
+ if (!profile->create_record)
+ return HAL_STATUS_INVALID;
+
chan = profile->channel;
sec_level = profile->sec_level;
}
--
1.8.5.3
^ permalink raw reply related
* [PATCH 08/11] android/socket: Register SDP record for application service
From: Andrzej Kaczmarek @ 2014-02-11 16:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1392137901-3403-1-git-send-email-andrzej.kaczmarek@tieto.com>
This patch adds SDP record for services registered from application
(other than built-in services).
---
android/socket.c | 40 +++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index e560609..9175bf3 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -350,6 +350,22 @@ static sdp_record_t *create_spp_record(uint8_t chan, const char *svc_name)
return record;
}
+static sdp_record_t *create_app_record(uint8_t chan,
+ const uint8_t *app_uuid,
+ const char *svc_name)
+{
+ sdp_record_t *record;
+ uuid_t uuid;
+
+ sdp_uuid128_create(&uuid, app_uuid);
+
+ record = create_rfcomm_record(chan, &uuid, svc_name, false);
+ if (!record)
+ return NULL;
+
+ return record;
+}
+
static const struct profile_info {
uint8_t uuid[16];
uint8_t channel;
@@ -396,19 +412,24 @@ static const struct profile_info {
},
};
-static uint32_t sdp_service_register(const struct profile_info *profile,
- const void *svc_name)
+static uint32_t sdp_service_register(uint8_t channel, const uint8_t *uuid,
+ const struct profile_info *profile,
+ const void *svc_name)
{
- sdp_record_t *record;
-
- if (!profile || !profile->create_record)
- return 0;
+ sdp_record_t *record = NULL;
+ uint8_t svc_hint = 0;
+
+ if (profile && profile->create_record) {
+ record = profile->create_record(channel, svc_name);
+ svc_hint = profile->svc_hint;
+ } else if (uuid) {
+ record = create_app_record(channel, uuid, svc_name);
+ }
- record = profile->create_record(profile->channel, svc_name);
if (!record)
return 0;
- if (bt_adapter_add_record(record, profile->svc_hint) < 0) {
+ if (bt_adapter_add_record(record, svc_hint) < 0) {
error("Failed to register on SDP record");
sdp_record_free(record);
return 0;
@@ -782,7 +803,8 @@ static uint8_t rfcomm_listen(int chan, const uint8_t *name, const uint8_t *uuid,
goto failed;
}
- rfsock->service_handle = sdp_service_register(profile, name);
+ rfsock->service_handle = sdp_service_register(chan, uuid, profile,
+ name);
servers[chan].rfsock = rfsock;
--
1.8.5.3
^ 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