From 5555a2f02931b6f0fe3d99e960b47efdafc2a41c Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 30 Dec 2011 10:19:21 +0100 Subject: [PATCH] udp: Use the IP_ADD_MEMBERSHIP socket option. For some reason, MCAST_JOIN_GROUP is not working under uClinux. We can just stick with the more traditional method. Signed-off-by: Richard Cochran --- udp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/udp.c b/udp.c index ee31ba5..ad3ba33 100644 --- a/udp.c +++ b/udp.c @@ -143,15 +143,15 @@ static int mcast_join(int fd, int index, const struct sockaddr *grp, socklen_t grplen) { int err; - struct group_req req; - req.gr_interface = index; - if (grplen > sizeof(req.gr_group)) { - return -1; - } - memcpy(&req.gr_group, grp, grplen); - err = setsockopt(fd, IPPROTO_IP, MCAST_JOIN_GROUP, &req, sizeof(req)); + struct ip_mreqn req; + struct sockaddr_in *sa = (struct sockaddr_in *) grp; + + memset(&req, 0, sizeof(req)); + memcpy(&req.imr_multiaddr, &sa->sin_addr, sizeof(struct in_addr)); + req.imr_ifindex = index; + err = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &req, sizeof(req)); if (err) { - pr_err("setsockopt MCAST_JOIN_GROUP failed: %m"); + pr_err("setsockopt IP_ADD_MEMBERSHIP failed: %m"); return -1; } return 0;