diff --git a/docs/examples/config b/docs/examples/config index 259bd7d..5061303 100644 --- a/docs/examples/config +++ b/docs/examples/config @@ -22,8 +22,10 @@ # multicast receivers (in priority order)- port number must be even #multicast_call_prio 0 #multicast_ttl 1 +#multicast_iface eth0 # needed for IPv6 multicast #multicast_jbuf_type fixed # off, fixed, adaptive #multicast_jbuf_delay 5-10 # frames #multicast_fade_time 125 # fade in/out time in [ms] #multicast_listener 224.0.2.21:50000 #multicast_listener 224.0.2.21:50002 +#multicast_listener [FF2E::42]:50004 diff --git a/modules/multicast/multicast.c b/modules/multicast/multicast.c index 7d5ce2e..8c348cd 100644 --- a/modules/multicast/multicast.c +++ b/modules/multicast/multicast.c @@ -6,6 +6,10 @@ * Copyright (C) 2021 Commend.com - c.huber@commend.com */ +#include +#undef LIST_INIT +#undef LIST_FOREACH + #include #include @@ -20,12 +24,14 @@ struct mccfg { uint32_t callprio; uint32_t ttl; uint32_t tfade; + char iface[128]; }; static struct mccfg mccfg = { 0, 1, 125, + "" }; @@ -309,6 +315,24 @@ static int cmd_mcreg(struct re_printf *pf, void *arg) goto out; } +#ifdef HAVE_GETIFADDRS + if (str_isset(mccfg.iface)) { + unsigned int if_index; + if_index = if_nametoindex(mccfg.iface); + if (!if_index) { + warning("multicast: could not find interface %s\n", + &mccfg.iface); + if (sa_af(&addr) == AF_INET6) { + err = EINVAL; + goto out; + } + } + else { + sa_set_scopeid(&addr, if_index); + } + } +#endif + err = mcreceiver_alloc(&addr, prio); out: @@ -645,6 +669,9 @@ static int module_read_config(void) if (mccfg.tfade > 2000) mccfg.tfade = 2000; + (void)conf_get_str(conf_cur(), "multicast_iface", mccfg.iface, + sizeof(mccfg.iface)); + sa_init(&laddr, AF_INET); err = conf_apply(conf_cur(), "multicast_listener", module_read_config_handler, &prio);