-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multicast: add multicast_iface for IPv6 multicast (#51)
- Loading branch information
1 parent
243e870
commit 5ff0759
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
* Copyright (C) 2021 Commend.com - [email protected] | ||
*/ | ||
|
||
#include <net/if.h> | ||
#undef LIST_INIT | ||
#undef LIST_FOREACH | ||
|
||
#include <re.h> | ||
#include <baresip.h> | ||
|
||
|
@@ -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); | ||
|