⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 igmp_router.cpp~

📁 igmp for switch in vxworks
💻 CPP~
📖 第 1 页 / 共 4 页
字号:
/***************************************************
函数名称:RouterProcessGroupV1HostPresentTimeOutEvent
函数功能:处理GroupV1HostPresent定时器超时事件
输入参数:IgmpGroup 指向组播组的指针
返回值:	 无
***************************************************/
void RouterProcessGroupV1HostPresentTimeOutEvent (GroupEntity * IgmpGroup)
{
	if (!FindIgmpGroupFromList (IgmpGroup))
	{
		if (bIgmpDebug)
		{
			printf ("GroupV1HostPresentTimeOut ERROR:Group Not Found!\n");
		}
		return;
	}
	IgmpGroup->bGroupV1HostPresentFlag = FALSE;
	IgmpGroup->tGroupV1HostPresentTimer = 0;
}

/***************************************************
函数名称:RouterProcessGroupPortV2MembershipTimeOutEvent
函数功能:处理GroupPortV2Membership定时器超时事件
输入参数:IgmpGroup 指向组播组的指针
		 usPort 端口号
返回值:	 无
***************************************************/
void RouterProcessGroupPortV2MembershipTimeOutEvent (GroupEntity * IgmpGroup,
	USHORT usPort)
{
	int i, j;
	if (!FindIgmpGroupFromList (IgmpGroup))
	{
		if (bIgmpDebug)
		{
			printf ("PortV2MembershipTimeOut ERROR:Group Not Found!\n");
		}
		return;
	}
	DelPortFromGroup1(IgmpGroup->unGroupAddress, usPort);
	IgmpGroup->tGroupPortV1HostTimer[usPort] = 0;
	IgmpGroup->tGroupPortLastMemberQueryTimer[usPort] = 0;
	IgmpGroup->tHostReportDelayTimer = 0;
	IgmpGroup->tGroupPortV1HostTimer[usPort] = 0;
	IgmpGroup->tGroupPortV2MembershipTimer[usPort] = 0;
	IgmpGroup->eGroupPortStatus[usPort] = NoMembersPresent;
	DelPortFromSearchGroup(IgmpGroup, usPort);
	IgmpGroup->usGroupUserNumber--;
	usCurrentUser--;
	if (IgmpGroup->usGroupUserNumber == 0)
	{
		DelGroup (IgmpGroup->unGroupAddress); /*先通知底层 */
		SpecificGroupSendLeaveGroup (IgmpGroup->unGroupAddress);
		/*printf("最后成员,开始删除组播组\n");*/
		/*DeleteSpecificIgmpGroup (IgmpGroup);*/
		IgmpGroup->tGroupV1HostPresentTimer = 0;
		IgmpGroup->unGroupAddress = 0;
	}

	return;
}

/***************************************************
函数名称:StartOtherQuerierPresentTimer
函数功能:启动OtherQuerierPresent定时器
输入参数:无
返回值:	 无
***************************************************/
void StartOtherQuerierPresentTimer (void)
{
	TimerEntity *TimeOut;

	if (tOtherQuerierPresentTimer != 0)
	{
              nos_deltimer(tOtherQuerierPresentTimer);  /*mod by aibin */
		/*TimeOut = (TimerEntity *) StopTimer (tOtherQuerierPresentTimer);*/
	}
	else
	{
              TimeOut = (TimerEntity *) malloc (sizeof (TimerEntity));
		/*TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));*/
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		memset(TimeOut,0,sizeof (TimerEntity));
		TimeOut->TimerType = OtherQuerierPresentTimeOutEvent;
		TimeOut->IgmpGroup = NULL;
		usCurrentTimer++;
	}
	tOtherQuerierPresentTimer =
		nos_timerout((long)usOtherQuerierPresentInterval * 1000, (long)ProcessIgmpTimerEvent, (char *) TimeOut);/*替换定时器aibin *?
		/*StartTimer ((UINT) usOtherQuerierPresentInterval * 1000,*/
		/*(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERONESHOT);*/

}

/***************************************************
函数名称:StopOtherQuerierPresentTimer
函数功能:停止OtherQuerierPresent定时器
输入参数:无
返回值:	 无
***************************************************/
void StopOtherQuerierPresentTimer (void)
{
	/*TimerEntity *TimeOut;*/

	if (tOtherQuerierPresentTimer != 0)
	{  
	       nos_deltimer(tOtherQuerierPresentTimer);  /*mod by aibin */ 
		/*TimeOut = (TimerEntity *) StopTimer (tOtherQuerierPresentTimer);*/
              /*free (TimeOut);	*/
		/*CustomFree ((void *) TimeOut);*/
		usCurrentTimer--;
	}
	tOtherQuerierPresentTimer = 0;
}

