Skip to content
Permalink
Browse files

udp: fix uv__udp_set_source_membership6

Use the correct socket options: `MCAST_JOIN_SOURCE_GROUP` and
`MCAST_LEAVE_SOURCE_GROUP`.
Set mreq.gsr_interface = 0 if iface_addr = NULL.

PR-URL: #2202
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
  • Loading branch information...
santigimeno committed Feb 21, 2019
1 parent 9efc196 commit f91702a470ffc12af2f8d0c4a5b806f5c6907049
Showing with 8 additions and 4 deletions.
  1. +4 −2 src/unix/udp.c
  2. +4 −2 src/win/udp.c
@@ -725,15 +725,17 @@ static int uv__udp_set_source_membership6(uv_udp_t* handle,
if (err)
return err;
mreq.gsr_interface = addr6.sin6_scope_id;
} else {
mreq.gsr_interface = 0;
}

memcpy(&mreq.gsr_group, multicast_addr, sizeof(mreq.gsr_group));
memcpy(&mreq.gsr_source, source_addr, sizeof(mreq.gsr_source));

if (membership == UV_JOIN_GROUP)
optname = IP_ADD_SOURCE_MEMBERSHIP;
optname = MCAST_JOIN_SOURCE_GROUP;
else if (membership == UV_LEAVE_GROUP)
optname = IP_DROP_SOURCE_MEMBERSHIP;
optname = MCAST_LEAVE_SOURCE_GROUP;
else
return UV_EINVAL;

@@ -782,15 +782,17 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
if (err)
return err;
mreq.gsr_interface = addr6.sin6_scope_id;
} else {
mreq.gsr_interface = 0;
}

memcpy(&mreq.gsr_group, multicast_addr, sizeof(mreq.gsr_group));
memcpy(&mreq.gsr_source, source_addr, sizeof(mreq.gsr_source));

if (membership == UV_JOIN_GROUP)
optname = IP_ADD_SOURCE_MEMBERSHIP;
optname = MCAST_JOIN_SOURCE_GROUP;
else if (membership == UV_LEAVE_GROUP)
optname = IP_DROP_SOURCE_MEMBERSHIP;
optname = MCAST_LEAVE_SOURCE_GROUP;
else
return UV_EINVAL;

2 comments on commit f91702a

@Simn

This comment has been minimized.

Copy link

replied Sep 17, 2019

I had to reverse the win/udp.c change when cross-compiling from cygwin through mingw64-x86_64 because the MCAST_JOIN_SOURCE_GROUP and MCAST_LEAVE_SOURCE_GROUP defines are unknown. Any pointers as to where these are supposed to come from?

@saghul

This comment has been minimized.

Copy link
Member

replied Sep 18, 2019

Check #2461

Please sign in to comment.
You can’t perform that action at this time.