/* Join a multicast group. the group is specified by a class D multicast address 224.0.0.0/8 in the in_addr structure passed in as a parameter.  */
static int join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
/* Join a multicast group. the group is specified by a class D multicast address 224.0.0.0/8 in the in_addr structure passed in as a parameter.  */
static int join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
{
	struct ip_mreqn mreq;
	struct net_device *dev;
	int ret;
	memset(&mreq, 0, sizeof(mreq));
	memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr));
	if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
		return -ENODEV;
	if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
		return -EINVAL;
	mreq.imr_ifindex = dev->ifindex;
	lock_sock(sk);
	ret = ip_mc_join_group(sk, &mreq);
	release_sock(sk);
	return ret;
}