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

📄 mpbdlmanagement.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* mpBdlManagement.c - Mp Bundle Management *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01d,06aug02,jr  fixed build warnings 01c,19feb02,ak  input parameter validation in all the functions01b,19sep01,ak  support for calculation of aggregate MRU and MRU share of 				individual member links01a,19feb01,ak	created*//*DESCRIPTIONThis module implements a part of Multi-Link Point-to-Point Protocol specified by RFC 1990. This module contains functions for that are used for managing bundle structures used by the MP implementation. These functions are used whena link is added to or remove from the bundle*/ /* includes */#include "vxWorks.h"#include "ppp/mp.h" #include "private/ppp/mpFramingLayerP.h"#include "string.h"#include "tickLib.h"#include "sllLib.h"#include "stdio.h"/* externs *//* locals and forwards */BOOL is_bundle_exist	(PFW_OBJ  *, PFW_PLUGIN_OBJ_STATE	**,							 MP_BUNDLE_IDENTIFIER *);STATUS mpInitialize (PFW_PLUGIN_OBJ_STATE *, PFW_STACK_OBJ *);			void mp_initialize_sending_end_of_the_bundle (PFW_PLUGIN_OBJ_STATE *);void mp_initialize_receiving_end_of_the_bundle (PFW_PLUGIN_OBJ_STATE *);STATUS mp_remove_port_from_sending_end_of_the_bundle 						(PFW_PLUGIN_OBJ_STATE *, PFW_STACK_OBJ *);char * mp_fragment_flag_enum_to_string (enum FRAGMENT_FLAG);TEST mp_receive_port_is_in_bundle (PFW_STACK_OBJ	*,						PFW_STACK_OBJ	**);STATUS mp_remove_port_from_receiving_end_of_the_bundle 						(PFW_PLUGIN_OBJ_STATE *, PFW_STACK_OBJ *);STATUS mp_bundle_sending_end_update_bandwidth_share_information						(PFW_PLUGIN_OBJ_STATE *);void mpBundleProfileGet (PFW_PLUGIN_OBJ_STATE *, LCP_BUNDLE_PROFILE	*);LOCAL BOOL are_station_discriminator_same (MP_DISCRIMINATOR_CLASS *,						MP_DISCRIMINATOR_CLASS *);LOCAL STATUS mp_construct_sending_end_of_the_bundle (PFW_PLUGIN_OBJ_STATE *,						PFW_STACK_OBJ *);LOCAL void mp_initialize_sending_end_link_class (PFW_PLUGIN_OBJ_STATE *, 						USHORT);LOCAL STATUS mp_construct_receiving_end_of_the_bundle						(PFW_PLUGIN_OBJ_STATE *, PFW_STACK_OBJ *);LOCAL void mp_initialize_receiving_end_link_class (PFW_PLUGIN_OBJ_STATE	*, 						USHORT);STATUS mp_bundle_sending_end_update_mru_share_information (PFW_PLUGIN_OBJ_STATE	*);/******************************************************************************** is_bundle_exist - Checks whether any bundle exists with the given bundle * identifier in the given framework* * This function compares the members of the given bundle identifier structure * with those of the bundle identifier structures of the already existing * bundles in the given framework. If the given bundle identifier matches with * that of any of the existing bundle, it fills the plugin obj state of the * mpFraming layer in that bundle stack in one of the passed input parameter.*  * RETURNS: TRUE or FALSE*/BOOL is_bundle_exist	(	PFW_OBJ 				*pfwObj,				/* framework reference */	PFW_PLUGIN_OBJ_STATE	**ppMpFramingLayerState, 		/* Matching bundle's mpFraming layer state is filled in this variable */	MP_BUNDLE_IDENTIFIER	*pBundleIdentifier		/* bundle identifier */	)	{	MP_FRAMING_LAYER					*pMpFramingLayerComponentData = NULL;	UINT 								bundleNumber = 0;	MP_BUNDLE_IDENTIFIER				*pBundleId = NULL;	BOOL 								returnCode;	MP_FRAMING_LAYER_STACK_DATA         *pStackData = NULL;	PFW_PLUGIN_OBJ						*pPluginObj = NULL;	if (pfwObj == NULL)		{		printf ("Null framework pointer\n");		return FALSE;		}	if ((ppMpFramingLayerState == NULL) || (pBundleIdentifier == NULL))		return FALSE;	/* Get component object */	pPluginObj = 		pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER");	if (pPluginObj == NULL)		{		printf ("MpFraming layer component does not exist in the framework\n");		return FALSE;		}	pMpFramingLayerComponentData = 				(MP_FRAMING_LAYER *) pPluginObj;	if (semTake (pMpFramingLayerComponentData->componentSem, WAIT_FOREVER)																 == ERROR)		return FALSE;	/* 	 * compare the bundle identifier with the bundle identifiers of the already 	 * existing bundle in the framework	 */	returnCode = FALSE;			for (bundleNumber = 0; 			bundleNumber < pMpFramingLayerComponentData->no_of_bundles;			bundleNumber++)		{		if (pfwPluginObjStateLock (pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]) == ERROR)			if (semGive (pMpFramingLayerComponentData->componentSem) == ERROR)				return FALSE;		pStackData = 				(MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]->stackData;				pBundleId = &pStackData->bundle.id;		/* Compare local discriminators */		if (are_station_discriminator_same 					(&pBundleId->local_station_discriminator, 			  		 &pBundleIdentifier->local_station_discriminator) == FALSE)			{			if (pfwPluginObjStateRelease (pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]) == ERROR)				{				if (semGive (pMpFramingLayerComponentData->componentSem) 																	== ERROR)					return FALSE;				}			continue;			}		/* Compare remote discriminatosr */		if (are_station_discriminator_same 					(&pBundleId->remote_station_discriminator, 					 &pBundleIdentifier->remote_station_discriminator) == FALSE)			{			if (pfwPluginObjStateRelease (pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]) == ERROR)				{				if (semGive (pMpFramingLayerComponentData->componentSem) 																	== ERROR)					return FALSE;				}			continue;			}		/* Compare local user and remote user name */		if (pBundleIdentifier->link_failed_to_be_authenticated == FALSE)			{			if (strcmp (pBundleIdentifier->local_user_name, 						pBundleId->local_user_name) != 0)				{				if (pfwPluginObjStateRelease (pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]) == ERROR)					{					if (semGive (pMpFramingLayerComponentData->componentSem)															   		== ERROR)						return FALSE;					}				continue;				}			if (strcmp (pBundleIdentifier->remote_user_name, 						pBundleId->remote_user_name) != 0)				{				if (pfwPluginObjStateRelease (pMpFramingLayerComponentData->								pMpFramingLayerState [bundleNumber]) == ERROR)					{					if (semGive (pMpFramingLayerComponentData->componentSem) 																	 == ERROR)						return FALSE;					}				continue;				}			}			/* Match is found */			*ppMpFramingLayerState = pMpFramingLayerComponentData->										pMpFramingLayerState [bundleNumber];			if (pfwPluginObjStateRelease (pMpFramingLayerComponentData->							pMpFramingLayerState [bundleNumber]) == ERROR)				{				if (semGive (pMpFramingLayerComponentData->componentSem) 																== ERROR)					return FALSE;					}			returnCode = TRUE;			break;		}	if (semGive (pMpFramingLayerComponentData->componentSem) == ERROR)		return FALSE;			return returnCode;	}/******************************************************************************** are_station_discriminators_same - *						Checks whether given two end point discriminators same* * RETURNS: TRUE or FALSE*/LOCAL BOOL are_station_discriminator_same	(	MP_DISCRIMINATOR_CLASS	*pFirstDiscriminator, /* First Discriminator */	MP_DISCRIMINATOR_CLASS	*pSecondDiscriminator /* Second Discriminator */	)	{	if (pFirstDiscriminator == NULL || pSecondDiscriminator == NULL)		{		return FALSE;		}	if (pFirstDiscriminator->discriminatorClass != 			pSecondDiscriminator->discriminatorClass)		{		return FALSE;		}	if (pFirstDiscriminator->length != pSecondDiscriminator->length)		{		return FALSE;		}	if (memcmp ( (const void *)pFirstDiscriminator->address, 					(const void *)pSecondDiscriminator->address, 					(size_t) pFirstDiscriminator->length) != 0)				{		return FALSE;		}		return TRUE;	}/******************************************************************************** mp_initialize - Adds a link to the bundle** This function adds the link to the given bundle. It constructs sending end and * receiving end of the bundle. It assigns the bundle to the Member Stack in the * bundle assignment class using mp_set_port_to_bundle_number_mapping ()						* * RETURNS: OK or ERROR*/STATUS mpInitialize	(	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;	MP_FRAMING_LAYER		        *pComponentData = NULL;	UINT 							loopIndex = 0;	LCP_BUNDLE_OPTIONS				*pLcpBundleOptions = NULL;	STATUS							status;	if ((pMpFramingLayerState == NULL) || (pMemberStackObj == NULL))		return ERROR;		pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pComponentData = 				(MP_FRAMING_LAYER *) pMpFramingLayerState->pluginObj;	/* 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;	/* Construct sending end for the link */	if (pLcpBundleOptions->is_link_in_sending_end == TRUE)		{		status = mp_construct_sending_end_of_the_bundle      		    	(pMpFramingLayerState, pMemberStackObj);		if (status == ERROR)			return ERROR;		}	/* Construct receiving end for the link */	if (pLcpBundleOptions->is_link_in_receiving_end == TRUE)		{		status = mp_construct_receiving_end_of_the_bundle 					(pMpFramingLayerState, pMemberStackObj);		if (status == ERROR)			return ERROR;		}	/* 	 * Serach the matching entry for the link in the port_to_bundle_assignment	 * array 	 */	for (loopIndex = 0; loopIndex < pComponentData->no_of_ports; loopIndex++)		{		if (pComponentData->port_to_bundle_assignment[loopIndex].pMemberStackObj															 == pMemberStackObj)			break;		}	if (loopIndex == pComponentData->no_of_ports)		{		if (pComponentData->no_of_ports == MAX_NO_OF_PPP_PORTS)			return ERROR;		/* Add new entry for the link */		pComponentData->no_of_ports++;		}	/* Set bundle assignment for the link */		pComponentData->port_to_bundle_assignment[loopIndex].pMemberStackObj			 	= pMemberStackObj;			pComponentData->port_to_bundle_assignment[loopIndex].pManagerStackObj			 	= pMpFramingLayerState->stackObj;			pComponentData->	port_to_bundle_assignment[loopIndex].is_port_assigned_to_a_bundle = TRUE;	if (pLcpBundleOptions->is_link_in_receiving_end == TRUE)		{		pComponentData->		port_to_bundle_assignment[loopIndex].port_used_in_receiving_end = TRUE;				}	if (pLcpBundleOptions->is_link_in_sending_end == TRUE)		{		pComponentData->		port_to_bundle_assignment[loopIndex].port_used_in_sending_end = TRUE;				}	return OK;	}/******************************************************************************** mp_construct_sending_end_of_the_bundle - *							Constructs or updates the sending end of the bundle** This function constructs the sending end link class for the given link. If the * given link is the first link in the sending end of the bundle, it initializes * the sending end class of the bundle and configures the transmit end parameters * like remote MRRU,  MP header format etc. with the values negotiated on the * link.					* * RETURNS: OK or ERROR*/LOCAL STATUS mp_construct_sending_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;	MP_FRAMING_LAYER_PROFILE_DATA 	*pProfileData = NULL;	UINT 							loopIndex = 0;	LCP_BUNDLE_OPTIONS				*pLcpBundleOptions = NULL;	USHORT 							linkNumber = 0;	PFW_OBJ							*pfwObj = NULL;	PFW_PLUGIN_OBJ_STATE			*pState = NULL;	PFW_PLUGIN_OBJ					*pPluginObj = NULL;	MP_BUNDLE_SENDING_END_CLASS		*pSendingEndClass = NULL;	STATUS							status;	if ((pMpFramingLayerState == NULL) || (pMemberStackObj == NULL))		return ERROR;		pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;	pProfileData = 			 pMpFramingLayerState->profileData;

⌨️ 快捷键说明

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