Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 04/31] Bluetooth: Allow l2cap_chan_check_security() to be used for LE links.
From: Johan Hedberg @ 2013-12-04 14:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386166287-13693-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

With connection oriented L2CAP channels some code paths will be shared
with BR/EDR links. It is therefore necessary to allow the
l2cap_chan_check_security function to be usable also for LE links in
addition to BR/EDR ones. This means that smp_conn_security() needs to be
called instead of hci_conn_security() in the case of an LE link.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 03b641c2f39d..510a17cefd26 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -726,6 +726,9 @@ int l2cap_chan_check_security(struct l2cap_chan *chan)
 	struct l2cap_conn *conn = chan->conn;
 	__u8 auth_type;
 
+	if (conn->hcon->type == LE_LINK)
+		return smp_conn_security(conn->hcon, chan->sec_level);
+
 	auth_type = l2cap_get_auth_type(chan);
 
 	return hci_conn_security(conn->hcon, chan->sec_level, auth_type);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 03/31] Bluetooth: Update l2cap_global_chan_by_psm() to take a link type
From: Johan Hedberg @ 2013-12-04 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386166287-13693-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

Once connection oriented L2CAP channels become possible for LE we need
to be able to specify the link type we're interested in when looking up
L2CAP channels. Therefore, add a link_type parameter to the
l2cap_global_chan_by_psm() function which gets compared to the address
type associated with each l2cap_chan.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 70be2eb8ed03..03b641c2f39d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1703,7 +1703,8 @@ EXPORT_SYMBOL(l2cap_conn_put);
  */
 static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
 						   bdaddr_t *src,
-						   bdaddr_t *dst)
+						   bdaddr_t *dst,
+						   u8 link_type)
 {
 	struct l2cap_chan *c, *c1 = NULL;
 
@@ -1713,6 +1714,12 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
 		if (state && c->state != state)
 			continue;
 
+		if (link_type == ACL_LINK && c->src_type != BDADDR_BREDR)
+			continue;
+
+		if (link_type == LE_LINK && c->src_type == BDADDR_BREDR)
+			continue;
+
 		if (c->psm == psm) {
 			int src_match, dst_match;
 			int src_any, dst_any;
@@ -3713,7 +3720,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
 
 	/* Check if we have socket listening on psm */
 	pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src,
-					 &conn->hcon->dst);
+					 &conn->hcon->dst, ACL_LINK);
 	if (!pchan) {
 		result = L2CAP_CR_BAD_PSM;
 		goto sendresp;
@@ -6380,7 +6387,8 @@ static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm,
 	if (hcon->type != ACL_LINK)
 		goto drop;
 
-	chan = l2cap_global_chan_by_psm(0, psm, &hcon->src, &hcon->dst);
+	chan = l2cap_global_chan_by_psm(0, psm, &hcon->src, &hcon->dst,
+					ACL_LINK);
 	if (!chan)
 		goto drop;
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 02/31] Bluetooth: Add module parameter to enable LE CoC support
From: Johan Hedberg @ 2013-12-04 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386166287-13693-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

Along with the L2CAP Connection Oriented Channels features it is now
allowed to use both custom fixed CIDs as well as PSM based (connection
oriented connections). Since the support for this (with the subsequent
patches) is still on an experimental stage, add a module parameter to
enable it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/l2cap.h |  1 +
 net/bluetooth/l2cap_sock.c    | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index c853b16de4ef..94645d56fea7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -809,6 +809,7 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
 }
 
 extern bool disable_ertm;
+extern bool enable_lecoc;
 
 int l2cap_init_sockets(void);
 void l2cap_cleanup_sockets(void);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 7cc24d263caa..5a1d0cb0b8d5 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -27,6 +27,7 @@
 
 /* Bluetooth L2CAP sockets. */
 
+#include <linux/module.h>
 #include <linux/export.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -35,6 +36,8 @@
 
 #include "smp.h"
 
+bool enable_lecoc;
+
 static struct bt_sock_list l2cap_sk_list = {
 	.lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock)
 };
