FreeBSD/sys/netinet6/in6_mcast.c
/*
 * Look up a source filter entry for a multicast group.
 *
 * inm is the group descriptor to work with.
 * addr is the IPv6 address to look up.
 * noalloc may be non-zero to suppress allocation of sources.
 * *pims will be set to the address of the retrieved or allocated source.
 *
 * SMPng: NOTE: may be called with locks held.
 * Return 0 if successful, otherwise return a non-zero error code.
 */
Look up a source filter entry for a multicast group.
inm is the group descriptor to work with.
addr is the IPv6 address to look up.
noalloc may be non-zero to suppress allocation of sources.
*pims will be set to the address of the retrieved or allocated source.

may be called with locks held.
Return 0 if successful, otherwise return a non-zero error code.
Look up a source filter entry for a multicast group . inm is the group descriptor to work with . addr is the IPv6 address to look up . noalloc may be non - zero to suppress allocation of sources . * pims will be set to the address of the retrieved or allocated source . may be called with locks held . Return 0 if successful otherwise return a non - zero error code .
static int
in6m_get_source(struct in6_multi *inm, const struct in6_addr *addr,
    const int noalloc, struct ip6_msource **pims)
{
	struct ip6_msource	 find;
	struct ip6_msource	*ims, *nims;
#ifdef KTR
	char			 ip6tbuf[INET6_ADDRSTRLEN];
#endif
	find.im6s_addr = *addr;
	ims = RB_FIND(ip6_msource_tree, &inm->in6m_srcs, &find);
	if (ims == NULL && !noalloc) {
		if (inm->in6m_nsrc == in6_mcast_maxgrpsrc)
			return (ENOSPC);
		nims = malloc(sizeof(struct ip6_msource), M_IP6MSOURCE,
		    M_NOWAIT | M_ZERO);
		if (nims == NULL)
			return (ENOMEM);
		nims->im6s_addr = *addr;
		RB_INSERT(ip6_msource_tree, &inm->in6m_srcs, nims);
		++inm->in6m_nsrc;
		ims = nims;
		CTR3(KTR_MLD, "%s: allocated %s as %p", __func__,
		    ip6_sprintf(ip6tbuf, addr), ims);
	}
	*pims = ims;
	return (0);
}
static int in6m_get_source ( struct in6_multi * inm , const struct in6_addr * addr , const int noalloc , struct ip6_msource * * pims ) { struct ip6_msource find ; struct ip6_msource * ims , * nims ; #ifdef KTR char ip6tbuf [ INET6_ADDRSTRLEN ] ; #endif find . im6s_addr = * addr ; ims = RB_FIND ( ip6_msource_tree , & inm -> in6m_srcs , & find ) ; if ( ims == NULL && ! noalloc ) { if ( inm -> in6m_nsrc == in6_mcast_maxgrpsrc ) return ( ENOSPC ) ; nims = malloc ( sizeof ( struct ip6_msource ) , M_IP6MSOURCE , M_NOWAIT | M_ZERO ) ; if ( nims == NULL ) return ( ENOMEM ) ; nims -> im6s_addr = * addr ; RB_INSERT ( ip6_msource_tree , & inm -> in6m_srcs , nims ) ; ++ inm -> in6m_nsrc ; ims = nims ; CTR3 ( KTR_MLD , " " , __func__ , ip6_sprintf ( ip6tbuf , addr ) , ims ) ; } * pims = ims ; return ( 0 ) ; }
Look up a source filter entry for a multicast group.
Look up a source filter entry for a multicast group .