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

📄 mpinterfacelayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* mpInterfaceLayer.c - MP Interface Layer source file *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01l,05mar03,ijm SPR# 86614, in mpInterfaceLayerMpLinkDownEventHandler set                link's manager to NULL when link is removed from bundle01k,26oct02,ijm subscribe to PPP_LINK_RESET_EVENT instead of MP_LINK_DOWN01j,22oct02,ijm include mpP.h01i,06aug02,jr  fixed build warnings 01h,23feb02,ak  Deleting the references to the mpFraming layer interfaces in 				LCP Down event handler01g,23feb02,jr  setting pointers to NULL after freeing01f,17feb02,ak  Initializing local variables in all the functions01e,18dec01,ak  support for dynamic assignment of MP Member Stack to Manager 				Stack01d,18sep01,ak  Deleting MP_BUNDLE_MANAGEMENT_INTERFACE in LCP UP and AUTH UP 				event handlers01c,18sep01,ak  Deleting LCP_NEGOTIATED_AUTH_PROTOCOL interface reference in 				stackDelete()01b,26feb01,ak  added event handlers01a,22feb01,sd	created*//*DESCRIPTIONThis module implements the MP_INTERFACE_LAYER component. Itimplements the standard plug-in object functions in accordance with theWindNet PPP architecture.This component is implemented as an operational layer, but with no components in it and is placed as the upper most layer in the data plane.The introduction of this layer allows compression on member links. The data packets in the Member Stack are processed by all the components in the layers below this layer in the data plane. This layer submits the packet to the Manager Stack. While sending, the Manager Stack submits all the data packets to this layer and from this layer, the packets are processed down the stack. This pluginObj contains one profile, which identifies the bundle to which the member link belongs.It subscribes for LCP_UP / PPP_LINK_RESET_EVENT and PPP_AUTH_SUCCESSFUL /PPP_AUTH_UNSUCCESSFUL events.INCLUDES: mp.h mpInterfaceLayerP.h*//* includes */#include "stdlib.h"#include "stdio.h"#include "ppp/mp.h"#include "private/ppp/mpP.h"#include "private/ppp/mpInterfaceLayerP.h"#include "ppp/interfaces/mpFramingLayerInterfaces.h"#include "ppp/interfaces/lcpInterfaces.h"#include "ppp/interfaces/pppControlLayerInterface.h"#include "private/ppp/mpFramingLayerP.h"#include "ppp/pppInterfaces.h"/* typedefs */typedef struct mpInterfaceLayerParams	{	char * name;	PFW_PARAMETER_HANDLER handler;	} MP_INTERFACE_LAYER_PARAMS;/* locals and forwards */IMPORT STATUS mpReceiveQueueAdd (PFW_OBJ *, FUNCPTR jobHandlerFunc,								 void *, int);/* layer component interface  */LOCAL STATUS mpInterfaceLayerProfileDataConstruct (PFW_OBJ *,												void * pProfileData);LOCAL STATUS mpInterfaceLayerInterfaceBind (PFW_PLUGIN_OBJ * pluginObj);LOCAL STATUS mpInterfaceLayerStackAdd (PFW_PLUGIN_OBJ_STATE *, 											PFW_PLUGIN_OBJ_CALLBACKS *);LOCAL STATUS mpInterfaceLayerSend (PFW_PLUGIN_OBJ_STATE *, M_BLK_ID *);LOCAL STATUS mpInterfaceLayerStackDelete (PFW_PLUGIN_OBJ_STATE *);LOCAL STATUS mpInterfaceLayerReceive (PFW_PLUGIN_OBJ_STATE *, M_BLK_ID *);LOCAL STATUS mpInterfaceLayerStackDataConstruct (PFW_OBJ *, void * stackData,											void * profileData);LOCAL void _mpReceive ( void *);/* parameter handlers */LOCAL STATUS mpInterface_managerStackId (PFW_OBJ *, PFW_PARAMETER_OPERATION_TYPE,						void *, char *);LOCAL STATUS mpInterface_memberLinkSpeed (PFW_OBJ *, PFW_PARAMETER_OPERATION_TYPE,						void *, char *);LOCAL MP_INTERFACE_LAYER_PARAMS mpInterfaceLayerParams[] =    {	{"mpInterface_memberLinkSpeed", mpInterface_memberLinkSpeed},	{"mpInterface_managerStackId", mpInterface_managerStackId}    }; LOCAL int numMpInterfaceLayerParams = NELEMENTS (mpInterfaceLayerParams);/* event handlers */LOCAL STATUS mpInterfaceLayerLcpUpEventHandler (PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS mpInterfaceLayerMpLinkDownEventHandler 										(PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS mpInterfaceLayerAuthUpEventHandler										(PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS mpInterfaceLayerAuthDownEventHandler										(PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS mpInterfaceLayerBundleCloseEventHandler (PFW_PLUGIN_OBJ_STATE	*,														void *);/******************************************************************************** mpInterfaceLayerCreate - create MP_INTERFACE_LAYER component* * This routine creates the MP_INTERFACE_LAYER. It initializes the PFW_PLUGIN_OBJ * data structure representing the MP_INTERFACE_LAYER component. It registers the * component with the framework. It adds the plugin object specific configuration* parameters and adds the component to the framework. ** RETURNS: OK/ERROR*/STATUS mpInterfaceLayerCreate	(	PFW_OBJ * pfw					/* framework reference */	)	{	MP_INTERFACE_LAYER_COMPONENT	*pMpInterfaceLayer = NULL;	PFW_LAYER_OBJ					*pLayerObj = NULL;	UINT							loopCount = 0; 	if (pfw == NULL)		return ERROR;	/* allocate memory for the MP Interface layer object */		if ((pMpInterfaceLayer = pfwMalloc (pfw, 			sizeof (MP_INTERFACE_LAYER_COMPONENT)))	== NULL)		{		pfwPrintError (__FILE__, "mpInterfaceLayerInit", __LINE__, pfw, 0, \				"Unable to allocate memory");		return (ERROR);		}	bzero ((void*) pMpInterfaceLayer, sizeof(MP_INTERFACE_LAYER_COMPONENT));	/* initialize the MP Interface Layer Plugin Object functions */	pLayerObj = &pMpInterfaceLayer->layer;	strcpy (pLayerObj->pluginObj.name, "MP_INTERFACE_LAYER");	pLayerObj->pluginObj.profileDataSize = 								sizeof (MP_INTERFACE_LAYER_PROFILE_DATA);	pLayerObj->pluginObj.stackDataSize = sizeof (MP_INTERFACE_LAYER_STACK_DATA);	pLayerObj->pluginObj.profileDataConstruct = 										mpInterfaceLayerProfileDataConstruct;		pLayerObj->pluginObj.profileDataCopy = NULL;	pLayerObj->pluginObj.profileDataDestruct = NULL;		pLayerObj->pluginObj.stackDataConstruct = 										mpInterfaceLayerStackDataConstruct;		pLayerObj->pluginObj.stackDataDestruct = NULL;		pLayerObj->pluginObj.stackAdd = mpInterfaceLayerStackAdd;	pLayerObj->pluginObj.stackDelete = mpInterfaceLayerStackDelete;	pLayerObj->pluginObj.stackDataShow = NULL;		pLayerObj->pluginObj.send = mpInterfaceLayerSend;	pLayerObj->pluginObj.receive = mpInterfaceLayerReceive;	pLayerObj->pluginObj.interfaceBind = mpInterfaceLayerInterfaceBind;	pLayerObj->pluginObj.pfwObj = pfw;	/* initialize the MP Interface layer, layer obj members */	pLayerObj->planeId = DATA_PLANE;	pLayerObj->position = 20;	pLayerObj->type = OPERATIONAL_LAYER;	pLayerObj->packetType = NULL;	pLayerObj->componentAdd = NULL;	pLayerObj->componentDelete = NULL;						pLayerObj->addDynamicComponentToStack = NULL;			pLayerObj->deleteDynamicComponentFromStack = NULL;		/* add the MP Interface Layer to the Framework */	if (pfwLayerAdd ( pLayerObj) == ERROR)		{		pfwPrintError (__FILE__, "mpInterfaceLayerInit", __LINE__, pfw,0, \			"MP Interface layer could not be added to the stack");		return (ERROR);		}	/* add configurable parameters to the framework */	for (loopCount = 0; loopCount < numMpInterfaceLayerParams; loopCount++)		{		if (pfwParameterAdd ((PFW_PLUGIN_OBJ *)pLayerObj,			mpInterfaceLayerParams [loopCount].name,			mpInterfaceLayerParams [loopCount].handler) == ERROR)			{			pfwPrintError (__FILE__, "mpInterfaceLayerInit", __LINE__, pfw, 0, \			 			   "Error in registering a profile parameter");			return (ERROR);			}		}		return OK;	}/******************************************************************************** mpInterfaceLayerDelete - delete the MP_INTERFACE_LAYER component.** This function is called with the framework object to delete the * MP_INTERFACE_LAYER component from the framework. The plug-in component object * allocated by mpInterfaceLayerCreate () is freed if there are no references to * this object from a Stack or Profile object in the framework.** RETURNS: OK/ERROR*/STATUS mpInterfaceLayerDelete	(	PFW_OBJ *pfw		/* framework reference */	)	{	PFW_LAYER_OBJ *pLayerObj = NULL;	pLayerObj = pfwLayerObjGet (pfw, "MP_INTERFACE_LAYER");	if (pLayerObj == NULL)		return ERROR;	/* delete the layer */	if (pfwLayerDelete (pLayerObj) == OK)		{                pfwFree (pLayerObj);                pLayerObj = NULL;                return OK;		}	return ERROR;	}/******************************************************************************** mpFramingLayerStackDataConstruct - called by the framework to initialize the *										stack data** This function is called when a stack is created to initialize the stack data * of the MP_INTERFACE_LAYER component. This function initializes the * mpInterfaceStackData structure. The structure members are set to their initial * values. ** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerStackDataConstruct	(	PFW_OBJ * pfwObj,			/* the framework object */	void 	* stackData,	/* pointer to stackData */ 	void 	* profileData	/* pointer to profileData */	)	{	MP_INTERFACE_LAYER_STACK_DATA * pStackData = 								(MP_INTERFACE_LAYER_STACK_DATA *) stackData;	MP_INTERFACE_LAYER_PROFILE_DATA * pProfileData =								(MP_INTERFACE_LAYER_PROFILE_DATA *) profileData;	PFW_STACK_OBJ * pManagerStackObj = NULL;	pManagerStackObj = pProfileData->mpInterface_managerStackId;	bzero ((void *)pStackData, sizeof (MP_INTERFACE_LAYER_STACK_DATA));	return OK;	}/******************************************************************************** mpInterfaceLayerInterfaceBind - bind to the interfaces** The framework calls this function to bind the interfaces the Plugin object * implements. ** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerInterfaceBind	(	PFW_PLUGIN_OBJ * pMpInterfaceLayerObj	)	{	return OK;	}/******************************************************************************** mpInterfacelayerStackAdd - add the MP_INTERFACE_LAYER component to the stack** This function is called when the MP_INTERFACE_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, PPP_AUTH_SUCCESSFUL/ PPP_AUTH_UNSUCCESSFUL* and MP_BUNDLE_CLOSED and registers for the interfaces implemented by the * other components and calls stackAddComplete ( ) callback routine. ** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerStackAdd	(	PFW_PLUGIN_OBJ_STATE 		*pLayerState,	/* plug-in obj state */	PFW_PLUGIN_OBJ_CALLBACKS 	*pCallbacks		/* call back routines */	)	{	MP_INTERFACE_LAYER_STACK_DATA 		*pStackData = 										pLayerState->stackData;	PFW_OBJ 							*pfwObj = 										pLayerState->pluginObj->pfwObj;	UINT 								interfaceId = 0;	PFW_EVENT_OBJ 						*pEventObj = NULL;	PFW_PLUGIN_OBJ 						*mpFramingPluginObj = NULL;	mpFramingPluginObj = pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER");		pStackData->callbacks = pCallbacks;	/* get the interface objects */ 	if ((pStackData->authMpInterfaceId = pfwInterfaceIdGet (pfwObj, 											"AUTH_INFO_INTERFACE")) <= 0 )		return ERROR;	if ((interfaceId = pfwInterfaceIdGet (pfwObj, 						 "MP_CONTROL_LAYER_INTERFACE")) > 0 )		{		if (pfwInterfaceObjAndStateGetViaStackObj (pLayerState->stackObj,			interfaceId, 			&pStackData->mpControlLayerInterfaceStatePair) != OK)	    	{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \					   	   pfwObj, pLayerState->stackObj, "Unable to get the \						   reference to CONTROL_LAYER_INTERFACE state pair\n");			return ERROR;	  	  	}		}	else    	{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \				   	   pfwObj, pLayerState->stackObj, "Unable to get the \					   reference id of the CONTROL_LAYER_INTERFACE state \					   pair\n");		return ERROR;  	  	}	if ((interfaceId = pfwInterfaceIdGet (pfwObj, 						 "LCP_PACKET_SEND_INTERFACE")) > 0 )		{		if (pfwInterfaceObjAndStateGetViaStackObj (pLayerState->stackObj,			interfaceId, 			&pStackData->lcpPacketSendInterfaceStatePair) != OK)	    	{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__,\					   	   pfwObj, pLayerState->stackObj, "Unable to get the \						   reference to LCP_PACKET_SEND_INTERFACE\n");			return ERROR;	  	  	}		}	else    	{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__,\				   	   pfwObj, pLayerState->stackObj, "Unable to get the \					   reference id of the LCP_PACKET_SEND_INTERFACE state \					   pair\n");		return ERROR;  	  	}	if ((interfaceId = pfwInterfaceIdGet (pfwObj, 				 "LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE")) > 0 )		{		if (pfwInterfaceObjAndStateGetViaStackObj (pLayerState->stackObj,			interfaceId, 			&pStackData->lcpNegotiatedAuthProtocolInterfaceStatePair) != OK)	    	{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__,\					   	   pfwObj, pLayerState->stackObj, "Unable to get the \						   reference to \						   LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE");			return ERROR;	  	  	}		}	else    	{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__,\				   	   pfwObj, pLayerState->stackObj, "Unable to get the \					   reference id of the \					   LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE state pair");		return ERROR;  	  	}	/* subscribe for the events */	if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "LCP_UP_EVENT")) != NULL)		{		if (ERROR == (pfwEventStackSubscribe (pLayerState, pEventObj, 								mpInterfaceLayerLcpUpEventHandler)))    		{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \					   	   pfwObj, pLayerState->stackObj, "Failed to subscribe \						   for LCP_UP event");			return ERROR;  	  		}		}	else   		{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__,\				   	   pfwObj, pLayerState->stackObj, "Unable to get event obj\					   of the LCP_UP event\n");		return ERROR;  		}	if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "PPP_LINK_RESET_EVENT")) != NULL)		{		if (ERROR == (pfwEventStackSubscribe (pLayerState, pEventObj, 								mpInterfaceLayerMpLinkDownEventHandler)))    		{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \					   	   pfwObj, pLayerState->stackObj, "Failed to subscribe \						   for PPP_LINK_RESET_EVENT event");			return ERROR;  	  		}		}	else   		{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \				   	   pfwObj, pLayerState->stackObj, "Unable to get event obj \					   of the PPP_LINK_RESET_EVENT event\n");		return ERROR;  		}	if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj,									 "PPP_AUTH_SUCCESSFUL_EVENT")) != NULL)		{		if (ERROR == (pfwEventStackSubscribe (pLayerState, pEventObj, 								mpInterfaceLayerAuthUpEventHandler)))    		{			pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \					   	   pfwObj, pLayerState->stackObj, "Failed to subscribe \						   for PPP_AUTH_SUCCESSFUL_EVENT event");			return ERROR;  	  		}		}	else   		{		pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \				   	   pfwObj, pLayerState->stackObj, "Unable to get event obj \					   of the PPP_AUTH_SUCCESSFUL_EVENT event\n");		return ERROR;  		}

⌨️ 快捷键说明

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