FreeBSD/sys/netinet6/in6_mcast.c
/*
 * Find an IPv6 multicast group entry for this ip6_moptions instance
 * which matches the specified group, and optionally an interface.
 * Return its index into the array, or -1 if not found.
 */
Find an IPv6 multicast group entry for this ip6_moptions instance
which matches the specified group, and optionally an interface.
Return its index into the array, or -1 if not found.
Find an IPv6 multicast group entry for this ip6_moptions instance which matches the specified group and optionally an interface . Return its index into the array or - 1 if not found .
static size_t
im6o_match_group(const struct ip6_moptions *imo, const struct ifnet *ifp,
    const struct sockaddr *group)
{
	const struct sockaddr_in6 *gsin6;
	struct in6_multi	**pinm;
	int		  idx;
	int		  nmships;
	gsin6 = (const struct sockaddr_in6 *)group;
	if (imo->im6o_membership == NULL || imo->im6o_num_memberships == 0)
		return (-1);
	nmships = imo->im6o_num_memberships;
	pinm = &imo->im6o_membership[0];
	for (idx = 0; idx < nmships; idx++, pinm++) {
		if (*pinm == NULL)
			continue;
		if ((ifp == NULL || ((*pinm)->in6m_ifp == ifp)) &&
		    IN6_ARE_ADDR_EQUAL(&(*pinm)->in6m_addr,
		    &gsin6->sin6_addr)) {
			break;
		}
	}
	if (idx >= nmships)
		idx = -1;
	return (idx);
}
static size_t im6o_match_group ( const struct ip6_moptions * imo , const struct ifnet * ifp , const struct sockaddr * group ) { const struct sockaddr_in6 * gsin6 ; struct in6_multi * * pinm ; int idx ; int nmships ; gsin6 = ( const struct sockaddr_in6 * ) group ; if ( imo -> im6o_membership == NULL || imo -> im6o_num_memberships == 0 ) return ( -1 ) ; nmships = imo -> im6o_num_memberships ; pinm = & imo -> im6o_membership [ 0 ] ; for ( idx = 0 ; idx < nmships ; idx ++ , pinm ++ ) { if ( * pinm == NULL ) continue ; if ( ( ifp == NULL || ( ( * pinm ) -> in6m_ifp == ifp ) ) && IN6_ARE_ADDR_EQUAL ( & ( * pinm ) -> in6m_addr , & gsin6 -> sin6_addr ) ) { break ; } } if ( idx >= nmships ) idx = -1 ; return ( idx ) ; }
Find an IPv6 multicast group entry for this ip6_moptions instance
 which matches the specified group, and optionally an interface.
Find an IPv6 multicast group entry for this ip6_moptions instance which matches the specified group and optionally an interface .
/* The im6o_membership array may be lazy allocated. */