pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/python/cpython/issues/129288

ps://github.githubassets.com/assets/repository-6ec84ae2261fecf8.css" /> Support for Bluetooth LE L2CAP Connection-oriented channels through AF_BLUETOOTH/BTPROTO_L2CAP socket · Issue #129288 · python/cpython · GitHub
Skip to content

Support for Bluetooth LE L2CAP Connection-oriented channels through AF_BLUETOOTH/BTPROTO_L2CAP socket #129288

@themadinventor

Description

@themadinventor

Feature or enhancement

Proposal:

As has been discussed previously (69242, 70145), "new" fields have been added in sockaddr_l2, but are still not supported in CPython's socket implementation.

  • The lack of l2_bdaddr_type prevents opening L2CAP connection-oriented channels to Bluetooth LE devices.
  • Likewise, the missing l2_cid prevents raw access to e.g ATT.

My suggestion is to add support for a third and fourth optional element in the address tuple for l2_cid and l2_bdaddr_type respectively.

  • Only one of psm and cid can be non-zero. This is enforced by the kernel.
  • l2_bdaddr_type can take the value of BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM. BDADDR_BREDR is implied if the element is missing, preserving compatibility with existing code.

I.e for LE CoC connection to PSM 0x80

sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)
sock.connect((bdaddr, 0x80, 0, BDADDR_LE_RANDOM))

For a raw LE ATT connection:

CID_ATT = 0x04
sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)
s.bind((BDADDR_ANY, 0, CID_ATT, BDADDR_LE_RANDOM))
s.connect((bdaddr, 0, CID_ATT, BDADDR_LE_RANDOM))

while keeping the existing format for classic BR/EDR L2CAP.

sock.connect((bdaddr, 0x80))

I have a working implementation of this locally (tested on Linux 6.11) and will file a PR for review as soon as I've got this issue number assigned.

This is my first attempt at contributing to CPython, so I apologize in advance for any mistakes in the process.

Edit 2025-01-26: Added CID field to proposal. PR to be updated.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#69242
#70145

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





      Check this box to remove all script contents from the fetched content.



      Check this box to remove all images from the fetched content.


      Check this box to remove all CSS styles from the fetched content.


      Check this box to keep images inefficiently compressed and original size.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy