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

📄 mpinterfacelayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	if (pMpBundleManagementInterfaceObj == NULL)		{		printf ("MP: No MP_BUNDLE_MANAGEMENT_INTERFACE in the Manager \				 Stack 0x%x", (int) pMpInterfaceLayerState->stackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		return ERROR;		}	pManagerStackObj = 		pMpBundleManagementInterfaceObj->mpOpenBundleOrAddToTheExistingBundle 						  (pMemberLcpState, pStackData->mpUpCalls, 						   pStackData->userHandler); 	if (pfwInterfaceReferenceDelete 		(&pMpBundleManagementInterfaceObj->interfaceObj) == ERROR) 		{		pfwPrintError (__FILE__, "mpInterfaceLayerLcpUpEventHandler", __LINE__, \		   pfwObj, pMpInterfaceLayerState->stackObj,\		   "Error in deleting the reference to MP_BUNDLE_MANAGEMENT INTERFACE");		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);				/*		 * If the member can't be able to added to any bundle closing the 		 * connection is fine, also taken further action for the same in 		 * LCP DOWN EVENT hnadler 		 */		return ERROR;		}	if (pManagerStackObj == NULL)		{		pfwPrintError (__FILE__, "mpInterfaceLayerLcpUpEventHandler", __LINE__, \					   pfwObj, pMpInterfaceLayerState->stackObj, \					   "Addition of the stack 0x%x to the bundle failed. \				 		Connection terminated");		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);				/*		 * If the member can't be able to added to any bundle closing the 		 * connection is fine, also taken further action for the same in 		 * LCP DOWN EVENT hnadler 		 */		return ERROR;		}	/* Link has not negotiated MP at both the ends */	if (pManagerStackObj == (PFW_STACK_OBJ *) NOT_A_MP_LINK)		{		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		return OK;		}	/* 	 * Get the state pair of MP bundle management interface and  MP packet 	 * receive interface 	 */	status = pfwInterfaceObjAndStateGetViaStackObj 						(pManagerStackObj, interfaceId, &pStackData-> 						 mpBundleManagementInterfaceStatePair);	if (status == ERROR)		{		printf ("MP: No BUNDLE_MANAGEMENT_INTERFACE in the Manager Stack 0x%x",\				 (int) pManagerStackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);		return ERROR;		}	interfaceId = pfwInterfaceIdGet (pfwObj, "MP_PACKET_RECEIVE_INTERFACE");	status = pfwInterfaceObjAndStateGetViaStackObj 						(pManagerStackObj, interfaceId, &pStackData-> 						 mpPacketRcvInterfaceStatePair);	if (status == ERROR)		{		printf ("MP: No MP_PACKET_RECEIVE_INTERFACE in the Manager Stack 0x%x",\				 (int) pManagerStackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);		return ERROR;		}	/* Assign the Manager Stack */	pStackData->pManagerStackObj = pManagerStackObj;	/* Set the Control layer in the MP Member link mode */	pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 TRUE, pManagerStackObj);	/* Call MP up calls */	if (pStackData->mpUpCalls != NULL)		if (pStackData->mpUpCalls->linkAddedToBundle != NULL)			(*pStackData->mpUpCalls->linkAddedToBundle)											(pStackData->userHandler, pMpInterfaceLayerState->stackObj, 				 	 pManagerStackObj);	return OK;	}/******************************************************************************** mpInterfaceLayerMpLinkDownEventHandler - mpInterface layer PPP_LINK_RESET event *                                          handler* 	* This function removes the link from the bundle through the function * mp_remove_a_port_from _bundle () provided by the interface * MP_BUNDLE_MANAGEMENT_INTERFACE* * RETURNS: OK or ERROR*/LOCAL STATUS mpInterfaceLayerMpLinkDownEventHandler 	(	PFW_PLUGIN_OBJ_STATE	*pMpInterfaceLayerState,	void 					*eventData	)	{	MP_INTERFACE_LAYER_STACK_DATA	*pStackData = NULL;	MP_BUNDLE_MANAGEMENT_INTERFACE	*pMpBundleManagementInterface = NULL;	MP_CONTROL_LAYER_INTERFACE		*pMpControlLayerInterface = NULL;	PFW_STACK_OBJ					*pManagerStackObj = NULL; 	PFW_OBJ							*pfw = NULL;	pfw = pfwStackObjPfwGet (pMpInterfaceLayerState->stackObj);	pStackData = 			(MP_INTERFACE_LAYER_STACK_DATA *) pMpInterfaceLayerState->stackData;	/* 	 * Link is not part of any of the existing bundle. Adding the link to bundle	 * has failed  	 */	if (pStackData->pManagerStackObj == NULL)		return OK;	pMpBundleManagementInterface = (MP_BUNDLE_MANAGEMENT_INTERFACE *)				pStackData->mpBundleManagementInterfaceStatePair.interfaceObj;	pMpBundleManagementInterface->mpRemoveAPortFromBundle 				(pStackData->mpBundleManagementInterfaceStatePair.state, 				 pMpInterfaceLayerState->stackObj);	/* Get the MPControl Layer Interface Obj */	pMpControlLayerInterface = (MP_CONTROL_LAYER_INTERFACE *)				pStackData->mpControlLayerInterfaceStatePair.interfaceObj;	/* Set the Control layer in the MP Member link mode */	pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);	/* Call MP up calls */	pManagerStackObj = 		pStackData->mpBundleManagementInterfaceStatePair.state->stackObj;	if (pStackData->mpUpCalls != NULL)		if (pStackData->mpUpCalls->linkRemovedFromBundle != NULL)			(*pStackData->mpUpCalls->linkRemovedFromBundle)											(pStackData->userHandler, pMpInterfaceLayerState->stackObj, 				 	 pManagerStackObj);	/* delete the references to the interfaces */	if (pStackData->mpBundleManagementInterfaceStatePair.interfaceObj != NULL)		{	    if (pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *)			pStackData->mpBundleManagementInterfaceStatePair.interfaceObj)																 == ERROR)  	 		{			pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \				   	   pfw, pMpInterfaceLayerState->stackObj, "Error in deleting \					   the reference to BUNDLE_MANAGEMENT_INTERFACE");			return ERROR;  			}		pStackData->mpBundleManagementInterfaceStatePair.interfaceObj = NULL; 		}			if (pStackData->mpPacketRcvInterfaceStatePair.interfaceObj != NULL)		{   		if (pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *)				pStackData->mpPacketRcvInterfaceStatePair.interfaceObj) 																== ERROR)   			{			pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \				   	   pfw, pMpInterfaceLayerState->stackObj, "Error in deleting \					   the reference to MP_PACKET_RECEIVE_INTERFACE");			return ERROR;  			}		pStackData->mpPacketRcvInterfaceStatePair.interfaceObj = NULL; 		}    /* this link is no longer part of the bundle */    pStackData->pManagerStackObj = NULL;	return OK;	}/******************************************************************************** mpInterfaceLayerAuthUpEventHandler - mpInterface layer AUTH_UP event handler* 	* This function adds the link to the appropriate bundle.*  * RETURNS: OK or ERROR*/LOCAL STATUS mpInterfaceLayerAuthUpEventHandler	(	PFW_PLUGIN_OBJ_STATE	*pMpInterfaceLayerState,	void 					*eventData	)	{	MP_INTERFACE_LAYER_STACK_DATA			*pStackData = NULL;	MP_INTERFACE_LAYER_PROFILE_DATA 		*pProfileData = NULL;	PFW_STACK_OBJ							*pManagerStackObj = NULL;	PFW_PLUGIN_OBJ_STATE					*pMemberLcpState = NULL;	PFW_PLUGIN_OBJ							*pPluginObj = NULL;	MP_BUNDLE_MANAGEMENT_INTERFACE			*pMpBundleManagementInterfaceObj = NULL;	MP_CONTROL_LAYER_INTERFACE				*pMpControlLayerInterface = NULL;	PFW_OBJ									*pfwObj = NULL;	UINT									interfaceId = 0;	STATUS									status;	pfwObj = pfwStackObjPfwGet (pMpInterfaceLayerState->stackObj);	if (pfwObj == NULL)		{		printf ("NULL Framework Reference\n");		return ERROR;		}	pStackData = 		(MP_INTERFACE_LAYER_STACK_DATA *) pMpInterfaceLayerState->stackData;	pProfileData = 		(MP_INTERFACE_LAYER_PROFILE_DATA *) pMpInterfaceLayerState->profileData;	/*	Retrieve LCP state pair */	pMemberLcpState = 				pStackData->lcpNegotiatedAuthProtocolInterfaceStatePair.state;	/* Get the MPControl Layer Interface Obj */	pMpControlLayerInterface = (MP_CONTROL_LAYER_INTERFACE *)				pStackData->mpControlLayerInterfaceStatePair.interfaceObj;	if (pMpControlLayerInterface == NULL)		return ERROR;	/* Add the link to the bundle */	pPluginObj = pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER");	if (pPluginObj == NULL)		{		pfwPrintError (__FILE__, "mpInterfaceLayerLcpUpEventHandler", __LINE__, \					   pfwObj, pMpInterfaceLayerState->stackObj, \					   "mpFraming layer does not exist in the framework");		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		return (ERROR);		}	/* Get reference to the MP bundle Management interface */	interfaceId = pfwInterfaceIdGet (pfwObj, "MP_BUNDLE_MANAGEMENT_INTERFACE");	pMpBundleManagementInterfaceObj = (MP_BUNDLE_MANAGEMENT_INTERFACE *)					pfwInterfaceObjGetViaPluginObj (pPluginObj, interfaceId);	if (pMpBundleManagementInterfaceObj == NULL)		{		printf ("PPP: No MP_BUNDLE_MANAGEMENT_INTERFACE in the Manager \				 Stack 0x%x", (int) pMpInterfaceLayerState->stackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		return ERROR;		}	pManagerStackObj = 		pMpBundleManagementInterfaceObj->mpOpenBundleOrAddToTheExistingBundle 						  (pMemberLcpState, pStackData->mpUpCalls, 						   pStackData->userHandler);	if (pfwInterfaceReferenceDelete 		(&pMpBundleManagementInterfaceObj->interfaceObj) == ERROR) 		{		pfwPrintError (__FILE__, "mpInterfaceLayerAuthUpEventHandler", __LINE__,  \		   pfwObj, pMpInterfaceLayerState->stackObj, \		   "Error in deleting the reference to MP_BUNDLE_MANAGEMENT INTERFACE");		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);				/*		 * If the member can't be able to added to any bundle closing the 		 * connection is fine, also taken further action for the same in 		 * LCP DOWN EVENT handler 		 */		return ERROR;		}	if (pManagerStackObj == (PFW_STACK_OBJ *) NOT_A_MP_LINK)		{		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		return OK;		}	if (pManagerStackObj == NULL)		{		pfwPrintError (__FILE__, "mpInterfaceLayerAuthUpEventHandler", __LINE__, \					   pfwObj, pMpInterfaceLayerState->stackObj, \					   "Addition of the stack to the bundle failed. \				 		Connection terminated");		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);		return ERROR;		}	/* 	 * Get the state pair of MP bundle management interface and  MP packet 	 * receive interface	 */	status = pfwInterfaceObjAndStateGetViaStackObj 						(pManagerStackObj, interfaceId, &pStackData-> 						 mpBundleManagementInterfaceStatePair);	if (status == ERROR)		{		printf ("PPP: No BUNDLE_MANAGEMENT_INTERFACE in the Manager Stack 0x%x",\				 (int) pManagerStackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);		return ERROR;		}	interfaceId = pfwInterfaceIdGet (pfwObj, "MP_PACKET_RECEIVE_INTERFACE");	status = pfwInterfaceObjAndStateGetViaStackObj 						(pManagerStackObj, interfaceId, &pStackData-> 						 mpPacketRcvInterfaceStatePair);	if (status == ERROR)		{		printf ("PPP: No MP_PACKET_RECEIVE_INTERFACE in the Manager Stack 0x%x",\				 (int) pManagerStackObj);		pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 FALSE, NULL);		pppConnectionClose (pMemberLcpState->stackObj);		return ERROR;		}	/* Assign the Manager Stack */	pStackData->pManagerStackObj = pManagerStackObj;	/* Set the Control layer in the MP Member link mode */	pMpControlLayerInterface->pppMpMemberSet							(pStackData->mpControlLayerInterfaceStatePair.state,						 TRUE, pManagerStackObj);	/* Call MP up calls */		if (pStackData->mpUpCalls != NULL)		if (pStackData->mpUpCalls->linkAddedToBundle != NULL)			(*pStackData->mpUpCalls->linkAddedToBundle)											(pStackData->userHandler, pMpInterfaceLayerState->stackObj, 				 	 pManagerStackObj);	return OK;	}/******************************************************************************** mpInterfaceLayerAuthDownEventHandler - mpInterface layer AUTH_DOWN event *							  			 handler*  * * RETURNS: OK or ERROR*/LOCAL STATUS mpInterfaceLayerAuthDownEventHandler 	(	PFW_PLUGIN_OBJ_STATE	*pMpInterfaceLayerState,	void 					*eventData	)	{	return OK;	}/******************************************************************************** mpInterfaceLayerBundleCloseEventHandler - *  								mpInterface layer MP_BUNDLE_CLOSED event handler* This function checks whether the event has been raised from the link's  * Manager Stack. If so, it closes the PPP connection on the link. Otherwise, * it returns* * RETURNS: OK or ERROR*/LOCAL STATUS mpInterfaceLayerBundleCloseEventHandler 	(	PFW_PLUGIN_OBJ_STATE	*pMpInterfaceLayerState,	void 					*eventData	)	{	MP_INTERFACE_LAYER_STACK_DATA 	*pStackData = NULL;	PFW_STACK_OBJ				  	*pManagerStackObj = NULL;	MP_CONTROL_LAYER_INTERFACE 		*pMpControlLayerInterface = NULL;	pStackData = 		(MP_INTERFACE_LAYER_STACK_DATA *) pMpInterfaceLayerState->stackData;	pManagerStackObj = (PFW_STACK_OBJ *) eventData;	/* Get the MPControl Layer Interface Obj */	pMpControlLayerInterface = (MP_CONTROL_LAYER_INTERFACE *)					pStackData->mpControlLayerInterfaceStatePair.interfaceObj;	/* Set the Member Stack to Non-MP Member Mode */	pMpControlLayerInterface->pppMpMemberSet						(pStackData->mpControlLayerInterfaceStatePair.state,					 FALSE, NULL);	if (pStackData->pManagerStackObj == pManagerStackObj)		pppConnectionClose (pMpInterfaceLayerState->stackObj);	return OK;	}

⌨️ 快捷键说明

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