Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [BUG] usb problems in .38-rc3+
From: Ed Tomlinson @ 2011-02-06  4:27 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <Pine.LNX.4.44L0.1102051515330.4210-100000@netrider.rowland.org>

On Saturday 05 February 2011 15:16:19 Alan Stern wrote:
> On Sat, 5 Feb 2011, Ed Tomlinson wrote:
> 
> > Hi,
> > 
> > My bluetooth usb dongle has stopped working in .38-rc3+
> > 
> > Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
> > 
> > and in dmesg
> > 
> > [108495.369056] usb 5-1: new full speed USB device using ohci_hcd and address 3
> > [108495.573077] usb 5-1: New USB device found, idVendor=0a12, idProduct=0001
> > [108495.580099] usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > [108652.971977] usb 5-1: USB disconnect, address 3
> > [108652.972718] btusb_bulk_complete: hci0 urb ffff8800684e99c0 failed to resubmit (19)
> > [108652.973725] btusb_bulk_complete: hci0 urb ffff8800684e9c00 failed to resubmit (19)
> > [108652.974707] btusb_intr_complete: hci0 urb ffff8800684e9840 failed to resubmit (19)
> > [108653.001690] btusb_send_frame: hci0 urb ffff8800bb42a240 submission failed
> > [108657.007541] usb 2-4.7: new full speed USB device using ehci_hcd and address 8
> > [108657.147736] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
> > [108657.154954] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > 
> > Its been working for years here.
> > 
> > Any ideas on what to try or additional info to gather?
> 
> Does it still work with earlier kernels or on other computers?

Alan,

yes its working fine with .37 so the hw is ok.  It looks to be a change in .38 that triggered the failure.

Ed

.37 dmesg follows:

[   10.515289] usb 2-4.7: new full speed USB device using ehci_hcd and address 5
[   10.648949] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
[   10.648952] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   10.832380] Bluetooth: Core ver 2.15
[   10.832418] NET: Registered protocol family 31
[   10.832421] Bluetooth: HCI device and connection manager initialized
[   10.832425] Bluetooth: HCI socket layer initialized
[   10.871896] Bluetooth: Generic Bluetooth USB driver ver 0.6
[   10.872246] usbcore: registered new interface driver btusb
[   11.816907] input: ov519 as /devices/pci0000:00/0000:00:12.1/usb4/4-1/input/input6
[   11.817153] gspca: video0 created
[   11.817382] usbcore: registered new interface driver usbserial_generic
[   11.817385] usbserial: USB Serial Driver core
[   11.818128] usbcore: registered new interface driver ov519
[   11.820102] USB Serial support registered for pl2303
[   11.820200] pl2303 5-3:1.0: PL-2303 hack: descriptors matched but endpoints did not
[   11.820234] pl2303 5-3:1.1: pl2303 converter detected
[   11.841717] usb 5-3: pl2303 converter now attached to ttyUSB0
[   11.841742] usbcore: registered new interface driver pl2303
[   11.841745] pl2303: Prolific PL2303 USB to serial adaptor driver
[   28.477896] sr0: scsi3-mmc drive: 40x/40x writer cd/rw xa/form2 cdda tray
[   28.477900] cdrom: Uniform CD-ROM driver Revision: 3.20
[   28.478226] sr 6:0:0:0: Attached scsi CD-ROM sr0
[   30.195117] powernow-k8: Found 1 AMD Phenom(tm) II X4 940 Processor (4 cpu cores) (version 2.20.00)
[   30.195167] powernow-k8:    0 : pstate 0 (3000 MHz)
[   30.195169] powernow-k8:    1 : pstate 1 (2300 MHz)
[   30.195172] powernow-k8:    2 : pstate 2 (1800 MHz)
[   30.195174] powernow-k8:    3 : pstate 3 (800 MHz)
[   30.899098] EXT4-fs (sdb3): re-mounted. Opts: (null)
[   31.194619] EXT4-fs (sdc3): mounted filesystem with ordered data mode. Opts: (null)
[   33.673078] Bluetooth: L2CAP ver 2.15
[   33.673090] Bluetooth: L2CAP socket layer initialized
[   33.727139] Bluetooth: RFCOMM TTY layer initialized
[   33.727168] Bluetooth: RFCOMM socket layer initialized
[   33.727177] Bluetooth: RFCOMM ver 1.11
[   33.814213] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   33.814223] Bluetooth: BNEP filters: protocol multicast
[   33.861898] Bluetooth: SCO (Voice Link) ver 0.6
[   33.861907] Bluetooth: SCO socket layer initialized
[   35.600125] sky2 0000:02:00.0: eth0: enabling interface
[   36.103536] Adding 5986300k swap on /dev/sdc2.  Priority:-1 extents:1 across:5986300k 
[   36.116190] Adding 1020120k swap on /dev/sda2.  Priority:-2 extents:1 across:1020120k 
[   37.355836] NET: Registered protocol family 10
[   37.357093] lo: Disabled Privacy Extensions
[   37.357355] ADDRCONF(NETDEV_UP): eth0: link is not ready
[   38.198205] sky2 0000:02:00.0: eth0: Link is up at 1000 Mbps, full duplex, flow control both
[   38.203688] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   47.727778] IPv6 over IPv4 tunneling driver
[   47.728551] sit0: Disabled Privacy Extensions
[   47.761803] tun: Universal TUN/TAP device driver, 1.6
[   47.761813] tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
[   48.434301] eth0: no IPv6 routers present
[   48.960936] sixxs: Disabled Privacy Extensions
[   79.568088] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[   79.593964] input: Apple Wireless Mouse as /devices/pci0000:00/0000:00:13.2/usb2/2-4/2-4.7/2-4.7:1.0/bluetooth/hci0/hci0:41/input7
[   79.595105] magicmouse 0005:05AC:030D.0004: input,hidraw3: BLUETOOTH HID v0.84 Mouse [Apple Wireless Mouse] on 00:0A:3A:55:07:5A





^ permalink raw reply

* Re: [BUG] usb problems in .38-rc3+
From: Przemo Firszt @ 2011-02-05 22:50 UTC (permalink / raw)
  To: Alan Stern; +Cc: Ed Tomlinson, linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <Pine.LNX.4.44L0.1102051515330.4210-100000@netrider.rowland.org>

Dnia 2011-02-05, sob o godzinie 15:16 -0500, Alan Stern pisze:
> On Sat, 5 Feb 2011, Ed Tomlinson wrote:
> 
> > Hi,
> > 
> > My bluetooth usb dongle has stopped working in .38-rc3+
> > 
> > Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
> > 
> > and in dmesg
> > 
> > [108495.369056] usb 5-1: new full speed USB device using ohci_hcd and address 3
> > [108495.573077] usb 5-1: New USB device found, idVendor=0a12, idProduct=0001
> > [108495.580099] usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > [108652.971977] usb 5-1: USB disconnect, address 3
> > [108652.972718] btusb_bulk_complete: hci0 urb ffff8800684e99c0 failed to resubmit (19)
> > [108652.973725] btusb_bulk_complete: hci0 urb ffff8800684e9c00 failed to resubmit (19)
> > [108652.974707] btusb_intr_complete: hci0 urb ffff8800684e9840 failed to resubmit (19)
> > [108653.001690] btusb_send_frame: hci0 urb ffff8800bb42a240 submission failed
> > [108657.007541] usb 2-4.7: new full speed USB device using ehci_hcd and address 8
> > [108657.147736] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
> > [108657.154954] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > 
> > Its been working for years here.
> > 
> > Any ideas on what to try or additional info to gather?
> 
> Does it still work with earlier kernels or on other computers?
[przemo@pldmachine ~]$ lsusb
[..]
Bus 003 Device 002: ID 03f0:011d Hewlett-Packard Integrated Bluetooth
Module
[przemo@pldmachine ~]$ uname -a
Linux pldmachine 2.6.38-rc3-00201-g44f2c5c #7 Sat Feb 5 21:42:38 GMT
2011 i686 Intel(R)_Pentium(R)_M_processor_1.86GHz PLD Linux

Works fine for me - tested with a wacom tablet. I have built-in
bluetooth and the dongle. There is something in dmesg:

