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

📄 mpframinglayerinterface.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	/* Local End EID */	bzero (profileString, sizeof (profileString)); 	bzero (temp, sizeof (temp));	/* EID support */	strcpy (temp, (char *) lcpBundleProfile.local_station_discriminator);	cptr_parameter = strtok (temp, "-");	eidClass = atoi (cptr_parameter);	if (eidClass == 0)		strcpy (profileString, "Local:Negotiation Not Required, Not Negotiable: 0");	else		{	/* EID support */		strcpy (profileString, "Local:Negotiation Required, Not Negotiable:");		strcat (profileString, (char *) lcpBundleProfile.local_station_discriminator);		}	pfwStackParamSet (pMemberStackObj, paramId, "Local:"); 	pfwStackParamSet (pMemberStackObj, paramId, profileString);	/* Remote End EID */	bzero (profileString, sizeof (profileString)); 	bzero (temp, sizeof (temp));	/* EID support */	strcpy (temp, (char *) lcpBundleProfile.remote_station_discriminator);	cptr_parameter = strtok (temp, "-"); 	eidClass = atoi (cptr_parameter);	if (eidClass == 0)		strcpy (profileString, "Remote:Negotiation Not Required, Not Negotiable: 0");	else		{		/* EID support */		strcpy (profileString, "Remote:Negotiation Required, Not Negotiable:");		strcat (profileString, (char *) lcpBundleProfile.remote_station_discriminator);		}	pfwStackParamSet (pMemberStackObj, paramId, "Remote:"); 	pfwStackParamSet (pMemberStackObj, paramId, profileString);	/* Authentication Protocol */	paramId = pfwParameterIdGet (pfwObj, "lcp_authProtocol");	/* Local authentication protocol */	bzero (temp, sizeof (temp));	bzero (profileString, sizeof (profileString));	strcpy (profileString, "Local:Negotiation Required, Not Negotiable:");	if (lcpBundleProfile.localAuthProtocol == 0)		{		strcpy (profileString, "Local:");		}	else		{		/* Configure local end auth component */		sprintf (temp, "%x", lcpBundleProfile.localAuthProtocol); 		strcat (profileString, temp);		}	pfwStackParamSet (pMemberStackObj, paramId, "Local:"); 	pfwStackParamSet (pMemberStackObj, paramId, profileString);	/* Remote authentication protocol */	bzero (temp, sizeof (temp));	bzero (profileString, sizeof (profileString));	strcpy (profileString, "Remote:Negotiation Required, Not Negotiable:");	if (lcpBundleProfile.remoteAuthProtocol == 0)		{		strcpy (profileString, "Remote:");		}	else		{		sprintf (temp, "%x", lcpBundleProfile.remoteAuthProtocol);			strcat (profileString, temp);		}	pfwStackParamSet (pMemberStackObj, paramId, "Remote:"); 	pfwStackParamSet (pMemberStackObj, paramId, profileString);	/* Set port to bundle assignment */	if (mpSetPortToBundleMapping (pMemberStackObj, pManagerStackObj) == 																		FAIL) 		return ERROR;#ifdef PPP_DEBUG		printf ("The link 0x%x was configured with the profile of the bundle  \				 0x%x\n", (int) pMemberStackObj, (int) pManagerStackObj);#endif	return OK;	}/******************************************************************************** mpBAPLinkInfoListGet - Get the list of MP_LINK_INFO structures for the links in the * bundle** This function constructs the list of MP_LINK_INFO structures for the links in * the bundle. This function is called by BAP component when it comes UP. BAP * initializes its structures with this list** RETURNS: SL_LIST * or NULL*/SL_LIST * mpBAPLinkInfoListGet	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState							/* mpFraming layer state representing the bundle */	)	{	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	SL_LIST							*pMpInfoList = NULL;	MP_LINK_INFO_ITEM				*pMpLinkInfoItem = NULL;	PFW_OBJ							*pfwObj = NULL;	LCP_BUNDLE_OPTIONS				*pLcpBundleOptions = NULL;	UINT							loopIndex = 0;	if (pMpFramingLayerState == NULL)		return NULL;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData;		/* Getting the framework reference */	pfwObj = pfwStackObjPfwGet (pMpFramingLayerState->stackObj);	if (pfwObj == NULL)		{		pfwPrintError (__FILE__, "mpLinkAssign",__LINE__, 0,  \						pMpFramingLayerState->stackObj, "NULL Framework \						reference");		return NULL;		}	pMpInfoList = (SL_LIST *) pfwMalloc (pfwObj, sizeof (SL_LIST));	if (pMpInfoList == NULL)		{		pfwPrintError (__FILE__, "mpBAPLinkInfoListConstruct", __LINE__, \                             pfwObj,pMpFramingLayerState->stackObj,"Unable to allocate memory");		return (NULL);		}	sllInit (pMpInfoList); 	if (pfwPluginObjStateLock (pMpFramingLayerState) == ERROR)		return NULL;	for (loopIndex = 0; loopIndex < pStackData->bundle.no_of_links; loopIndex++)		{		 pMpLinkInfoItem = 			(MP_LINK_INFO_ITEM *) pfwMalloc (pfwObj, sizeof(MP_LINK_INFO_ITEM));		    if (pMpLinkInfoItem == NULL)			{			pfwPrintError (__FILE__, "mpBAPLinkInfoListConstruct", __LINE__, \				pfwObj, pMpFramingLayerState->stackObj, "Unable to allocate memory");			if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR)				return NULL;			return (NULL);			}			pMpLinkInfoItem->mpLinkInfo.pLinkStackObj = 						pStackData->bundle.memberLinks[loopIndex].pMemberStackObj;		pMpLinkInfoItem->mpLinkInfo.port_speed = 						pStackData->bundle.memberLinks[loopIndex].speed;		pLcpBundleOptions = 					pStackData->bundle.memberLinks[loopIndex].pLcpBundleOptions;		pMpLinkInfoItem->mpLinkInfo.local_link_discriminator = 						pLcpBundleOptions->local_link_discriminator;		pMpLinkInfoItem->mpLinkInfo.remote_link_discriminator = 						pLcpBundleOptions->remote_link_discriminator;				sllPutAtTail (pMpInfoList, (SL_NODE *) pMpLinkInfoItem);		}			if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR)		return NULL;	return pMpInfoList;	} /******************************************************************************** authInformationOnTheLinkGet - Retrieves auth. information from the member link* * This function retrieves local user name and remote user name information used * in the authentication phase at the local end and remote end in the member * link through the AUTH_INFO_INTERFACE implemented by the authentication * components. * * RETURNS: OK or ERROR*/LOCAL STATUS authInformationOnTheLinkGet 	( 	LCP_BUNDLE_OPTIONS	*pLcpBundleOptions, /* reference to LCP_BUNDLE_OPTIONS 											   structure to store authentication 											   information  */	PFW_STACK_OBJ		*pMemberStackObj    /* stackObj of the member link */	)	{	STATUS	status;	if ((pLcpBundleOptions == NULL) || (pMemberStackObj == NULL))		return ERROR;	/* 	 * If authentication phase does not exist in the stack, set 	 * link_failed_to_be_autheticated to TRUE 	 */	if ((pLcpBundleOptions->localAuthProtocol == 0) &&		(pLcpBundleOptions->remoteAuthProtocol == 0))		{		pLcpBundleOptions->bundle_identifier.link_failed_to_be_authenticated =																		   TRUE;		strcpy 		(pLcpBundleOptions->bundle_identifier.local_user_name, NULL_STRING);		strcpy 		(pLcpBundleOptions->bundle_identifier.remote_user_name, NULL_STRING);		}	else		{			/* Retrieve the local user name */		status = userNameOnTheLinkGet 								(pMemberStackObj, 								 pLcpBundleOptions->localAuthProtocol,								 LOCAL_END_AUTH_PHASE, pLcpBundleOptions->bundle_identifier.local_user_name);		if (status == ERROR)			return ERROR;		/* Retrieve the remote user name */		status = userNameOnTheLinkGet 								(pMemberStackObj, 								 pLcpBundleOptions->remoteAuthProtocol,								 REMOTE_END_AUTH_PHASE,								 pLcpBundleOptions->bundle_identifier.remote_user_name);		if (status == ERROR)			return ERROR;							 		pLcpBundleOptions->bundle_identifier.link_failed_to_be_authenticated =																		  FALSE;		}	return OK;	}/******************************************************************************** userNameOnTheLinkGet - Retrieves user name information from the member link* * This function retrieves  user name used in the authentication phase at the * remote end or local end in the member link through AUTH_INFO_INTERFACE * implemented by the authentication components. * * RETURNS: OK or ERROR*/LOCAL STATUS userNameOnTheLinkGet 	(	PFW_STACK_OBJ		*pMemberStackObj,    /* stackObj of the member link */	USHORT				authProtocol,		 /* Authentication protocol used */	AUTH_PHASE			authPhase,			 /* local end or remote end */	char				*pUserName	         /* buffer to copy the user name */	)	{	PFW_PLUGIN_OBJ			*pAuthPluginObj = NULL;	PFW_OBJ					*pfwObj = NULL;	UINT					authMpInterfaceId = 0;	AUTH_INFO_INTERFACE		*pAuthMpInterfaceObj = NULL;	PFW_PLUGIN_OBJ_STATE	*pAuthComponentState = NULL;	if ((pUserName == NULL) || (pMemberStackObj == NULL))		return ERROR;	if (authProtocol == 0)		{		strcpy (pUserName, NULL_STRING);		return OK;		}			else		{			/* Get framework obj */		pfwObj = pfwStackObjPfwGet (pMemberStackObj);		if (pfwObj == NULL)			{			pfwPrintError (__FILE__, "userNameOnTheLinkGet",__LINE__, 0, 0, \						   "NULL Framework reference");			return ERROR;			}		/* Get the AUTH_INFO_INTERFACE id */		authMpInterfaceId = pfwInterfaceIdGet (pfwObj, "AUTH_INFO_INTERFACE");		if (authMpInterfaceId == 0) 			return ERROR;		/* Get the plugin obj of the auth. protocol */		pAuthPluginObj = (PFW_PLUGIN_OBJ *)pfwComponentObjGetByProtocol 														(pfwObj, authProtocol);			if (pAuthPluginObj == NULL)			{			printf ("MP:userNameOnTheLinkGet():could not find plugin obj for  \					 protocol #0x%x\n", authProtocol);			return ERROR;			}		/* 		 * Get the reference for MP_AUTH_INTERFACE implemented by the auth.		 * protocol 		 */		pAuthMpInterfaceObj = 					(AUTH_INFO_INTERFACE *) pfwInterfaceObjGetViaPluginObj 											(pAuthPluginObj, authMpInterfaceId);		if (pAuthMpInterfaceObj == NULL)			{			printf ("MP:userNameOnTheLinkGet():No AUTH_INFO_INTERFACE for  \					 protocol 0x%x\n", authProtocol);			return ERROR;			}				/* 		 * Get the plugin obj state of the auth. protocol in the member 		 * stack 		 */		pAuthComponentState = 			pfwPluginObjStateGet (pMemberStackObj, pAuthPluginObj);		if (pAuthComponentState == NULL)			{			printf ("MP:userNameOnTheLinkGet():Component implementing protocol  \					0x%x does not exist in the stack 0x%x\n", authProtocol, \					(int) pMemberStackObj);            pfwInterfaceReferenceDelete (                            &pAuthMpInterfaceObj->interfaceObj);			return ERROR;			}		/* Retrieve the user name */		switch (authPhase)			{			case LOCAL_END_AUTH_PHASE:				pAuthMpInterfaceObj->localUserNameGet 											(pAuthComponentState, pUserName);				break;			case REMOTE_END_AUTH_PHASE:				pAuthMpInterfaceObj->remoteUserNameGet 											(pAuthComponentState, pUserName);				break;			default:				return ERROR;			}           pfwInterfaceReferenceDelete (                            &pAuthMpInterfaceObj->interfaceObj);		}	return OK;	}/******************************************************************************** linkToTheBundleAdd - Adds the link to the bundle * * This function adds the link to the bundle. It adds the link to the port class * array of the bundle structure and updates sending end class and recieving end * class.** RETURNS: OK or ERROR*/LOCAL STATUS linkToTheBundleAdd		(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState,							/* mpFraming layer state representing the bundle */	PFW_STACK_OBJ			*pMemberStackObj, /* Stack Obj of the member link */	LCP_BUNDLE_OPTIONS		*pLcpBundleOptions    			 /* structure containing MP related parameters of the member link */	)	{	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	PFW_STACK_OBJ					*pManagerStackObj = NULL;	PFW_OBJ							*pfwObj = NULL;	char 							speed [MAX_PROFILE_PARAM_LENGTH];	USHORT							linkNumber = 0;	UINT							paramId = 0;	STATUS							status;		if ((pMpFramingLayerState == NULL) || (pMemberStackObj == NULL))		return ERROR;	bzero (speed, sizeof (speed));	pStackData = 			(MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData;	/* Get framework obj */	pfwObj = pfwStackObjPfwGet (pMpFramingLayerState->stackObj);	if (pfwObj == NULL)		{		pfwPrintError (__FILE__, "linkToTheBundleAdd",__LINE__, 0, 0, \					   "NULL Framework reference");		return ERROR;		}	/* Initialize the port class structure of the link in the bundle */	pManagerStackObj = pMpFramingLayerState->stackObj;	paramId = pfwParameterIdGet (pfwObj, "mpInterface_memberLinkSpeed");	if (paramId == 0)		{		printf ("Invalid parameter id for the profile parameter %s\n",           		"mpInterface_memberLinkSpeed");		}	pfwStackParamGet (pMemberStackObj, paramId, speed);	if (pfwPluginObjStateLock (pMpFramingLayerState) == ERROR)		return ERROR;	linkNumber = pStackData->bundle.no_of_links;	pStackData->bundle.memberLinks[linkNumber].pMemberStackObj = 														pMemberStackObj;	pStackData->bundle.memberLinks[linkNumber].speed = atol (speed);	pStackData->bundle.memberLinks[linkNumber].pLcpBundleOptions =															 pLcpBundleOptions;	pStackData->bundle.no_of_links++;	/* 	 * Construct sending end and receiving end for the link based on the 	 * options negotiated on the link 	 */	status = mpInitialize (pMpFramingLayerState, pMemberStackObj);	if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR)		return ERROR;	if (status == ERROR)		return ERROR;	return OK;	}	/******************************************************************************** bundleProfileInit - Initialize the bundle profile * * This function initialize the bundle profile structure in the stack data * stucture of the mpFraming layer state with the MP related parameters retrieved * from the Member Stack** RETURNS: N/A*/LOCAL STATUS bundleProfileInit 	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState,							/* mpFraming layer state representing the bundle */ 	LCP_BUNDLE_OPTIONS	    *pLcpBundleOptions /* reference to 											   LCP_BUNDLE_OPTIONS structure

⌨️ 快捷键说明

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