/***************************************************
函数名称:StartStartupQueryTimer
函数功能:启动StartupQuery定时器
输入参数:无
返回值:	 无
***************************************************/
void StartStartupQueryTimer (void)
{
	TimerEntity *TimeOut;

	if (tStartupQueryTimer != 0)
	{
		nos_deltimer(tStartupQueryTimer);
	}
	else
	{
              TimeOut = (TimerEntity *) malloc (sizeof (TimerEntity));
		/*TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));*/
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		memset(TimeOut,0,sizeof (TimerEntity));
		usCurrentTimer++;
		TimeOut->TimerType = StartupQueryTimeOutEvent;
		TimeOut->IgmpGroup = NULL;
	}
	tStartupQueryTimer =
		nos_timerout((long)usStartupQueryInterval * 1000, (long)ProcessIgmpTimerEvent, (char *) TimeOut); /*替换定时器aibin*/
		/*StartTimer ((UINT) usStartupQueryInterval * 1000,*/
		/*(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERONESHOT);*/
}

/***************************************************
函数名称:StopStartupQueryTimer
函数功能:停止StartupQuery定时器
输入参数:无
返回值:	 无
***************************************************/
void StopStartupQueryTimer (void)
{
	/*TimerEntity *TimeOut;*/

	if (tStartupQueryTimer != 0)
	{       
	       nos_deltimer(tStartupQueryTimer);  /*mod by aibin */
		/*TimeOut = (TimerEntity *) StopTimer (tStartupQueryTimer);*/
		/*free (TimeOut);*/
		/*CustomFree ((void *) TimeOut);*/
		usCurrentTimer--;
	}
	tStartupQueryTimer = 0;
}

/***************************************************
函数名称:StartGeneralQueryTimer
函数功能:启动GeneralQuery定时器
输入参数:无
返回值:	 无
***************************************************/
void StartGeneralQueryTimer (void)
{
	TimerEntity *TimeOut;

	if(tStartupQueryTimer != 0)
	{
		return;
	}

	/*if (tGeneralQueryTimer != 0)                  在调用此定时器的函数内判断2005-01-21 aibin */
	/*{
	/*	/*TimeOut = (TimerEntity *) StopTimer (tGeneralQueryTimer);*/
	/*	unGeneralQueryTimerCount = 0;
	/*	return;
	/*}                                                                                                            */
	/*else
	/*{                                                                                            */
	       TimeOut = (TimerEntity *) malloc (sizeof (TimerEntity));
		/*TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));*/
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		memset(TimeOut,0,sizeof (TimerEntity));
		usCurrentTimer++;
		TimeOut->TimerType = GeneralQueryTimeOutEvent;
		TimeOut->IgmpGroup = NULL;
		tGeneralQueryTimer =     
		nos_timerout((long)1000, (long)ProcessIgmpTimerEvent, (char *) TimeOut); /*1000 change to 5000 替换定时器2005-2-18 aibin*/
		/*nos_timerout_every(1000, ProcessIgmpTimerEvent, (char *) TimeOut); /*替换定时器 aibin*/
		/*StartTimer (1000,(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERFOREVER);*/
}

/***************************************************
函数名称:StopGeneralQueryTimer
函数功能:停止GeneralQuery定时器
输入参数:无
返回值:	 无
***************************************************/
void StopGeneralQueryTimer (void)
{
	/*TimerEntity *TimeOut;*/

	if (tGeneralQueryTimer != 0)
	{
              nos_deltimer(tGeneralQueryTimer);  /*mod by aibin */  
		/*TimeOut = (TimerEntity *) StopTimer (tGeneralQueryTimer);*/
		/*free (TimeOut);*/		
		/*CustomFree ((void *) TimeOut);*/
		usCurrentTimer--;
	}
	tGeneralQueryTimer = 0;
}