usb 3-2: new full speed USB device using uhci_hcd and address 2
usb 3-2: New USB device found, idVendor=03f0, idProduct=011d
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 3-2: Product: HP integrated Bluetooth module
usb 3-2: Manufacturer: Broadcom
intel8x0_measure_ac97_clock: measured 52706 usecs (2540 samples)
intel8x0: clocking to 48000
Adding 3068376k swap on /dev/sda1.  Priority:-1 extents:1
across:3068376k 
EXT4-fs (sda2): warning: maximal mount count reached, running e2fsck is
recommended
EXT4-fs (sda2): re-mounted. Opts: (null)
input: PS/2 Generic Mouse
as /devices/platform/i8042/serio4/serio5/input/input5
auditd (1883): /proc/1883/oom_adj is deprecated, please
use /proc/1883/oom_score_adj instead.
Bluetooth: L2CAP ver 2.15
Bluetooth: L2CAP socket layer initialized
Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Bluetooth: BNEP filters: protocol multicast
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM ver 1.11
------------[ cut here ]------------
WARNING: at kernel/printk.c:430 do_syslog+0x347/0x36d()
Hardware name: HP Compaq nc4200 (PV983AW#ABU)  
Attempt to access syslog with CAP_SYS_ADMIN but no CAP_SYSLOG
(deprecated and denied).
Modules linked in: rfcomm bnep l2cap btusb bluetooth pcmcia ipw2200
snd_intel8x0 snd_ac97_codec libipw cfg80211 ac97_bus snd_pcm rfkill
yenta_socket tpm_infineon sdhci_pci sdhci snd_timer pcmcia_rsrc uhci_hcd
ehci_hcd mmc_core snd lib80211 tg3 pcmcia_core sg psmouse tpm container
ac usbcore fan battery processor thermal evdev soundcore snd_page_alloc
tpm_bios ata_piix libata sd_mod crc_t10dif scsi_mod ext4 mbcache jbd2
crc16 jbd [last unloaded: scsi_wait_scan]
Pid: 1993, comm: syslog-ng Not tainted 2.6.38-rc3-00201-g44f2c5c #7
Call Trace:
 [<c10195f2>] ? warn_slowpath_common+0x6a/0x7d
 [<c1019ce2>] ? do_syslog+0x347/0x36d
 [<c101966b>] ? warn_slowpath_fmt+0x28/0x2c
 [<c1019ce2>] ? do_syslog+0x347/0x36d
 [<c10c82c1>] ? smack_inode_permission+0x3b/0x42
 [<c10b4798>] ? kmsg_release+0x0/0x11
 [<c10b47b9>] ? kmsg_open+0x10/0x12
 [<c10ae32f>] ? proc_reg_open+0x63/0xc4
 [<c10c6674>] ? security_dentry_open+0x47/0x4d
 [<c10ae2cc>] ? proc_reg_open+0x0/0xc4
 [<c107c316>] ? __dentry_open+0xfb/0x1eb
 [<c107cfc8>] ? nameidata_to_filp+0x32/0x3d
 [<c10862f9>] ? finish_open+0x7f/0x11f
 [<c10867c3>] ? do_filp_open+0x16e/0x563
 [<c124a464>] ? do_page_fault+0x378/0x392
 [<c124a451>] ? do_page_fault+0x365/0x392
 [<c108db95>] ? alloc_fd+0x41/0xa5
[<c107d014>] ? do_sys_open+0x41/0xbe
 [<c107d0af>] ? sys_open+0x1e/0x23
 [<c100264c>] ? sysenter_do_call+0x12/0x22
---[ end trace 889c8d9ad011dab5 ]---
Bluetooth: SCO (Voice Link) ver 0.6
Bluetooth: SCO socket layer initialized
ADDRCONF(NETDEV_UP): lan: link is not ready
wireless: no IPv6 routers present
ata1.00: configured for UDMA/100
ata1: EH complete
blueman-applet[2631]: segfault at b7896048 ip b778e077 sp bfe08324 error
7 in libpython2.7.so.1.0[b7725000+138000]
lib80211_crypt: registered algorithm 'CCMP'
Intel AES-NI instructions are not detected.
lib80211_crypt: registered algorithm 'TKIP'
EXT4-fs (sda2): re-mounted. Opts: commit=0
hci_cmd_task: hci0 command tx timeout
Bluetooth: HIDP (Human Interface Emulation) ver 1.2
input: WACOM Pen Tablet
as /devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/bluetooth/hci0/hci0:1/input6
wacom 0005:056A:0081.0001: input,hidraw0: BLUETOOTH HID v1.00 Mouse
[WACOM Pen Tablet] on 00:1F:81:00:08:30
hci_cmd_task: hci0 command tx timeout
hci_cmd_task: hci0 command tx timeout
hci_cmd_task: hci0 command tx timeout


-- 
Przemo Firszt


^ permalink raw reply

* Re: [BUG] usb problems in .38-rc3+
From: Alan Stern @ 2011-02-05 20:16 UTC (permalink / raw)
  To: Ed Tomlinson; +Cc: linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <201102051417.58953.edt@aei.ca>

On Sat, 5 Feb 2011, Ed Tomlinson wrote:

> Hi,
> 
> My bluetooth usb dongle has stopped working in .38-rc3+
> 
> Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
> 
> and in dmesg
> 
> [108495.369056] usb 5-1: new full speed USB device using ohci_hcd and address 3
> [108495.573077] usb 5-1: New USB device found, idVendor=0a12, idProduct=0001
> [108495.580099] usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> [108652.971977] usb 5-1: USB disconnect, address 3
> [108652.972718] btusb_bulk_complete: hci0 urb ffff8800684e99c0 failed to resubmit (19)
> [108652.973725] btusb_bulk_complete: hci0 urb ffff8800684e9c00 failed to resubmit (19)
> [108652.974707] btusb_intr_complete: hci0 urb ffff8800684e9840 failed to resubmit (19)
> [108653.001690] btusb_send_frame: hci0 urb ffff8800bb42a240 submission failed
> [108657.007541] usb 2-4.7: new full speed USB device using ehci_hcd and address 8
> [108657.147736] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
> [108657.154954] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> 
> Its been working for years here.
> 
> Any ideas on what to try or additional info to gather?

Does it still work with earlier kernels or on other computers?

Alan Stern


^ permalink raw reply

* [BUG] usb problems in .38-rc3+
From: Ed Tomlinson @ 2011-02-05 19:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-bluetooth, linux-usb

Hi,

My bluetooth usb dongle has stopped working in .38-rc3+

Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

and in dmesg

[108495.369056] usb 5-1: new full speed USB device using ohci_hcd and address 3
[108495.573077] usb 5-1: New USB device found, idVendor=0a12, idProduct=0001
[108495.580099] usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[108652.971977] usb 5-1: USB disconnect, address 3
[108652.972718] btusb_bulk_complete: hci0 urb ffff8800684e99c0 failed to resubmit (19)
[108652.973725] btusb_bulk_complete: hci0 urb ffff8800684e9c00 failed to resubmit (19)
[108652.974707] btusb_intr_complete: hci0 urb ffff8800684e9840 failed to resubmit (19)
[108653.001690] btusb_send_frame: hci0 urb ffff8800bb42a240 submission failed
[108657.007541] usb 2-4.7: new full speed USB device using ehci_hcd and address 8
[108657.147736] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
[108657.154954] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0

Its been working for years here.

Any ideas on what to try or additional info to gather?

TIA
Ed Tomlinson


^ permalink raw reply

* Inconsistent fake-hid-input callback behaviour
From: David Herrmann @ 2011-02-05 15:47 UTC (permalink / raw)
  To: linux-bluetooth

The fake-hid-input API (bluez/input/ plugin) calls the ->connect
callback quite randomly.

The ->connect callback (inside struct fake_hid, NOT struct fake_input)
is called inside input_device_connect() and fake_hid_connadd().
However, input_device_connect() calls it only if the "fake" member is
set, which actually is NEVER set at this point, because the "fake"
member is set on "hsp" connections only and never on "hid"
connections. input_device_connect() works only on "hid" connections
(which is actually written in uppercase "HID" and the device creation
uses lowercase "hid" which should be fixed for consistency (although
it might be case insensitive, I don't know)).
So input_device_connect() never calls this ->connect callback.
fake_hid_connadd() calls the callback only if a second connection is
created on the same device (which never happens because
fake_hid_connadd is only called on PSM 0x11/0x13 HID connections and
there can only be ONE connection on this PSM). So the whole ->connect
callback in struct fake_hid seems useless, same as the code testing
whether fake_hid_connadd() already has an open connection.

All in all it is quite confusing reading input/device.c because the
fake_input structure is used for two purposes, once rfcomm connections
of "hsp" connections and second for HID-fake connections which is
l2cap.

It is not clear to me, why devices registered with fake_input_register
use the same structure (struct fake_input) as fake-HID devices
registered with input_device_register(and then fake_hid_connadd). The
latter one only need the "uinput" member of this structure while all
other members are redundant.

I try to implement a Wii-Remote driver as fake-hid input driver which
actually works and allows the remote to establish connections to my
host and vice-versa, however, trying to understand input/device.c code
is quite impossible and getting this ->connect callback to work is
also not possible. I would be glad to get some help here because my
wiimote-uinput driver needs some initialization before the ->event
callback can be called and doing this inside the uinput_setup callback
seems misplaced as long as there is a ->connect callback.

David

^ permalink raw reply

* Re: Health interfaces
From: Jose Antonio Santos Cadenas @ 2011-02-05 11:39 UTC (permalink / raw)
  To: Zahirul Islam; +Cc: sancane, epx, linux-bluetooth
In-Reply-To: <AANLkTi=qXPsLwAd96i5Okw_sh-PFKPy6chnEJ6zb9nu7@mail.gmail.com>

Hi Zahirul,

First, please do not do top posting in this mailing list.

2011/2/4 Zahirul Islam <zahir1976@gmail.com>:
> Hi Jose,
> Thank you for your mail. I really appreciate it.
> Let me explain little more. I am trying to read data from Health device
> (blood pressure monitor) and for this trying to create a sink in D-bus using
> python.
> I downloaded python script from there and ran deb packages.

What python script do you mean? and what deb packages?

> Now python script can create channel in MCAP as follows:
>
> Discovering device 00:15:83:43:36:EC CSR - bc4
>
> Discovering device 00:09:1F:80:07:E4 AND BP5091101130
>
> Handle 00010001:
>
> [{'mcap_procedures': ('reconnect_init', 'reconnect_accept'), 'handle':
> 65537, 'features': [{'mdep_id': 17, 'role': 'source', 'description': u'Blood
> Pressure Monitor ', 'data_type': 4103}], 'description': '', 'mcap_data_psm':
> 4099, 'mcap_control_psm': 4097, 'data_spec': 1, 'provider': '', 'name': ''}]
>
> Discovering device 00:09:1F:80:0F:0B AND SC5091150921
>
> Handle 00010001:
>
> [{'mcap_procedures': ('reconnect_init', 'reconnect_accept'), 'handle':
> 65537, 'features': [{'mdep_id': 17, 'role': 'source', 'description':
> u'Weighing Scale ', 'data_type': 4111}], 'description': '', 'mcap_data_psm':
> 4099, 'mcap_control_psm': 4097, 'data_spec': 1, 'provider': '', 'name': ''}]


I've got no idea about what this dictionaries are. I recognize some of
the data there, but I've never seen this dictionaries. Where did you
get them? Can you give more details.


>
> but I guess I need HealthManager interface (CreateApplication method) to
> establish connection. I dont see that interface in my qt dbus viewer.
> I am doing right things? I will appreciate any advice.

I thing that you are mixing things. As I told you in my previous email
you don't need to use anything from hdpy (wich is a different
implementation for HDP that was performed just for testing purposes).
You just have to use D-Bus interfaces.

Regards.

>
> Thanks again.
>
> On Fri, Feb 4, 2011 at 10:49 AM, Jose Antonio Santos Cadenas
> <santoscadenas@gmail.com> wrote:
>>
>> Hi Zahirul,
>>
>> 2011/2/4 Zahirul Islam <zahir1976@gmail.com>
>> >
>> > I am using ubuntu kernel 2.6.36 (enhanced transmission enabled) and
>> > qdbusviewer to browse bluez services ..
>> >
>> > Thanks in advance.
>> >
>> > Regards
>> > Zahir
>> >
>> > On Fri, Feb 4, 2011 at 10:31 AM, Zahirul Islam <zahir1976@gmail.com>
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >>
>> >> I have installed bluez 4.85 on my Ubuntu and was expecting following Health Interfaces
>> >> (according to http://gitorious.org/hdpy) in service org.bluez:
>> >>
>> >> Org.bluez.HealthManager
>> >> Org.bluez.HealthApplication
>> >> Org.bluez.HealthService
>> >> Org.bluez.HealthAgent
>> >>
>> >>
>> >> I can see only org.bluez.Manager interface available. How could I get those interfaces.
>> >>
>> >> I will appreciate any advice.
>> >>
>> >>
>> >> Regards
>> >>
>> >> Zahir
>>
>> Adding the bluez mail list in CC because this kind of questions should
>> be reported there.
>>
>> I think that your are mixing thing a little bit. If you are using
>> BlueZ you don't need hdpy. BlueZ implements MCAP and HDP since version
>> 4.76. The interface is exposed in D-Bus and this should be the unique
>> way to access HDP.
>>
>> You can find the API documentation of the HDP profile in the "docs"
>> folder of the BlueZ project.
>>
>> Regards.
>>
>> Jose.
>
>

^ permalink raw reply

* Emulating Bluetooth - Design Check
From: Michael Lochov @ 2011-02-04 23:43 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

Im working on a piece of userspace bluetooth emulation softare that will use the Bluez stack. My plan is to create two virtual bluetooth device with hciemu (hci0 and hci1), they will use the vhci module and my software will pretend to be hci1 and create/inject packets into hci0. hci0 will be managed by typical userspace bluetooth software/tools so it will look like this:

My Software (hci1/hciemu/vhci) -----[hci protocol]-----> hci0/hciemu/vhci ------> VHCI -----> Bluez  ----> Some frontend userspace software utilizing hci0

So my software will do nothing more than emulate a bluetooth device by sending and recieving packets on hci1.

I want to do things like simulate simple conversations over the bluetooth stack, such as basic device discovery, l2capp talking and maybe even file transfers.

Does this sound possible given the architecture layout I have defined above? Could my userspace emulator software simulate a file transfer over hci0/hci1 to the other software assuming it generated and understood all the protocols invovled (transfering them over HCI at the lowest level into the virtual device from hciemu).

Just want to check if my approach is sane, or if I am missing some additional components in the picture?

Any help greatly appreciated!

Michael

^ permalink raw reply

* ID_SERIAL for udev bluetooth joystick events
From: Antonio Ospite @ 2011-02-04 22:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: linux-input, Alan Ott

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

Hi,

I have a question about udev events generated by a bluetooth joystick:
when the bt joystick generates the joystick event, the ID_SERIAL
property matches the one of the bt adapter not the one of the joystick.

For example (using "udevadm monitor --property"), when connecting the
Sony Sixaxis via usb I get:
ID_SERIAL=Sony_PLAYSTATION_R_3_Controller
in the input and joystick events, but when I connect it via bt, I get:
ID_SERIAL=Broadcom_Corp_ANYCOM_Blue_USB-200_250
which matches my bluetooth adapter.

Is this expected/known, or is it a bug?
I am using kernel 2.6.37, udev 164

For the records, I also get ID_BUS=usb when connecting via bt, but I can
live with that since I can differenciate usb and bt operation using
ID_USB_DRIVER=usbhid
versus
ID_USB_DRIVER=btusb

Some insight of what I am trying to achieve with udev:
  1. Monitor new joystick devices.
  2. If ID_SERIAL != Sony_PLAYSTATION_R_3_Controller, then STOP.
  3. Get the associated hidraw device node navigating the event tree.
  4. Set leds using the value from the ID_INPUT_JOYSTICK property.
  5. If ID_USB_DRIVER=usbhid do the needed pairing.

And with the current behaviour for ID_SERIAL I cannot enforce 2.
I could listen for the (hid) event and use HID_NAME which seems to be a
little more consistent:
usb -> HID_NAME=Sony PLAYSTATION(R)3 Controller
bt  -> HID_NAME=PLAYSTATION(R)3 Controller
and navigate the event hierarchy to get ID_INPUT_JOYSTICK, but that is
slightly more complicated, and I am curious about the ID_SERIAL
behavior anyways :)

Thanks,
  Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

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

^ permalink raw reply

* [PATCH] Fix control channel shutdown in case of errors.
From: jaikumar @ 2011-02-04 21:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaikumar Ganesh

From: Jaikumar Ganesh <jaikumar@google.com>

When there are connection errors, like host is down, when
establishing the control channel connection, the control io
channel was not being shutdown. This will cause future
connections to fail.
---
 input/device.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/input/device.c b/input/device.c
index 5cb57ea..21f8329 100644
--- a/input/device.c
+++ b/input/device.c
@@ -856,6 +856,7 @@ static void control_connect_cb(GIOChannel *chan, GError *conn_err,
 		error("%s", conn_err->message);
 		reply = btd_error_failed(iconn->pending_connect,
 						conn_err->message);
+		g_io_channel_shutdown(chan, TRUE, NULL);
 		goto failed;
 	}
 
-- 
1.7.3.1


^ permalink raw reply related

* Re: Health interfaces
From: Jose Antonio Santos Cadenas @ 2011-02-04 16:49 UTC (permalink / raw)
  To: Zahirul Islam; +Cc: sancane, epx, linux-bluetooth
In-Reply-To: <AANLkTin60Z53M=vYA37tU7=7mQzv_Y+aeZp7ZeODSvaU@mail.gmail.com>

Hi Zahirul,

2011/2/4 Zahirul Islam <zahir1976@gmail.com>
>
> I am using ubuntu kernel 2.6.36 (enhanced transmission enabled) and qdbusviewer to browse bluez services ..
>
> Thanks in advance.
>
> Regards
> Zahir
>
> On Fri, Feb 4, 2011 at 10:31 AM, Zahirul Islam <zahir1976@gmail.com> wrote:
>>
>> Hello,
>>
>> I have installed bluez 4.85 on my Ubuntu and was expecting following Health Interfaces (according to http://gitorious.org/hdpy) in service org.bluez:
>>
>> Org.bluez.HealthManager
>> Org.bluez.HealthApplication
>> Org.bluez.HealthService
>> Org.bluez.HealthAgent
>>
>> I can see only org.bluez.Manager interface available. How could I get those interfaces.
>>
>> I will appreciate any advice.
>>
>>
>> Regards
>>
>> Zahir

Adding the bluez mail list in CC because this kind of questions should
be reported there.

I think that your are mixing thing a little bit. If you are using
BlueZ you don't need hdpy. BlueZ implements MCAP and HDP since version
4.76. The interface is exposed in D-Bus and this should be the unique
way to access HDP.

You can find the API documentation of the HDP profile in the "docs"
folder of the BlueZ project.

Regards.

Jose.

^ permalink raw reply

* [PATCH] Add UUID property to GATT service object
From: Elvis Pfützenreuter @ 2011-02-04 14:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: epx

---
 attrib/client.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 44638d3..e8b814d 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -940,6 +940,7 @@ static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
 	DBusMessageIter dict;
 	GSList *l;
 	char **chars;
+	char *uuid;
 	int i;
 
 	reply = dbus_message_new_method_return(msg);
@@ -962,6 +963,10 @@ static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
 
 	dict_append_array(&dict, "Characteristics", DBUS_TYPE_OBJECT_PATH,
 								&chars, i);
+	uuid = g_strdup(prim->att->uuid);
+	dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
+
+	g_free(uuid);
 	g_free(chars);
 
 	dbus_message_iter_close_container(&iter, &dict);
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH 1/2] Add UUID property to GATT service object
From: Elvis Pfützenreuter @ 2011-02-04 13:58 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296827707-20199-1-git-send-email-epx@signove.com>


On 4 Feb 2011, at 11:55 , Elvis Pfützenreuter wrote:

> ---
> attrib/client.c |    5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)

Please ignore this patch, header is wrong, it is not part of a series. Sending correct one right away...

^ permalink raw reply

* [PATCH 1/2] Add UUID property to GATT service object
From: Elvis Pfützenreuter @ 2011-02-04 13:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: epx

---
 attrib/client.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 44638d3..9b8efa8 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -940,6 +940,7 @@ static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
 	DBusMessageIter dict;
 	GSList *l;
 	char **chars;
+	char *uuid;
 	int i;
 
 	reply = dbus_message_new_method_return(msg);
@@ -962,6 +963,10 @@ static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
 
 	dict_append_array(&dict, "Characteristics", DBUS_TYPE_OBJECT_PATH,
 								&chars, i);
+	uuid = g_strdup(prim->att->uuid);
+	dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
+
+	g_free(uuid);
 	g_free(chars);
 
 	dbus_message_iter_close_container(&iter, &dict);
-- 
1.7.1


^ permalink raw reply related

* Re: Not able to test GATT on ubuntu
From: Luiz Augusto von Dentz @ 2011-02-04 13:45 UTC (permalink / raw)
  To: Vijayalakshmi N; +Cc: Mika Linnanoja, linux-bluetooth
In-Reply-To: <AANLkTinVkr3ivG0-Jt-sCJe0VLpPFTUAgDaTTiM5U51A@mail.gmail.com>

Hi,

On Fri, Feb 4, 2011 at 2:33 PM, Vijayalakshmi N
<vijayalakshmi.nk@gmail.com> wrote:
> Hi Mika,
>
> I did use --le option but I get that the socket cannot bind error:
>
> l2cap_bind: Address already in use (98)
>
> I did take Vinicius Gomes'  kernel patches for LE and compile it.
>
> I will get the hcidump for LE as you have said.
>
> Could you pls. tell me why I'm getting the l2cap error.

Well that normally indicate that there is some other application
listen on the same psm, but I doubt that could happen in this case
since normally you are not able to run multiple instances of
bluetoothd simultaneously, so perhaps this could be caused by LE not
enabled in the kernel or something like that.

> Thanks,
> Vijayalakshmi
>
>
>
> On Fri, Feb 4, 2011 at 5:43 PM, Mika Linnanoja <mika.linnanoja@nokia.com> wrote:
>> On 02/04/2011 01:59 PM, ext Vijayalakshmi N wrote:
>>>
>>> Dear all,
>>>
>>> I have taken the bluetooth code with BLE changes  (net/bluetooth and
>>> include/net/bluetooth) from
>>>
>>>
>>> http://git.infradead.org/users/vcgomes/linux-2.6.git/tree/refs/heads/le-l2cap
>>> to my 2.6.35 kernel and built the kernel.
>>>
>>> and also built bluez 4.84 on ubuntu 10.10.
>>>
>>> Tried testing GATT with the gatttool that is available with the bluez.
>>>
>>> gatttool --primary -b<bd-address>
>>
>> Hi.
>>
>> If you want to use LE add "--le" to gatttool options. Otherwise (and evident
>> from your hcidump) it tries to create classic BT connection.
>>
>> We haven't tried adding LE kernel patches to .35 kernels (stock ubuntu one),
>> why don't you checkout whole vcgomes' kernel and compile it for your ubuntu
>> box instead?
>>
>> Boots fine in Ubuntu 10.10. Used "make oldconfig" with .config from /boot/
>> for stock kernel and answered defaults to most questions and "Y" to the one
>> asking about enabling SMP for BT LE.
>>
>>> Please see the log (hcidump) of the Master BT device below followed by
>>> the hcidump of Slave (GATT Server).
>>
>> Also, upgrade to hcidump 2.0 it has LE stuff in it, logs will be more
>> useful. Ie get git version and compile and run from compile dir, no need to
>> install.
>>
>>> Thanks,
>>> Vijayalakshmi
>>
>> BR,
>> Mika
>>
> --
> 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
Computer Engineer

^ permalink raw reply

* Re: [bluetooth-next 00/16] l2cap.c split
From: Gustavo F. Padovan @ 2011-02-04 13:44 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=P8dnzL9O-SatX_-zddHKndOLxA1vm3V1K+oji@mail.gmail.com>

Hi Luiz,

* Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-02-04 14:38:13 +0200]:

> Hi,
> 
> On Fri, Feb 4, 2011 at 8:01 AM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > Here is the first real split of l2cap.c file. That file was getting so big that
> > we really need to split it in two or more. By now we have two file:
> > l2cap_sock.c and l2cap_core.c. In l2cap_sock.c we have all functions that deals
> > with sockets, in l2cap_core.c the rest.
> >
> > Side efects are that I had to move the declaration of many functions to l2cap.h
> > along the l2cap socket list.
> >
> > There are more steps on this, but this is surely a big one.
> 
> What about creating a l2cap directory like rfcomm? Or that would cause
> too much hassle with building system?

We plan to merge l2cap.ko and sco.ko modules into bluetooth.ko. That is the
reason why I'm doing it the net/bluetooth/ directory. There isn't a good use
case where one won't want to use the l2cap.ko and sco.ko modules and it will
be always possible to disable L2CAP and SCO in the menuconfig.

Regards,

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [bluetooth-next 00/16] l2cap.c split
From: Luiz Augusto von Dentz @ 2011-02-04 12:38 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1296799318-5517-1-git-send-email-padovan@profusion.mobi>

Hi,

On Fri, Feb 4, 2011 at 8:01 AM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Here is the first real split of l2cap.c file. That file was getting so big that
> we really need to split it in two or more. By now we have two file:
> l2cap_sock.c and l2cap_core.c. In l2cap_sock.c we have all functions that deals
> with sockets, in l2cap_core.c the rest.
>
> Side efects are that I had to move the declaration of many functions to l2cap.h
> along the l2cap socket list.
>
> There are more steps on this, but this is surely a big one.

What about creating a l2cap directory like rfcomm? Or that would cause
too much hassle with building system?

-- 
Luiz Augusto von Dentz
Computer Engineer

^ permalink raw reply

* Re: Not able to test GATT on ubuntu
From: Vijayalakshmi N @ 2011-02-04 12:33 UTC (permalink / raw)
  To: Mika Linnanoja; +Cc: linux-bluetooth
In-Reply-To: <4D4BED6C.3040506@nokia.com>

Hi Mika,

I did use --le option but I get that the socket cannot bind error:

l2cap_bind: Address already in use (98)

I did take Vinicius Gomes'  kernel patches for LE and compile it.

I will get the hcidump for LE as you have said.

Could you pls. tell me why I'm getting the l2cap error.

Thanks,
Vijayalakshmi



On Fri, Feb 4, 2011 at 5:43 PM, Mika Linnanoja <mika.linnanoja@nokia.com> wrote:
> On 02/04/2011 01:59 PM, ext Vijayalakshmi N wrote:
>>
>> Dear all,
>>
>> I have taken the bluetooth code with BLE changes  (net/bluetooth and
>> include/net/bluetooth) from
>>
>>
>> http://git.infradead.org/users/vcgomes/linux-2.6.git/tree/refs/heads/le-l2cap
>> to my 2.6.35 kernel and built the kernel.
>>
>> and also built bluez 4.84 on ubuntu 10.10.
>>
>> Tried testing GATT with the gatttool that is available with the bluez.
>>
>> gatttool --primary -b<bd-address>
>
> Hi.
>
> If you want to use LE add "--le" to gatttool options. Otherwise (and evident
> from your hcidump) it tries to create classic BT connection.
>
> We haven't tried adding LE kernel patches to .35 kernels (stock ubuntu one),
> why don't you checkout whole vcgomes' kernel and compile it for your ubuntu
> box instead?
>
> Boots fine in Ubuntu 10.10. Used "make oldconfig" with .config from /boot/
> for stock kernel and answered defaults to most questions and "Y" to the one
> asking about enabling SMP for BT LE.
>
>> Please see the log (hcidump) of the Master BT device below followed by
>> the hcidump of Slave (GATT Server).
>
> Also, upgrade to hcidump 2.0 it has LE stuff in it, logs will be more
> useful. Ie get git version and compile and run from compile dir, no need to
> install.
>
>> Thanks,
>> Vijayalakshmi
>
> BR,
> Mika
>

^ permalink raw reply

* Re: Not able to test GATT on ubuntu
From: Mika Linnanoja @ 2011-02-04 12:13 UTC (permalink / raw)
  To: ext Vijayalakshmi N; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=652bHGqL841fp1ufO1_7C3iTq+tZ4eBcGtEiO@mail.gmail.com>

On 02/04/2011 01:59 PM, ext Vijayalakshmi N wrote:
> Dear all,
>
> I have taken the bluetooth code with BLE changes  (net/bluetooth and
> include/net/bluetooth) from
>
> http://git.infradead.org/users/vcgomes/linux-2.6.git/tree/refs/heads/le-l2cap
> to my 2.6.35 kernel and built the kernel.
>
> and also built bluez 4.84 on ubuntu 10.10.
>
> Tried testing GATT with the gatttool that is available with the bluez.
>
> gatttool --primary -b<bd-address>

Hi.

If you want to use LE add "--le" to gatttool options. Otherwise (and evident 
from your hcidump) it tries to create classic BT connection.

We haven't tried adding LE kernel patches to .35 kernels (stock ubuntu one), 
why don't you checkout whole vcgomes' kernel and compile it for your ubuntu 
box instead?

Boots fine in Ubuntu 10.10. Used "make oldconfig" with .config from /boot/ for 
stock kernel and answered defaults to most questions and "Y" to the one asking 
about enabling SMP for BT LE.

> Please see the log (hcidump) of the Master BT device below followed by
> the hcidump of Slave (GATT Server).

Also, upgrade to hcidump 2.0 it has LE stuff in it, logs will be more useful. 
Ie get git version and compile and run from compile dir, no need to install.

> Thanks,
> Vijayalakshmi

BR,
Mika

^ permalink raw reply

* Not able to test GATT on ubuntu
From: Vijayalakshmi N @ 2011-02-04 11:59 UTC (permalink / raw)
  To: linux-bluetooth

Dear all,

I have taken the bluetooth code with BLE changes  (net/bluetooth and
include/net/bluetooth) from

http://git.infradead.org/users/vcgomes/linux-2.6.git/tree/refs/heads/le-l2cap
to my 2.6.35 kernel and built the kernel.

and also built bluez 4.84 on ubuntu 10.10.

Tried testing GATT with the gatttool that is available with the bluez.

gatttool --primary -b <bd-address>

gives me the following error:

 hci_acl_tx_to: hci0 ACL tx timeout
 hci_acl_tx_to: hci0 killing stalled ACL connection F5:61:0D:28:00:08
 hci_acl_tx_to: hci0 ACL tx timeout

This error occurs in both cases where there is an existing ACL
connection and no connection.

Other commands related to LE through hciconfig and hcitool work fine,
like hciconfig hciX leadv,
hcitool lescan, hcitool lecc, hcitool ledc.

But it seems like the GATT connection is not happening and thereby not
fetching me the required data.

Please let me know if anyone has come accross this problem and how to
get through this.

Please see the log (hcidump) of the Master BT device below followed by
the hcidump of Slave (GATT Server).

Thanks,
Vijayalakshmi

root@ubuntu-desktop:/home/ubuntu# hcitool lescan
LE Scan ...
08:00:28:0D:61:56
08:00:28:0D:61:56
08:00:28:0D:61:56
08:00:28:0D:61:56
^C
root@ubuntu-desktop:/home/ubuntu# hcidump -XVt &
[1] 9999
root@ubuntu-desktop:/home/ubuntu# HCI sniffer - Bluetooth packet
analyzer ver 1.42
device: hci0 snap_len: 1028 filter: 0xffffffff

root@ubuntu-desktop:/home/ubuntu# hcitool lecc 08:00:28:0D:61:56
2000-01-01 05:41:44.057189 < HCI Command: Unknown (0x08|0x000d) plen 25
  0000: 04 00 04 00 00 00 56 61  0d 28 00 08 00 0f 00 0f  ......Va.(......
  0010: 00 00 00 80 0c 01 00 01  00                       .........
2000-01-01 05:41:44.098845 > HCI Event: Command Status (0x0f) plen 4
    Unknown (0x08|0x000d) status 0x00 ncmd 1
Connection handle 1025
2000-01-01 05:41:44.676970 > HCI Event: code 0x3e plen 19
  0000: 01 00 01 04 00 00 56 61  0d 28 00 08 0f 00 00 00  ......Va.(......
  0010: 80 0c 01                                          ...
root@ubuntu-desktop:/home/ubuntu# hcitool con
Connections:
        < LE 08:00:28:0D:61:56 handle 1025 state 1 lm MASTER
root@ubuntu-desktop:/home/ubuntu#
root@ubuntu-desktop:/home/ubuntu# gatttool --primary -b 08:00:28:0D:61:56
2000-01-01 05:42:37.480315 < HCI Command: Create Connection
(0x01|0x0005) plen 13
    bdaddr 08:00:28:0D:61:56 ptype 0xcc18 rswitch 0x01 clkoffset 0x0000
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5
2000-01-01 05:42:37.512938 > HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
2000-01-01 05:42:41.114531 > HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 1 bdaddr 08:00:28:0D:61:56 type ACL encrypt 0x00
2000-01-01 05:42:41.114562 > HCI Event: Max Slots Change (0x1b) plen 3
    handle 1 slots 5
2000-01-01 05:42:41.114653 < HCI Command: Read Remote Supported
Features (0x01|0x001b) plen 2
    handle 1
2000-01-01 05:42:41.130370 > HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
2000-01-01 05:42:41.130400 > HCI Event: Read Remote Supported Features
(0x0b) plen 11
    status 0x00 handle 1
    Features: 0xff 0xfe 0x2d 0xfe 0xdb 0xff 0x7b 0x87
2000-01-01 05:42:41.130461 < HCI Command: Read Remote Extended
Features (0x01|0x001c) plen 3
    handle 1 page 1
2000-01-01 05:42:41.146117 > HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
2000-01-01 05:42:41.169188 > HCI Event: Read Remote Extended Features
(0x23) plen 13
    status 0x00 handle 1 page 1 max 1
    Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
2000-01-01 05:42:41.169219 < HCI Command: Authentication Requested
(0x01|0x0011) plen 2
    handle 1
2000-01-01 05:42:41.184813 > HCI Event: Command Status (0x0f) plen 4
    Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
2000-01-01 05:42:41.184844 > HCI Event: Link Key Request (0x17) plen 6
    bdaddr 08:00:28:0D:61:56
2000-01-01 05:42:41.185362 < HCI Command: Link Key Request Reply
(0x01|0x000b) plen 22
    bdaddr 08:00:28:0D:61:56 key 60CD21545C338F83BA01C22A9076D385
2000-01-01 05:42:41.202361 > HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr 08:00:28:0D:61:56
2000-01-01 05:42:41.238310 > HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 1
2000-01-01 05:42:41.238371 < HCI Command: Set Connection Encryption
(0x01|0x0013) plen 3
    handle 1 encrypt 0x01
2000-01-01 05:42:41.254698 > HCI Event: Command Status (0x0f) plen 4
    Set Connection Ehci_acl_tx_to: hci0 ACL tx timeout
ncryption (0x01|hci_acl_tx_to: hci0 killing stalled ACL connection
56:61:0D:28:00:08
0x0013) status 0x00 ncmd 1
2000-01-01 05:42:41.294249 > HCI Event: Encrypt Change (0x08) plen 4
    status 0x00 handle 1 encrypt 0x01
2000-01-01 05:42:41.294hci_acl_tx_to: hci0 ACL tx timeout
310 < ACL data: handle 1 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
2000-01-01 05:42:41.306822 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 1 reason 0x13
    Reason: Remote User Terminated Connection
2000-01-01 05:42:41.319548 > HCI Event: Number of Completed Packets
(0x13) plen 5
    handle 1 packets 1
2000-01-01 05:42:41.319579 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
2000-01-01 05:42:41.319609 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 1 reason 0x16
    Reason: Connection Terminated by Local Host
Software caused connection abort (103)
root@ubuntu-desktop:/home/ubuntu#


-----------------------------------------------------SLAVE----------------------------------------

2000-01-01 08:34:45.474151 > HCI Event: Connect Request (0x04) plen 10
    bdaddr 08:00:28:0D:61:F5 class 0x100100 type ACL
2000-01-01 08:34:45.474212 < HCI Command: Accept Connection Request
(0x01|0x0009) plen 7
    bdaddr 08:00:28:0D:61:F5 role 0x01
    Role: Slave
2000-01-01 08:34:45.489776 > HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
2000-01-01 08:34:45.489806 > HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 1 bdaddr 08:00:28:0D:61:F5 type ACL encrypt 0x00
2000-01-01 08:34:45.489806 > HCI Event: Page Scan Repetition Mode
Change (0x20) plen 7
    bdaddr 08:00:28:0D:61:F5 mode 1
2000-01-01 08:34:45.489867 < HCI Command: Read Remote Supported
Features (0x01|0x001b) plen 2
    handle 1
2000-01-01 08:34:45.505980 > HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
2000-01-01 08:34:45.520995 > HCI Event: Max Slots Change (0x1b) plen 3
    handle 1 slots 5
2000-01-01 08:34:45.520995 > HCI Event: Read Remote Supported Features
(0x0b) plen 11
    status 0x00 handle 1
    Features: 0xff 0xfe 0x2d 0xfe 0xdb 0xff 0x7b 0x87
2000-01-01 08:34:45.521056 < HCI Command: Read Remote Extended
Features (0x01|0x001c) plen 3
    handle 1 page 1
2000-01-01 08:34:45.536590 > HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
2000-01-01 08:34:45.536620 > HCI Event: Read Remote Extended Features
(0x23) plen 13
    status 0x00 handle 1 page 1 max 1
    Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
2000-01-01 08:34:45.615569 > HCI Event: Link Key Request (0x17) plen 6
    bdaddr 08:00:28:0D:61:F5
2000-01-01 08:34:45.615996 < HCI Command: Link Key Request Reply
(0x01|0x000b) plen 22
    bdaddr 08:00:28:0D:61:F5 key 60CD21545C338F83BA01C22A9076D385
2000-01-01 08:34:45.629546 > HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr 08:00:28:0D:61:F5
2000-01-01 08:34:45.692809 > HCI Event: Encrypt Change (0x08) plen 4
    status 0x00 handle 1 encrypt 0x01
hci_acl_tx_to: hci0 ACL tx timeout
hci_acl_tx_to: hci0 killing stalled ACL connection F5:61:0D:28:00:08
2000-01-01 08:34:45.716308 > ACL data: handle 1 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
2000-01-01 08:34:45.716338 < ACL data: handle 1 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x00b8
2000-01-01 08:34:45.726195 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 1 reason 0x13
    Reason: Remote User Terminated Connection
2000-01-01 08:34:45.740600 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
2000-01-01 08:34:45.809996 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x02 handle 1 reason 0x00
    Error: Unknown Connection Identifier
2000-01-01 08:34:45.809996 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 1 reason 0x13
    Reason: Remote User Terminated Connection

^ permalink raw reply

* [bluetooth-next 16/16] Bluetooth: move __l2cap_sock_close() to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-16-git-send-email-padovan@profusion.mobi>

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 include/net/bluetooth/l2cap.h |    2 +
 net/bluetooth/l2cap_core.c    |   84 +----------------------------------------
 net/bluetooth/l2cap_sock.c    |   78 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index d4c93ed..75ef0b2 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -451,6 +451,8 @@ void l2cap_sock_kill(struct sock *sk);
 void l2cap_sock_init(struct sock *sk, struct sock *parent);
 struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
 							int proto, gfp_t prio);
+void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err);
+void l2cap_chan_del(struct sock *sk, int err);
 int l2cap_do_connect(struct sock *sk);
 
 void l2cap_load(void);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0ba097d..ba7f9da 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -70,8 +70,6 @@ struct bt_sock_list l2cap_sk_list = {
 
 static void l2cap_busy_work(struct work_struct *work);
 
-static void l2cap_sock_close(struct sock *sk);
-
 static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 				u8 code, u8 ident, u16 dlen, void *data);
 
@@ -207,7 +205,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
 
 /* Delete channel.
  * Must be called on the locked socket. */
-static void l2cap_chan_del(struct sock *sk, int err)
+void l2cap_chan_del(struct sock *sk, int err)
 {
 	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
 	struct sock *parent = bt_sk(sk)->parent;
@@ -457,7 +455,7 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
 	}
 }
 
-static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err)
+void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err)
 {
 	struct l2cap_disconn_req req;
 
@@ -739,84 +737,6 @@ static struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
 	return node ? sk : sk1;
 }
 
-static void l2cap_sock_cleanup_listen(struct sock *parent)
-{
-	struct sock *sk;
-
-	BT_DBG("parent %p", parent);
-
-	/* Close not yet accepted channels */
-	while ((sk = bt_accept_dequeue(parent, NULL)))
-		l2cap_sock_close(sk);
-
-	parent->sk_state = BT_CLOSED;
-	sock_set_flag(parent, SOCK_ZAPPED);
-}
-
-void __l2cap_sock_close(struct sock *sk, int reason)
-{
-	BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
-
-	switch (sk->sk_state) {
-	case BT_LISTEN:
-		l2cap_sock_cleanup_listen(sk);
-		break;
-
-	case BT_CONNECTED:
-	case BT_CONFIG:
-		if (sk->sk_type == SOCK_SEQPACKET ||
-				sk->sk_type == SOCK_STREAM) {
-			struct l2cap_conn *conn = l2cap_pi(sk)->conn;
-
-			l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
-			l2cap_send_disconn_req(conn, sk, reason);
-		} else
-			l2cap_chan_del(sk, reason);
-		break;
-
-	case BT_CONNECT2:
-		if (sk->sk_type == SOCK_SEQPACKET ||
-				sk->sk_type == SOCK_STREAM) {
-			struct l2cap_conn *conn = l2cap_pi(sk)->conn;
-			struct l2cap_conn_rsp rsp;
-			__u16 result;
-
-			if (bt_sk(sk)->defer_setup)
-				result = L2CAP_CR_SEC_BLOCK;
-			else
-				result = L2CAP_CR_BAD_PSM;
-
-			rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
-			rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
-			rsp.result = cpu_to_le16(result);
-			rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
-			l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
-					L2CAP_CONN_RSP, sizeof(rsp), &rsp);
-		} else
-			l2cap_chan_del(sk, reason);
-		break;
-
-	case BT_CONNECT:
-	case BT_DISCONN:
-		l2cap_chan_del(sk, reason);
-		break;
-
-	default:
-		sock_set_flag(sk, SOCK_ZAPPED);
-		break;
-	}
-}
-
-/* Must be called on unlocked socket. */
-static void l2cap_sock_close(struct sock *sk)
-{
-	l2cap_sock_clear_timer(sk);
-	lock_sock(sk);
-	__l2cap_sock_close(sk, ECONNRESET);
-	release_sock(sk);
-	l2cap_sock_kill(sk);
-}
-
 int l2cap_do_connect(struct sock *sk)
 {
 	bdaddr_t *src = &bt_sk(sk)->src;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 4b4e020..adf4169 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -854,6 +854,84 @@ void l2cap_sock_kill(struct sock *sk)
 	sock_put(sk);
 }
 
