nuttx/net/bluetooth
Stephen Fox 990ac856b2 net/bluetooth: fix BTPROTO_HCI socket device lookup
bluetooth_sendto() uses netdev_findbyindex(conn->bc_ldev + 1) to find
the Bluetooth network device for an HCI socket.  netdev_findbyindex
searches by global interface index, but bc_ldev is a 0-based count of
Bluetooth devices only — it bears no fixed relationship to the global
interface index.  If any netdev other than a Bluetooth device is
registered before it (e.g. loopback or Ethernet), the Bluetooth device
will not be at global index bc_ldev + 1 and the lookup will return NULL
or the wrong device.

Fix this by replacing netdev_findbyindex with a netdev_foreach walk
using a small callback (bluetooth_dev_byidx_callback) that counts only
NET_LL_BLUETOOTH devices and returns the bc_ldev-th one, regardless of
what else is registered or in what order.

Signed-off-by: Stephen Fox <stephenfox@geotab.com>
2026-05-06 14:45:46 +08:00
..
bluetooth.h net: make the sendmsg param type consistent with posix specification 2026-01-16 21:11:39 +08:00
bluetooth_callback.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth_conn.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth_container.c net/bluetooth: replace net_lock with conn_lock and conn_lock_dev 2026-01-02 07:48:06 -03:00
bluetooth_finddev.c net: migrate to SPDX identifier 2024-09-12 01:08:11 +08:00
bluetooth_initialize.c net/bufpool: Call init automatically on alloc 2025-01-07 22:00:21 +08:00
bluetooth_input.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth_poll.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth_recvmsg.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth_sendmsg.c net/bluetooth: fix BTPROTO_HCI socket device lookup 2026-05-06 14:45:46 +08:00
bluetooth_sockif.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
CMakeLists.txt net: migrate to SPDX identifier 2024-09-12 01:08:11 +08:00
Kconfig Remove the tail spaces from all files except Documentation 2023-02-26 13:24:24 -08:00
Make.defs net: migrate to SPDX identifier 2024-09-12 01:08:11 +08:00