@@ -73,11 +76,11 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
 		return -EINVAL;
 
 	if (bdaddr_type_is_le(la.l2_bdaddr_type)) {
-		/* Connection oriented channels are not supported on LE */
-		if (la.l2_psm)
+		if (!enable_lecoc && la.l2_psm)
 			return -EINVAL;
 		/* We only allow ATT user space socket */
-		if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
+		if (la.l2_cid &&
+		    la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
 			return -EINVAL;
 	}
 
@@ -189,11 +192,11 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
 		return -EINVAL;
 
 	if (bdaddr_type_is_le(la.l2_bdaddr_type)) {
-		/* Connection oriented channels are not supported on LE */
-		if (la.l2_psm)
+		if (!enable_lecoc && la.l2_psm)
 			return -EINVAL;
 		/* We only allow ATT user space socket */
-		if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
+		if (la.l2_cid &&
+		    la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
 			return -EINVAL;
 	}
 
@@ -1469,3 +1472,6 @@ void l2cap_cleanup_sockets(void)
 	bt_sock_unregister(BTPROTO_L2CAP);
 	proto_unregister(&l2cap_proto);
 }
+
+module_param(enable_lecoc, bool, 0644);
+MODULE_PARM_DESC(enable_lecoc, "Enable support for LE CoC");
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 01/31] Bluetooth: Remove unnecessary braces from one-line if-statement
From: Johan Hedberg @ 2013-12-04 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386166287-13693-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

This patch is just a trivial coding style fix to remove unnecessary
braces from a one-line if-statement.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4af3821df880..70be2eb8ed03 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6612,11 +6612,10 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 		}
 
 		if (chan->state == BT_CONNECT) {
-			if (!status) {
+			if (!status)
 				l2cap_start_connection(chan);
-			} else {
+			else
 				__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
-			}
 		} else if (chan->state == BT_CONNECT2) {
 			struct l2cap_conn_rsp rsp;
 			__u16 res, stat;
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 00/31] Bluetooth: LE CoC support
From: Johan Hedberg @ 2013-12-04 14:10 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

This patch set implements support for LE Connection oriented Channels
(PSM based connections over LE with credit based flow control).

Johan

----------------------------------------------------------------
Johan Hedberg (31):
      Bluetooth: Remove unnecessary braces from one-line if-statement
      Bluetooth: Add module parameter to enable LE CoC support
      Bluetooth: Update l2cap_global_chan_by_psm() to take a link type
      Bluetooth: Allow l2cap_chan_check_security() to be used for LE links.
      Bluetooth: Pass command length to LE signaling channel handlers
      Bluetooth: Move LE L2CAP initiator procedure to its own function
      Bluetooth: Add definitions for LE connection oriented channels
      Bluetooth: Add initial code for LE L2CAP Connect Request
      Bluetooth: Add smp_sufficient_security helper function
      Bluetooth: Refactor L2CAP connect rejection to its own function
      Bluetooth: Add basic LE L2CAP connect request receiving support
      Bluetooth: Fix L2CAP channel closing for LE connections
      Bluetooth: Add L2CAP Disconnect suppport for LE
      Bluetooth: Make l2cap_le_sig_cmd logic consistent
      Bluetooth: Add LE L2CAP flow control mode
      Bluetooth: Track LE L2CAP credits in l2cap_chan
      Bluetooth: Limit L2CAP_OPTIONS socket option usage with LE
      Bluetooth: Add new BT_SNDMTU and BT_RCVMTU socket options
      Bluetooth: Implement returning of LE L2CAP credits
      Bluetooth: Add LE flow control discipline
      Bluetooth: Reject LE CoC commands when the feature is not enabled
      Bluetooth: Introduce L2CAP channel callback for suspending
      Bluetooth: Add LE L2CAP segmentation support for outgoing data
      Bluetooth: Implement LE L2CAP reassembly
      Bluetooth: Fix LE L2CAP Connect Request handling together with SMP
      Bluetooth: Fix suspending the L2CAP socket if we start with 0 credits
      Bluetooth: Limit LE MPS to the MTU value
      Bluetooth: Fix clearing of chan->omtu for LE CoC channels
      Bluetooth: Fix CID ranges for LE CoC CID allocations
      Bluetooth: Fix validating LE PSM values
      Bluetooth: Add debugfs controls for LE CoC MPS and Credits

 include/net/bluetooth/bluetooth.h |   3 +
 include/net/bluetooth/l2cap.h     |  46 +++
 net/bluetooth/l2cap_core.c        | 731 +++++++++++++++++++++++++++++++++---
 net/bluetooth/l2cap_sock.c        | 157 +++++++-
 net/bluetooth/smp.c               |  16 +-
 net/bluetooth/smp.h               |   1 +
 6 files changed, 885 insertions(+), 69 deletions(-)


^ permalink raw reply

* pull request: bluetooth-next 2013-12-04
From: Gustavo Padovan @ 2013-12-04 13:25 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth, linux-kernel

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

Hi John,

This is the first batch of patches intended for 3.14. There is nothing big here.
Most of the code are refactors, clean up, small fixes, plus some new device id
support.

Please pull or let me know of any problems! Thanks.

	Gustavo

---
The following changes since commit 4b074b07625f603d40d4d04937f8874a00415dc4:

  Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next (2013-12-02 14:25:38 -0500)

are available in the git repository at:


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

for you to fetch changes up to 201a5929c8c788f9ef53b010065c9ce70c9c06f0:

  Bluetooth: Remove dead code from SMP encryption function (2013-12-04 11:09:05 -0200)

----------------------------------------------------------------
Andre Guedes (5):
      Bluetooth: Check address in mgmt_disconnect_failed()
      Bluetooth: Add an extra check in mgmt_device_disconnected()
      Bluetooth: Remove link type check in hci_disconn_complete_evt()
      Bluetooth: Remove unneeded check in hci_disconn_complete_evt()
      Bluetooth: Refactor hci_disconn_complete_evt

Bing Zhao (3):
      Bluetooth: btmrvl: operate on 16-bit opcodes instead of ogf/ocf
      Bluetooth: btmrvl: use cal-data from device-tree instead of conf file
      Bluetooth: btmrvl: remove cal-data byte swapping and redundant mem copy

Johan Hedberg (3):
      Bluetooth: Remove unnecessary 'send' parameter from smp_failure()
      Bluetooth: Remove useless smp_rand function
      Bluetooth: Remove dead code from SMP encryption function

Marcel Holtmann (4):
      Bluetooth: Fix limited discoverable mode for Zeevo modules
      Bluetooth: Set default own address type only during controller setup
      Bluetooth: Remove debug statement for features complete event
      Bluetooth: Store supported commands only during setup procedure

Sujith Manoharan (2):
      Bluetooth: ath3k: Add support for another AR3012 card
      Bluetooth: ath3k: Add support for a new AR3012 device

Tedd Ho-Jeong An (2):
      Bluetooth: Add support for Intel Bluetooth device [8087:0a2a]
      Bluetooth: Enable autosuspend for Intel Bluetooth device

 drivers/bluetooth/ath3k.c       |   4 ++
 drivers/bluetooth/btmrvl_drv.h  |  25 +++++-----
 drivers/bluetooth/btmrvl_main.c | 130 ++++++++++++---------------------------------------
 drivers/bluetooth/btmrvl_sdio.c |   9 +---
 drivers/bluetooth/btmrvl_sdio.h |   2 -
 drivers/bluetooth/btusb.c       |   7 ++-
 net/bluetooth/hci_core.c        |  20 ++++----
 net/bluetooth/hci_event.c       |  72 +++++++++++++---------------
 net/bluetooth/mgmt.c            |  17 ++++++-
 net/bluetooth/smp.c             |  40 +++++-----------
 10 files changed, 124 insertions(+), 202 deletions(-)


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

^ permalink raw reply

* Re: [PATCH] Bluetooth: Add support for Toshiba Bluetooth device [0930:0220]
From: Gustavo Padovan @ 2013-12-04 13:12 UTC (permalink / raw)
  To: Marco Piazza; +Cc: linux-bluetooth
In-Reply-To: <1385594125-7964-1-git-send-email-mpiazza@gmail.com>

Hi Marco,

2013-11-28 Marco Piazza <mpiazza@gmail.com>:

> This patch adds support for new Toshiba Bluetooth device.
> 
> T:  Bus=05 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0930 ProdID=0220 Rev=00.02
> C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> 
> Signed-off-by: Marco Piazza <mpiazza@gmail.com>
> ---
>  drivers/bluetooth/ath3k.c | 2 ++
>  drivers/bluetooth/btusb.c | 1 +
>  2 files changed, 3 insertions(+)

Patch has been applied to bluetooth.git. Thanks.

	Gustavo

^ permalink raw reply

* Re: [PATCH 1/6] android/a2dp: Fix possible NULL dereference
From: Andrei Emeltchenko @ 2013-12-04  8:36 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZKRWtCvq_yg7dT+2iJFL5rvPauiOkqYP3diCc_6TN_SkA@mail.gmail.com>

Hi Luiz,

On Tue, Dec 03, 2013 at 09:53:43PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
> 
> On Tue, Dec 3, 2013 at 5:53 PM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > Since a2dp_record may return NULL, check return value. This
> > silences static analysers tools.
> > ---
> >  android/a2dp.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/android/a2dp.c b/android/a2dp.c
> > index cee4bfa..36a0714 100644
> > --- a/android/a2dp.c
> > +++ b/android/a2dp.c
> > @@ -366,9 +366,10 @@ bool bt_a2dp_register(const bdaddr_t *addr)
> >         }
> >
> >         rec = a2dp_record();
> > -       if (bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
> > +       if (!rec || bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
> 
> Usually we check the return individually, that means you do if (rec)
> and perhaps handle the error path with goto, but first make sure that
> a2dp_record can actually fail otherwise this is pointless.

It might return NULL if malloc fails, do you think that we need to change
malloc to g_malloc in sdp code. Otherwise every tools warns about NULL
dereference.

Best regards 
Andrei Emeltchenko 

>
> >                 error("Failed to register on A2DP record");
> > -               sdp_record_free(rec);
> > +               if (rec)
> > +                       sdp_record_free(rec);
> >                 g_io_channel_shutdown(server, TRUE, NULL);
> >                 g_io_channel_unref(server);
> >                 server = NULL;
> > --
> > 1.8.3.2
> >
> > --
> > 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
> 
> 
> 
> -- 
> Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCHv1 0/2] Introduce default adapter property
From: Szymon Janc @ 2013-12-04  8:32 UTC (permalink / raw)
  To: Timo Mueller; +Cc: linux-bluetooth, Timo Mueller
In-Reply-To: <cover.1386078490.git.timo.mueller@bmw-carit.de>

Hi Timo,

> From: Timo Mueller <timo.mueller@bmw-carit.de>
> 
> Hi,
> 
> the information about the default adapter is currently not available
> through the D-Bus API of BlueZ. But as plugins can use this
> information to choose the adapter they act upon it would be helpful
> for users to be able to retrieve this information as well.
>
> For example the neard plugin uses this information to decide for which
> adapter oob data is generated. Users could use the same information to
> power the adapter before actually sending the oob data.

I think this property is bluetoothd internal detail and should not be needed
to be exported to user. If reason for this is scenario where multiple BT and
NFC adapters are present and you need to match them in pairs, then proper
solution would probably require extending neard agent interface. Neard plugin
could be also made 'smarter' about multiple adapters eg. try to choose other
controller if default one is not powered etc. Regarding changing power state
of bt controller, I think this could be done by neard plugin itself (possible
based on some static configuration or even runtime dbus setting...). It is on
my 'TODO when have some spare time' list :)

It would be good if you could outline usecases you are trying to address with
this change.

-- 
BR
Szymon Janc



^ permalink raw reply

* Re: have to re-pair mouse every few hours (update: mouse needs periodic authorization?)
From: Brian J. Murrell @ 2013-12-04  0:06 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386112361.5405.37.camel@nuvo>

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

On Wed, 2013-12-04 at 00:12 +0100, Bastien Nocera wrote: 
> 
> Just how did you pair your mouse?

With mate[gnome]-bluetooth-properties.

Cheers,
b.




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* Re: have to re-pair mouse every few hours (update: mouse needs periodic authorization?)
From: Bastien Nocera @ 2013-12-03 23:12 UTC (permalink / raw)
  To: Brian J. Murrell; +Cc: linux-bluetooth
In-Reply-To: <1386107032.8730.22.camel@pc.interlinx.bc.ca>

On Tue, 2013-12-03 at 16:43 -0500, Brian J. Murrell wrote:
> On Sat, 2013-11-30 at 15:37 -0500, Brian J. Murrell wrote: 
> > Hi,
> > 
> > I'm using a Microsoft Sculpt Touch Mouse on a Fedora 19 machine
> > (kernel-3.11.9-200.fc19.x86_64 and bluez-4.101-9.fc19.x86_64) with a:
> > 
> > Bus 002 Device 019: ID 0a5c:2148 Broadcom Corp. BCM92046DG-CL1ROM Bluetooth 2.1 Adapter
> > 
> > bluetooth adapter.  This exact same configuration worked for months just
> > fine with a Logitech bluetooth mouse.  But sadly that mouse was crap
> > (second one to fail within the warranty period of one of them) so
> > replaced it with this MS one.
> > 
> > The problem with this MS mouse is that it just goes AWOL and needs to be
> > delete and re-paired with the machine every few hours.  Typically it's
> > after I have gotten up from the computer and have come back to it.  But
> > I have also had it just happen while using it.
> > 
> > When this happens, the messages log reports messages such as:
> > 
> > Nov 30 12:42:03 pc kernel: [2500032.028982] Bluetooth: Unexpected continuation frame (len 0)
> > Nov 30 12:42:03 pc kernel: [2500032.115027] Bluetooth: Unexpected continuation frame (len 0)
> > 
> > Any ideas what the problem might be here?
> 
> So an interesting development in this is that after a reboot, I am now
> starting to see notification bubbles pop up when the mouse goes AWOL
> that say:
> 
> Authorization request from 'Microsoft Sculpt Touch Mouse' with a "Check
> authorization" button it.  When I click that I get a dialog popping up
> that says:
> 
> Grant access to '<uuid>'
> 
> Device 'Microsoft Sculpt Touch Mouse' (<MAC address>) wants access to
> the service '<uuid>'.
> 
> With both a Reject and a Grant button as well as an "Always grant
> access" checkbox.
> 
> Clicking Grant restores the functionality of the mouse and clearly I
> could click the Always grant access checkbox to have this automatic.

