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

📄 mpframinglayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
				   pfw, NULL, "Failed to get MP_BUNDLE_OPENED_EVENT event obj");		return ERROR;		}	if ((pStackData->pMpMemberAddedEventObj = pfwEventObjGet (pfw,										"MP_MEMBER_ADDED_EVENT")) == NULL)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDataConstruct", __LINE__, \				   pfw, NULL, "Failed to get MP_MEMBER_ADDED_EVENT event obj");		return ERROR;		}		if ((pStackData->pMpMemberDroppedEventObj = pfwEventObjGet (pfw,										"MP_MEMBER_DROPPED_EVENT")) == NULL)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDataConstruct", __LINE__, \				  pfw, NULL, "Failed to get MP_MEMBER_DROPPED_EVENT event obj");		return ERROR;		}    if ((pStackData->pMpSubLayerDeadEventObj = pfwEventObjGet (pfw,                                        "PPP_SUB_LAYER_DEAD_EVENT")) == NULL)        {        pfwPrintError (__FILE__, "mpFramingLayerStackDataConstruct", __LINE__, \                   pfw, NULL, "Failed to get PPP_SUB_LAYER_DEAD_EVENT event obj");        return ERROR;        }	return OK;	}/******************************************************************************** mpFramingLayerInterfaceBind - bind to the interfaces** The framework calls this function to bind the interfaces the Plugin object * implements. ** RETURNS: OK/ERROR*/LOCAL STATUS mpFramingLayerInterfaceBind	(	PFW_PLUGIN_OBJ * pMpFramingLayerObj	)	{	int 							interfaceId = 0;	MP_FRAMING_LAYER 				* pLayerObj = 										(MP_FRAMING_LAYER *) pMpFramingLayerObj;	MP_BUNDLE_MANAGEMENT_INTERFACE 	* mpBundleManagement = 										&pLayerObj->mpBundleManagementInterface;	MP_PACKET_RECEIVE_INTERFACE 	* mpPacketReceive = 										&pLayerObj->mpPacketReceiveInterface;	PFW_OBJ 						* pfw = pMpFramingLayerObj->pfwObj;	/* get the MP_PACKET_RECEIVE_INTERFACE id and bind to it */	if ((interfaceId = pfwInterfaceRegister (pfw,							"MP_PACKET_RECEIVE_INTERFACE")) == 0)		{        if (pLayerObj != NULL)            {            pfwFree ((void *) pLayerObj);            pLayerObj = NULL;            }		return ERROR;		}		mpPacketReceive->interfaceObj.id = interfaceId;	mpPacketReceive->interfaceObj.pluginObj = 								(PFW_PLUGIN_OBJ *) &pLayerObj->layer;	mpPacketReceive->mpFramingLayerReceive = mpFramingLayerReceive;	if (pfwInterfaceBind (&mpPacketReceive->interfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerInterfaceBind", __LINE__, \				   pfw, NULL, "Unable to bind MP_PACKET_RECEIVE_INTERFACE");		return ERROR;		}		/* get the MP_BUNDLE_MANAGEMENT_INTERFACE id and bind to it */	if ((interfaceId = pfwInterfaceRegister (pfw,							"MP_BUNDLE_MANAGEMENT_INTERFACE")) == 0)		{        if (pLayerObj != NULL)            {            pfwFree ((void *) pLayerObj);            pLayerObj = NULL;            }		return ERROR;		}		mpBundleManagement->interfaceObj.id = interfaceId;	mpBundleManagement->interfaceObj.pluginObj = 								(PFW_PLUGIN_OBJ *) &pLayerObj->layer;	mpBundleManagement->mpLinkAssign = mpLinkAssign;	mpBundleManagement->mpBAPLinkInfoListGet = mpBAPLinkInfoListGet;	mpBundleManagement->mpRemoveAPortFromBundle = 								mp_remove_port_from_bundle;	mpBundleManagement->mpOpenBundleOrAddToTheExistingBundle =								mp_open_bundle_or_add_to_the_existing_bundle;	if (pfwInterfaceBind (&mpBundleManagement->interfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerInterfaceBind", __LINE__, \		   pfw, NULL, "Unable to bind MP_BUNDLE_MANAGEMENT_INTERFACE");		return ERROR;		}	return OK;	}/******************************************************************************** mpFraminglayerStackAdd - add the MP_FRAMING_LAYER component to the stack** This function is called when the MP_FRAMING_LAYER plug-in object is added to * a stack that is being built to support a connection. This function subscribes * for the events LCP_UP / PPP_LINK_RESET and LCP_ECHO_REPLY_RECEIVED and registers* for the interfaces implemented by the other components and calls * stackAddComplete ( ) callback routine. ** RETURNS: OK/ERROR*/LOCAL STATUS mpFramingLayerStackAdd	(	PFW_PLUGIN_OBJ_STATE 		*pLayerState,	/* plug-in obj state */	PFW_PLUGIN_OBJ_CALLBACKS 	*pCallbacks		/* call back routines */	)	{	MP_FRAMING_LAYER_STACK_DATA 	* pStackData = pLayerState->stackData;	PFW_OBJ 						* pfwObj = pLayerState->pluginObj->pfwObj;	int 							interfaceId = 0;	PFW_EVENT_OBJ 					* pEventObj = NULL;	PFW_PLUGIN_OBJ 					* lcpPluginObj = NULL;	lcpPluginObj = pfwPluginObjGet (pfwObj, "PPP_LCP");		pStackData->callbacks = pCallbacks;	/* get the interface objects */	if ((interfaceId = pfwInterfaceIdGet (pfwObj, 										"LCP_BUNDLE_OPTIONS_INTERFACE")) > 0)		{		if ((pStackData->pLcpBundleOptionsInterfaceObj = 			(LCP_BUNDLE_OPTIONS_INTERFACE *) pfwInterfaceObjGetViaPluginObj 										(lcpPluginObj, interfaceId)) == NULL)			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			   pfwObj, pLayerState->stackObj, "Unable to get the interface obj \			   of the LCP_BUNDLE_OPTIONS_INTERFACE");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		  pfwObj, pLayerState->stackObj, "Unable to get the interface id \		  of the LCP_BUNDLE_OPTIONS_INTERFACE");		return ERROR;		}#if 0 /* NOT SUPPORTED IN THIS RELEASE */	if ((interfaceId = pfwInterfaceIdGet (pfwObj, "LCP_MP_TIME_INTERFACE")) > 0)		{		if ((pStackData->pLcpMpLinkTimeInterfaceObj = (LCP_MP_TIME_INTERFACE *) 				pfwInterfaceObjGetViaPluginObj (lcpPluginObj, interfaceId)) 																	== NULL)			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \				   pfwObj, pLayerState->stackObj, "Unable to get the  \				   interface obj of the LCP_MP_TIME_INTERFACE");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			pfwObj, pLayerState->stackObj, "Unable to get the interface \			of the LCP_MP_TIME_INTERFACE");		return ERROR;		}#endif /* NOT SUPPORTED IN THIS RELEASE */	if ((interfaceId =  pfwInterfaceIdGet (pfwObj, 										 "LCP_PROXYLCP_INTERFACE")) > 0 )		{		if (pfwInterfaceObjAndStateGetViaStackObj (pLayerState->stackObj,				interfaceId, &pStackData->proxyLcpInterfaceStatePair) == ERROR)			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \				pfwObj, pLayerState->stackObj, "Unable to get the interface obj \				of the LCP_PROXYLCP_INTERFACE");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		   pfwObj, pLayerState->stackObj, "Unable to get the interface id \		   of the LCP_PROXYLCP_INTERFACE");		return ERROR;		}	if ((interfaceId =  pfwInterfaceIdGet (pfwObj, 						 "PPP_LINK_STATUS_COUNTER_INCREMENT_INTERFACE")) > 0 )		{		if ((pfwInterfaceObjAndStateGetViaStackObj (pLayerState->stackObj,			interfaceId, &pStackData->			pppLinkStatusCounterIncrementInterfaceStatePair)) == ERROR)			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		  	 	pfwObj, pLayerState->stackObj, "Unable to get the interface obj \		  	    of the PPP_LINK_STATUS_COUNTER_INCREMENT_INTERFACE");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		   pfwObj, pLayerState->stackObj, "Unable to get the interface id \		   of the PPP_LINK_STATUS_COUNTER_INCREMENT_INTERFACE");		return ERROR;		}	if ((pStackData->authMpInterfaceId = pfwInterfaceIdGet (pfwObj, 											"AUTH_INFO_INTERFACE")) <= 0 )		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		   pfwObj, pLayerState->stackObj, "Unable to get the interface \		   id of the AUTH_INFO_INTERFACE");		return ERROR;		}	if ((interfaceId = pfwInterfaceIdGet (pfwObj, 										 "LCP_PACKET_SEND_INTERFACE")) > 0 )		{		if ((pStackData->pLcpPacketSendInterfaceObj=(LCP_PACKET_SEND_INTERFACE *) 			pfwInterfaceObjGetViaPluginObj (lcpPluginObj, interfaceId)) == NULL)			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			  	 pfwObj, pLayerState->stackObj, "Unable to get the interface obj \			  	 of the LCP_PACKET_SEND_INTERFACE");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \		   pfwObj, pLayerState->stackObj, "Unable to get the interface id \		   of the LCP_PACKET_SEND_INTERFACE");		return ERROR;		}	/* subscribe for the events */	if ((pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "LCP_UP_EVENT")) != NULL)		{		if (ERROR == pfwEventStackSubscribe (pLayerState, pEventObj, 								mpFramingLayerLcpUpEventHandler))			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \				pfwObj, pLayerState->stackObj, "Unable to subsribe for \				LCP_UP event");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			pfwObj, pLayerState->stackObj, "Unable to get LCP_UP event obj"); 		return ERROR;		}		if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "PPP_LINK_RESET_EVENT")) != NULL)		{		if (ERROR == pfwEventStackSubscribe (pLayerState, pEventObj, 								mpFramingLayerMpLinkDownEventHandler))			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \				pfwObj, pLayerState->stackObj, "Unable to subsribe for \			PPP_LINK_RESET event");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			pfwObj, pLayerState->stackObj, "Unable to get PPP_LINK_RESET event obj");		return ERROR;		}#if 0 /* NOT SUPPORTED IN THIS RELEASE */	if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "LCP_ECHO_REPLY_RECEIVED_EVENT")) != NULL)		{		if (ERROR == pfwEventStackSubscribe (pLayerState, pEventObj, 								mpFramingLayerLcpEchoReplyReceivedEventHandler))			{			pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \				pfwObj, pLayerState->stackObj, "Unable to subsribe for \				LCP_ECHO_REPLY_RECEIVED_EVENT event");			return ERROR;			}		}	else		{		pfwPrintError (__FILE__, "mpFramingLayerStackAdd", __LINE__, \			pfwObj, pLayerState->stackObj, "Unable to get  \			LCP_ECHO_REPLY_RECEIVED_EVENT event obj");		return ERROR;		}#endif	/* call the callback routine */	if (pStackData->callbacks && pStackData->callbacks->stackAddComplete)		{		(*pStackData->callbacks->stackAddComplete)				(pStackData->callbacks, pLayerState);		return OK;		}	else		return ERROR;		}/******************************************************************************** mpFramingLayerStackDelete - called when the stack containing the *								plugin is deleted.** The framework calls this function when the stack that contains the Plugin * object is deleted. This function deletes the references to the previously * registered interfaces, frees the memory and calls the callback routine if * provided. ** RETURNS: OK/ERROR*/ LOCAL STATUS mpFramingLayerStackDelete	(	PFW_PLUGIN_OBJ_STATE *pMpFramingLayerState /* state for the stack */	)	{	MP_FRAMING_LAYER_STACK_DATA * pStackData = pMpFramingLayerState->stackData;	PFW_OBJ						* pfw = pMpFramingLayerState->pluginObj->pfwObj;	/* delete the reference to the interfaces */    if (pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *)							pStackData->pLcpBundleOptionsInterfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDelete", __LINE__, \		  	 pfw, pMpFramingLayerState->stackObj, "Error in deleting the \			 reference to the LCP_BUNDLE_OPTIONS_INTERFACE");		return ERROR;		}#if 0 /* NOT SUPPORTED IN THIS RELEASE */    if (pfwInterfaceReferenceDelete 		((PFW_INTERFACE_OBJ *)pStackData->pLcpMpLinkTimeInterfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDelete", __LINE__, \		  	 pfw, pMpFramingLayerState->stackObj, "Error in deleting the \			 reference to the LCP_MP_TIME_INTERFACE");		return ERROR;		}#endif     if (pfwInterfaceReferenceDelete 		(pStackData->proxyLcpInterfaceStatePair.interfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDelete", __LINE__, \		  	 pfw, pMpFramingLayerState->stackObj, "Error in deleting the \			 reference to the LCP_PROXYLCP_INTERFACE");		return ERROR;		}    if (pfwInterfaceReferenceDelete 		((PFW_INTERFACE_OBJ *)pStackData->pLcpPacketSendInterfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDelete", __LINE__, \		  	 	   pfw, pMpFramingLayerState->stackObj, "Error in deleting \				   the reference to the LCP_PACKET_SEND_INTERFACE");		return ERROR;		}    if (pfwInterfaceReferenceDelete 		((PFW_INTERFACE_OBJ *)pStackData->			pppLinkStatusCounterIncrementInterfaceStatePair.			interfaceObj) == ERROR)		{		pfwPrintError (__FILE__, "mpFramingLayerStackDelete", __LINE__, \  	 	   pfw, pMpFramingLayerState->stackObj, "Error in deleting \		   the reference to the PPP_LINK_STATUS_COUNTER_INCREMENT_INTERFACE");		return ERROR;		}	/* call the callback routine */    if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete)		{		(*pStackData->callbacks->stackDeleteComplete)				    (pStackData->callbacks, pMpFramingLayerState);

⌨️ 快捷键说明

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