* [PATCH 1/2] scotest: Add deferred setup option
From: Frédéric Dalleau @ 2012-11-19 15:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frédéric Dalleau
In-Reply-To: <1353340244-16443-1-git-send-email-frederic.dalleau@linux.intel.com>
---
test/scotest.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 5 deletions(-)
diff --git a/test/scotest.c b/test/scotest.c
index de65edf..a40e395 100644
--- a/test/scotest.c
+++ b/test/scotest.c
@@ -57,6 +57,8 @@ static long data_size = 672;
static bdaddr_t bdaddr;
+static int defer_setup = 0;
+
static float tv2fl(struct timeval tv)
{
return (float)tv.tv_sec + (float)(tv.tv_usec/1000000.0);
@@ -147,6 +149,14 @@ static void do_listen(void (*handler)(int sk))
goto error;
}
+ /* Enable deferred setup */
+ if (defer_setup && setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP,
+ &defer_setup, sizeof(defer_setup)) < 0) {
+ syslog(LOG_ERR, "Can't enable deferred setup : %s (%d)",
+ strerror(errno), errno);
+ goto error;
+ }
+
/* Listen for connections */
if (listen(sk, 10)) {
syslog(LOG_ERR,"Can not listen on the socket: %s (%d)",
@@ -181,8 +191,10 @@ static void do_listen(void (*handler)(int sk))
if (getsockopt(nsk, SOL_SCO, SCO_CONNINFO, &conn, &optlen) < 0) {
syslog(LOG_ERR, "Can't get SCO connection information: %s (%d)",
strerror(errno), errno);
- close(nsk);
- goto error;
+ if (!defer_setup) {
+ close(nsk);
+ goto error;
+ }
}
ba2str(&addr.sco_bdaddr, ba);
@@ -190,6 +202,18 @@ static void do_listen(void (*handler)(int sk))
ba, conn.hci_handle,
conn.dev_class[2], conn.dev_class[1], conn.dev_class[0]);
+ /* Handle deferred setup */
+ if (defer_setup) {
+ syslog(LOG_INFO, "Waiting for %d seconds",
+ abs(defer_setup) - 1);
+ sleep(abs(defer_setup) - 1);
+
+ if (defer_setup < 0) {
+ close(nsk);
+ goto error;
+ }
+ }
+
handler(nsk);
syslog(LOG_INFO, "Disconnect");
@@ -207,6 +231,15 @@ static void dump_mode(int sk)
{
int len;
+ if (defer_setup) {
+ len = read(sk, buf, sizeof(buf));
+ if (len < 0)
+ syslog(LOG_ERR, "Initial read error: %s (%d)",
+ strerror(errno), errno);
+ else
+ syslog(LOG_INFO, "Initial bytes %d", len);
+ }
+
syslog(LOG_INFO,"Receiving ...");
while ((len = read(sk, buf, data_size)) > 0)
syslog(LOG_INFO, "Recevied %d bytes", len);
@@ -216,6 +249,16 @@ static void recv_mode(int sk)
{
struct timeval tv_beg,tv_end,tv_diff;
long total;
+ int len;
+
+ if (defer_setup) {
+ len = read(sk, buf, sizeof(buf));
+ if (len < 0)
+ syslog(LOG_ERR, "Initial read error: %s (%d)",
+ strerror(errno), errno);
+ else
+ syslog(LOG_INFO, "Initial bytes %d", len);
+ }
syslog(LOG_INFO, "Receiving ...");
@@ -328,14 +371,17 @@ static void usage(void)
{
printf("scotest - SCO testing\n"
"Usage:\n");
- printf("\tscotest <mode> [-b bytes] [bd_addr]\n");
+ printf("\tscotest <mode> [options] [bd_addr]\n");
printf("Modes:\n"
"\t-d dump (server)\n"
"\t-c reconnect (client)\n"
"\t-m multiple connects (client)\n"
"\t-r receive (server)\n"
"\t-s connect and send (client)\n"
- "\t-n connect and be silent (client)\n");
+ "\t-n connect and be silent (client)\n"
+ "Options:\n"
+ "\t[-b bytes]\n"
+ "\t[-W seconds] enable deferred setup\n");
}
int main(int argc ,char *argv[])
@@ -343,7 +389,7 @@ int main(int argc ,char *argv[])
struct sigaction sa;
int opt, sk, mode = RECV;
- while ((opt=getopt(argc,argv,"rdscmnb:")) != EOF) {
+ while ((opt = getopt(argc, argv, "rdscmnb:W:")) != EOF) {
switch(opt) {
case 'r':
mode = RECV;
@@ -373,6 +419,10 @@ int main(int argc ,char *argv[])
data_size = atoi(optarg);
break;
+ case 'W':
+ defer_setup = atoi(optarg);
+ break;
+
default:
usage();
exit(1);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/2] Add support for SCO defered setup in test
From: Frédéric Dalleau @ 2012-11-19 15:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Frédéric Dalleau
This adds support for deferred setup in userspace test tools for SCO
connections.
Regards,
Frédéric
Frédéric Dalleau (2):
scotest: Add deferred setup option
btiotest: Enable deferred setup for sco sockets
test/btiotest.c | 22 +++++++++++++++-----
test/scotest.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 72 insertions(+), 10 deletions(-)
--
1.7.9.5
^ permalink raw reply
* Re: [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Lucas De Marchi @ 2012-11-19 15:38 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZ+oP-2YarvFndGCrUeGAqb=Nt7CxQ=1ULasaRXqvRy68A@mail.gmail.com>
On Mon, Nov 19, 2012 at 1:08 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lucas,
>
> On Mon, Nov 19, 2012 at 3:18 PM, Lucas De Marchi
> <lucas.demarchi@profusion.mobi> wrote:
>> On Mon, Nov 19, 2012 at 10:49 AM, Luiz Augusto von Dentz
>> <luiz.dentz@gmail.com> wrote:
>>> Hi Lucas,
>>>
>>> On Mon, Nov 19, 2012 at 2:06 PM, Lucas De Marchi
>>> <lucas.demarchi@profusion.mobi> wrote:
>>>> Hi Luiz,
>>>>
>>>> On Mon, Nov 19, 2012 at 6:46 AM, Luiz Augusto von Dentz
>>>> <luiz.dentz@gmail.com> wrote:
>>>>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>>>>
>>>>> This makes g_dbus_setup_bus to automatically register '/' path so
>>>>> user application that don't export any interface on '/' will have it
>>>>> registered for ObjectManager.
>>>>>
>>>>> Note that it is now required to call g_dbus_close before exit.
>>>>
>>>> I'm no really fan of this. Why do we need to register '/' now? If we
>>>> are not going to support ObjectManager interfaces in subtrees, it
>>>> would be easier to just move the ObjectManager to the shortest path
>>>> registered rather than always registering '/'.
>>>
>>> Maybe I should have made clear this in the description, if you look at
>>> the spec it suggest that each sub-tree root should implement
>>> ObjectManager, the current implementation does that but if you think
>>> about it probably doesn't make sense to have sub-trees because that
>>> would creates extra round trips that ObjectManager was meant to
>>
>> HUmn... I think you are a bit confused now.
>>
>> 1 entire tree can be managed by a single ObjectManager, or multiple
>> ones if there are objects that are not interesting to everybody and
>> only a few types of clients would be interested in the objects changed
>> beyond that path.
>>
>> Example:
>>
>> /org/bluez
>> - ObjectManager
>> /org/bluez/adapter/bla/bli
>> - MyInterfaceWithLotsOfObjects
>>
>> If you put only 1 ObjectManager it means you get called for each
>> change in /org/bluez/adapter/bla/bli even though most of the clients
>> will not be interested in that. Therefore the spec allows you to
>> attach another ObjectManager in /org/bluez/adapter/[...] so the first
>> ObjectManager only send updates and "manage" the objects until the
>> path containing another ObjectManager.
>>
>> I do think we don't really need that feature right now. I think we are
>> fine with a single ObjectManager in "/", but always registering "/"
>> IMO is not the right solution.
>
> As far I know /org/bluez/adapter/bla/bli is a child of /org/bluez thus
> you don't need another ObjectManager, anyway the point is that
Sure we don't need it, but it was made that way so projects could
actually use multiple object managers for the reasons pointed out in
the previous email. Projects could even have separate ObjectManagers
for completely different things, like one in /org/bluez/bla and
another in /org/bluez/bli instead of 1 in /org/bluez. But it's an
application decision where to put the ObjectManager.
If all projects using gdbus decide to have a single ObjectManager on
"/" because it's simpler and fit the needs for everybody, then fine.
I'd suggest to even register it earlier than it is. Otherwise we might
choose to let the application (bluez, connman, ofono, etc) decide
where to put it, by adding a "g_dbus_attach_object_manager(conn,
path)" or the like.
> multiple ObjectManagers for the same connection might not make sense
> as it will create more round trips to discover the object tree e.g:
> /org/bluez vs /org/somethingelse
I'm not arguing about one object manager per object path component.
>
> There is also the problem of supporting changing the root, the spec
> doesn't mention anything about that even though it says it can support
> sub-trees thus the application could in theory register a new root
> e.g. /org at any point which basically invalidates the entire
> sub-trees which I don't think would be convenient for anyone watching
> it.
then it's a misuse of object manager by the application, not a problem
with the spec. We need to define in the API where the object
manager(s) will be and not randomly adding/removing them.
Lucas De Marchi
^ permalink raw reply
* Re: [PATCH] Bluetooth: Remove device OOB data if it was discovered in band
From: Szymon Janc @ 2012-11-19 15:17 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <20121119150537.GA10702@x220>
On Monday 19 of November 2012 17:05:37 Johan Hedberg wrote:
> Hi Szymon,
Hi Johan,
>
> On Mon, Nov 19, 2012, Szymon Janc wrote:
> > OOB authentication mechanism should be used only if pairing process
> > has been activated by previous OOB information exchange (Core Spec
> > 4.0 , vol. 1, Part A, 5.1.4.3). Stored OOB data for specific device
> > should be removed if that device was discovered in band later on.
> >
> > Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> > ---
> >
> > This could also be done by userspace but would require calling remove remote
> > OOB data mgmt command for every device found. Userspace could also track for
> > which devices OOB data were added but this could be problematic as OOB data
> > persists userspace restart. Doing it in kernel seems better.
> >
> >
> > net/bluetooth/hci_event.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 9f5c5f2..cda5bac 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -1946,6 +1946,8 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > for (; num_rsp; num_rsp--, info++) {
> > bool name_known, ssp;
> >
> > + hci_remove_remote_oob_data(hdev, &info->bdaddr);
> > +
> > bacpy(&data.bdaddr, &info->bdaddr);
> > data.pscan_rep_mode = info->pscan_rep_mode;
> > data.pscan_period_mode = info->pscan_period_mode;
>
> Why would you do this only in hci_inquiry_result_evt? What about
> hci_extended_inquiry_result_evt and hci_inquiry_result_with_rssi_evt?
> Maybe hci_inquiry_cache_update would be a better function to put this
> into.
Yes, I guess hci_inquiry_cache_update will be the right place to put this.
Will send V2.
Thx!
> Johan
--
BR
Szymon Janc
^ permalink raw reply
* Re: [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Luiz Augusto von Dentz @ 2012-11-19 15:08 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAMOw1v43vHHseyKKXK6t2sooS6dFkQdwbF4nOcCUGojpgbmGzQ@mail.gmail.com>
Hi Lucas,
On Mon, Nov 19, 2012 at 3:18 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> On Mon, Nov 19, 2012 at 10:49 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> Hi Lucas,
>>
>> On Mon, Nov 19, 2012 at 2:06 PM, Lucas De Marchi
>> <lucas.demarchi@profusion.mobi> wrote:
>>> Hi Luiz,
>>>
>>> On Mon, Nov 19, 2012 at 6:46 AM, Luiz Augusto von Dentz
>>> <luiz.dentz@gmail.com> wrote:
>>>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>>>
>>>> This makes g_dbus_setup_bus to automatically register '/' path so
>>>> user application that don't export any interface on '/' will have it
>>>> registered for ObjectManager.
>>>>
>>>> Note that it is now required to call g_dbus_close before exit.
>>>
>>> I'm no really fan of this. Why do we need to register '/' now? If we
>>> are not going to support ObjectManager interfaces in subtrees, it
>>> would be easier to just move the ObjectManager to the shortest path
>>> registered rather than always registering '/'.
>>
>> Maybe I should have made clear this in the description, if you look at
>> the spec it suggest that each sub-tree root should implement
>> ObjectManager, the current implementation does that but if you think
>> about it probably doesn't make sense to have sub-trees because that
>> would creates extra round trips that ObjectManager was meant to
>
> HUmn... I think you are a bit confused now.
>
> 1 entire tree can be managed by a single ObjectManager, or multiple
> ones if there are objects that are not interesting to everybody and
> only a few types of clients would be interested in the objects changed
> beyond that path.
>
> Example:
>
> /org/bluez
> - ObjectManager
> /org/bluez/adapter/bla/bli
> - MyInterfaceWithLotsOfObjects
>
> If you put only 1 ObjectManager it means you get called for each
> change in /org/bluez/adapter/bla/bli even though most of the clients
> will not be interested in that. Therefore the spec allows you to
> attach another ObjectManager in /org/bluez/adapter/[...] so the first
> ObjectManager only send updates and "manage" the objects until the
> path containing another ObjectManager.
>
> I do think we don't really need that feature right now. I think we are
> fine with a single ObjectManager in "/", but always registering "/"
> IMO is not the right solution.
As far I know /org/bluez/adapter/bla/bli is a child of /org/bluez thus
you don't need another ObjectManager, anyway the point is that
multiple ObjectManagers for the same connection might not make sense
as it will create more round trips to discover the object tree e.g:
/org/bluez vs /org/somethingelse
There is also the problem of supporting changing the root, the spec
doesn't mention anything about that even though it says it can support
sub-trees thus the application could in theory register a new root
e.g. /org at any point which basically invalidates the entire
sub-trees which I don't think would be convenient for anyone watching
it.
>> prevent, also Im not completely sure now but I remember someone
>> mentioning the '/' is kind special and should always be available no
>> matter what, so by registering '/' directly on g_dbus_setup_bus we
>> guarantee we have it always and that no sub-tree is going to be
>> generated since '/' is the root no matter what path the user code
>> register.
>
> Kind of true... what really needs to be treated are calls to
> Introspectable interface on "/". This is used by tools like d-feet to
> navigate the tree (looking for the "<node ...>" tags) -- I *think*
> this is also used by some bindings like python's. If you look in other
> projects around, they prefer using the project's namespace rather than
> "/" (examples: systemd, udisks, policykit, dconf).
>
> So, if we register "/", but not an Introspectable interface in there,
> it means we will break tools like d-feet. If we don't register it,
> libdbus will handle the messages to Introspectable (this is why other
> projects don't even bother about "/").
Yep, I assume it was more convenient to have in '/' because it would
basically work in any case, but we can default to something else it
just a matter to have this set directly when we do g_dbus_setup_bus so
it is available since the beginning.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH] Bluetooth: Remove device OOB data if it was discovered in band
From: Johan Hedberg @ 2012-11-19 15:05 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1353336407-10863-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Mon, Nov 19, 2012, Szymon Janc wrote:
> OOB authentication mechanism should be used only if pairing process
> has been activated by previous OOB information exchange (Core Spec
> 4.0 , vol. 1, Part A, 5.1.4.3). Stored OOB data for specific device
> should be removed if that device was discovered in band later on.
>
> Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> ---
>
> This could also be done by userspace but would require calling remove remote
> OOB data mgmt command for every device found. Userspace could also track for
> which devices OOB data were added but this could be problematic as OOB data
> persists userspace restart. Doing it in kernel seems better.
>
>
> net/bluetooth/hci_event.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 9f5c5f2..cda5bac 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1946,6 +1946,8 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
> for (; num_rsp; num_rsp--, info++) {
> bool name_known, ssp;
>
> + hci_remove_remote_oob_data(hdev, &info->bdaddr);
> +
> bacpy(&data.bdaddr, &info->bdaddr);
> data.pscan_rep_mode = info->pscan_rep_mode;
> data.pscan_period_mode = info->pscan_period_mode;
Why would you do this only in hci_inquiry_result_evt? What about
hci_extended_inquiry_result_evt and hci_inquiry_result_with_rssi_evt?
Maybe hci_inquiry_cache_update would be a better function to put this
into.
Johan
^ permalink raw reply
* [PATCH 4/4] neard: Append hash/randomizer in EIR only if remote provided it
From: Szymon Janc @ 2012-11-19 15:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337438-21865-1-git-send-email-szymon.janc@tieto.com>
Read local OOB data for RequestOOB reply only if remote also provided
hash and randomizer in EIR. This will allow for faster reply when only
discovery is done OOB. It is also required to pass NFC handover test
related to Bluetooth just-works pairing.
---
plugins/neard.c | 89 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 55 insertions(+), 34 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 4627f52..f8d023c 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -158,6 +158,46 @@ unregister:
AGENT_INTERFACE);
}
+static DBusMessage *create_request_oob_reply(struct btd_adapter *adapter,
+ uint8_t *hash,
+ uint8_t *randomizer,
+ DBusMessage *msg)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ uint8_t eir[NFC_OOB_EIR_MAX];
+ uint8_t *peir = eir;
+ int len;
+
+ len = eir_create_oob(adapter_get_address(adapter),
+ btd_adapter_get_name(adapter),
+ btd_adapter_get_class(adapter), hash,
+ randomizer, main_opts.did_vendor,
+ main_opts.did_product, main_opts.did_version,
+ main_opts.did_source,
+ btd_adapter_get_services(adapter), eir);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+ &dict);
+
+ dict_append_array(&dict, "EIR", DBUS_TYPE_BYTE, &peir, len);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
static void read_local_complete(struct btd_adapter *adapter, uint8_t *hash,
uint8_t *randomizer, void *user_data)
{
@@ -177,39 +217,10 @@ static void read_local_complete(struct btd_adapter *adapter, uint8_t *hash,
return;
}
- if (hash && randomizer) {
- int len;
- uint8_t eir[NFC_OOB_EIR_MAX];
- uint8_t *peir = eir;
- DBusMessageIter iter;
- DBusMessageIter dict;
-
- len = eir_create_oob(adapter_get_address(adapter),
- btd_adapter_get_name(adapter),
- btd_adapter_get_class(adapter), hash,
- randomizer, main_opts.did_vendor,
- main_opts.did_product, main_opts.did_version,
- main_opts.did_source,
- btd_adapter_get_services(adapter), eir);
-
- reply = dbus_message_new_method_return(msg);
-
- dbus_message_iter_init_append(reply, &iter);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
- &dict);
-
- dict_append_array(&dict, "EIR", DBUS_TYPE_BYTE, &peir, len);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- } else {
+ if (hash && randomizer)
+ reply = create_request_oob_reply(adapter, hash, randomizer, msg);
+ else
reply = error_reply(msg, EIO);
- }
dbus_message_unref(msg);
@@ -273,7 +284,7 @@ static int check_device(struct btd_adapter *adapter, const char *address)
return 0;
}
-/* returns 1 if pairing is not needed */
+/* returns 1 if action (pairing or reading local data) is not needed */
static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
bdaddr_t *remote)
{
@@ -317,9 +328,16 @@ static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
if (remote)
bacpy(remote, &eir_data.addr);
+ /*
+ * In RequestOOB reply append local hash and randomizer only if
+ * received EIR also contained it.
+ */
+ if (!remote && !eir_data.hash)
+ ret = 1;
+
eir_data_free(&eir_data);
- return 0;
+ return ret;
}
/*
@@ -651,6 +669,9 @@ static DBusMessage *request_oob(DBusConnection *conn, DBusMessage *msg,
if (ret < 0)
return error_reply(msg, -ret);
+ if (ret == 1)
+ return create_request_oob_reply(adapter, NULL, NULL, msg);
+
ret = btd_adapter_read_local_oob_data(adapter);
if (ret < 0)
return error_reply(msg, -ret);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/4] neard: Add support for nokia.com:bt type
From: Szymon Janc @ 2012-11-19 15:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337438-21865-1-git-send-email-szymon.janc@tieto.com>
This adds support for parsing nokia.com:bt type supported by some Nokia
NFC enabled devices. This is not fully documented Nokia extension so
to keep implementation sane and simple only PushOOB method suports
this type so only static handover is possible.
---
plugins/neard.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 196 insertions(+), 2 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 8319445..4627f52 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -322,6 +322,194 @@ static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
return 0;
}
+/*
+ * This is (barely documented) Nokia extension format, most work was done by
+ * reverse engineering.
+ *
+ * Binary format varies among different devices, type depends on first byte
+ * 0x00 - BT address not reversed, 16 bytes authentication data (all zeros)
+ * 0x01 - BT address not reversed, 16 bytes authentication data (4 digit PIN,
+ * padded with zeros)
+ * 0x02 - BT address not reversed, 16 bytes authentication data (not sure if
+ * 16 digit PIN or link key?, Nokia refers to it as ' Public Key')
+ * 0x10 - BT address reversed, no authentication data
+ * 0x24 - BT address not reversed, 4 bytes authentication data (4 digit PIN)
+ *
+ * General structure:
+ * 1 byte - marker
+ * 6 bytes - BT address (reversed or not, depends on marker)
+ * 3 bytes - Class of Device
+ * 0, 4 or 16 bytes - authentication data, interpretation depends on marker
+ * 1 bytes - name length
+ * N bytes - name
+ */
+
+struct nokia_com_bt {
+ bdaddr_t address;
+ uint32_t cod;
+ uint8_t pin[16];
+ int pin_len;
+ char *name;
+};
+
+static int process_nokia_long (void *data, size_t size, uint8_t marker,
+ struct nokia_com_bt *nokia)
+{
+ struct {
+ bdaddr_t address;
+ uint8_t class[3];
+ uint8_t authentication[16];
+ uint8_t name_len;
+ uint8_t name[0];
+ }__attribute__((packed)) *n = data;
+
+ if (size != sizeof(*n) + n->name_len)
+ return -EINVAL;
+
+ /* address is not reverted */
+ baswap(&nokia->address, &n->address);
+
+ nokia->cod = n->class[0] | (n->class[1] << 8) | (n->class[2] << 16);
+
+ if (n->name_len > 0)
+ nokia->name = g_strndup((char *)n->name, n->name_len);
+
+ if (marker == 0x01) {
+ memcpy(nokia->pin, n->authentication, 4);
+ nokia->pin_len = 4;
+ } else if (marker == 0x02) {
+ memcpy(nokia->pin, n->authentication, 16);
+ nokia->pin_len = 16;
+ }
+
+ return 0;
+}
+
+static int process_nokia_short (void *data, size_t size,
+ struct nokia_com_bt *nokia)
+{
+ struct {
+ bdaddr_t address;
+ uint8_t class[3];
+ uint8_t authentication[4];
+ uint8_t name_len;
+ uint8_t name[0];
+ }__attribute__((packed)) *n = data;
+
+ if (size != sizeof(*n) + n->name_len)
+ return -EINVAL;
+
+ /* address is not reverted */
+ baswap(&nokia->address, &n->address);
+
+ nokia->cod = n->class[0] | (n->class[1] << 8) | (n->class[2] << 16);
+
+ if (n->name_len > 0)
+ nokia->name = g_strndup((char *)n->name, n->name_len);
+
+ memcpy(nokia->pin, n->authentication, 4);
+ nokia->pin_len = 4;
+
+ return 0;
+}
+
+static int process_nokia_extra_short (void *data, size_t size,
+ struct nokia_com_bt *nokia)
+{
+ struct {
+ bdaddr_t address;
+ uint8_t class[3];
+ uint8_t name_len;
+ uint8_t name[0];
+ }__attribute__((packed)) *n = data;
+
+ if (size != sizeof(*n) + n->name_len)
+ return -EINVAL;
+
+ bacpy(&nokia->address, &n->address);
+
+ nokia->cod = n->class[0] | (n->class[1] << 8) | (n->class[2] << 16);
+
+ if (n->name_len > 0)
+ nokia->name = g_strndup((char *)n->name, n->name_len);
+
+ return 0;
+}
+
+/* returns 1 if pairing is not needed */
+static int process_nokia_com_bt(struct btd_adapter *adapter, void *data,
+ size_t size, bdaddr_t *remote)
+{
+ uint8_t *marker;
+ struct nokia_com_bt nokia;
+ int ret;
+ char remote_address[18];
+
+ /* Support this only for PushOOB */
+ if (!remote)
+ return -EOPNOTSUPP;
+
+ marker = data++;
+ size --;
+
+ DBG("marker: 0x%.2x size: %zu", *marker, size);
+
+ memset(&nokia, 0, sizeof(nokia));
+
+ switch (*marker) {
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ ret = process_nokia_long(data, size, *marker, &nokia);
+ break;
+ case 0x10:
+ ret = process_nokia_extra_short(data, size, &nokia);
+ break;
+ case 0x24:
+ ret = process_nokia_short(data, size, &nokia);
+ break;
+ default:
+ info("Not supported Nokia NFC extension (0x%.2x)", *marker);
+ ret = -EPROTONOSUPPORT;
+ break;
+ }
+
+ if (ret < 0)
+ return ret;
+
+ ba2str(&nokia.address, remote_address);
+ DBG("hci%u remote:%s", adapter_get_dev_id(adapter), remote_address);
+
+ ret = check_device(adapter, remote_address);
+ if (ret != 0) {
+ g_free(nokia.name);
+ return ret;
+ }
+
+ DBG("hci%u remote:%s", adapter_get_dev_id(adapter), remote_address);
+
+ if (nokia.name) {
+ btd_event_remote_name(adapter_get_address(adapter), remote,
+ nokia.name);
+ g_free(nokia.name);
+ }
+
+ if (nokia.cod != 0)
+ write_remote_class(adapter_get_address(adapter), remote,
+ nokia.cod);
+
+ if (nokia.pin_len > 0) {
+ /* TODO
+ * Handle PIN, for now only discovery mode and 'common' PINs
+ * that might be provided by agent will work correctly.
+ */
+ }
+
+ bacpy(remote, &nokia.address);
+
+ return 0;
+}
+
static int process_params(DBusMessage *msg, struct btd_adapter *adapter,
bdaddr_t *remote)
{
@@ -371,8 +559,14 @@ static int process_params(DBusMessage *msg, struct btd_adapter *adapter,
return process_eir(adapter, eir, size, remote);
} else if (strcasecmp(key, "nokia.com:bt") == 0) {
- /* TODO add support for Nokia BT 2.0 proprietary stuff */
- return -ENOTSUP;
+ DBusMessageIter array;
+ uint8_t *data;
+ int size;
+
+ dbus_message_iter_recurse(&value, &array);
+ dbus_message_iter_get_fixed_array(&array, &data, &size);
+
+ return process_nokia_com_bt(adapter, data, size, remote);
}
return -EINVAL;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/4] neard: Move device object checking into separate helper
From: Szymon Janc @ 2012-11-19 15:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337438-21865-1-git-send-email-szymon.janc@tieto.com>
This will also be used by 'nokia.com:bt' handler.
---
plugins/neard.c | 47 +++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 1576be5..8319445 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -248,13 +248,38 @@ static void bonding_complete(struct btd_adapter *adapter,
error("D-Bus send failed");
}
+static int check_device(struct btd_adapter *adapter, const char *address)
+{
+ struct btd_device *device;
+
+ device = adapter_find_device(adapter, address);
+
+ /* If already paired */
+ if (device && device_is_paired(device)) {
+ DBG("already paired");
+ return 1;
+ }
+
+ /* Pairing in progress... */
+ if (device && device_is_bonding(device, NULL)) {
+ DBG("pairing in progress");
+ return -EINPROGRESS;
+ }
+
+ /* If we have unpaired device hanging around, purge it */
+ if (device)
+ adapter_remove_device(adapter, device, TRUE);
+
+ return 0;
+}
+
/* returns 1 if pairing is not needed */
static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
bdaddr_t *remote)
{
- struct btd_device *device;
struct eir_data eir_data;
char remote_address[18];
+ int ret;
DBG("size %zu", size);
@@ -267,26 +292,12 @@ static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
DBG("hci%u remote:%s", adapter_get_dev_id(adapter), remote_address);
- device = adapter_find_device(adapter, remote_address);
-
- /* If already paired do nothing */
- if (device && device_is_paired(device)) {
- DBG("already paired");
+ ret = check_device (adapter, remote_address);
+ if (ret != 0) {
eir_data_free(&eir_data);
- return 1;
+ return ret;
}
- /* Pairing in progress... */
- if (device && device_is_bonding(device, NULL)) {
- DBG("pairing in progress");
- eir_data_free(&eir_data);
- return -EINPROGRESS;
- }
-
- /* If we have unpaired device hanging around, purge it */
- if (device)
- adapter_remove_device(adapter, device, TRUE);
-
/* store OOB data */
if (eir_data.class != 0)
write_remote_class(adapter_get_address(adapter),
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/4] neard: Use ENONET error when adapter is not enabled
From: Szymon Janc @ 2012-11-19 15:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This results in returning error 'Disabled' instead of 'No such Device'.
Will allow neard to properly set power state of Bluetooth carrier.
---
plugins/neard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 8f8381c..1576be5 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -380,7 +380,7 @@ static int check_adapter(struct btd_adapter *adapter)
btd_adapter_get_mode(adapter, NULL, NULL, &pairable);
if (!pairable || !adapter_get_agent(adapter))
- return -ENOENT;
+ return -ENONET;
if (!btd_adapter_ssp_enabled(adapter))
return -ENOTSUP;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 5/5] device: Fix minor whitespace issues
From: Szymon Janc @ 2012-11-19 15:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337366-21590-1-git-send-email-szymon.janc@tieto.com>
---
src/device.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/device.c b/src/device.c
index 44e58ac..4b5363f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -191,7 +191,7 @@ struct btd_device {
gint ref;
- GIOChannel *att_io;
+ GIOChannel *att_io;
guint cleanup_id;
guint store_id;
};
@@ -1506,7 +1506,6 @@ static const GDBusSignalTable device_signals[] = {
{ }
};
-
static const GDBusPropertyTable device_properties[] = {
{ "Address", "s", dev_property_get_address },
{ "Name", "s", dev_property_get_name, NULL, dev_property_exists_name },
@@ -4037,4 +4036,3 @@ void device_set_pnpid(struct btd_device *device, uint8_t vendor_id_src,
device_set_product(device, product_id);
device_set_version(device, product_ver);
}
-
--
1.7.9.5
^ permalink raw reply related
* [PATCH 4/5] device: Remove not really used auto_id member from btd_device
From: Szymon Janc @ 2012-11-19 15:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337366-21590-1-git-send-email-szymon.janc@tieto.com>
auto_id is not used anymore as LE device connect is now done by
adapter autoconnect list.
---
src/device.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/device.c b/src/device.c
index bc78fa7..44e58ac 100644
--- a/src/device.c
+++ b/src/device.c
@@ -174,7 +174,6 @@ struct btd_device {
GSList *attios;
GSList *attios_offline;
guint attachid; /* Attrib server attach */
- guint auto_id; /* Auto connect source id */
gboolean connected;
gboolean profiles_connected; /* Profile level connected */
@@ -346,9 +345,6 @@ static void device_free(gpointer user_data)
if (device->discov_timer)
g_source_remove(device->discov_timer);
- if (device->auto_id)
- g_source_remove(device->auto_id);
-
DBG("%p", device);
if (device->authr)
@@ -4027,11 +4023,6 @@ gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id)
if (device->attios != NULL || device->attios_offline != NULL)
return TRUE;
- if (device->auto_id) {
- g_source_remove(device->auto_id);
- device->auto_id = 0;
- }
-
attio_cleanup(device);
return TRUE;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/5] adapter: Minor whitespace fix in btd_adapter_set_class
From: Szymon Janc @ 2012-11-19 15:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337366-21590-1-git-send-email-szymon.janc@tieto.com>
Indent with tab not spaces.
---
src/adapter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 8b599da..5c17a6e 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -181,7 +181,7 @@ static gboolean process_auth_queue(gpointer user_data);
int btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major,
uint8_t minor)
{
- return mgmt_set_dev_class(adapter->dev_id, major, minor);
+ return mgmt_set_dev_class(adapter->dev_id, major, minor);
}
static const char *mode2str(uint8_t mode)
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/5] adapter: Remove not needed variable from btd_adapter_start
From: Szymon Janc @ 2012-11-19 15:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353337366-21590-1-git-send-email-szymon.janc@tieto.com>
address is no longer used and can be removed.
---
src/adapter.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index d208cfa..8b599da 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2259,9 +2259,6 @@ void adapter_connect_list_remove(struct btd_adapter *adapter,
void btd_adapter_start(struct btd_adapter *adapter)
{
struct session_req *req;
- char address[18];
-
- ba2str(&adapter->bdaddr, address);
adapter->off_requested = FALSE;
adapter->up = TRUE;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/5] adapter: Remove not needed variable from btd_adapter_get_mode
From: Szymon Janc @ 2012-11-19 15:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
address is no longer used and can be removed.
---
src/adapter.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 9ecc0fa..d208cfa 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2180,10 +2180,6 @@ void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode,
uint16_t *discoverable_timeout,
gboolean *pairable)
{
- char address[18];
-
- ba2str(&adapter->bdaddr, address);
-
if (mode)
*mode = adapter->mode;
--
1.7.9.5
^ permalink raw reply related
* [PATCH] Bluetooth: Remove device OOB data if it was discovered in band
From: Szymon Janc @ 2012-11-19 14:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
OOB authentication mechanism should be used only if pairing process
has been activated by previous OOB information exchange (Core Spec
4.0 , vol. 1, Part A, 5.1.4.3). Stored OOB data for specific device
should be removed if that device was discovered in band later on.
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
---
This could also be done by userspace but would require calling remove remote
OOB data mgmt command for every device found. Userspace could also track for
which devices OOB data were added but this could be problematic as OOB data
persists userspace restart. Doing it in kernel seems better.
net/bluetooth/hci_event.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9f5c5f2..cda5bac 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1946,6 +1946,8 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
for (; num_rsp; num_rsp--, info++) {
bool name_known, ssp;
+ hci_remove_remote_oob_data(hdev, &info->bdaddr);
+
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode;
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH BlueZ 2/2] l2test: Add support to test auto select PSM
From: Syam Sidhardhan @ 2012-11-19 14:09 UTC (permalink / raw)
To: Syam Sidhardhan, linux-bluetooth
In-Reply-To: <20121116080528.GA9653@x220>
Hi Johan,
On Fri, Nov 16, 2012 at 1:35 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Syam,
>
> On Fri, Nov 09, 2012, Syam Sidhardhan wrote:
>> This patch enable us to test the auto select PSM by passing
>> PSM value as 0.
>>
>> Ex: l2test -d -P 0
>> l2test[2585]: Waiting for connection on psm 4099 ...
>> ---
>> test/l2test.c | 4 +---
>> 1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/test/l2test.c b/test/l2test.c
>> index 7645681..72ad4ba 100644
>> --- a/test/l2test.c
>> +++ b/test/l2test.c
>> @@ -87,7 +87,7 @@ static long buffer_size = 2048;
>>
>> /* Default addr and psm and cid */
>> static bdaddr_t bdaddr;
>> -static unsigned short psm = 0x1011;
>> +static unsigned short psm = 0;
>> static unsigned short cid = 0;
>>
>> /* Default number of frames to send (-1 = infinite) */
>> @@ -375,8 +375,6 @@ static int do_connect(char *svr)
>> addr.l2_cid = htobs(cid);
>> else if (psm)
>> addr.l2_psm = htobs(psm);
>> - else
>> - goto error;
>>
>> if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0 ) {
>> syslog(LOG_ERR, "Can't connect: %s (%d)",
>
> At least the second chunk is for the initiating (client) part, not the
> server (which the commit message implies you're dealing with). There's
> no "auto select" for the client.
>
True. While preparing the patch it got misplaced.
I'll send an updated version.
Thanks,
Syam.
^ permalink raw reply
* Re: [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Lucas De Marchi @ 2012-11-19 13:18 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZJ79UfsU9=ejGSEBGueca1FJouKt15LpukEy6TtK+QFYg@mail.gmail.com>
On Mon, Nov 19, 2012 at 10:49 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lucas,
>
> On Mon, Nov 19, 2012 at 2:06 PM, Lucas De Marchi
> <lucas.demarchi@profusion.mobi> wrote:
>> Hi Luiz,
>>
>> On Mon, Nov 19, 2012 at 6:46 AM, Luiz Augusto von Dentz
>> <luiz.dentz@gmail.com> wrote:
>>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>>
>>> This makes g_dbus_setup_bus to automatically register '/' path so
>>> user application that don't export any interface on '/' will have it
>>> registered for ObjectManager.
>>>
>>> Note that it is now required to call g_dbus_close before exit.
>>
>> I'm no really fan of this. Why do we need to register '/' now? If we
>> are not going to support ObjectManager interfaces in subtrees, it
>> would be easier to just move the ObjectManager to the shortest path
>> registered rather than always registering '/'.
>
> Maybe I should have made clear this in the description, if you look at
> the spec it suggest that each sub-tree root should implement
> ObjectManager, the current implementation does that but if you think
> about it probably doesn't make sense to have sub-trees because that
> would creates extra round trips that ObjectManager was meant to
HUmn... I think you are a bit confused now.
1 entire tree can be managed by a single ObjectManager, or multiple
ones if there are objects that are not interesting to everybody and
only a few types of clients would be interested in the objects changed
beyond that path.
Example:
/org/bluez
- ObjectManager
/org/bluez/adapter/bla/bli
- MyInterfaceWithLotsOfObjects
If you put only 1 ObjectManager it means you get called for each
change in /org/bluez/adapter/bla/bli even though most of the clients
will not be interested in that. Therefore the spec allows you to
attach another ObjectManager in /org/bluez/adapter/[...] so the first
ObjectManager only send updates and "manage" the objects until the
path containing another ObjectManager.
I do think we don't really need that feature right now. I think we are
fine with a single ObjectManager in "/", but always registering "/"
IMO is not the right solution.
> prevent, also Im not completely sure now but I remember someone
> mentioning the '/' is kind special and should always be available no
> matter what, so by registering '/' directly on g_dbus_setup_bus we
> guarantee we have it always and that no sub-tree is going to be
> generated since '/' is the root no matter what path the user code
> register.
Kind of true... what really needs to be treated are calls to
Introspectable interface on "/". This is used by tools like d-feet to
navigate the tree (looking for the "<node ...>" tags) -- I *think*
this is also used by some bindings like python's. If you look in other
projects around, they prefer using the project's namespace rather than
"/" (examples: systemd, udisks, policykit, dconf).
So, if we register "/", but not an Introspectable interface in there,
it means we will break tools like d-feet. If we don't register it,
libdbus will handle the messages to Introspectable (this is why other
projects don't even bother about "/").
Lucas De Marchi
^ permalink raw reply
* Re: [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Luiz Augusto von Dentz @ 2012-11-19 12:49 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAMOw1v7Y3EORhpSyydjhieG4Owx=0d5QAp=G66RweF7-cCshXQ@mail.gmail.com>
Hi Lucas,
On Mon, Nov 19, 2012 at 2:06 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> Hi Luiz,
>
> On Mon, Nov 19, 2012 at 6:46 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This makes g_dbus_setup_bus to automatically register '/' path so
>> user application that don't export any interface on '/' will have it
>> registered for ObjectManager.
>>
>> Note that it is now required to call g_dbus_close before exit.
>
> I'm no really fan of this. Why do we need to register '/' now? If we
> are not going to support ObjectManager interfaces in subtrees, it
> would be easier to just move the ObjectManager to the shortest path
> registered rather than always registering '/'.
Maybe I should have made clear this in the description, if you look at
the spec it suggest that each sub-tree root should implement
ObjectManager, the current implementation does that but if you think
about it probably doesn't make sense to have sub-trees because that
would creates extra round trips that ObjectManager was meant to
prevent, also Im not completely sure now but I remember someone
mentioning the '/' is kind special and should always be available no
matter what, so by registering '/' directly on g_dbus_setup_bus we
guarantee we have it always and that no sub-tree is going to be
generated since '/' is the root no matter what path the user code
register.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Lucas De Marchi @ 2012-11-19 12:06 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1353314786-11427-2-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Nov 19, 2012 at 6:46 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This makes g_dbus_setup_bus to automatically register '/' path so
> user application that don't export any interface on '/' will have it
> registered for ObjectManager.
>
> Note that it is now required to call g_dbus_close before exit.
I'm no really fan of this. Why do we need to register '/' now? If we
are not going to support ObjectManager interfaces in subtrees, it
would be easier to just move the ObjectManager to the shortest path
registered rather than always registering '/'.
Lucas De Marchi
^ permalink raw reply
* Re: [PATCH] bluetooth: Increase HCI command tx timeout
From: Johan Hedberg @ 2012-11-19 10:01 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1370568.JbBC3GLxi1@uw000953>
Hi Szymon,
On Mon, Nov 19, 2012, Szymon Janc wrote:
> On Monday 12 of November 2012 12:01:05 Janc Szymon wrote:
> > Read Local OOB Data command can take more than 1 second on some chips.
> > e.g. on CSR 0a12:0001 first call to Read Local OOB Data after reset
> > takes about 1300ms resulting in tx timeout error.
> >
> > [27698.368655] Bluetooth: hci0 command 0x0c57 tx timeout
> >
> > 2012-10-31 15:53:36.178585 < HCI Command: Read Local OOB Data (0x03|0x0057) plen 0
> > 2012-10-31 15:53:37.496996 > HCI Event: Command Complete (0x0e) plen 36
> > Read Local OOB Data (0x03|0x0057) ncmd 1
> > status 0x00
> > hash 0x92219d9b447f2aa9dc12dda2ae7bae6a
> > randomizer 0xb1948d0febe4ea38ce85c4e66313beba
> >
> > Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> > ---
> >
> > Spec doesn't seem to be posing any restrictions on how fast should HCI response...
> > I've increased timeout to 2 secs as this seems to fix this for me, but maybe this
> > could be increased to something more, like 5 secs or sth to minimize tx timeout
> > chance for other slow chips? If chip doesn't response for command it is FUBAR
> > anyway and having longer timeout would not make things that much worse (and
> > could even improve things on slow chips..).
> >
> >
> > include/net/bluetooth/hci.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 4bbabd8..45eee08 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -154,7 +154,7 @@ enum {
> > #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
> > #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
> > #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
> > -#define HCI_CMD_TIMEOUT msecs_to_jiffies(1000) /* 1 second */
> > +#define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
> > #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
> > #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
> >
> >
>
> ping
I'm fine with this but an ack from Marcel or Gustavo would be good.
Johan
^ permalink raw reply
* Re: [PATCH] bluetooth: Increase HCI command tx timeout
From: Szymon Janc @ 2012-11-19 9:46 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1352714465-17015-1-git-send-email-szymon.janc@tieto.com>
On Monday 12 of November 2012 12:01:05 Janc Szymon wrote:
> Read Local OOB Data command can take more than 1 second on some chips.
> e.g. on CSR 0a12:0001 first call to Read Local OOB Data after reset
> takes about 1300ms resulting in tx timeout error.
>
> [27698.368655] Bluetooth: hci0 command 0x0c57 tx timeout
>
> 2012-10-31 15:53:36.178585 < HCI Command: Read Local OOB Data (0x03|0x0057) plen 0
> 2012-10-31 15:53:37.496996 > HCI Event: Command Complete (0x0e) plen 36
> Read Local OOB Data (0x03|0x0057) ncmd 1
> status 0x00
> hash 0x92219d9b447f2aa9dc12dda2ae7bae6a
> randomizer 0xb1948d0febe4ea38ce85c4e66313beba
>
> Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> ---
>
> Spec doesn't seem to be posing any restrictions on how fast should HCI response...
> I've increased timeout to 2 secs as this seems to fix this for me, but maybe this
> could be increased to something more, like 5 secs or sth to minimize tx timeout
> chance for other slow chips? If chip doesn't response for command it is FUBAR
> anyway and having longer timeout would not make things that much worse (and
> could even improve things on slow chips..).
>
>
> include/net/bluetooth/hci.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 4bbabd8..45eee08 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -154,7 +154,7 @@ enum {
> #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
> #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
> #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
> -#define HCI_CMD_TIMEOUT msecs_to_jiffies(1000) /* 1 second */
> +#define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
> #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
> #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
>
>
ping
^ permalink raw reply
* [PATCH BlueZ 4/4] core: Make use of g_dbus_close
From: Luiz Augusto von Dentz @ 2012-11-19 8:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1353314786-11427-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
src/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main.c b/src/main.c
index 414849a..1ca6015 100644
--- a/src/main.c
+++ b/src/main.c
@@ -383,6 +383,7 @@ static void disconnect_dbus(void)
set_dbus_connection(NULL);
+ g_dbus_close(conn);
dbus_connection_unref(conn);
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 3/4] gdbus: Fix not calling dbus_connection_close for private connections
From: Luiz Augusto von Dentz @ 2012-11-19 8:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1353314786-11427-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
dbus_bus_get_private documentation says:
"Unlike dbus_bus_get(), always creates a new connection. This
connection will not be saved or recycled by libdbus. Caller owns a
reference to the bus and must either close it or know it to be closed
prior to releasing this reference."
---
gdbus/mainloop.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 49e6538..4771f20 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -328,6 +328,7 @@ DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
if (g_dbus_connect(conn, name, error))
return conn;
+ dbus_connection_close(conn);
dbus_connection_unref(conn);
return NULL;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 2/4] gdbus: Automatically register '/' path
From: Luiz Augusto von Dentz @ 2012-11-19 8:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1353314786-11427-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes g_dbus_setup_bus to automatically register '/' path so
user application that don't export any interface on '/' will have it
registered for ObjectManager.
Note that it is now required to call g_dbus_close before exit.
---
gdbus/gdbus.h | 1 +
gdbus/mainloop.c | 55 ++++++++++++++++++++++++++++++-------------------------
gdbus/object.c | 2 +-
3 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index ba49621..5056340 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -53,6 +53,7 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
DBusError *error);
+void g_dbus_close(DBusConnection *connection);
gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
DBusError *error);
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 099b67f..49e6538 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -286,27 +286,36 @@ static gboolean setup_bus(DBusConnection *conn, const char *name,
return TRUE;
}
-DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
+static gboolean g_dbus_connect(DBusConnection *conn, const char *name,
DBusError *error)
{
- DBusConnection *conn;
-
- conn = dbus_bus_get(type, error);
-
if (error != NULL) {
if (dbus_error_is_set(error) == TRUE)
- return NULL;
+ return FALSE;
}
- if (conn == NULL)
- return NULL;
+ if (setup_bus(conn, name, error) == FALSE)
+ return FALSE;
- if (setup_bus(conn, name, error) == FALSE) {
- dbus_connection_unref(conn);
- return NULL;
- }
+ if (!g_dbus_register_interface(conn, "/", NULL, NULL, NULL, NULL, NULL,
+ NULL))
+ return FALSE;
- return conn;
+ return TRUE;
+}
+
+DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
+ DBusError *error)
+{
+ DBusConnection *conn;
+
+ conn = dbus_bus_get(type, error);
+
+ if (g_dbus_connect(conn, name, error))
+ return conn;
+
+ dbus_connection_unref(conn);
+ return NULL;
}
DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
@@ -316,20 +325,16 @@ DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
conn = dbus_bus_get_private(type, error);
- if (error != NULL) {
- if (dbus_error_is_set(error) == TRUE)
- return NULL;
- }
-
- if (conn == NULL)
- return NULL;
+ if (g_dbus_connect(conn, name, error))
+ return conn;
- if (setup_bus(conn, name, error) == FALSE) {
- dbus_connection_unref(conn);
- return NULL;
- }
+ dbus_connection_unref(conn);
+ return NULL;
+}
- return conn;
+void g_dbus_close(DBusConnection *connection)
+{
+ g_dbus_unregister_interface(connection, "/", NULL);
}
gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
diff --git a/gdbus/object.c b/gdbus/object.c
index 43154f3..2a2982d 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -615,7 +615,7 @@ static struct interface_data *find_interface(GSList *interfaces,
for (list = interfaces; list; list = list->next) {
struct interface_data *iface = list->data;
- if (!strcmp(name, iface->name))
+ if (g_strcmp0(name, iface->name) == 0)
return iface;
}
--
1.7.11.7
^ 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