Skip to content

rp2040/rp2350: Support multicast TTL socket option - #11174

Draft
Daniiiil1 wants to merge 2 commits into
adafruit:mainfrom
Daniiiil1:fix/rp2-multicast-ttl
Draft

rp2040/rp2350: Support multicast TTL socket option#11174
Daniiiil1 wants to merge 2 commits into
adafruit:mainfrom
Daniiiil1:fix/rp2-multicast-ttl

Conversation

@Daniiiil1

Copy link
Copy Markdown

Closes #9938.

The Raspberry Pi port uses lwIP's raw API rather than its socket API, so it cannot delegate this option to lwip_setsockopt() as the Espressif port does. Handle IPPROTO_IP / IP_MULTICAST_TTL for UDP sockets by updating the UDP PCB's multicast TTL directly.

The implementation also:

  • returns EOPNOTSUPP for non-datagram sockets;
  • returns EINVAL for a closed UDP PCB or an empty option value;
  • follows lwIP's one-byte IP_MULTICAST_TTL representation.

Testing:

  • pre-commit run --files ports/raspberrypi/common-hal/socketpool/Socket.c
  • gmake -C ports/raspberrypi BOARD=raspberry_pi_pico_w -j4
  • gmake -C ports/raspberrypi BOARD=raspberry_pi_pico2_w -j4
  • inspected both generated objects to confirm the option path writes one byte to udp_pcb.mcast_ttl

Both builds produced firmware.uf2. I do not have a Pico W/Pico 2 W connected, so I have not performed an on-device multicast packet capture.

@tannewt

tannewt commented Aug 4, 2026

Copy link
Copy Markdown
Member

@todbot want to test this? The issue from jepler says it is needed for your MicroOSC.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rp2040/rp2350: support setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)

2 participants