Just how did you pair your mouse?


^ permalink raw reply

* cross compiling bluez 4.101
From: Daniel Schultze @ 2013-12-03 22:38 UTC (permalink / raw)
  To: linux-bluetooth

Hello Developers,

I'm having a bit of trouble cross compiling bluez 4.101 with an older
kernel 2.6.31. I'm using:

me@buildmachine:~/tmp/bluez-4.101$ arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I'll admit its a bit old but, its what I have to work with. In
addition I have built glibc 2.10.1, glib 2.28.8, and dbus 1.4.26
successfully to fulfill bluez's prerequisites.

This is error I'm getting:

  CCLD   src/bluetoothd
attrib/bluetoothd-gatt.o: In function `read_long_destroy':
gatt.c:(.text+0xfec): undefined reference to `__sync_fetch_and_sub_4'
attrib/bluetoothd-gatt.o: In function `read_blob_helper':
gatt.c:(.text+0x121c): undefined reference to `__sync_fetch_and_add_4'
attrib/bluetoothd-gatt.o: In function `read_char_helper':
gatt.c:(.text+0x13e8): undefined reference to `__sync_fetch_and_add_4'
attrib/bluetoothd-gatt.o: In function `gatt_read_char':
gatt.c:(.text+0x15d8): undefined reference to `__sync_fetch_and_add_4'
attrib/bluetoothd-gattrib.o: In function `g_attrib_ref':
gattrib.c:(.text+0x1fc): undefined reference to `__sync_fetch_and_add_4'
attrib/bluetoothd-gattrib.o: In function `g_attrib_unref':
gattrib.c:(.text+0x528): undefined reference to `__sync_fetch_and_sub_4'
collect2: ld returned 1 exit status
make[1]: *** [src/bluetoothd] Error 1
make: *** [all] Error 2

and I have configured using this line (for building outside of ltib):

./configure CFLAGS="--sysroot=/home/me/ltib_me/rootfs -march=armv5te"
--prefix=/usr --build=$MACHTYPE --host=arm-none-linux-gnueabi
--disable-alsa --disable-audio --enable-gatt --disable-pcmcia
--disable-gstreamer

and the build machine is:

me@buildmachine:~/tmp/bluez-4.101$ echo $MACHTYPE
i686-pc-linux-gnu
me@buildmachine:~/tmp/bluez-4.101$ uname -a
Linux buildmachine 3.0.0-12-generic-pae #20-Ubuntu SMP Fri Oct 7
16:37:17 UTC 2011 i686 i686 i386 GNU/Linux
me@buildmachine:~/tmp/bluez-4.101$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 11.10
Release: 11.10
Codename: oneiric

Any help on resolving this error would be appreciated.

^ permalink raw reply

* Re: have to re-pair mouse every few hours (update: mouse needs periodic authorization?)
From: Brian J. Murrell @ 2013-12-03 21:43 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385843856.12122.5.camel@pc.interlinx.bc.ca>

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

On Sat, 2013-11-30 at 15:37 -0500, Brian J. Murrell wrote: 
> Hi,
> 
> I'm using a Microsoft Sculpt Touch Mouse on a Fedora 19 machine
> (kernel-3.11.9-200.fc19.x86_64 and bluez-4.101-9.fc19.x86_64) with a:
> 
> Bus 002 Device 019: ID 0a5c:2148 Broadcom Corp. BCM92046DG-CL1ROM Bluetooth 2.1 Adapter
> 
> bluetooth adapter.  This exact same configuration worked for months just
> fine with a Logitech bluetooth mouse.  But sadly that mouse was crap
> (second one to fail within the warranty period of one of them) so
> replaced it with this MS one.
> 
> The problem with this MS mouse is that it just goes AWOL and needs to be
> delete and re-paired with the machine every few hours.  Typically it's
> after I have gotten up from the computer and have come back to it.  But
> I have also had it just happen while using it.
> 
> When this happens, the messages log reports messages such as:
> 
> Nov 30 12:42:03 pc kernel: [2500032.028982] Bluetooth: Unexpected continuation frame (len 0)
> Nov 30 12:42:03 pc kernel: [2500032.115027] Bluetooth: Unexpected continuation frame (len 0)
> 
> Any ideas what the problem might be here?

So an interesting development in this is that after a reboot, I am now
starting to see notification bubbles pop up when the mouse goes AWOL
that say:

Authorization request from 'Microsoft Sculpt Touch Mouse' with a "Check
authorization" button it.  When I click that I get a dialog popping up
that says:

Grant access to '<uuid>'

Device 'Microsoft Sculpt Touch Mouse' (<MAC address>) wants access to
the service '<uuid>'.

With both a Reject and a Grant button as well as an "Always grant
access" checkbox.

Clicking Grant restores the functionality of the mouse and clearly I
could click the Always grant access checkbox to have this automatic.

I just wonder what this functionality is.  I never had it with my
previous Logitech bluetooth mouse.

Cheers,
b.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* tools: Parsing commands is lenient?
From: Karol Babioch @ 2013-12-03 21:27 UTC (permalink / raw)
  To: linux-bluetooth

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

Hi,

I've stumbled across something, which is probably a feature, but I
couldn't find it documented anywhere, so I'm going to bring it up anyway.

The parsing of the "command" field for (at least) the tools "hcitool"
and "sdptool" is quite inaccurate. For example when I want to scan for
Bluetooth devices, I would use something like:

[johnpatcher@vpcs ~]$ hcitool scan
Scanning ...

This works great, but so does the following, too:

[johnpatcher@vpcs ~]$ hcitool scan123
Scanning ...

So, it seems that basically you can append whatever you want to a
command, as long as the command itself is valid.

First of all, I'm not sure whether it is actually a good idea to be
lenient when it comes down to parsing a command. I guess most of you are
around *nix systems even longer than me, but at least I'm used to some
sort of an error message as soon as I goof up a command on the console.
At least, theoretically speaking, one could come up with some scenarios,
where this could go terribly wrong when some commands are added and/or
changed.

Secondly, I think that this sort of behavior should actually be
documented when this is and/or was an explicit consideration, for
instance within the man page(s) of the appropriate tools.

Maybe I'm making too much of a fuss about this, but at least I was
*really* surprised by this. I just want to make sure that this isn't
something that was overlooked and/or introduced by a stupid
carelessness, but rather was a conscious decision.

Best regards,
Karol Babioch


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

^ permalink raw reply

* Re: [PATCH 1/6] android/a2dp: Fix possible NULL dereference
From: Luiz Augusto von Dentz @ 2013-12-03 19:53 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Tue, Dec 3, 2013 at 5:53 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Since a2dp_record may return NULL, check return value. This
> silences static analysers tools.
> ---
>  android/a2dp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index cee4bfa..36a0714 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -366,9 +366,10 @@ bool bt_a2dp_register(const bdaddr_t *addr)
>         }
>
>         rec = a2dp_record();
> -       if (bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
> +       if (!rec || bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {

Usually we check the return individually, that means you do if (rec)
and perhaps handle the error path with goto, but first make sure that
a2dp_record can actually fail otherwise this is pointless.

>                 error("Failed to register on A2DP record");
> -               sdp_record_free(rec);
> +               if (rec)
> +                       sdp_record_free(rec);
>                 g_io_channel_shutdown(server, TRUE, NULL);
>                 g_io_channel_unref(server);
>                 server = NULL;
> --
> 1.8.3.2
>
> --
> 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



-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: Missing BT_POWER option for l2cap sockets in bluetooth.h?
From: Mathieu Laurendeau @ 2013-12-03 17:46 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20131203092228.GA9498@x220.p-661hnu-f1>

On Tue, Dec 03, 2013, Johan Hedberg wrote:
> What are you planning to use this for?
I'm working on a software [1] that can make a PC take the identity of a 
Sixaxis and control a PS3 over bluetooth. It worked fine until kernel 
3.1 from which there was a connection issue (a variable latency of at 
least 4s). I tried tweaking the flush timeout, but it was not 
concluding. Lately I took a look at the kernel source code and saw the 
BT_POWER option was introduced in kernel 3.1. I turned it off and the 
latency disappeared.

Thanks for the patch,

Mathieu

[1] https://github.com/matlo/GIMX

^ permalink raw reply

* [PATCH] obex: Fix checking incorrect error code
From: Andrei Emeltchenko @ 2013-12-03 16:04 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

chdir return -1 if error and 0 in success. Checking for > 0 is pointless.
---
 tools/obex-server-tool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
index e37c56f..86c2271 100644
--- a/tools/obex-server-tool.c
+++ b/tools/obex-server-tool.c
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (option_root && chdir(option_root) > 0) {
+	if (option_root && chdir(option_root) < 0) {
 		perror("chdir:");
 		exit(EXIT_FAILURE);
 	}
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 6/6] avdtp: Remove unneeded local variable
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 profiles/audio/avdtp.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index f866b39..e12ad9d 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -773,10 +773,9 @@ static int get_send_buffer_size(int sk)
 	socklen_t optlen = sizeof(size);
 
 	if (getsockopt(sk, SOL_SOCKET, SO_SNDBUF, &size, &optlen) < 0) {
-		int err = -errno;
-		error("getsockopt(SO_SNDBUF) failed: %s (%d)", strerror(-err),
-									-err);
-		return err;
+		error("getsockopt(SO_SNDBUF) failed: %s (%d)", strerror(errno),
+									errno);
+		return -errno;
 	}
 
 	/*
@@ -792,10 +791,9 @@ static int set_send_buffer_size(int sk, int size)
 	socklen_t optlen = sizeof(size);
 
 	if (setsockopt(sk, SOL_SOCKET, SO_SNDBUF, &size, optlen) < 0) {
-		int err = -errno;
-		error("setsockopt(SO_SNDBUF) failed: %s (%d)", strerror(-err),
-									-err);
-		return err;
+		error("setsockopt(SO_SNDBUF) failed: %s (%d)", strerror(errno),
+									errno);
+		return -errno;
 	}
 
 	return 0;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 5/6] sdp: Remove dead code
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

sdp_next_handle always returns value >= 0x10000.
---
 src/sdpd-service.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 38bf808..448c76b 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -424,10 +424,6 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
 
 	if (rec->handle == 0xffffffff) {
 		rec->handle = sdp_next_handle();
-		if (rec->handle < 0x10000) {
-			sdp_record_free(rec);
-			goto invalid;
-		}
 	} else {
 		if (sdp_record_find(rec->handle)) {
 			/* extract_pdu_server will add the record handle
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 4/6] android/doc: Add socket-api.txt document
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Document describes how socket HAL is working.
---
 android/socket-api.txt | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 android/socket-api.txt

diff --git a/android/socket-api.txt b/android/socket-api.txt
new file mode 100644
index 0000000..9f622f9
--- /dev/null
+++ b/android/socket-api.txt
@@ -0,0 +1,61 @@
+Android Socket protocol for Bluetooth
+=====================================
+
+Since Android switched from BlueZ (where sockets where nicely implemented) to
+Bluedroid user space stack there is a need to emulate bluetooth sockets.
+
+Android Bluetooth Socket Hardware Abstraction Layer (HAL) bt_sock.h has
+only 2 functions:
+
+static btsock_interface_t sock_if = {
+	sizeof(sock_if),
+	sock_listen,
+	sock_connect
+};
+
+with following parameters:
+
+sock_listen(btsock_type_t type, const char *service_name,
+		const uint8_t *uuid, int chan, int *sock_fd, int flags)
+sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
+		const uint8_t *uuid, int chan, int *sock_fd, int flags)
+
+socket type RFCOMM is only supported at the moment. uuid and channel used
+to decide where to connect.
+
+sockfd is used to return socket fd to Android framework. It is used to inform
+framework when remote device is connected.
+
+listen()
+========
+
+Listens on RFCOMM socket, socket channel is either found based on uuid or
+channel parameter used directly. Returns sock_fd to Android framework.
+
+Through this sock_fd channel number as (int) needs to be written right after
+listen() succeeds.
+
+When remote device is connected to this socket we shall send accept signal
+through sock_fd
+
+connect()
+=========
+
+Connects to remote device specified in bd_addr parameter. Socket channel is
+found by SDP search of remote device by supplied uuid. Returns sock_fd to
+Android framework.
+
+Through this sock_fd channel number as (int) needs to be written right after
+connects() succeeds.
+
+When remote device is connected to this socket we shall send connect signal
+through sock_fd
+
+The format of connect/accept signal is shown below:
+
+struct hal_sock_connect_signal {
+	short   size;
+	uint8_t bdaddr[6];
+	int     channel;
+	int     status;
+} __attribute__((packed));
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 3/6] android/pan: Fix no return on error path
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

This fixes possible crash in case connect fails.
---
 android/pan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/android/pan.c b/android/pan.c
index 87fa4e8..7e9b3c3 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -172,6 +172,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 		error("%s", err->message);
 		bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
 		pan_device_free(dev);
+		return;
 	}
 
 	src = (local_role == HAL_PAN_ROLE_NAP) ? BNEP_SVC_NAP : BNEP_SVC_PANU;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 2/6] android/pan: Remove unneeded NULL assignment
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085993-22055-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/pan.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/android/pan.c b/android/pan.c
index fe6ee26..87fa4e8 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -81,7 +81,6 @@ static void pan_device_free(struct pan_device *dev)
 
 	devices = g_slist_remove(devices, dev);
 	g_free(dev);
-	dev = NULL;
 }
 
 static void bt_pan_notify_conn_state(struct pan_device *dev, uint8_t state)
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/6] android/a2dp: Fix possible NULL dereference
From: Andrei Emeltchenko @ 2013-12-03 15:53 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Since a2dp_record may return NULL, check return value. This
silences static analysers tools.
---
 android/a2dp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index cee4bfa..36a0714 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -366,9 +366,10 @@ bool bt_a2dp_register(const bdaddr_t *addr)
 	}
 
 	rec = a2dp_record();
-	if (bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
+	if (!rec || bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
 		error("Failed to register on A2DP record");
-		sdp_record_free(rec);
+		if (rec)
+			sdp_record_free(rec);
 		g_io_channel_shutdown(server, TRUE, NULL);
 		g_io_channel_unref(server);
 		server = NULL;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 4/4] android/socket: Setup socket buffer sizes
From: Andrei Emeltchenko @ 2013-12-03 15:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085873-21715-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Set socket buffer sizes for socketpair's end and real RFCOMM socket
equal to SOCKET_BUFFER.
---
 android/socket.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/android/socket.c b/android/socket.c
index 6293b59..3898767 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -82,6 +82,9 @@ static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
 {
 	int fds[2] = {-1, -1};
 	struct rfcomm_sock *rfsock;
+	socklen_t len = sizeof(int);
+	int size = SOCKET_BUFFER;
+	int i;
 
 	if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0) {
 		error("socketpair(): %s", strerror(errno));
@@ -94,6 +97,15 @@ static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
 	*hal_fd = fds[1];
 	rfsock->real_sock = sock;
 
+	for (i = 0; i < 2; i++) {
+		if (setsockopt(fds[i], SOL_SOCKET, SO_SNDBUF, &size, len) < 0)
+			warn("setsockopt() SO_SNDBUF fd: %d %s", fds[i],
+							strerror(errno));
+		if (setsockopt(fds[i], SOL_SOCKET, SO_RCVBUF, &size, len) < 0)
+			warn("setsockopt() SO_RCVBUF fd: %d %s", fds[i],
+							strerror(errno));
+	}
+
 	rfsock->buf = g_malloc(SOCKET_BUFFER);
 
 	return rfsock;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2 3/4] android/socket: Use heap instead of stack
From: Andrei Emeltchenko @ 2013-12-03 15:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386085873-21715-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Keep buffer used in socket copy in heap instead of stack.
---
 android/socket.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/android/socket.c b/android/socket.c
index 9ff9019..6293b59 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -73,6 +73,8 @@ struct rfcomm_sock {
 	bdaddr_t dst;
 	uint32_t service_handle;
 
+	unsigned char *buf;
+
 	const struct profile_info *profile;
 };
 
@@ -92,6 +94,8 @@ static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
 	*hal_fd = fds[1];
 	rfsock->real_sock = sock;
 
+	rfsock->buf = g_malloc(SOCKET_BUFFER);
+
 	return rfsock;
 }
 
@@ -123,6 +127,8 @@ static void cleanup_rfsock(gpointer data)
 	if (rfsock->service_handle)
 		bt_adapter_remove_record(rfsock->service_handle);
 
+	g_free(rfsock->buf);
+
 	g_free(rfsock);
 }
 
@@ -489,7 +495,6 @@ static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
 								gpointer data)
 {
 	struct rfcomm_sock *rfsock = data;
-	unsigned char buf[SOCKET_BUFFER];
 	int len, sent;
 
 	if (cond & G_IO_HUP) {
@@ -503,14 +508,14 @@ static gboolean sock_stack_event_cb(GIOChannel *io, GIOCondition cond,
 		goto fail;
 	}
 
-	len = read(rfsock->fd, buf, sizeof(buf));
+	len = read(rfsock->fd, rfsock->buf, SOCKET_BUFFER);
 	if (len <= 0) {
 		error("read(): %s", strerror(errno));
 		/* Read again */
 		return TRUE;
 	}
 
-	sent = try_write_all(rfsock->real_sock, buf, len);
+	sent = try_write_all(rfsock->real_sock, rfsock->buf, len);
 	if (sent < 0) {
 		error("write(): %s", strerror(errno));
 		goto fail;
@@ -528,7 +533,6 @@ static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
 								gpointer data)
 {
 	struct rfcomm_sock *rfsock = data;
-	unsigned char buf[SOCKET_BUFFER];
 	int len, sent;
 
 	if (cond & G_IO_HUP) {
@@ -542,14 +546,14 @@ static gboolean sock_rfcomm_event_cb(GIOChannel *io, GIOCondition cond,
 		goto fail;
 	}
 
-	len = read(rfsock->real_sock, buf, sizeof(buf));
+	len = read(rfsock->real_sock, rfsock->buf, SOCKET_BUFFER);
 	if (len <= 0) {
 		error("read(): %s", strerror(errno));
 		/* Read again */
 		return TRUE;
 	}
 
-	sent = try_write_all(rfsock->fd, buf, len);
+	sent = try_write_all(rfsock->fd, rfsock->buf, len);
 	if (sent < 0) {
 		error("write(): %s", strerror(errno));
 		goto fail;
-- 
1.8.3.2


^ permalink raw reply related


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