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

📄 mpapi.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* mpAPI.c - MP user interfaces functions source file *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01o,31jan03,ijm fix for SPR# 86001, cannot re-establish bundle if peer reboots01n,15jan03,ijm fix for SPR# 85776, mpBundleCreate should not attempt to                remove conflicting FRAMING plane components from profile01m,22oct02,ijm include mpP.h01l,06aug02,jr  fixed build warnings 01k,04may02,ak  modifcations in printing class 1 EID in mpBundleListShow()01j,23feb02,jr  setting the pointers to NULL after freeing01i,19feb02,ak  input parameter validations in all the functions01h,18dec01,ak  support for dynamic assignment of MP Member Stack to Manager                 Stack01g,19sep01,ak  Removing SIO_ADAPTER from the profile before the Manager Stack                 population in mpBundleCreate()01f,19sep01,ak  input parameter validation in mpLinkAdd() and mpBundleCreate()01e,28aug01,as  modified printDiscriminator () function01e,08jul01,as  modified printDiscriminator () function01d,03jul01,ak  configuring mpInterface_managerStackId in the                 mpSetPortToBundleMapping()01c,20jun01,ak  removed the intialization in the for loops in mpBundleClose ()                for warning free compilation01c,05may01,ak  changed API names to WRS naming conventions01b,04may01,ak  added printDiscriminator ()01a,21feb01,as	created*//*DESCRIPTIONThis module provides the API functions provided by theMP_FRAMING_LAYER and the MP_INTERFACE_LAYER components.It provides user interface to Create, Close and Delete bundles.It also provides function to add a link to specific bundle.It provides various show routines for user to view and verify the bundle properties, link properties within a specific bundle.INCLUDE FILES : mpFramingLayerP.h mpAPI.h*//* defines *//* includes */#include "private/ppp/mpFramingLayerP.h"#include "private/ppp/mpP.h"#include "ppp/mpAPI.h"#include "ppp/pppInterfaces.h"#include "stdlib.h"#include "fioLib.h"#include "stdio.h"#include "net/inet.h"#include "netLib.h"#include "pfw/pfwProfile.h"/* externs */IMPORT void mp_initialize_sending_end_of_the_bundle (PFW_PLUGIN_OBJ_STATE *);IMPORT void mp_initialize_receiving_end_of_the_bundle (PFW_PLUGIN_OBJ_STATE *);IMPORT STATUS mpLinkAssign (PFW_STACK_OBJ *, PFW_STACK_OBJ	*);IMPORT BOOL is_bundle_exist	(PFW_OBJ  *, PFW_PLUGIN_OBJ_STATE	**,							 MP_BUNDLE_IDENTIFIER *); IMPORT BOOL is_RFC_1990_5_1_3_CASE_1 (MP_BUNDLE_IDENTIFIER	*); /* locals */LOCAL void printDiscriminator (PFW_OBJ *, MP_DISCRIMINATOR_CLASS, BOOL);/******************************************************************************** mpBundleCreate - create a manager Stack** This function creates a manager's stack for a bundle based on <pMgrProfileObj>.* This function will not remove any FRAMING PLANE components from the profile.* It will add the MP FRAMING LAYER to <pMgrProfileObj>. ** RETURNS: PFW_STACK_OBJ * or NULL**/PFW_STACK_OBJ * mpBundleCreate    (    PFW_PROFILE_OBJ         * pMgrProfileObj,  /* manager profile */	    PFW_STACK_OBJ_CALLBACKS * callbacks,       /* callback functions */    void                    * userHandle     )    {    PFW_OBJ                 * pfwFrameworkObj = NULL;    PFW_STACK_OBJ           * pManagerStackObj = NULL;    UINT                      paramId = 0;    if (pMgrProfileObj == NULL)        return NULL;    pfwFrameworkObj = pfwProfilePfwObjGet (pMgrProfileObj);    if (pfwFrameworkObj == NULL)         return NULL;    /* Add MP FRAMING LAYER to manager's profile */    paramId = pfwParameterIdGet (pfwFrameworkObj, "_add_static_MP_FRAMING_LAYER");    if (paramId == 0)        return NULL;    if (pfwProfileSet (pMgrProfileObj, paramId, "") != OK)        return NULL;            pManagerStackObj = pfwStackAdd (pMgrProfileObj, callbacks, userHandle);    return pManagerStackObj;    }/******************************************************************************** mpBundleDown - bring bundle down** This function sets bundle state to BUNDLE_CLOSED and raises BUNDLE_CLOSED * event. On this event, member links close the connection by sending LCP * Terminate-Request. It also closes the LCP on the stack through proxy * LCP interface. If adminClose is TRUE, the bundle will be closed* administratively. ** RETURNS: OK or ERROR** NOMANUAL*/STATUS mpBundleDown    (    PFW_STACK_OBJ *pManagerStackObj,  /* manager stack object */    BOOL          adminClose          /* close bundle administratively */    )    {	PFW_OBJ 						* pfwFrameworkObj = NULL;	PFW_PLUGIN_OBJ 					* pluginObj = NULL;	PFW_PLUGIN_OBJ_STATE 			* mpFramingLayerPluginObjState = NULL;	MP_FRAMING_LAYER_STACK_DATA 	* pFramingLayerStackData = NULL;	MP_FRAMING_LAYER 				* mpFramingComponent = NULL;	int 							no_of_links = 0;	int 							found = 0;	USHORT 							bundleIndex = 0;	int 							loopIndex = 0;	PFW_STACK_OBJ					* pMemberStackObj = NULL;	LCP_BUNDLE_OPTIONS				* pLcpBundleOptions = NULL;	if (pManagerStackObj == NULL)		return ERROR;	pfwFrameworkObj = pfwStackObjPfwGet (pManagerStackObj);	pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER");	if ((mpFramingLayerPluginObjState = pfwPluginObjStateGet 										(pManagerStackObj, pluginObj)) == NULL)		{		return ERROR;		}	if (pfwPluginObjStateLock (mpFramingLayerPluginObjState) == ERROR)		return ERROR;	pFramingLayerStackData = mpFramingLayerPluginObjState->stackData;	if (pFramingLayerStackData->bundle_state == MP_BUNDLE_CLOSED_STATE)		{		if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR)			return ERROR;		return OK;		}	no_of_links = pFramingLayerStackData->bundle.no_of_links;	/* Initialize sending_end class of the bundle */	mp_initialize_sending_end_of_the_bundle (mpFramingLayerPluginObjState);	/* Initialize receiving_end class of the bundle */	mp_initialize_receiving_end_of_the_bundle (mpFramingLayerPluginObjState);		pFramingLayerStackData->bundle.sending_end.master_long_sequence_number = 0;	pFramingLayerStackData->bundle.sending_end.master_short_sequence_number = 0;		/* Clear the Port Class Array */		for (loopIndex = 0; loopIndex < no_of_links; loopIndex++)		{		pLcpBundleOptions = pFramingLayerStackData->							bundle.memberLinks [loopIndex].pLcpBundleOptions;	    if (pLcpBundleOptions != NULL)            {            pfwFree (pLcpBundleOptions);            pLcpBundleOptions = NULL;            }		}				pFramingLayerStackData->bundle_state = MP_BUNDLE_CLOSED_STATE;	/* get the MP FRAMING LAYER COMPONENT structure address */	mpFramingComponent = (MP_FRAMING_LAYER *) 										mpFramingLayerPluginObjState->pluginObj;	if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR)		{	 	if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR)			return ERROR;		return ERROR;		}	/* Update Bundle Count to Manager Stack look up class array */	for (bundleIndex = 0;		bundleIndex < mpFramingComponent->no_of_bundles;		bundleIndex ++)		{		if (mpFramingComponent->bundle_count_to_manager_stackObj_lookup							[bundleIndex].pManagerStackObj == pManagerStackObj)			{			found = 1;			break;			}		}	if (found == 1)		{		for (;			bundleIndex < (mpFramingComponent->no_of_bundles - 1);			bundleIndex ++)			{			mpFramingComponent->bundle_count_to_manager_stackObj_lookup 			[bundleIndex].pManagerStackObj = 			mpFramingComponent->bundle_count_to_manager_stackObj_lookup			[bundleIndex + 1].pManagerStackObj;			}			mpFramingComponent->bundle_count_to_manager_stackObj_lookup 								[bundleIndex].pManagerStackObj = NULL;		}		/* Searching the entry in the mpFraming layer state array */	for (bundleIndex = 0;		bundleIndex < mpFramingComponent->no_of_bundles;		bundleIndex ++)		{		if (mpFramingComponent->pMpFramingLayerState[bundleIndex]						== mpFramingLayerPluginObjState)			{			found = 1;			break;			}		}		if (found == 1) 		{		/* Remove the entry from the mpFraming layer state array */		for (;			bundleIndex < (mpFramingComponent->no_of_bundles - 1);			bundleIndex ++)			{			mpFramingComponent->pMpFramingLayerState[bundleIndex] = 							mpFramingComponent->pMpFramingLayerState[bundleIndex + 1];			}		mpFramingComponent->pMpFramingLayerState[bundleIndex] = NULL;		}	/* Decrement the bundle count */	mpFramingComponent->no_of_bundles--;	/* Update Bundle Assignment Array */	for (loopIndex = 0; loopIndex < mpFramingComponent->no_of_ports; 		 loopIndex++)		{		if (mpFramingComponent->port_to_bundle_assignment[loopIndex].										pManagerStackObj == pManagerStackObj)			mpFramingComponent->port_to_bundle_assignment[loopIndex].										port_used_in_sending_end  = FALSE;			mpFramingComponent->port_to_bundle_assignment[loopIndex].										port_used_in_receiving_end  = FALSE; 		}	if (semGive (mpFramingComponent->componentSem) == ERROR)		{	 	if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR) 			return ERROR;		return ERROR;		}	/* Raise the Bundle Closed Event to Member Links */	no_of_links = mpGetNoOfLinksInTheBundle (pManagerStackObj);	pFramingLayerStackData->bundle.no_of_links = 0; 	for (loopIndex = 0; loopIndex < no_of_links; loopIndex++)		{		pMemberStackObj = 		pFramingLayerStackData->bundle.memberLinks [loopIndex].pMemberStackObj;		bzero ((char *)&pFramingLayerStackData->bundle.memberLinks [loopIndex],				sizeof (MP_PORT_CLASS));		pfwEventRaise (pMemberStackObj, 					   pFramingLayerStackData->pMpBundleClosedEventObj,					   pManagerStackObj);		}		/* Raise the Bundle Closed Event to Manager Stack */	pfwEventRaise (pManagerStackObj, 					pFramingLayerStackData->pMpBundleClosedEventObj,					pManagerStackObj);    if (!adminClose)        pfwEventRaise (pManagerStackObj,                       pFramingLayerStackData->pMpSubLayerDeadEventObj,NULL); 	if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR) 		return ERROR;    if (adminClose)        pppConnectionClose (pManagerStackObj);	return OK;	}/******************************************************************************** mpBundleClose - close a bundle** This function sets bundle state to BUNDLE_CLOSED and raises BUNDLE_CLOSED* event. On this event, member links close connections by sending LCP* Terminate-Request. This function also closes <pManagerStackObj>* administratively.** RETURNS: OK, or ERROR*/STATUS mpBundleClose    (    PFW_STACK_OBJ *pManagerStackObj     /* manager stack object */    )    {    return (mpBundleDown (pManagerStackObj,TRUE));    }/******************************************************************************** mpBundleDelete - Closes all the links in the bundle and deletes the Manager Stack** This function closes the PPP connection on all the member links and also the * Manager Stack. It deletes the Manager Stack. It updates bundle-assignment * class, bundle-count-to-manager-stack lookup class in the mpFramingLayer * component structure and removes the entry of this stack from mpFramingLayer.** RETURNS: OK/ERROR*/STATUS mpBundleDelete	(	PFW_STACK_OBJ *pManagerStackObj		/* manger stack object */	)	{	PFW_OBJ 						* pfwFrameworkObj = NULL;	PFW_PLUGIN_OBJ 					* pluginObj = NULL;	PFW_PLUGIN_OBJ_STATE 			* mpFramingLayerPluginObjState = NULL;	MP_FRAMING_LAYER_STACK_DATA 	* pFramingLayerStackData = NULL;	MP_FRAMING_LAYER 				* mpFramingComponent = NULL;	USHORT 							bundleIndex = 0;	if (pManagerStackObj == NULL)			return ERROR;	pfwFrameworkObj = pfwStackObjPfwGet (pManagerStackObj);	pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER");	if ((mpFramingLayerPluginObjState = pfwPluginObjStateGet 						(pManagerStackObj, pluginObj)) == NULL)		{		return ERROR;		}	pFramingLayerStackData = mpFramingLayerPluginObjState->stackData;	/* Close the bundle */	if (pFramingLayerStackData->bundle_state != MP_BUNDLE_CLOSED_STATE)		{

⌨️ 快捷键说明

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