/***************************************************
函数名称:StartGroupV1HostPresentTimer
函数功能:启动GroupV1HostPresent定时器
输入参数:IgmpGroup 指向组播组的指针
返回值:	 无
***************************************************/
void StartGroupV1HostPresentTimer (GroupEntity * IgmpGroup)
{
	IgmpGroup->tGroupV1HostPresentTimer = usGroupMembershipInterval * TIMER_RATE;
	
	#if 0
	TimerEntity *TimeOut;

	if (IgmpGroup->tGroupV1HostPresentTimer != 0)
	{
		TimeOut =
			(TimerEntity *) StopTimer (IgmpGroup->tGroupV1HostPresentTimer);
	}
	else
	{
		TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		usCurrentTimer++;
	}
	TimeOut->TimerType = GroupV1HostPresentTimeOutEvent;
	TimeOut->IgmpGroup = IgmpGroup;
	IgmpGroup->tGroupV1HostPresentTimer =
		StartTimer ((UINT) usGroupMembershipInterval * 1000,
		(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERONESHOT);
	#endif
}

/***************************************************
函数名称:StopGroupV1HostPresentTimer
函数功能:停止GroupV1HostPresent定时器
输入参数:unTimerID 定时器ID号
返回值:	 无
***************************************************/
void StopGroupV1HostPresentTimer (GroupEntity * IgmpGroup)
{
	IgmpGroup->tGroupV1HostPresentTimer = 0;
	
	#if 0
	TimerEntity *TimeOut;

	if (unTimerID != 0)
	{
		TimeOut = (TimerEntity *) StopTimer (unTimerID);
		CustomFree ((void *) TimeOut);
		usCurrentTimer--;
	}
	#endif
}

/***************************************************
函数名称:StartGroupPortV1HostTimer
函数功能:启动GroupPortV1Host定时器
输入参数:IgmpGroup 指向组播组的指针
		 usPort 端口号
返回值:	 无
***************************************************/
void StartGroupPortV1HostTimer (GroupEntity * IgmpGroup, USHORT usPort)
{
	IgmpGroup->tGroupPortV1HostTimer[usPort] = usGroupMembershipInterval * TIMER_RATE;

	
	#if 0
	TimerEntity *TimeOut;

	if (IgmpGroup->tGroupPortV1HostTimer[usPort] != 0)
	{
		TimeOut =
			(TimerEntity *) StopTimer (IgmpGroup->
			tGroupPortV1HostTimer[usPort]);
	}
	else
	{
		TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		usCurrentTimer++;
	}
	TimeOut->TimerType = GroupPortV1HostTimeOutEvent;
	TimeOut->IgmpGroup = IgmpGroup;
	TimeOut->usPort = usPort;
	IgmpGroup->tGroupPortV1HostTimer[usPort] =
		StartTimer ((UINT) usGroupMembershipInterval * 1000,
		(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERONESHOT);
	#endif
}

/***************************************************
函数名称:StopGroupPortV1HostTimer
函数功能:停止GroupPortV1Host定时器
输入参数:unTimerID 定时器ID号
返回值:	 无
***************************************************/
void StopGroupPortV1HostTimer (GroupEntity * IgmpGroup, USHORT usPort)
{
	IgmpGroup->tGroupPortV1HostTimer[usPort] = 0;

	#if 0
	TimerEntity *TimeOut;

	if (unTimerID != 0)
	{
		TimeOut = (TimerEntity *) StopTimer (unTimerID);
		CustomFree ((void *) TimeOut);
		usCurrentTimer--;
	}
	#endif

}

/***************************************************
函数名称:StartGroupPortV2MembershipTimer
函数功能:启动GroupPortV2Membership定时器
输入参数:IgmpGroup 指向组播组的指针
		 usPort 端口号
返回值:	 无
***************************************************/
void StartGroupPortV2MembershipTimer (GroupEntity * IgmpGroup, USHORT usPort)
{
	IgmpGroup->tGroupPortV2MembershipTimer[usPort] = 0;
	
	#if 0
	TimerEntity *TimeOut;

	if (IgmpGroup->tGroupPortV2MembershipTimer[usPort] != 0)
	{
		TimeOut =
			(TimerEntity *) StopTimer (IgmpGroup->
			tGroupPortV2MembershipTimer[usPort]);
	}
	else
	{
		TimeOut = (TimerEntity *) CustomMalloc (sizeof (TimerEntity));
		if (TimeOut == NULL)
		{
			if (bIgmpDebug)
			{
				printf ("Malloc Timer ERROR!\n");
			}
			return;
		}
		usCurrentTimer++;
	}
	TimeOut->TimerType = GroupPortV2MembershipTimeOutEvent;
	TimeOut->IgmpGroup = IgmpGroup;
	TimeOut->usPort = usPort;
	IgmpGroup->tGroupPortV2MembershipTimer[usPort] =
		StartTimer ((UINT) usGroupMembershipInterval * 1000,
		(TIMERFUNC) ProcessIgmpTimerEvent, (ULONG) TimeOut, TIMERONESHOT);
	#endif
}

/***************************************************
函数名称:StopGroupPortV2MembershipTimer
函数功能:停止GroupPortV2Membership定时器
输入参数:unTimerID 定时器ID号
返回值:	 无
***************************************************/
void StopGroupPortV2MembershipTimer (GroupEntity * IgmpGroup, USHORT usPort)
{
	IgmpGroup->tGroupPortV2MembershipTimer[usPort] = 0;
	
	#if 0
	TimerEntity *TimeOut;

	if (unTimerID != 0)
	{
		TimeOut = (TimerEntity *) StopTimer (unTimerID);
		CustomFree ((void *) TimeOut);
		usCurrentTimer--;
	}
	#endif
}

/***************************************************
函数名称:StartGroupPortLastMemberQueryTimer
函数功能:启动GroupPortLastMemberQuery定时器
输入参数:IgmpGroup 指向组播组的指针
		 usPort 端口号
返回值:	 无
***************************************************/
void StartGroupPortLastMemberQueryTimer (GroupEntity * IgmpGroup, USHORT usPort)
{
	int leavedelaytime;
	leavedelaytime = GetLeaveDelay (IgmpGroup->unGroupAddress);
	if (leavedelaytime)
	{
		IgmpGroup->tGroupPortLastMemberQueryTimer[usPort] = leavedelaytime * TIMER_RATE/usLastMemberQueryInterval;
	}
	else
	{
		IgmpGroup->tGroupPortLastMemberQueryTimer[usPort] = usLastMemberQueryInterval * TIMER_RATE;
	}
	#if 0
	TimerEntity *TimeOut;

	if (IgmpGroup->tGroupPortLastMemberQueryTimer[usPort] != 0)
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -