This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: socket.connect() no longer works with AF_BLUETOOTH L2CAP sockets
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mathew.Martineau, Tim.Tisdall, Yaniv.Aknin, pitrou
Priority: normal Keywords: easy, patch

Created on 2010-02-02 00:13 by Mathew.Martineau, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
zero_l2cap_addr_struct.diff Yaniv.Aknin, 2010-04-07 11:12
Messages (8)
msg98700 - (view) Author: Mathew Martineau (Mathew.Martineau) Date: 2010-02-02 00:13
The sockaddr_l2 struct used with connect() has changed in recent versions of the Linux kernel.  There is a new l2_cid member.

connect() only works with L2CAP sockets if l2_cid is set to 0.

Suggest initializing the whole sockaddr_l2 struct to 0 in getsockaddrarg() (socketmodule.c).
msg98701 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-02-02 00:14
Could you produce a patch?
msg99244 - (view) Author: Mathew Martineau (Mathew.Martineau) Date: 2010-02-12 00:13
I can submit a patch, but my employer has an involved process for doing this (even for small fixes like this).  It will take a few more days to get to a point where I can post the patch, but I will do so as soon as I can.
msg102445 - (view) Author: Yaniv Aknin (Yaniv.Aknin) Date: 2010-04-06 09:44
I wouldn't mind producing the patch, if Mathew is OK with this.
msg102472 - (view) Author: Mathew Martineau (Mathew.Martineau) Date: 2010-04-06 16:16
Yaniv - Please proceed!
msg102474 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-06 16:33
By the way, even better if you find a way of having unit tests for bluetooth sockets. Is there some kind of "dummy" device which gives predictable results (à la /dev/zero, for example)?
msg102533 - (view) Author: Yaniv Aknin (Yaniv.Aknin) Date: 2010-04-07 11:12
I've zero experience with programming bluetooth (to be honest, I only tackled this bug because I'm learning how to contribute to Python and it seemed ultra-easy), so I'm not an authoritative source on whether such a 'loopback' test is possible.

On #bluez in freenode I was told that generally no, there is no 'localhost' for BT sockets, and that a while ago there was a bluetooth emulation tool called 'hciemu' which is no longer maintained.

I'm attaching the patch (it's just a oneliner), it passes regression though obviously isn't really tested by it... I suggest Mathew will try the patch out and see if it helps; we can decide how to proceed from there.
msg104483 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-29 10:19
Committed in r80610. Thanks!
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52082
2014-07-14 15:53:02Tim.Tisdallsetnosy: + Tim.Tisdall
2010-04-29 10:19:10pitrousetstatus: open -> closed
resolution: fixed
messages: + msg104483

stage: needs patch -> resolved
2010-04-07 11:12:23Yaniv.Akninsetfiles: + zero_l2cap_addr_struct.diff
keywords: + patch
messages: + msg102533
2010-04-06 16:33:44pitrousetmessages: + msg102474
2010-04-06 16:16:59Mathew.Martineausetmessages: + msg102472
2010-04-06 09:44:20Yaniv.Akninsetnosy: + Yaniv.Aknin
messages: + msg102445
2010-02-12 00:13:58Mathew.Martineausetmessages: + msg99244
2010-02-02 00:14:53pitrousetpriority: normal

nosy: + pitrou
messages: + msg98701

keywords: + easy
stage: needs patch
2010-02-02 00:13:32Mathew.Martineaucreate