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

📄 mpbdlmanagement.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	/* Search the matching entry for the link in port array */		for (loopIndex = 0; loopIndex < pStackData->bundle.no_of_links; 	    														loopIndex++)		{		if (pStackData->bundle.memberLinks[loopIndex].pMemberStackObj == 																pMemberStackObj)			break;		}	if (loopIndex == pStackData->bundle.no_of_links)		return ERROR;		pLcpBundleOptions = 				pStackData->bundle.memberLinks [loopIndex].pLcpBundleOptions;	pSendingEndClass = &pStackData->bundle.sending_end;	/* if first link, construct sending end of the bundle */	if (pSendingEndClass->no_of_links == 0)		{		mp_initialize_sending_end_of_the_bundle (pMpFramingLayerState);		pSendingEndClass->remoteMRRU = pLcpBundleOptions->remoteMRRU;		pSendingEndClass->use_short_sequence_number = 				pLcpBundleOptions->use_short_sequence_number_in_tx_end;		pSendingEndClass->small_packet_length = 								pProfileData->mpFraming_smallPacketLength;		}	/* Construct link class for the link */	linkNumber = pSendingEndClass->no_of_links;	mp_initialize_sending_end_link_class (pMpFramingLayerState, linkNumber);	pSendingEndClass->links[linkNumber].pMemberStackObj = pMemberStackObj;	/* Get framework obj */	pfwObj = pfwStackObjPfwGet (pMemberStackObj);	if (pfwObj == NULL)		{		printf ("NULL Framework Reference\n");		return ERROR;		}	/* Get control layer state in the member stack */	pPluginObj = 		(PFW_PLUGIN_OBJ *) pfwPluginObjGet (pfwObj, "CONTROL_LAYER");	if (pPluginObj == NULL)		{		printf ("control layer does not exist in the framework\n");		return ERROR;		}	pState = pfwPluginObjStateGet (pMemberStackObj, pPluginObj);	if (pState == NULL)		{		printf ("control layer does not exist in the stack 0x%x\n", \						(int) pMemberStackObj);		return ERROR;		}	pSendingEndClass->links[linkNumber].pMpControlLayerState = pState;	/* Get interface layer state in the member stack */	pPluginObj = 		(PFW_PLUGIN_OBJ *) pfwPluginObjGet (pfwObj, "MP_INTERFACE_LAYER");	if (pPluginObj == NULL)		{		printf ("mpInterface layer does not exist in the framework 0x%x\n", \				 (int) pfwObj);		return ERROR;		}	pState = pfwPluginObjStateGet (pMemberStackObj, pPluginObj);	if (pState == NULL)		{		printf ("mpInterface layer layer does not exist in the stack 0x%x\n",  \				(int) pMemberStackObj);		return ERROR;		}	pSendingEndClass->links[linkNumber].pMpInterfaceLayerState = pState;	pSendingEndClass->links[linkNumber].remoteMru = 								pLcpBundleOptions->remoteMRU; 	pSendingEndClass->no_of_links++;	pSendingEndClass->aggregateMru += 		pSendingEndClass->links[linkNumber].remoteMru;	pSendingEndClass->total_bandwidth += 				pStackData->bundle.memberLinks[loopIndex].speed;	status = mp_bundle_sending_end_update_bandwidth_share_information 								(pMpFramingLayerState);	if (status == ERROR)		return ERROR;	status = mp_bundle_sending_end_update_mru_share_information 								(pMpFramingLayerState);	if (status == ERROR)		{		printf ("mru_share calculation failed\n");		return ERROR;		}	return OK;	}/******************************************************************************** mp_bundle_sending_end_update_bandwidth_share_information - *						Updates the bandwidth share of each link in the bundle** This functions calculates the percentage of the total BW available in the * sending end of the bundle provided by each member link 				* * RETURNS: OK or ERROR*/STATUS mp_bundle_sending_end_update_bandwidth_share_information 	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState							/* mpFraming layer state representing the bundle */	)	{	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	UINT 							loopIndex = 0;	USHORT 							linkNumber = 0;	MP_BUNDLE_SENDING_END_CLASS		*pSendingEndClass = NULL;	BYTE							total_percentage_so_far = 0;	if (pMpFramingLayerState == NULL)		return ERROR;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pSendingEndClass = &pStackData->bundle.sending_end;	for (linkNumber = 0; linkNumber < pSendingEndClass->no_of_links;		 linkNumber++)		{		/* Search the matching entry for the link in port array */			for (loopIndex = 0; loopIndex < pStackData->bundle.no_of_links;     														loopIndex++)			{			if (pStackData->bundle.memberLinks[loopIndex].pMemberStackObj == 							pSendingEndClass->links[linkNumber].pMemberStackObj)			break;			}		if (loopIndex == pStackData->bundle.no_of_links)			return ERROR;			/* Calculate BW share information for the link */#if defined (__FLOATING_POINT_LIBRARY_AVAILABLE__)		pSendingEndClass->bandwidth_share [linkNumber] = 				(pStackData->bundle.memberLinks [loopIndex].speed / 				pSendingEndClass->total_bandwidth);#else		if ((linkNumber != (pSendingEndClass->no_of_links - 1)) && 			(pSendingEndClass->total_bandwidth != 0))			{			pSendingEndClass->bandwidth_share [linkNumber] = 					(pStackData->bundle.memberLinks [loopIndex].speed * 100/ 	 	  			 pSendingEndClass->total_bandwidth);				total_percentage_so_far += 					 (BYTE) pSendingEndClass->bandwidth_share [linkNumber];			}		else			pSendingEndClass->bandwidth_share [linkNumber] = 										(BYTE) (100 - total_percentage_so_far);#endif				}	return OK;		}/******************************************************************************** mp_bundle_sending_end_update_mru_share_information - *						Updates the remote MRU share of each link in the bundle** This functions calculates the percentage of the aggregate MRU available in the * sending end of the bundle provided by each member link 				* * RETURNS: OK or ERROR*/STATUS mp_bundle_sending_end_update_mru_share_information 	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState							/* mpFraming layer state representing the bundle */	)	{	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	USHORT 							linkNumber = 0;	MP_BUNDLE_SENDING_END_CLASS		*pSendingEndClass = NULL;	BYTE							total_percentage_so_far = 0;	if (pMpFramingLayerState == NULL)		return ERROR;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pSendingEndClass = &pStackData->bundle.sending_end;	for (linkNumber = 0; linkNumber < pSendingEndClass->no_of_links;		 linkNumber++)		{		/* Calculate BW share information for the link */#if defined (__FLOATING_POINT_LIBRARY_AVAILABLE__)		pSendingEndClass->mru_share [linkNumber] = 				pSendingEndClass->links[linkNumber].remoteMru / 				pSendingEndClass->aggregateMru);#else		if ((linkNumber != (pSendingEndClass->no_of_links - 1)) && 			(pSendingEndClass->aggregateMru != 0))			{			pSendingEndClass->mru_share [linkNumber] = 					(pSendingEndClass->links[linkNumber].remoteMru * 100/ 	 	  			 pSendingEndClass->aggregateMru);				total_percentage_so_far += 					 (BYTE) pSendingEndClass->mru_share [linkNumber];			}		else			pSendingEndClass->mru_share [linkNumber] = 										(BYTE) (100 - total_percentage_so_far);#endif				}	return OK;		}/******************************************************************************** mp_initialize_sending_end_of_the_bundle - *						Initializes sending end of the class** This functions clears the sending end class of the given bundle* * RETURNS: N/A*/void mp_initialize_sending_end_of_the_bundle	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState							/* mpFraming layer state representing the bundle */	)	{	MP_BUNDLE_SENDING_END_CLASS		*pSendingEndClass = NULL;	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	if (pMpFramingLayerState == NULL)		return;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pSendingEndClass = &(pStackData->bundle.sending_end);	/* Clear the sending end class of the bundle */	bzero ((void *)pSendingEndClass, sizeof (MP_BUNDLE_SENDING_END_CLASS));	}/******************************************************************************** mp_initialize_sending_end_link_class - *						Initializes sending end link class of the given link** This functions clears the sending end link class of the given link* * RETURNS: N/A*/LOCAL void mp_initialize_sending_end_link_class	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState,							/* mpFraming layer state representing the bundle */	USHORT					linkNumber /* link number in the sending end */	)	{	MP_BUNDLE_SENDING_END_CLASS		*pSendingEndClass = NULL;	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	if (pMpFramingLayerState == NULL)		return;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pSendingEndClass = &(pStackData->bundle.sending_end);	/* Clear the sending end class of the bundle */	bzero ((void *)&pSendingEndClass->links[linkNumber], 				sizeof (MP_BUNDLE_SENDING_END_LINK_CLASS));	}/******************************************************************************** mp_construct_receiving_end_of_the_bundle - *						Constructs or updates the receiving end of the bundle** This function constructs the receiving end link class for the given link. If * the given link is the first link in the receiving end of the bundle, it * initializes the receiving end class of the bundle and configures the receiving * end parameters like local MRRU, MP header format etc. with the values * negotiated for the receiving end on the link. It times the link by sending echo* request packet on the link through LCP_MP_TIME_LINK_INTERFACE. When the LCP in * the member stack receives echo reply, it raises the ECHO_RECEIVED event which * MP_FRAMING_LAYER component subscribes for. In this event handler, it times the * link 				* * RETURNS: OK or ERROR*/LOCAL STATUS mp_construct_receiving_end_of_the_bundle	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState,							/* mpFraming layer state representing the bundle */	PFW_STACK_OBJ			*pMemberStackObj /*stack obj representing the link*/	)	{	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	UINT 							loopIndex = 0;	LCP_BUNDLE_OPTIONS				*pLcpBundleOptions = NULL;	USHORT 							linkNumber = 0;	PFW_OBJ							*pfwObj = NULL;	PFW_PLUGIN_OBJ_STATE			*pMemberLcpState = NULL;	PFW_PLUGIN_OBJ					*pPluginObj = NULL;	MP_BUNDLE_RECEIVING_END_CLASS	*pReceivingEndClass = NULL;	if ((pMpFramingLayerState == NULL) || (pMemberStackObj == NULL))		return ERROR;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	/* Search the matching entry for the link in port array */		for (loopIndex = 0; loopIndex < pStackData->bundle.no_of_links;     														loopIndex++)		{		if (pStackData->bundle.memberLinks[loopIndex].pMemberStackObj == 																pMemberStackObj)			break;		}	if (loopIndex == pStackData->bundle.no_of_links)		return ERROR;		pLcpBundleOptions = 				pStackData->bundle.memberLinks [loopIndex].pLcpBundleOptions;	pReceivingEndClass = &pStackData->bundle.receiving_end;	/* 	 * if first link in the receiving end, construct receiving end of the 	 * bundle 	 */	if (pReceivingEndClass->no_of_links == 0)		{		mp_initialize_receiving_end_of_the_bundle (pMpFramingLayerState);		pReceivingEndClass->localMRRU = pLcpBundleOptions->localMRRU;		pReceivingEndClass->use_short_sequence_number = 				pLcpBundleOptions->use_short_sequence_number_in_rx_end;		}	/* Construct link class for the link */	linkNumber = pReceivingEndClass->no_of_links;	mp_initialize_receiving_end_link_class (pMpFramingLayerState, linkNumber);	pReceivingEndClass->links [linkNumber].pMemberStackObj = pMemberStackObj;		pReceivingEndClass->links [linkNumber].localMRU = 				pLcpBundleOptions->localMRU;	/* Time the link */	/* Get framework obj */	pfwObj = pfwStackObjPfwGet (pMemberStackObj);	if (pfwObj == NULL)		{		printf ("NULL Framework Reference\n");		return ERROR;		}	/* Get LCP state in the member stack */	pPluginObj = 		(PFW_PLUGIN_OBJ *) pfwPluginObjGet (pfwObj, "PPP_LCP");		if (pPluginObj == NULL)		{		printf ("LCP component does not exist in the framework\n");		return ERROR;		}	pMemberLcpState = pfwPluginObjStateGet (pMemberStackObj, pPluginObj);		if (pMemberLcpState == NULL)		{		printf ("LCP component does not exist in the stack 0x%x\n", \							(int) pMemberStackObj);		return ERROR;		}#if 0	/* NOT SUPPORTED IN THIS RELEASE */	/* Send Echo Request packet */	(pStackData->pLcpPacketSendInterfaceObj->lcpEchoRequestSend) 				(pMemberLcpState);	/* Set Member LCP in MP Timing Mode */		(pStackData->pLcpMpLinkTimeInterfaceObj->lcpMPLinkTime) (pMemberLcpState);	pReceivingEndClass->links[linkNumber].clock_ticks_when_timer_starts = 				tickGet ();#endif /* NOT SUPPORTED IN THIS RELEASE */	 pReceivingEndClass->no_of_links++;	return OK;	}

⌨️ 快捷键说明

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