Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicast: add multicast_iface for IPv6 multicast #51

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/examples/config
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions modules/multicast/multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* Copyright (C) 2021 Commend.com - c.huber@commend.com
*/

#include <net/if.h>
#undef LIST_INIT
#undef LIST_FOREACH

#include <re.h>
#include <baresip.h>

Expand All @@ -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,
""
};


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
Loading