FreeBSD/sys/netinet/in_mcast.c
/*
 * Find an IPv4 multicast group entry for this ip_moptions instance
 * which matches the specified group, and optionally an interface.
 * Return its index into the array, or -1 if not found.
 */
Find an IPv4 multicast group entry for this ip_moptions instance
which matches the specified group, and optionally an interface.
Return its index into the array, or -1 if not found.
Find an IPv4 multicast group entry for this ip_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
imo_match_group(const struct ip_moptions *imo, const struct ifnet *ifp,
    const struct sockaddr *group)
{
	const struct sockaddr_in *gsin;
	struct in_multi	**pinm;
	int		  idx;
	int		  nmships;
	gsin = (const struct sockaddr_in *)group;
	if (imo->imo_membership == NULL || imo->imo_num_memberships == 0)
		return (-1);
	nmships = imo->imo_num_memberships;
	pinm = &imo->imo_membership[0];
	for (idx = 0; idx < nmships; idx++, pinm++) {
		if (*pinm == NULL)
			continue;
		if ((ifp == NULL || ((*pinm)->inm_ifp == ifp)) &&
		    in_hosteq((*pinm)->inm_addr, gsin->sin_addr)) {
			break;
		}
	}
	if (idx >= nmships)
		idx = -1;
	return (idx);
}
static size_t imo_match_group ( const struct ip_moptions * imo , const struct ifnet * ifp , const struct sockaddr * group ) { const struct sockaddr_in * gsin ; struct in_multi * * pinm ; int idx ; int nmships ; gsin = ( const struct sockaddr_in * ) group ; if ( imo -> imo_membership == NULL || imo -> imo_num_memberships == 0 ) return ( -1 ) ; nmships = imo -> imo_num_memberships ; pinm = & imo -> imo_membership [ 0 ] ; for ( idx = 0 ; idx < nmships ; idx ++ , pinm ++ ) { if ( * pinm == NULL ) continue ; if ( ( ifp == NULL || ( ( * pinm ) -> inm_ifp == ifp ) ) && in_hosteq ( ( * pinm ) -> inm_addr , gsin -> sin_addr ) ) { break ; } } if ( idx >= nmships ) idx = -1 ; return ( idx ) ; }
Find an IPv4 multicast group entry for this ip_moptions instance
 which matches the specified group, and optionally an interface.
Find an IPv4 multicast group entry for this ip_moptions instance which matches the specified group and optionally an interface .
/* The imo_membership array may be lazy allocated. */