-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Motivation
Today, when a server detects a protocol violation (e.g., oversized SDU/PDU, malformed framing, abuse), there’s no public API to actively terminate the L2CAP CoC from the NimBLEL2CAPChannel object. The NimBLE host already supports this (ble_l2cap_disconnect() / ble_l2cap_get_conn_handle()), but esp‑nimble‑cpp doesn’t surface it. This forces applications either to keep the link alive (risking repeated abuse) or to terminate the entire GAP connection via NimBLEServer::disconnect (too coarse). A channel‑level disconnect is the correct and efficient response for DoS‑style abuse in L2CAP CoC services.
Proposed API
- Add to
NimBLEL2CAPChannel:bool disconnect();
Callsble_l2cap_disconnect(channel)and returns success/failure.uint16_t getConnHandle() const;
Returnsble_l2cap_get_conn_handle(channel)(orBLE_HS_CONN_HANDLE_NONEif not connected).- Optional:
bool getChanInfo(ble_l2cap_chan_info& info) const;for callers that need MTU or PSM without re-querying host internals.
Use case
- L2CAP CoC server detects oversized payloads or invalid framing in
onRead()and cleanly disconnects only that channel, leaving the BLE link intact for other services.
This keeps esp‑nimble‑cpp aligned with NimBLE capabilities, improves robustness/security, and avoids application‑level hacks.