+/* Must be called on unlocked socket. */
+static void l2cap_sock_close(struct sock *sk)
+{
+	l2cap_sock_clear_timer(sk);
+	lock_sock(sk);
+	__l2cap_sock_close(sk, ECONNRESET);
+	release_sock(sk);
+	l2cap_sock_kill(sk);
+}
+
+static void l2cap_sock_cleanup_listen(struct sock *parent)
+{
+	struct sock *sk;
+
+	BT_DBG("parent %p", parent);
+
+	/* Close not yet accepted channels */
+	while ((sk = bt_accept_dequeue(parent, NULL)))
+		l2cap_sock_close(sk);
+
+	parent->sk_state = BT_CLOSED;
+	sock_set_flag(parent, SOCK_ZAPPED);
+}
+
+void __l2cap_sock_close(struct sock *sk, int reason)
+{
+	BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
+
+	switch (sk->sk_state) {
+	case BT_LISTEN:
+		l2cap_sock_cleanup_listen(sk);
+		break;
+
+	case BT_CONNECTED:
+	case BT_CONFIG:
+		if (sk->sk_type == SOCK_SEQPACKET ||
+				sk->sk_type == SOCK_STREAM) {
+			struct l2cap_conn *conn = l2cap_pi(sk)->conn;
+
+			l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
+			l2cap_send_disconn_req(conn, sk, reason);
+		} else
+			l2cap_chan_del(sk, reason);
+		break;
+
+	case BT_CONNECT2:
+		if (sk->sk_type == SOCK_SEQPACKET ||
+				sk->sk_type == SOCK_STREAM) {
+			struct l2cap_conn *conn = l2cap_pi(sk)->conn;
+			struct l2cap_conn_rsp rsp;
+			__u16 result;
+
+			if (bt_sk(sk)->defer_setup)
+				result = L2CAP_CR_SEC_BLOCK;
+			else
+				result = L2CAP_CR_BAD_PSM;
+
+			rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
+			rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
+			rsp.result = cpu_to_le16(result);
+			rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
+			l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
+					L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+		} else
+			l2cap_chan_del(sk, reason);
+		break;
+
+	case BT_CONNECT:
+	case BT_DISCONN:
+		l2cap_chan_del(sk, reason);
+		break;
+
+	default:
+		sock_set_flag(sk, SOCK_ZAPPED);
+		break;
+	}
+}
+
 static int l2cap_sock_shutdown(struct socket *sock, int how)
 {
 	struct sock *sk = sock->sk;
-- 
1.7.4.rc3


^ permalink raw reply related

* [bluetooth-next 15/16] Bluetooth: move l2cap_sock_kill() to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-15-git-send-email-padovan@profusion.mobi>

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/l2cap_core.c |   16 ----------------
 net/bluetooth/l2cap_sock.c |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1baa16c..0ba097d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -753,22 +753,6 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)
 	sock_set_flag(parent, SOCK_ZAPPED);
 }
 
-/* Kill socket (only if zapped and orphan)
- * Must be called on unlocked socket.
- */
-void l2cap_sock_kill(struct sock *sk)
-{
-	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
-		return;
-
-	BT_DBG("sk %p state %d", sk, sk->sk_state);
-
-	/* Kill poor orphan */
-	bt_sock_unlink(&l2cap_sk_list, sk);
-	sock_set_flag(sk, SOCK_DEAD);
-	sock_put(sk);
-}
-
 void __l2cap_sock_close(struct sock *sk, int reason)
 {
 	BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 23bb968..4b4e020 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -838,6 +838,22 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
 	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
 }
 
+/* Kill socket (only if zapped and orphan)
+ * Must be called on unlocked socket.
+ */
+void l2cap_sock_kill(struct sock *sk)
+{
+	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
+		return;
+
+	BT_DBG("sk %p state %d", sk, sk->sk_state);
+
+	/* Kill poor orphan */
+	bt_sock_unlink(&l2cap_sk_list, sk);
+	sock_set_flag(sk, SOCK_DEAD);
+	sock_put(sk);
+}
+
 static int l2cap_sock_shutdown(struct socket *sock, int how)
 {
 	struct sock *sk = sock->sk;
-- 
1.7.4.rc3


^ permalink raw reply related

* [bluetooth-next 14/16] Bluetooth: move L2CAP sock timers function to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-14-git-send-email-padovan@profusion.mobi>

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/l2cap_core.c |   13 -------------
 net/bluetooth/l2cap_sock.c |   13 +++++++++++++
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4e3a06e..1baa16c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -77,19 +77,6 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 
 static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb);
 
