Skip to content

Commit

Permalink
LwIP: Support Server Multicast registration
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Dec 5, 2024
1 parent 7ad6579 commit ae16290
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/lwip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ CFLAGS += -Ilwip/src/include/ -Ilwip/src/include/ipv4/ \

LWIP_SRC = def.c init.c tapif.c etharp.c netif.c timeouts.c stats.c udp.c \
tcp.c pbuf.c ip4_addr.c ip4.c inet_chksum.c tcp_in.c tcp_out.c \
icmp.c raw.c ip4_frag.c sys_arch.c ethernet.c ip.c mem.c memp.c tcpip.c
icmp.c raw.c ip4_frag.c sys_arch.c ethernet.c ip.c mem.c memp.c \
igmp.c tcpip.c
vpath %.c lwip/src/core/ lwip/contrib/ports/unix/proj/minimal/ \
lwip/src/netif/ lwip/src/core/ipv4/ lwip/contrib/ports/unix/port/ \
lwip/contrib/ports/unix/port/netif/ lwip/src/api/
Expand Down
11 changes: 10 additions & 1 deletion examples/lwip/config/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@
#define LWIP_IPV6 1
#define LWIP_IPV6_REASS 0

#define LWIP_IPV6_MLD 0
#define LWIP_ICMP6 (LWIP_IPV6==1)

/* Set to 1 if TCP support is required */
#define LWIP_TCP 0

#if LWIP_IPV4
/* Set to 1 if Multicast registration support is required for IPv4 */
#define LWIP_IGMP 0
#endif

#if LWIP_IPV6
/* Set to 1 if Multicast registration support is required for IPv6 */
#define LWIP_IPV6_MLD 0
#endif

#ifndef netif_get_index
#define netif_get_index(netif) ((u8_t)((netif)->num + 1))
#endif
Expand Down
31 changes: 31 additions & 0 deletions examples/lwip/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

#include <lwip/init.h>
#include <lwip/timeouts.h>
#if LWIP_IGMP && LWIP_IPV4
#include <lwip/igmp.h>
#endif /* LWIP_IGMP && LWIP_IPV4 */
#if LWIP_IPV6_MLD && LWIP_IPV6
#include <lwip/mld6.h>
#endif /* LWIP_IPV6_MLD && LWIP_IPV6 */

#include <netif/etharp.h>
#include <netif/tapif.h>
Expand All @@ -46,8 +52,17 @@

#if LWIP_IPV4
static ip4_addr_t ipaddr, netmask, gw;
#if LWIP_IGMP
static ip4_addr_t v4group;
#endif /* LWIP_IGMP */
#endif /* LWIP_IPV4 */

#if LWIP_IPV6
#if LWIP_IPV6_MLD
static ip6_addr_t v6group;
#endif /* LWIP_IPV6_MLD */
#endif /* LWIP_IPV6 */

static int quit = 0;

void
Expand Down Expand Up @@ -100,7 +115,13 @@ main(int argc, char **argv) {
IP4_ADDR(&gw, 192,168,113,1);
IP4_ADDR(&ipaddr, 192,168,113,2);
IP4_ADDR(&netmask, 255,255,255,0);
#if LWIP_IGMP
IP4_ADDR(&v4group, 224,0,1,187);
#endif /* LWIP_IGMP */
#endif /* LWIP_IPV4 */
#if LWIP_IPV6_MLD
IP6_ADDR(&v6group, PP_HTONL(0xff020000),0,0,PP_HTONL(0xfd));
#endif /* LWIP_IPV6_MLD */

#if NO_SYS
lwip_init();
Expand All @@ -120,6 +141,11 @@ main(int argc, char **argv) {
netif_set_up(&netif);
#if LWIP_IPV4
printf("IP4 %s\n", ip4addr_ntoa(ip_2_ip4(&netif.ip_addr)));
#if LWIP_IGMP
if (igmp_joingroup_netif(&netif, &v4group) == ERR_OK) {
printf("mIP4 %s\n", ip4addr_ntoa(&v4group));
}
#endif /* LWIP_IGMP */
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
netif_create_ip6_linklocal_address(&netif, 1);
Expand All @@ -128,6 +154,11 @@ main(int argc, char **argv) {
#else /* ! LWIP_IPV4 */
printf("IP6 [%s]\n", ip6addr_ntoa(&netif.ip6_addr[0].addr));
#endif /* ! LWIP_IPV4 */
#if LWIP_IPV6_MLD
if (mld6_joingroup_netif(&netif, &v6group) == ERR_OK) {
printf("mIP6 [%s]\n", ip6addr_ntoa(&v6group));
}
#endif /* LWIP_IPV6_MLD */
#endif /* LWIP_IPV6 */

/* start applications here */
Expand Down

0 comments on commit ae16290

Please sign in to comment.