FreeBSD/sys/netinet6/in6_mcast.c
/*
 * Select the interface for transmitting IPv6 multicast datagrams.
 *
 * Either an instance of struct in6_addr or an instance of struct ipv6_mreqn
 * may be passed to this socket option. An address of in6addr_any or an
 * interface index of 0 is used to remove a previous selection.
 * When no interface is selected, one is chosen for every send.
 */
Select the interface for transmitting IPv6 multicast datagrams.
Either an instance of struct in6_addr or an instance of struct ipv6_mreqn
may be passed to this socket option. An address of in6addr_any or an
interface index of 0 is used to remove a previous selection.
When no interface is selected, one is chosen for every send.
Select the interface for transmitting IPv6 multicast datagrams . Either an instance of struct in6_addr or an instance of struct ipv6_mreqn may be passed to this socket option . An address of in6addr_any or an interface index of 0 is used to remove a previous selection . When no interface is selected one is chosen for every send .
static int
in6p_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
{
	struct ifnet		*ifp;
	struct ip6_moptions	*imo;
	u_int			 ifindex;
	int			 error;
	if (sopt->sopt_valsize != sizeof(u_int))
		return (EINVAL);
	error = sooptcopyin(sopt, &ifindex, sizeof(u_int), sizeof(u_int));
	if (error)
		return (error);
	if (V_if_index < ifindex)
		return (EINVAL);
	if (ifindex == 0)
		ifp = NULL;
	else {
		ifp = ifnet_byindex(ifindex);
		if (ifp == NULL)
			return (EINVAL);
		if ((ifp->if_flags & IFF_MULTICAST) == 0)
			return (EADDRNOTAVAIL);
	}
	imo = in6p_findmoptions(inp);
	imo->im6o_multicast_ifp = ifp;
	INP_WUNLOCK(inp);
	return (0);
}
static int in6p_set_multicast_if ( struct inpcb * inp , struct sockopt * sopt ) { struct ifnet * ifp ; struct ip6_moptions * imo ; u_int ifindex ; int error ; if ( sopt -> sopt_valsize != sizeof ( u_int ) ) return ( EINVAL ) ; error = sooptcopyin ( sopt , & ifindex , sizeof ( u_int ) , sizeof ( u_int ) ) ; if ( error ) return ( error ) ; if ( V_if_index < ifindex ) return ( EINVAL ) ; if ( ifindex == 0 ) ifp = NULL ; else { ifp = ifnet_byindex ( ifindex ) ; if ( ifp == NULL ) return ( EINVAL ) ; if ( ( ifp -> if_flags & IFF_MULTICAST ) == 0 ) return ( EADDRNOTAVAIL ) ; } imo = in6p_findmoptions ( inp ) ; imo -> im6o_multicast_ifp = ifp ; INP_WUNLOCK ( inp ) ; return ( 0 ) ; }
Select the interface for transmitting IPv6 multicast datagrams.
Select the interface for transmitting IPv6 multicast datagrams .