コード例 #1
0
ファイル: rttable.c プロジェクト: springware/92u10
/**
*   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;
}
コード例 #2
0
ファイル: igmpv3.c プロジェクト: wingedboar/rtl819x-toolchain
int igmp_add_mr( __u32 group, __u32 src, int enable )
{
	struct MRouteDesc	mrd;
        int idx ;
	/* add multicast routing entry */
	//mrd.OriginAdr.s_addr = src;
	mrd.SubsAdr.s_addr = 0;
	mrd.McAdr.s_addr = group;

	
	memset(mrd.TtlVc, 0, sizeof(mrd.TtlVc));
	mrd.TtlVc[igmp_down_if_idx] = enable;	

	IGMPV3LOG( "%s> group:%s", __FUNCTION__, inet_ntoa(mrd.McAdr) );
	IGMPV3LOG( ", src:%s, enable:%d\n", inet_ntoa(src), enable );
	for(idx=0;idx<igmp_up_if_num;idx++)
	{    
		mrd.InVif = igmp_up_if_idx[idx];
		if (src)
			mrd.OriginAdr.s_addr = src;
		else
			mrd.OriginAdr.s_addr =igmp_up_if_idx[idx];
		addMRoute(&mrd);
	}
	return (1);
}
コード例 #3
0
ファイル: rttable.c プロジェクト: ViToni/igmpproxy
/**
*   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;
}
コード例 #4
0
ファイル: igmpv3.c プロジェクト: wingedboar/rtl819x-toolchain
int igmp_add_mr( __u32 group, __u32 src, int enable )
{
	struct MRouteDesc	mrd;

	/* add 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.SubsAdr.s_addr = 0;
	mrd.McAdr.s_addr = group;

	mrd.InVif = igmp_up_if_idx;
	memset(mrd.TtlVc, 0, sizeof(mrd.TtlVc));
	mrd.TtlVc[igmp_down_if_idx] = enable;	

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

	return (addMRoute(&mrd));
}