Skip to content

Add usrsctp component (sctplab/usrsctp + ESP-IDF lwIP integration) (IEC-545)#754

Draft
vikramdattu wants to merge 2 commits into
espressif:masterfrom
vikramdattu:feat/add-usrsctp
Draft

Add usrsctp component (sctplab/usrsctp + ESP-IDF lwIP integration) (IEC-545)#754
vikramdattu wants to merge 2 commits into
espressif:masterfrom
vikramdattu:feat/add-usrsctp

Conversation

@vikramdattu
Copy link
Copy Markdown
Contributor

Summary

Adds usrsctp — an ESP-IDF wrapper around upstream sctplab/usrsctp (0.9.5). Submodule pinned at 2e1ab10, with five build-time patches applied at configure time.

usrsctp is a portable userland implementation of SCTP (RFC 4960). It's the standard SCTP stack used by WebRTC data channels (SCTP-over-DTLS-over-UDP) and by other consumers that need SCTP on platforms without a kernel-level implementation. Pairs naturally with the libsrtp2 component (PR #753) for the WebRTC use case.

Why a new component

We've been carrying this as a downstream component on the AWS KVS WebRTC SDK port for ESP32, in production on ESP32-P4 for the camera/WebRTC workstream. Bringing it into idf-extra-components so any IDF project can add-dependency espressif/usrsctp.

Naming

Bare upstream project name, matching the idf-extra-components convention (cf. cbor, nghttp, freetype, zlib, etc., which all match the upstream project's primary name — even when the install artifact is called lib<name>.a).

Searchable tag synonyms in idf_component.yml: sctp, sctplab, esp_usrsctp, esp_sctp, libusrsctp, webrtc, data-channel, rfc4960.

Commits

  1. feat(usrsctp): add component (sctplab/usrsctp + ESP-IDF lwIP integration) — wrapper sources, usrsctp/usrsctp as a submodule gitlink at 2e1ab10, root .gitmodules entry, five build-time patches in patches/.
  2. ci: register usrsctp in CI manifests.idf_build_apps.toml, upload-component components:, bug-report dropdown. Alphabetical.

Patches

Five local patches in patches/, applied via git apply --check-gated loop in CMakeLists.txt (idempotent — already-applied patches are skipped):

# Patch Status
0001 Added LWIP support Upstream PR in flight: sctplab/usrsctp#743. Will be dropped once it lands + we re-pin the submodule.
0002 Fix overflow error / allocate for larger sin6 structure Bug fix. Will offer upstream as a separate small PR.
0003 ESP_PLATFORM: add support for thread-safe netif API ESP-IDF-specific. Stays as downstream patch.
0004 feat(esp): allocate usrsctp thread stacks from SPIRAM ESP-IDF-specific (helps on memory-constrained C5 / C6). Stays.
0005 Fix non-LWIP / Linux-target buildability in 'Added LWIP support' Buildability fix. Folds into 0001 when it goes upstream.

See patches/README.md for the ledger.

Layout

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

Build / test verification (local)

  • test_apps/ on esp32: ✅ builds clean
  • test_apps/ on esp32c3: ✅ builds clean
  • host_test/ on IDF Linux target: ✅ builds clean + binary runs (usrsctp host_test: PASS, exit 0)
  • examples/get_started/ builds clean
  • .github/consistency_check.py passes
  • Downstream verification: this same wrapper (under the old name esp_usrsctp) drives the WebRTC data-channel transport for our ESP32-P4 KVS WebRTC port in production.

License

Apache-2.0 AND BSD-3-Clause — ESP-IDF port glue is Apache-2.0; the bundled usrsctp/ submodule remains under upstream's BSD-3-Clause.

Related

Reviews welcome — happy to split the patch series further, rename the option knobs, or rework anything that doesn't fit.

…ion)

Adds the usrsctp wrapper component: sctplab/usrsctp 0.9.5 as a submodule
(pinned at 2e1ab10) plus the ESP-IDF build glue and five local patches.

usrsctp is a portable userland implementation of the SCTP protocol
(RFC 4960). It is the standard SCTP stack used by WebRTC data channels
(SCTP-over-DTLS-over-UDP) and by other consumers that need SCTP on
platforms without a kernel-level SCTP implementation.

What's bundled:
- usrsctplib/ (the library proper) registered as the component's
  in-repo includes; CMakeLists pulls the lib into ESP-IDF's build
  graph and links against lwip / mbedtls / pthread / freertos.
- Five build-time patches applied via 'git apply' at configure time
  (idempotent — already-applied patches are skipped):
    0001 LWIP support (the big one — see sctplab/usrsctp#743,
         upstream PR in flight; will be dropped once it lands)
    0002 sin6 buffer overflow fix
    0003 ESP_PLATFORM thread-safe netif API
    0004 SPIRAM-backed worker thread stacks (memory-constrained
         targets like ESP32-C5 / C6)
    0005 Linux-target buildability for the 'Added LWIP support' patch
- Embedded smoke test (test_apps/) and host-side socket-lifecycle test
  (host_test/) for the IDF Linux target.
- Kconfig knobs (USRSCTP_DEBUG, USRSCTP_THREAD_STACK_IN_SPIRAM,
  USRSCTP_USE_MBEDTLS_SHA1).

Targets: full ESP32 family (esp32 / s2 / s3 / c3 / c5 / c6 / p4) plus
the IDF Linux target for host-side testing.

Naming follows the idf-extra-components convention for upstream-library
wrappers — bare upstream project name (matches usrsctp's own naming
even though the artifact is libusrsctp.a; see cbor, nghttp, freetype,
zlib, etc. which all match their upstream project's primary name).
- .idf_build_apps.toml: add usrsctp/.build-test-rules.yml entry so
  build_apps picks up the new component during repo-wide CI runs.
- .github/workflows/upload_component.yml: add usrsctp to the 'components:'
  list so 'compote component upload' processes the tarball on push to
  master.
- .github/ISSUE_TEMPLATE/bug-report.yml: add usrsctp to the component
  dropdown so users can file bugs against it.

All three entries inserted alphabetically.
@github-actions github-actions Bot changed the title Add usrsctp component (sctplab/usrsctp + ESP-IDF lwIP integration) Add usrsctp component (sctplab/usrsctp + ESP-IDF lwIP integration) (IEC-545) May 24, 2026
@vikramdattu
Copy link
Copy Markdown
Contributor Author

Heads-up — moving this to espressif/esp-protocols instead of idf-extra-components, on the same migration track as the libsrtp PR (#753espressif/esp-protocols#1060).

New PR: espressif/esp-protocols#1063 (Draft — sits behind #1060 + #1061 on the migration train, will flip to ready-for-review once either lands and we apply consistent review feedback).

Component name and patch set carry over unchanged; conventions adapted to esp-protocols (.cz.yaml, paths under components/usrsctp/, .build-test-rules.yml rooted at the repo root, component-local .github/workflows/ dropped — replaced by the top-level usrsctp__build.yml matching the lws_build.yml pattern).

Closing this once the esp-protocols PR lands.

cc @euripedesrocha

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants