Exemple #1
0
/**
*   Updates the Kernel routing table. If activate is 1, the route
*   is (re-)activated. If activate is false, the route is removed.
*/
int internUpdateKernelRoute(struct RouteTable *route, int activate)
{
    struct   MRouteDesc     mrDesc;
    struct   IfDesc         *Dp;
    unsigned                Ix;
    struct IfDesc*      upstrIf;
    // Get the upstream VIF...
    upstrIf = getIfByIx( upStreamVif );
    
    if(upstrIf == NULL) 
        atlog(LOG_ERR, 0 ,"FATAL: Unable to get Upstream IF.");

    if( IN6_ARE_ADDR_EQUAL( &(route->group), &allzero_addr ) ) 
        return 1;

    if( IN6_ARE_ADDR_EQUAL( &(route->originAddr), &allzero_addr ) ) 
        return 1;
     
    // Build route descriptor from table entry...
    // Set the source address and group address...
    mrDesc.McAdr.sin6_addr = route->group;
    mrDesc.McAdr.sin6_family = AF_INET6;
    mrDesc.McAdr.sin6_flowinfo = 0;
    mrDesc.McAdr.sin6_port = 0;
    mrDesc.McAdr.sin6_scope_id = upstrIf->index;
    mrDesc.OriginAdr.sin6_addr = route->originAddr;

    // clear output interfaces 
    memset( mrDesc.TtlVc, 0, sizeof( mrDesc.TtlVc ) );

    IF_DEBUG atlog(LOG_DEBUG, 0, "Vif bits : 0x%08x", route->vifBits);

    for( Ix = 0 ; Ix < MAXMIFS; Ix++ ) 
    {
        Dp = getIfDescFromMifByIx(Ix);
        if (Dp == NULL)
            break;
        if ( Dp->state == IF_STATE_UPSTREAM ) 
            mrDesc.InVif = Ix;
        else if(BIT_TST(route->vifBits, Dp->index)) 
        {
            mrDesc.TtlVc[ Ix ] = Dp->threshold;
        }
    }

    // Do the actual Kernel route update...
    if(activate)
    {
        // Add route in kernel...
        addMRoute( &mrDesc );

    }
    else 
    {
        // Delete the route from Kernel...
        delMRoute( &mrDesc );
    }

    return 1;
}
int igmp_del_mr( __u32 group, __u32 src )
{
	struct MRouteDesc	mrd;
	int ret=0;

	/* delete multicast routing entry */
	if(src){
	
		mrd.OriginAdr.s_addr = src;
	}
	else{
		mrd.OriginAdr.s_addr =igmp_up_if_idx;
		
	}
	//mrd.OriginAdr.s_addr = src;
	mrd.McAdr.s_addr = group;
	mrd.InVif = igmp_up_if_idx;
	memset(mrd.TtlVc, 0, sizeof(mrd.TtlVc));

	IGMPV3LOG( "%s> group:%s", __FUNCTION__, inet_ntoa(mrd.McAdr) );
	IGMPV3LOG( ", src:%s\n", inet_ntoa(mrd.OriginAdr) );

	delMRoute(&mrd);	
	return ret;
}
Exemple #3
0
/**
*   Updates the Kernel routing table. If activate is 1, the route
*   is (re-)activated. If activate is false, the route is removed.
*/
int internUpdateKernelRoute(struct RouteTable *route, int activate) {
    struct   MRouteDesc mrDesc;
    struct   IfDesc     *Dp;
    unsigned            Ix;
    int                 i;

    for (int i = 0; i < MAX_ORIGINS; i++) {
        if (route->originAddrs[i] == 0 || route->upstrVif == -1) {
            continue;
        }

        // Build route descriptor from table entry...
        // Set the source address and group address...
        mrDesc.McAdr.s_addr     = route->group;
        mrDesc.OriginAdr.s_addr = route->originAddrs[i];

        // clear output interfaces
        memset( mrDesc.TtlVc, 0, sizeof( mrDesc.TtlVc ) );

        my_log(LOG_DEBUG, 0, "Vif bits : 0x%08x", route->vifBits);

        mrDesc.InVif = route->upstrVif;

        // Set the TTL's for the route descriptor...
        for ( Ix = 0; (Dp = getIfByIx(Ix)); Ix++ ) {
            if(Dp->state == IF_STATE_UPSTREAM) {
                continue;
            }
            else if(BIT_TST(route->vifBits, Dp->index)) {
                my_log(LOG_DEBUG, 0, "Setting TTL for Vif %d to %d", Dp->index, Dp->threshold);
                mrDesc.TtlVc[ Dp->index ] = Dp->threshold;
            }
        }

        // Do the actual Kernel route update...
        if(activate) {
            // Add route in kernel...
            addMRoute( &mrDesc );
        } else {
            // Delete the route from Kernel...
            delMRoute( &mrDesc );
        }
    }

    return 1;
}