-/* ---- L2CAP timers ---- */
-void l2cap_sock_set_timer(struct sock *sk, long timeout)
-{
-	BT_DBG("sk %p state %d timeout %ld", sk, sk->sk_state, timeout);
-	sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
-}
-
-void l2cap_sock_clear_timer(struct sock *sk)
-{
-	BT_DBG("sock %p state %d", sk, sk->sk_state);
-	sk_stop_timer(sk, &sk->sk_timer);
-}
-
 /* ---- L2CAP channels ---- */
 static struct sock *__l2cap_get_chan_by_dcid(struct l2cap_chan_list *l, u16 cid)
 {
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index fe4f834..23bb968 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -30,6 +30,7 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/l2cap.h>
 
+/* ---- L2CAP timers ---- */
 static void l2cap_sock_timeout(unsigned long arg)
 {
 	struct sock *sk = (struct sock *) arg;
@@ -63,6 +64,18 @@ static void l2cap_sock_timeout(unsigned long arg)
 	sock_put(sk);
 }
 
+void l2cap_sock_set_timer(struct sock *sk, long timeout)
+{
+	BT_DBG("sk %p state %d timeout %ld", sk, sk->sk_state, timeout);
+	sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
+}
+
+void l2cap_sock_clear_timer(struct sock *sk)
+{
+	BT_DBG("sock %p state %d", sk, sk->sk_state);
+	sk_stop_timer(sk, &sk->sk_timer);
+}
+
 static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src)
 {
 	struct sock *sk;
-- 
1.7.4.rc3


^ permalink raw reply related

* [bluetooth-next 13/16] Bluetooth: move l2cap_sock_sendmsg() to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-13-git-send-email-padovan@profusion.mobi>

Also moves some L2CAP sending functions declaration to l2cap.h

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 include/net/bluetooth/l2cap.h |   11 +++-
 net/bluetooth/l2cap_core.c    |  116 +++--------------------------------------
 net/bluetooth/l2cap_sock.c    |  102 ++++++++++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+), 112 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index c9df0ef..d4c93ed 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -436,6 +436,14 @@ void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *d
 int l2cap_build_conf_req(struct sock *sk, void *data);
 int __l2cap_wait_ack(struct sock *sk);
 
+struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len);
+struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len);
+struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
+int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len);
+void l2cap_do_send(struct sock *sk, struct sk_buff *skb);
+void l2cap_streaming_send(struct sock *sk);
+int l2cap_ertm_send(struct sock *sk);
+
 void l2cap_sock_set_timer(struct sock *sk, long timeout);
 void l2cap_sock_clear_timer(struct sock *sk);
 void __l2cap_sock_close(struct sock *sk, int reason);
@@ -445,9 +453,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
 							int proto, gfp_t prio);
 int l2cap_do_connect(struct sock *sk);
 
-int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len);
-
-
 void l2cap_load(void);
 
 #endif /* __L2CAP_H */
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0368a2e..4e3a06e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -992,7 +992,7 @@ static void l2cap_drop_acked_frames(struct sock *sk)
 		del_timer(&l2cap_pi(sk)->retrans_timer);
 }
 
-static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
+void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
 {
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
 	struct hci_conn *hcon = pi->conn->hcon;
@@ -1008,7 +1008,7 @@ static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
 	hci_send_acl(hcon, skb, flags);
 }
 
-static void l2cap_streaming_send(struct sock *sk)
+void l2cap_streaming_send(struct sock *sk)
 {
 	struct sk_buff *skb;
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
@@ -1077,7 +1077,7 @@ static void l2cap_retransmit_one_frame(struct sock *sk, u8 tx_seq)
 	l2cap_do_send(sk, tx_skb);
 }
 
-static int l2cap_ertm_send(struct sock *sk)
+int l2cap_ertm_send(struct sock *sk)
 {
 	struct sk_buff *skb, *tx_skb;
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
@@ -1217,7 +1217,7 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in
 	return sent;
 }
 
-static struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len)
+struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len)
 {
 	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
 	struct sk_buff *skb;
@@ -1246,7 +1246,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr
 	return skb;
 }
 
-static struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len)
+struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len)
 {
 	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
 	struct sk_buff *skb;
@@ -1274,7 +1274,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *ms
 	return skb;
 }
 
-static struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen)
+struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen)
 {
 	struct l2cap_conn *conn = l2cap_pi(sk)->conn;
 	struct sk_buff *skb;
@@ -1319,7 +1319,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *m
 	return skb;
 }
 
-static inline int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len)
+int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len)
 {
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
 	struct sk_buff *skb;
@@ -1365,108 +1365,6 @@ static inline int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, siz
 	return size;
 }
 
-int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
-{
-	struct sock *sk = sock->sk;
-	struct l2cap_pinfo *pi = l2cap_pi(sk);
-	struct sk_buff *skb;
-	u16 control;
-	int err;
-
-	BT_DBG("sock %p, sk %p", sock, sk);
-
-	err = sock_error(sk);
-	if (err)
-		return err;
-
-	if (msg->msg_flags & MSG_OOB)
-		return -EOPNOTSUPP;
-
-	lock_sock(sk);
-
-	if (sk->sk_state != BT_CONNECTED) {
-		err = -ENOTCONN;
-		goto done;
-	}
-
-	/* Connectionless channel */
-	if (sk->sk_type == SOCK_DGRAM) {
-		skb = l2cap_create_connless_pdu(sk, msg, len);
-		if (IS_ERR(skb)) {
-			err = PTR_ERR(skb);
-		} else {
-			l2cap_do_send(sk, skb);
-			err = len;
-		}
-		goto done;
-	}
-
-	switch (pi->mode) {
-	case L2CAP_MODE_BASIC:
-		/* Check outgoing MTU */
-		if (len > pi->omtu) {
-			err = -EMSGSIZE;
-			goto done;
-		}
-
-		/* Create a basic PDU */
-		skb = l2cap_create_basic_pdu(sk, msg, len);
-		if (IS_ERR(skb)) {
-			err = PTR_ERR(skb);
-			goto done;
-		}
-
-		l2cap_do_send(sk, skb);
-		err = len;
-		break;
-
-	case L2CAP_MODE_ERTM:
-	case L2CAP_MODE_STREAMING:
-		/* Entire SDU fits into one PDU */
-		if (len <= pi->remote_mps) {
-			control = L2CAP_SDU_UNSEGMENTED;
-			skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0);
-			if (IS_ERR(skb)) {
-				err = PTR_ERR(skb);
-				goto done;
-			}
-			__skb_queue_tail(TX_QUEUE(sk), skb);
-
-			if (sk->sk_send_head == NULL)
-				sk->sk_send_head = skb;
-
-		} else {
-		/* Segment SDU into multiples PDUs */
-			err = l2cap_sar_segment_sdu(sk, msg, len);
-			if (err < 0)
-				goto done;
-		}
-
-		if (pi->mode == L2CAP_MODE_STREAMING) {
-			l2cap_streaming_send(sk);
-		} else {
-			if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) &&
-					(pi->conn_state & L2CAP_CONN_WAIT_F)) {
-				err = len;
-				break;
-			}
-			err = l2cap_ertm_send(sk);
-		}
-
-		if (err >= 0)
-			err = len;
-		break;
-
-	default:
-		BT_DBG("bad state %1.1x", pi->mode);
-		err = -EBADFD;
-	}
-
-done:
-	release_sock(sk);
-	return err;
-}
-
 static void l2cap_chan_ready(struct sock *sk)
 {
 	struct sock *parent = bt_sk(sk)->parent;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 93af233..fe4f834 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -681,6 +681,108 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 	return err;
 }
 
