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

📄 mptest.c

📁 这是全套的PPP协议的源码
💻 C
字号:
/* mpTest.c - MP Functionality testing *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01i,22oct02,ijm  changed MP_PROFILE_STRING_SIZE to MAX_VALUE_STRING_LENGTH01h,19feb02,ak	 Input parameter validations01f,05sep01,ak   Modification of the comments relating to MRRU configuration01e,28aug01,ak	 Added a comment on configuring the MRRU of the bundle01d,20jun01,ak   code clean-up01c,20jun01,ak	 added description about configuring the manager profile obj and				 member profile obj01b,20jun01,ak	 added description about configuring the manager profile obj and				 member profile obj01a,22Apr01,ak	 created*//* includes */#include "pfw/pfw.h"#include "pfw/pfwStack.h"#include "ppp/mp.h"#include "pfw/pfwProfile.h"#include "private/ppp/mpFramingLayerP.h"#include "ppp/pppMPFramingLayer.h"#include "ppp/mpAPI.h"#include "logLib.h"#include "stdlib.h"#include "stdio.h"/*DESCRIPTION: Contains test scripts for testing the operation of the MP implementation. This file contains two similar functions mpPeerTest() and mpPeer1Test(). These functions can be run on two different peers toform a ML-PPP Bundle of 2 links between the peers.Each of these functions is used to create a bundle and add two links to the bundle.The links are added to the bundle through the mpLinkAdd() function. Configuring Manager Stack Profile:----------------------------------All the parameters that controls the operation of the bundle as a whole are configured in the Manager Stack's profile obj. e.glcp_ML_maxRcvdReconstructedUnit 	- 	MRRU for the bundle lcp_ML_shortSeqNumberHdrFormat  	-	ML-PPP Header formatlcp_endpointDiscriminator		  	-	End Point Discriminator for the bundlempFraming_smallPacketLength	  		-	Packet length that need not be 										fragmentedmpFraming_localUserName		  		-	User name that need to be used by the 										member links in the authentication phase										at the remote endmpFraming_disableAuthOnBundle	  	-	Enabling or Disabling authentication on 										the bundlelcp_authProtocol				  	-	Authentication protocol that needs to be 										used on the member links as well as in 										the Manager Stack if 										mpFraming_disableAuthOnBundle is set                                   		to FALSEipcp_ipAddr					  		_	IP adresses for IPCP negotiationConfiguring Manager Stack Profile:----------------------------------Following parameters MUST be configured on the Member Profile. mpInterface_managerStackId			-	Manager Stack Obj of the bundle which 										the link needs to be added.mpInterface_memberLinkSpeed			-	Speed of the link in bytes/sec.										This parameter will decide the load on 										the link when the PPP packet is 										fragmented on the Manager Stack. Also, 										BAP will use this parameter as the 										bandwidth supported by the link and will										use it for choosing a link to drop if 										BODA wants to drop certain amount of 										banwidth from the bundle.																			If SIO_ADAPTER is used in the adapter 										layer, the baud rate configured in the 										"sio_baudRate" parameter MUST agree with										the value configured in this parameter.  *//* typedefs *//* define *//* externs */IMPORT	PFW_OBJ * pppSysFramework;IMPORT  PFW_PROFILE_OBJ * pppSysProfile;/* locals and forwards *//******************************************************************************** mpPeerTest - Test script for creating and adding the links to the bundle** RETURNS: void*/void mpPeerTest ()	{	PFW_PROFILE_OBJ *pMgrProfile = NULL;	PFW_PROFILE_OBJ *pMemberProfile = NULL;	PFW_PROFILE_OBJ *pMemberProfile1 = NULL;	PFW_STACK_OBJ	*pBundlePeerId = NULL;	PFW_STACK_OBJ	*pLinkStackObj = NULL;	UINT			pppParam = 0;	char 			profileString [MAX_VALUE_STRING_LENGTH]; 	bzero (profileString, sizeof (profileString));	pMgrProfile = pfwProfileCreate("pMgrProfile",pppSysProfile, 0);    if (pMgrProfile == NULL)		{		logMsg("Could not create Manager Stack profile\n",1,2,3,4,5,6);		return;		}	pMemberProfile = pfwProfileCreate("pMemberProfile",pppSysProfile, 0);    if (pMemberProfile == NULL)		{		logMsg("Could not create Member Stack profile\n",1,2,3,4,5,6);		return;		}	pMemberProfile1 = pfwProfileCreate("pMemberProfile1",pppSysProfile, 0);    if (pMemberProfile1 == NULL)		{		logMsg("Could not create Member Stack profile\n",1,2,3,4,5,6);		return;		}	/* Creating the Manager Stack to represent the bundle interface */	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_ML_shortSeqNumberHdrFormat");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable");     pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Required, Not Negotiable");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_ML_maxRcvdReconstructedUnit");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable:4000");    pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Required, Not Negotiable:4000");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_endpointDiscriminator");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable:1-ZWRS");    pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Not Required, Negotiable");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_authProtocol");    pfwProfileSet(pMgrProfile, pppParam, "Local:");    pfwProfileSet(pMgrProfile, pppParam, "Remote:");	pppParam = pfwParameterIdGet (pppSysFramework, "ipcp_ipAddr");	pfwProfileSet (pMgrProfile, pppParam, "Local:Negotiation Required,Not Negotiable:11.11.11.102");	pfwProfileSet (pMgrProfile, pppParam, "Remote:Negotiation Required,Not Negotiable:11.11.11.103"); 	if ((pBundlePeerId = mpBundleCreate (pMgrProfile, NULL, NULL)) == NULL)		printf ("bundleCreate() failed\n");	/* adding the first link to the bundle */	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pMemberProfile, pppParam, "0");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_baudRate");	pfwProfileSet(pMemberProfile, pppParam, "38400");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_maxSendQSize");	pfwProfileSet(pMemberProfile, pppParam, "100");	sprintf (profileString, "%d", (int) pBundlePeerId);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	if (pfwProfileSet (pMemberProfile, pppParam, profileString) == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "mpInterface_memberLinkSpeed");    pfwProfileSet(pMemberProfile, pppParam, "38400");	if ((pLinkStackObj = mpLinkAdd (pMemberProfile, NULL, NULL)) == NULL)		printf ("mpLinkAdd() failed\n");    /* adding the second link to the bundle */	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pMemberProfile1, pppParam, "1");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_baudRate");	pfwProfileSet(pMemberProfile1, pppParam, "38400");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_maxSendQSize");	pfwProfileSet(pMemberProfile1, pppParam, "100");	sprintf (profileString, "%d", (int) pBundlePeerId);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	if (pfwProfileSet (pMemberProfile1, pppParam, profileString) == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "mpInterface_memberLinkSpeed");    pfwProfileSet(pMemberProfile1, pppParam, "38400");	if ((pLinkStackObj = mpLinkAdd (pMemberProfile1, NULL, NULL)) == NULL)		printf ("mpLinkAdd() failed\n");	}/******************************************************************************** mpPeer1Test - Test script for creating and adding the links to the bundle** RETURNS: void*/void mpPeer1Test ()	{	PFW_PROFILE_OBJ *pMgrProfile = NULL;	PFW_PROFILE_OBJ *pMemberProfile = NULL;	PFW_PROFILE_OBJ *pMemberProfile1 = NULL;	PFW_STACK_OBJ	*pBundlePeerId = NULL;	PFW_STACK_OBJ	*pLinkStackObj = NULL;	UINT			pppParam = 0;	char 			profileString [MAX_VALUE_STRING_LENGTH];		bzero (profileString, sizeof (profileString));	pMgrProfile = pfwProfileCreate("pMgrProfile",pppSysProfile, 0);    if (pMgrProfile == NULL)		{		logMsg("Could not create Manager Stack profile\n",1,2,3,4,5,6);		return;		}	pMemberProfile = pfwProfileCreate("pMemberProfile",pppSysProfile, 0);    if (pMemberProfile == NULL)		{		logMsg("Could not create Member Stack profile\n",1,2,3,4,5,6);		return;		}	pMemberProfile1 = pfwProfileCreate("pMemberProfile1",pppSysProfile, 0);    if (pMemberProfile1 == NULL)		{		logMsg("Could not create Member Stack profile\n",1,2,3,4,5,6);		return;		}	/* Creating the Manager Stack to represent the bundle interface */	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_ML_shortSeqNumberHdrFormat");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable");    pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Required, Not Negotiable");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_ML_maxRcvdReconstructedUnit");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable:4000");     pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Required, Not Negotiable:4000");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_endpointDiscriminator");    pfwProfileSet(pMgrProfile, pppParam, "Local:Negotiation Required, Not Negotiable:1-ZWRS");    pfwProfileSet(pMgrProfile, pppParam, "Remote:Negotiation Not Required, Negotiable");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_authProtocol");    pfwProfileSet(pMgrProfile, pppParam, "Local:");    pfwProfileSet(pMgrProfile, pppParam, "Remote:");	pppParam = pfwParameterIdGet (pppSysFramework, "ipcp_ipAddr");	pfwProfileSet (pMgrProfile, pppParam, "Local:Negotiation Required,Not Negotiable:11.11.11.103");	pfwProfileSet (pMgrProfile, pppParam, "Remote:Negotiation Required,Not Negotiable:11.11.11.102"); 	if ((pBundlePeerId = mpBundleCreate (pMgrProfile, NULL, NULL)) == NULL)		printf ("bundleCreate() failed\n");	/* adding the first link to the bundle */	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pMemberProfile, pppParam, "0");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_baudRate");	pfwProfileSet(pMemberProfile, pppParam, "38400");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_maxSendQSize");	pfwProfileSet(pMemberProfile, pppParam, "100");	sprintf (profileString, "%d", (int) pBundlePeerId);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	if (pfwProfileSet (pMemberProfile, pppParam, profileString) == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "mpInterface_memberLinkSpeed");    pfwProfileSet(pMemberProfile, pppParam, "38400");	if ((pLinkStackObj = mpLinkAdd (pMemberProfile, NULL, NULL)) == NULL)		printf ("mpLinkAdd() failed\n");    /* adding the second link to the bundle */	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pMemberProfile1, pppParam, "1");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_baudRate");	pfwProfileSet(pMemberProfile1, pppParam, "38400");	pppParam = pfwParameterIdGet(pppSysFramework, "sio_maxSendQSize");	pfwProfileSet(pMemberProfile1, pppParam, "100");	sprintf (profileString, "%d", (int) pBundlePeerId);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	if (pfwProfileSet (pMemberProfile1, pppParam, profileString) == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "mpInterface_memberLinkSpeed");    pfwProfileSet(pMemberProfile1, pppParam, "38400");	if ((pLinkStackObj = mpLinkAdd (pMemberProfile1, NULL, NULL)) == NULL)		printf ("mpLinkAdd() failed\n");	}

⌨️ 快捷键说明

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