Allow network interface name to be specified when joining multicast group

This change renames `coap_join_mcast_group` to `coap_join_mcast_group_intf`
and adds an extra `const char *ifname` parameter to specify the interface
name.

A `coap_join_mcast_group` macro is defined to maintain backwards API
compatibility.

`coap_is_mcast` has been modified to recognize IPv6-mapped IPv4 multicast
addresses. Without this `coap_network_send` treats these addresses as
unicast which makes `semdmsg` fail with EINVAL.

Examples have been updated to use the new call.
This commit is contained in:
Szabolcs Szekelyi authored and Jon Shallow committed 2021-03-17 17:25:31 +00:00
1 parent 1d300a6275
commit 42b2f03470
8 files changed
+106 -46

No files matched your search

+1 -1
View File
@@ -869,7 +869,7 @@ main(int argc, char **argv) {
return -1;
if (group)
coap_join_mcast_group(ctx, group);
coap_join_mcast_group_intf(ctx, group, NULL);
init_resources(ctx);
+1 -1
View File
@@ -2784,7 +2784,7 @@ main(int argc, char **argv) {
sizeof(cache_ignore_options)/sizeof(cache_ignore_options[0]));
/* join multicast group if requested at command line */
if (group)
coap_join_mcast_group(ctx, group);
coap_join_mcast_group_intf(ctx, group, NULL);
coap_fd = coap_context_get_coap_fd(ctx);
if (coap_fd != -1) {