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

📄 mpframinglayerinterface.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
											   containing the MP related 											   parameters of the member link  */	)	{	LCP_BUNDLE_PROFILE				*pLcpBundleProfile = NULL;	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	if ((pMpFramingLayerState == NULL) || (pLcpBundleOptions == NULL))		return ERROR;	if (pfwPluginObjStateLock (pMpFramingLayerState) == ERROR)		return ERROR;	pStackData =		 (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData; 	/* Initialize the profile for the bundle */	pLcpBundleProfile = &pStackData->lcpBundleProfile;	pLcpBundleProfile->localMRRU = pLcpBundleOptions->localMRRU; 	pLcpBundleProfile->remoteMRRU = pLcpBundleOptions->remoteMRRU; 			pLcpBundleProfile->use_short_sequence_number_in_local_end = 				pLcpBundleOptions->use_short_sequence_number_in_rx_end;	pLcpBundleProfile->use_short_sequence_number_in_remote_end = 				pLcpBundleOptions->use_short_sequence_number_in_tx_end;	mpSetProfileFromLcpDiscriminatorBundleOption (		&pLcpBundleOptions->bundle_identifier.local_station_discriminator, 		pLcpBundleProfile->local_station_discriminator, TRUE);	mpSetProfileFromLcpDiscriminatorBundleOption (		&pLcpBundleOptions->bundle_identifier.remote_station_discriminator, 		pLcpBundleProfile->remote_station_discriminator, FALSE);			pLcpBundleProfile->localAuthProtocol = 				pLcpBundleOptions->localAuthProtocol;	pLcpBundleProfile->remoteAuthProtocol =  				pLcpBundleOptions->remoteAuthProtocol;	strcpy 		(pLcpBundleProfile->localUserName, 		 pLcpBundleOptions->bundle_identifier.local_user_name);	if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR)		return ERROR;	return OK;	}/******************************************************************************** mpSetProfileFromLcpDiscriminatorBundleOption - copy LCP end point discriminator * 												option * * RETURNS: N/A*/LOCAL void mpSetProfileFromLcpDiscriminatorBundleOption 	(    MP_DISCRIMINATOR_CLASS 	*lcpBundleOption,		/* bundle identifier 													   structures */	unsigned char			*station_discriminator,	/* LCP_BUNDLE_PROFILE */	BOOL 					isLocalDiscriminator	/* local/remote discriminator */	)	{	unsigned int discriminatorClassIdentifier;	ULONG 		magicNumber;	USHORT 		index=0;    struct		in_addr ipAddr;	char		temp[MAX_PROFILE_PARAM_LENGTH];	if ((lcpBundleOption == NULL) || (station_discriminator == NULL))			return;	bzero (temp, sizeof (temp));	discriminatorClassIdentifier = lcpBundleOption->discriminatorClass;		switch (discriminatorClassIdentifier)		{		case 0:			strcpy ((char *) station_discriminator, "0"); /* Adding "0" */			break;		case 1: 			if (isLocalDiscriminator)				{				strcpy ((char *) station_discriminator, "1"); /* Adding "1" */				strcat ((char *) station_discriminator, "-"); /* Adding "-" */				strncpy ((char *) &station_discriminator [2], 							(char *) lcpBundleOption->address, 							lcpBundleOption->length);				}			else				{				strcpy ((char *) station_discriminator, "100"); /* Adding flag */				strcat ((char *) station_discriminator, "-"); /* Adding "-" */				strcat ((char *) station_discriminator, "1"); /* Adding "1" */				strcat ((char *) station_discriminator, "-"); /* Adding "-" */				for (index = 0; index < lcpBundleOption->length; index ++)					{					bzero (temp, sizeof (temp));					sprintf (temp, "%x", lcpBundleOption->address [index]);					if (strlen (temp) < 2)						strcat ((char *) station_discriminator, "0"); 					strcat ((char *) station_discriminator, temp); 					}				}			break;		case 5:			strcpy ((char *) station_discriminator, "5"); /* Adding "5" */			strcat ((char *) station_discriminator, "-"); /* Adding "-" */			strncpy ((char *) &station_discriminator [2], 					(char *) lcpBundleOption->address, 					lcpBundleOption->length);			break;		case 2:			bzero ((char *)&ipAddr, sizeof (struct in_addr));			strcpy ((char *) station_discriminator, "2"); /* Adding "2" */			strcat ((char *) station_discriminator, "-"); /* Adding "-" */			ipAddr.s_addr = (ipAddr.s_addr |					 ((ULONG)lcpBundleOption->address [0]  << 24)) |					 ((ULONG)lcpBundleOption->address [1]  << 16) | 					 ((ULONG)lcpBundleOption->address [2] << 8) | 			 		(lcpBundleOption->address [3] );			ipAddr.s_addr = htonl (ipAddr.s_addr);		    inet_ntoa_b (ipAddr, (char *) &station_discriminator [2]);			break;		case 3:			strcpy ((char *) station_discriminator, "3"); /* Adding "3" */			for (index = 0; index < lcpBundleOption->length; index++)				{ 				strcat ((char *) station_discriminator, "-"); /* Adding "-" */				bzero (temp, sizeof (temp));				sprintf (temp, "%x", lcpBundleOption->address[index]);				strcat((char *) station_discriminator, temp); 				}			break;		case 4: 			strcpy ((char *) station_discriminator, "4"); /* Adding "4" */			for (index = 0; index < lcpBundleOption->length; index = index + 4)				{ 				magicNumber = 0;				bzero (temp, sizeof (temp));				strcat ((char *) station_discriminator, "-"); /* Adding "-" */				magicNumber = (magicNumber |((ULONG)lcpBundleOption->address [index]  << 24)) |					 ((ULONG)lcpBundleOption->address [index+1]  << 16) | 					 ((ULONG)lcpBundleOption->address [index+2] << 8) | 			 		(lcpBundleOption->address [index + 3] );				sprintf (temp, "%ld", magicNumber);				strcat((char *) station_discriminator, temp); 				}			break;		default:			break;		}	}/******************************************************************************** bundleOpenedEventRaise - Raise MP_BUNDLE_OPENED_EVENT * * RETURNS: OK or ERROR*/LOCAL STATUS bundleOpenedEventRaise	(	PFW_PLUGIN_OBJ_STATE	*pMpFramingLayerState,							/* mpFraming layer state representing the bundle */ 	LCP_BUNDLE_OPTIONS		*pLcpBundleOptions /* reference to LCP_BUNDLE_OPTIONS 											  structure containing the MP 											  related parameters											  of the member link  */	)	{	MP_BUNDLE_OPENED_EVENT_DATA		*pBundleOpenedEventData = NULL;	PFW_OBJ							*pfwObj = NULL;	STATUS							status;	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	if ((pMpFramingLayerState == NULL) || (pLcpBundleOptions == NULL))		return ERROR;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData;		/* Get framework obj */	pfwObj = pfwStackObjPfwGet (pMpFramingLayerState->stackObj);	if (pfwObj == NULL)		{		pfwPrintError (__FILE__, "bundleOpenedEventRaise",__LINE__, 0, 0, \					   "NULL Framework reference");		return ERROR;		}	/* Raise Bundle Opened Event */	pBundleOpenedEventData = (MP_BUNDLE_OPENED_EVENT_DATA *) 									pfwMalloc (pfwObj, sizeof (MP_LINK_INFO));    if (pBundleOpenedEventData == NULL)		{		pfwPrintError (__FILE__, "bundleOpenedEventRaise", __LINE__, pfwObj, \				pMpFramingLayerState->stackObj, "Unable to allocate memory");		return (ERROR);		}	pBundleOpenedEventData->localMRRU = pLcpBundleOptions->localMRRU;	pBundleOpenedEventData->remoteMRRU = pLcpBundleOptions->remoteMRRU;	status = pfwEventRaise (pMpFramingLayerState->stackObj, 				   pStackData->pMpBundleOpenedEventObj,				   (void *) pBundleOpenedEventData);        pfwFree ((void*) pBundleOpenedEventData);        pBundleOpenedEventData = NULL;	 	if (status == ERROR)			{		return ERROR;		}	return OK;	}/******************************************************************************** mpMemberAddedEventRaise - Raise MP_MEMBER_ADDED_EVENT * * RETURNS: OK or ERROR*/LOCAL STATUS mpMemberAddedEventRaise	(	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 							/* reference to LCP_BUNDLE_OPTIONS structure 							   containing the MP related parameters of the 							   member link  */	)	{	MP_MEMBER_ADDED_EVENT_DATA		*pMpMemberAddedEventData = NULL;	MP_LINK_INFO					*pMpLinkInfo = NULL;	PFW_OBJ							*pfwObj = NULL;	STATUS							status;	MP_FRAMING_LAYER_STACK_DATA		*pStackData = NULL;	if ((pMpFramingLayerState == NULL) || (pLcpBundleOptions == NULL))		return ERROR;	pStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData; 	/* Get framework obj */	pfwObj = pfwStackObjPfwGet (pMpFramingLayerState->stackObj);	if (pfwObj == NULL)		{		pfwPrintError (__FILE__, "mpMemberAddedEventRaise",__LINE__, 0, 0, \					   "NULL Framework reference");		return ERROR;		}	/* Raise MP_MEMBER_ADDED event */			pMpMemberAddedEventData = (MP_MEMBER_ADDED_EVENT_DATA *)					pfwMalloc (pfwObj, sizeof (MP_MEMBER_ADDED_EVENT_DATA));	if (pMpMemberAddedEventData == NULL)		{		pfwPrintError (__FILE__, "mpMemberAddedEventRaise", __LINE__, pfwObj, \				pMpFramingLayerState->stackObj, "Unable to allocate memory");		return (ERROR);		}	pMpLinkInfo = 			(MP_LINK_INFO *) pfwMalloc (pfwObj, sizeof (MP_LINK_INFO));	if (pMpLinkInfo == NULL)		{		pfwPrintError (__FILE__, "mpMemberAddedEventRaise", __LINE__, pfwObj, \				pMpFramingLayerState->stackObj, "Unable to allocate memory");            pfwFree (pMpMemberAddedEventData);            pMpMemberAddedEventData = NULL;        return (ERROR);		}		pMpLinkInfo->pLinkStackObj = pMemberStackObj;	pMpLinkInfo->remote_link_discriminator = 							pLcpBundleOptions->remote_link_discriminator;	pMpLinkInfo->local_link_discriminator = 							pLcpBundleOptions->local_link_discriminator;	pMpLinkInfo->port_speed = 		pStackData->bundle.memberLinks [pStackData->bundle.no_of_links - 1].speed;	pMpMemberAddedEventData->pMpLinkInfo = pMpLinkInfo;	status = pfwEventRaise (pMpFramingLayerState->stackObj, 						    pStackData->pMpMemberAddedEventObj,						    (void *) pMpMemberAddedEventData);        pfwFree ((void *)pMpMemberAddedEventData);        pMpMemberAddedEventData = NULL;        pfwFree ((void *)pMpLinkInfo);	        pMpLinkInfo = NULL;   if (status == ERROR)		{		return ERROR;		}	return OK;	}/******************************************************************************** mpStackOptionSet - set options in the stack    *  * RETURNS: N/A*/LOCAL void mpStackOptionSet 	(	PFW_STACK_OBJ *pStackObj,	/* stack object */  		char * profileString, 		/* configured profile string */	UINT paramId				/* parameter ID */	)	{	PFW_OBJ 	* pfwObj = NULL;	char 		remoteString [MAX_PROFILE_PARAM_LENGTH];	char 		localString [MAX_PROFILE_PARAM_LENGTH];	char 		tempLocalString [MAX_PROFILE_PARAM_LENGTH];	char 		* temp = NULL;	char 		* remote = NULL;	char 		* local = NULL;	USHORT 		length = 0;	UINT 		eidId = 0;	if ((pStackObj == NULL) || (profileString == NULL))		return;		bzero (remoteString, sizeof (remoteString));	bzero (localString, sizeof (localString));	bzero (tempLocalString, sizeof (tempLocalString));	pfwObj = pfwStackObjPfwGet (pStackObj);	eidId = pfwParameterIdGet (pfwObj, "lcp_endpointDiscriminator");	pfwStackParamSet (pStackObj, paramId, "Local:"); 	pfwStackParamSet (pStackObj, paramId, "Remote:"); 	local = strstr (profileString, "Local");	remote = strstr (profileString, "Remote");			if (remote != NULL)		{		if (local != NULL)			{			length = strlen (local) - strlen (remote) -1;			strncpy (tempLocalString, local, length);			tempLocalString [length] = '\0';			}		temp = strstr (remote, "Negotiation Required");		if ((eidId == paramId) && (temp != NULL))			{			length = strlen (remote) - strlen (temp);			strncpy (remoteString, remote, length);			remoteString [length] = '\0';			strcat (remoteString, "Negotiation Not Required");			strcat (remoteString, &temp [20]); /* length of "Negotiation Required" - 20 */			}		else			strcpy (remoteString, remote);		remoteString [strlen (remoteString) - 1] = '\0';		mpStackParamSet (pStackObj, paramId, remoteString, FALSE);		temp = NULL;		}	else 		{ 		if (local != NULL)			strcpy (tempLocalString, local);		} 	if (local != NULL)		{		strcpy (localString, tempLocalString);		localString [strlen (localString) - 1] = '\0';		mpStackParamSet (pStackObj, paramId, localString, TRUE);		}	}/******************************************************************************** mpStackParamSet - set parameter in the stack    *  * RETURNS: N/A*/LOCAL void mpStackParamSet 	(	PFW_STACK_OBJ *pStackObj,	/* stack object */ 	UINT paramId,				/* parameter ID */	char * valueString, 		/* profile string */	BOOL isLocal				/* local or remote */	)	{	char 	profileString [MAX_PROFILE_PARAM_LENGTH];	char 	* temp = NULL;	char 	stringToFind [7];	UINT8 	length = 0;	UINT8	offset = 0;	bzero (profileString, sizeof (profileString));	bzero (stringToFind, sizeof (stringToFind));	if (isLocal == TRUE)		{		offset = 5;		strcpy (stringToFind, "Local");		}	else		{		offset = 6;		strcpy (stringToFind, "Remote");		}	while ((temp = strstr (&valueString [offset], stringToFind)) != NULL)				{		length = strlen (valueString) - strlen (temp) -2;		strncpy (profileString, valueString, length);		profileString [length] = '\0';		pfwStackParamSet (pStackObj, paramId, profileString);		valueString = temp;		temp = NULL;		bzero (profileString, sizeof (profileString));		}	strcpy (profileString, valueString);	profileString [strlen (valueString)] = '\0';	pfwStackParamSet (pStackObj, paramId, profileString);	}/******************************************************************************** is_RFC_1990_5.1.3_CASE_1 - Check for RFC 1990 5.1.3 no EID no authentication *							 case* * RETURNS: TRUE or FALSE*/BOOL is_RFC_1990_5_1_3_CASE_1	(	MP_BUNDLE_IDENTIFIER	*pBundleIdentifier	)	{	if (pBundleIdentifier == NULL)		return FALSE;	if ((pBundleIdentifier->local_station_discriminator.discriminatorClass == 0)		 &&		(pBundleIdentifier->remote_station_discriminator.discriminatorClass == 0)		 &&		pBundleIdentifier->link_failed_to_be_authenticated 		)		return TRUE;	return FALSE;	}

⌨️ 快捷键说明

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