Skip to content

feat(usrsctp): add component (sctplab/usrsctp + ESP-IDF lwIP integration)#1063

Draft
vikramdattu wants to merge 1 commit into
espressif:masterfrom
vikramdattu:feat/usrsctp/add-component
Draft

feat(usrsctp): add component (sctplab/usrsctp + ESP-IDF lwIP integration)#1063
vikramdattu wants to merge 1 commit into
espressif:masterfrom
vikramdattu:feat/usrsctp/add-component

Conversation

@vikramdattu
Copy link
Copy Markdown
Contributor

Draft — sits behind #1060 (libsrtp) + #1061 (libwebsockets) on the same migration track from idf-extra-components. Will flip to ready-for-review after either lands and we apply the consistent review feedback here.

Summary

Adds usrsctp — userspace SCTP stack (RFC 4960) wrapping sctplab/usrsctp pinned at commit 2e1ab10. Used by WebRTC data channels (SCTP-over-DTLS-over-UDP) and by other consumers that need a portable SCTP implementation on platforms without a kernel SCTP.

Pairs naturally with libwebsockets and libsrtp in the WebRTC transport neighbourhood — that's the reason for landing here rather than in idf-extra-components.

Patches

Five ESP-IDF-specific patches applied at configure time. See patches/README.md for the full ledger.

# Patch Status
0001 Added LWIP support — userspace conn transport routes packets through lwIP for the espnetif path Upstream PR in flight: sctplab/usrsctp#743. Drops + re-pin once it lands.
0002 Allocate larger sin6 structure — fixes an on-stack overflow when the wrapper passes the v6 socket address Local bug fix; happy to upstream as a small standalone PR.
0003 ESP_PLATFORM: thread-safe netif APIs ESP-IDF-specific; stays downstream.
0004 feat(esp): allocate usrsctp thread stacks from SPIRAM ESP-IDF-specific (helps on memory-constrained C5 / C6); stays downstream.
0005 Fix non-LWIP / Linux-target buildability in 0001 Folds into 0001 when it lands upstream.

Layout

components/usrsctp/
├── CMakeLists.txt        # ESP-IDF component registration + idempotent patch-apply loop
├── Kconfig               # debug + thread-stack location toggles
├── idf_component.yml     # registry manifest (tags, sbom)
├── sbom_usrsctp.yml      # SBOM for the wrapped upstream
├── patches/              # 5 patches + README ledger
├── examples/get_started/ # minimal init/shutdown sanity app
├── test_apps/            # embedded Unity smoke (esp32 + esp32c3)
├── host_test/            # Linux-target socket-lifecycle test
├── usrsctp_register.c    # empty TU so idf_component_register has a source
└── usrsctp/              # sctplab/usrsctp submodule @ 2e1ab10

Local verification

  • pre-commit clean (yaml/copyright/astyle/codespell/eradicate/yapf/isort/flake8).
  • examples/get_started/ builds clean on esp32 with IDF v5.5.
  • .github/workflows/usrsctp__build.yml mirrors the lws_build.yml / libsrtp__build.yml pattern — label-gated on usrsctp. Maintainer drops the label and CI builds the get_started + test_apps matrix on release-v5.4 / release-v5.5 plus the host_test runs on the Linux target.
  • Downstream verification: this same wrapper (under the previous local name esp_usrsctp) drives the WebRTC data-channel transport for our ESP32-P4 KVS WebRTC port in production.

Previously

Initially prepared as espressif/idf-extra-components#754 (Draft). Moved here per discussion with @euripedesrocha — esp-protocols is the right neighbourhood for transport-stack components.

Related

cc @euripedesrocha @david-cermak

…ion)

Adds usrsctp — userspace SCTP stack (RFC 4960) wrapping cisco-style
sctplab/usrsctp pinned at 2e1ab10. Used by WebRTC data channels
(SCTP-over-DTLS-over-UDP) and by other consumers that need a portable
SCTP implementation on platforms without a kernel SCTP.

Pairs naturally with libwebsockets and libsrtp in the WebRTC transport
neighbourhood. PR espressif#1060 (libsrtp) + PR espressif#1061 (libwebsockets) sit on the
same migration track from idf-extra-components.

Five ESP-IDF-specific patches are applied at configure time, see
patches/README.md:
  0001 — LWIP routing layer for usrsctp's userspace 'conn' transport.
         Upstream PR sctplab/usrsctp#743 in flight; folds in once it
         lands.
  0002 — sin6 overflow fix for the on-stack sockaddr_in6 slot.
  0003 — ESP_PLATFORM thread-safe netif APIs (stays downstream).
  0004 — SPIRAM-backed worker thread stacks for the usrsctp service
         tasks (stays downstream).
  0005 — Buildability fix for the Linux target after 0001 (folds when
         0001 lands upstream).

Tests:
  test_apps/    — embedded Unity smoke on esp32 + esp32c3
  host_test/    — Linux-target socket-lifecycle test
  examples/get_started/ — minimal init/shutdown sanity app
  .github/workflows/usrsctp__build.yml — CI matrix gated on the
                  'usrsctp' label, matches the lws_build.yml pattern

Verified locally: pre-commit clean, get_started example builds clean
on esp32.

(Previously prepared as idf-extra-components#754 (Draft); relocated to
esp-protocols where it sits alongside libwebsockets / libsrtp / asio.)
@david-cermak
Copy link
Copy Markdown
Collaborator

Question (before review): Wouldn't it be easier to support linux/BSD like socket API with usrsctp upstream?

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 1, 2026
@vikramdattu
Copy link
Copy Markdown
Contributor Author

@david-cermak Yes, that's exactly the direction — the actual LWIP socket integration is already up at sctplab/usrsctp#743 (open, awaiting review). Until it lands, this component pins our fork; once merged upstream, the esp-protocols wrapper shrinks to build glue only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants