From f618fe125cdf5e544382752e9e85a1fa8eed6a39 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Tue, 29 Apr 2025 19:24:17 -0300 Subject: [PATCH] Fix lwIP builds fixes #3119 lwIP does not export ip_mreq by default, it requires enabling support for IGMP by setting LWIP_IGMP, with the associated extra stuff. Mongoose will print an error if mg_multicast_add() is called with no multicast support in lwIP. --- mongoose.c | 4 ++++ src/sock.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mongoose.c b/mongoose.c index b94797fb..a3142326 100644 --- a/mongoose.c +++ b/mongoose.c @@ -8394,11 +8394,15 @@ void mg_multicast_add(struct mg_connection *c, char *ip) { // TODO(): prvAllowIPPacketIPv4() #else // lwIP, Unix, Windows, Zephyr(, AzureRTOS ?) +#if MG_ENABLE_LWIP && !LWIP_IGMP + MG_ERROR(("LWIP_IGMP not defined, no multicast support")); +#else struct ip_mreq mreq; mreq.imr_multiaddr.s_addr = inet_addr(ip); mreq.imr_interface.s_addr = mg_htonl(INADDR_ANY); setsockopt(FD(c), IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof(mreq)); #endif +#endif } bool mg_open_listener(struct mg_connection *c, const char *url) { diff --git a/src/sock.c b/src/sock.c index 46e2ad2a..64147555 100644 --- a/src/sock.c +++ b/src/sock.c @@ -184,11 +184,15 @@ void mg_multicast_add(struct mg_connection *c, char *ip) { // TODO(): prvAllowIPPacketIPv4() #else // lwIP, Unix, Windows, Zephyr(, AzureRTOS ?) +#if MG_ENABLE_LWIP && !LWIP_IGMP + MG_ERROR(("LWIP_IGMP not defined, no multicast support")); +#else struct ip_mreq mreq; mreq.imr_multiaddr.s_addr = inet_addr(ip); mreq.imr_interface.s_addr = mg_htonl(INADDR_ANY); setsockopt(FD(c), IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreq, sizeof(mreq)); #endif +#endif } bool mg_open_listener(struct mg_connection *c, const char *url) {