+static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
+{
+	struct sock *sk = sock->sk;
+	struct l2cap_pinfo *pi = l2cap_pi(sk);
+	struct sk_buff *skb;
+	u16 control;
+	int err;
+
+	BT_DBG("sock %p, sk %p", sock, sk);
+
+	err = sock_error(sk);
+	if (err)
+		return err;
+
+	if (msg->msg_flags & MSG_OOB)
+		return -EOPNOTSUPP;
+
+	lock_sock(sk);
+
+	if (sk->sk_state != BT_CONNECTED) {
+		err = -ENOTCONN;
+		goto done;
+	}
+
+	/* Connectionless channel */
+	if (sk->sk_type == SOCK_DGRAM) {
+		skb = l2cap_create_connless_pdu(sk, msg, len);
+		if (IS_ERR(skb)) {
+			err = PTR_ERR(skb);
+		} else {
+			l2cap_do_send(sk, skb);
+			err = len;
+		}
+		goto done;
+	}
+
+	switch (pi->mode) {
+	case L2CAP_MODE_BASIC:
+		/* Check outgoing MTU */
+		if (len > pi->omtu) {
+			err = -EMSGSIZE;
+			goto done;
+		}
+
+		/* Create a basic PDU */
+		skb = l2cap_create_basic_pdu(sk, msg, len);
+		if (IS_ERR(skb)) {
+			err = PTR_ERR(skb);
+			goto done;
+		}
+
+		l2cap_do_send(sk, skb);
+		err = len;
+		break;
+
+	case L2CAP_MODE_ERTM:
+	case L2CAP_MODE_STREAMING:
+		/* Entire SDU fits into one PDU */
+		if (len <= pi->remote_mps) {
+			control = L2CAP_SDU_UNSEGMENTED;
+			skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0);
+			if (IS_ERR(skb)) {
+				err = PTR_ERR(skb);
+				goto done;
+			}
+			__skb_queue_tail(TX_QUEUE(sk), skb);
+
+			if (sk->sk_send_head == NULL)
+				sk->sk_send_head = skb;
+
+		} else {
+		/* Segment SDU into multiples PDUs */
+			err = l2cap_sar_segment_sdu(sk, msg, len);
+			if (err < 0)
+				goto done;
+		}
+
+		if (pi->mode == L2CAP_MODE_STREAMING) {
+			l2cap_streaming_send(sk);
+		} else {
+			if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) &&
+					(pi->conn_state & L2CAP_CONN_WAIT_F)) {
+				err = len;
+				break;
+			}
+			err = l2cap_ertm_send(sk);
+		}
+
+		if (err >= 0)
+			err = len;
+		break;
+
+	default:
+		BT_DBG("bad state %1.1x", pi->mode);
+		err = -EBADFD;
+	}
+
+done:
+	release_sock(sk);
+	return err;
+}
+
 static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
 {
 	struct sock *sk = sock->sk;
-- 
1.7.4.rc3


^ permalink raw reply related

* [bluetooth-next 12/16] Bluetooth: move l2cap_sock_shutdown() to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-12-git-send-email-padovan@profusion.mobi>

Declare __l2cap_wait_ack() and  l2cap_sock_clear_timer() in l2cap.h

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 include/net/bluetooth/l2cap.h |    3 ++-
 net/bluetooth/l2cap_core.c    |   35 ++---------------------------------
 net/bluetooth/l2cap_sock.c    |   31 +++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 336b2af7..c9df0ef 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -434,8 +434,10 @@ void l2cap_cleanup_sockets(void);
 u8 l2cap_get_ident(struct l2cap_conn *conn);
 void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
 int l2cap_build_conf_req(struct sock *sk, void *data);
+int __l2cap_wait_ack(struct sock *sk);
 
 void l2cap_sock_set_timer(struct sock *sk, long timeout);
+void l2cap_sock_clear_timer(struct sock *sk);
 void __l2cap_sock_close(struct sock *sk, int reason);
 void l2cap_sock_kill(struct sock *sk);
 void l2cap_sock_init(struct sock *sk, struct sock *parent);
@@ -444,7 +446,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
 int l2cap_do_connect(struct sock *sk);
 
 int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len);
-int l2cap_sock_shutdown(struct socket *sock, int how);
 
 
 void l2cap_load(void);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8184d54..0368a2e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -84,7 +84,7 @@ void l2cap_sock_set_timer(struct sock *sk, long timeout)
 	sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
 }
 
-static void l2cap_sock_clear_timer(struct sock *sk)
+void l2cap_sock_clear_timer(struct sock *sk)
 {
 	BT_DBG("sock %p state %d", sk, sk->sk_state);
 	sk_stop_timer(sk, &sk->sk_timer);
@@ -906,7 +906,7 @@ done:
 	return err;
 }
 
-static int __l2cap_wait_ack(struct sock *sk)
+int __l2cap_wait_ack(struct sock *sk)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	int err = 0;
@@ -1467,37 +1467,6 @@ done:
 	return err;
 }
 
-int l2cap_sock_shutdown(struct socket *sock, int how)
-{
-	struct sock *sk = sock->sk;
-	int err = 0;
-
-	BT_DBG("sock %p, sk %p", sock, sk);
-
-	if (!sk)
-		return 0;
-
-	lock_sock(sk);
-	if (!sk->sk_shutdown) {
-		if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
-			err = __l2cap_wait_ack(sk);
-
-		sk->sk_shutdown = SHUTDOWN_MASK;
-		l2cap_sock_clear_timer(sk);
-		__l2cap_sock_close(sk, 0);
-
-		if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
-			err = bt_sock_wait_state(sk, BT_CLOSED,
-							sk->sk_lingertime);
-	}
-
-	if (!err && sk->sk_err)
-		err = -sk->sk_err;
-
-	release_sock(sk);
-	return err;
-}
-
 static void l2cap_chan_ready(struct sock *sk)
 {
 	struct sock *parent = bt_sk(sk)->parent;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index fa2bc5d..93af233 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -723,6 +723,37 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
 	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
 }
 
+static int l2cap_sock_shutdown(struct socket *sock, int how)
+{
+	struct sock *sk = sock->sk;
+	int err = 0;
+
+	BT_DBG("sock %p, sk %p", sock, sk);
+
+	if (!sk)
+		return 0;
+
+	lock_sock(sk);
+	if (!sk->sk_shutdown) {
+		if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
+			err = __l2cap_wait_ack(sk);
+
+		sk->sk_shutdown = SHUTDOWN_MASK;
+		l2cap_sock_clear_timer(sk);
+		__l2cap_sock_close(sk, 0);
+
+		if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
+			err = bt_sock_wait_state(sk, BT_CLOSED,
+							sk->sk_lingertime);
+	}
+
+	if (!err && sk->sk_err)
+		err = -sk->sk_err;
+
+	release_sock(sk);
+	return err;
+}
+
 static int l2cap_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
-- 
1.7.4.rc3


^ permalink raw reply related

* [bluetooth-next 11/16] Bluetooth: move l2cap_sock_recvmsg() to l2cap_sock.c
From: Gustavo F. Padovan @ 2011-02-04  6:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1296799318-5517-11-git-send-email-padovan@profusion.mobi>

It causes the move of the declaration of 3 functions to l2cap.h:
l2cap_get_ident(), l2cap_send_cmd(), l2cap_build_conf_req()

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 include/net/bluetooth/l2cap.h |    5 +++-
 net/bluetooth/l2cap_core.c    |   49 ++--------------------------------------
 net/bluetooth/l2cap_sock.c    |   42 +++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 47 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index b5ebf87..336b2af7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -431,6 +431,10 @@ extern struct bt_sock_list l2cap_sk_list;
 int l2cap_init_sockets(void);
 void l2cap_cleanup_sockets(void);
 
+u8 l2cap_get_ident(struct l2cap_conn *conn);
+void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
+int l2cap_build_conf_req(struct sock *sk, void *data);
+
 void l2cap_sock_set_timer(struct sock *sk, long timeout);
 void __l2cap_sock_close(struct sock *sk, int reason);
 void l2cap_sock_kill(struct sock *sk);
@@ -440,7 +444,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
 int l2cap_do_connect(struct sock *sk);
 
 int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len);
-int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags);
 int l2cap_sock_shutdown(struct socket *sock, int how);
 
 
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2d141fc..8184d54 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -72,7 +72,6 @@ static void l2cap_busy_work(struct work_struct *work);
 
 static void l2cap_sock_close(struct sock *sk);
 
-static int l2cap_build_conf_req(struct sock *sk, void *data);
 static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 				u8 code, u8 ident, u16 dlen, void *data);
 
@@ -311,7 +310,7 @@ static inline int l2cap_check_security(struct sock *sk)
 								auth_type);
 }
 
-static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
+u8 l2cap_get_ident(struct l2cap_conn *conn)
 {
 	u8 id;
 
@@ -333,7 +332,7 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
 	return id;
 }
 
-static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
+void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
 {
 	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
 	u8 flags;
@@ -1468,48 +1467,6 @@ done:
 	return err;
 }
 
-int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
-{
-	struct sock *sk = sock->sk;
-
-	lock_sock(sk);
-
-	if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
-		struct l2cap_conn_rsp rsp;
-		struct l2cap_conn *conn = l2cap_pi(sk)->conn;
-		u8 buf[128];
-
-		sk->sk_state = BT_CONFIG;
-
-		rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
-		rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
-		rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
-		rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
-		l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident,
-					L2CAP_CONN_RSP, sizeof(rsp), &rsp);
-
-		if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
-			release_sock(sk);
-			return 0;
-		}
-
-		l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
-		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
-				l2cap_build_conf_req(sk, buf), buf);
-		l2cap_pi(sk)->num_conf_req++;
-
-		release_sock(sk);
-		return 0;
-	}
-
-	release_sock(sk);
-
-	if (sock->type == SOCK_STREAM)
-		return bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
-
-	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
-}
-
 int l2cap_sock_shutdown(struct socket *sock, int how)
 {
 	struct sock *sk = sock->sk;
@@ -1759,7 +1716,7 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
 	}
 }
 
-static int l2cap_build_conf_req(struct sock *sk, void *data)
+int l2cap_build_conf_req(struct sock *sk, void *data)
 {
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
 	struct l2cap_conf_req *req = data;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index e2f14f1..fa2bc5d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -681,6 +681,48 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 	return err;
 }
 
+static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
+{
+	struct sock *sk = sock->sk;
+
+	lock_sock(sk);
+
+	if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
+		struct l2cap_conn_rsp rsp;
+		struct l2cap_conn *conn = l2cap_pi(sk)->conn;
+		u8 buf[128];
+
+		sk->sk_state = BT_CONFIG;
+
+		rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
+		rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
+		rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
+		rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
+		l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident,
+					L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+
+		if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
+			release_sock(sk);
+			return 0;
+		}
+
+		l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
+		l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
+				l2cap_build_conf_req(sk, buf), buf);
+		l2cap_pi(sk)->num_conf_req++;
+
+		release_sock(sk);
+		return 0;
+	}
+
+	release_sock(sk);
+
+	if (sock->type == SOCK_STREAM)
+		return bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
+
+	return bt_sock_recvmsg(iocb, sock, msg, len, flags);
+}
+
 static int l2cap_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
-- 
1.7.4.rc3


^ 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