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

📄 bacptest.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* bacpTest.c - Test Script for testing BACP component *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01h,22oct02, ijm  changed MP_PROFILE_STRING_SIZE to MAX_VALUE_STRING_LENGTH01g,06aug02,  jr  fixed build warnings 01f,23feb02,  jr  setting the pointers to NULL after freeing01e,05nov01,  as  added a new parameter to BODA Up Call.				  BODA upcall has been modoifed with this added new parameter.				  new function bapUpcallMemoryFree () has been added to free				  the memory associtaed with BODA up call.01d,30June01, as  for all BODA UPCALL's added reason parameter 			      validation for NULL condition01c,3April01, as  added functions for BAP functionalities01b,3April01, sd  added functions for BODA functionalities01a,3April01, as  created*//*DESCRIPTION: 	This file contains test scripts for testing BACP componentINCLUDE FILES : mpFramingLayerP.h				mpAPI.h*//* includes */#include "vxWorks.h"#include "pfw/pfw.h"#include "pfw/pfwProfile.h"#include "ppp/pppMPFramingLayer.h"#include "stdlib.h"#include "stdio.h"#include "ppp/mp.h"#include "ppp/mpAPI.h"#include "ppp/m2pppSecuritySecretsLib.h"#include "private/ppp/pppBacpComponentP.h"#include "ppp/pppBacpComponent.h"#include "ppp/bacpInterfaces.h"#include "private/ppp/mpFramingLayerP.h"#include "ppp/kbacpif.h"/* imports */IMPORT	PFW_OBJ * pppSysFramework;IMPORT  PFW_PROFILE_OBJ * pppSysProfile;IMPORT STATUS pmPortToListAdd (LINK_INFO *);IMPORT STATUS pmPortListDelete (USHORT);/* Locals and Forwards */void addBandwidthUsingCallRequest (PFW_STACK_OBJ *, USHORT);void addBandwidthUsingCallBackRequest (PFW_STACK_OBJ *, USHORT);void removeBandwidth (PFW_STACK_OBJ *, USHORT);void dropBandwidth (PFW_STACK_OBJ *, USHORT);void initializeUpcallFunctionPtr ();void portManagerInitCallBackReq ();void portManagerInitCallReq ();/* defines */#define PPP_SYSTEM_DEFAULT_FRAMEWORK_NAME "SYS_PPP"#define 	PROFILE_DATA_SIZE 						100#define 	PPP_MP_SEND_QUEUE_SIZE 					8092#define 	PPP_MP_RECEIVE_QUEUE_SIZE 				8092#define 	PPP_MP_SEND_QUEUE_TASK_PRIORITY 		100#define 	PPP_MP_RECEIVE_QUEUE_TASK_PRIORITY 		60#define		BAP_DEBUG /* deine for messages in the test script */#undef 		BAP_DEBUG								/* Globals */PFW_STACK_OBJ * pManagerStackObj; BACP_UPCALL_FUNCTIONS * upcallFuncPtr; /* BODA UPCALL Functions */LOCAL ULONG bacp_upcall_bacp_is_started     (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bacp_upcall_bacp_is_up          (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bacp_upcall_bacp_is_down        (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bacp_upcall_bacp_is_stopped     (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_call_request_status  (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_call_request_received(PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_drop_query_request   (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_request_timeout      (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_port_up              (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_port_down            (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_not_processed 		(PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_request_full_nak     (PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);LOCAL ULONG bap_upcall_processed 			(PFW_STACK_OBJ *, USHORT  port, PFW_STACK_OBJ *, BYTE , char **);  LOCAL BYTE bap_event_upcall (PFW_STACK_OBJ *, USHORT, USHORT, PFW_STACK_OBJ *, BYTE , char **);/****************************************************************************/static ULONG (*fptr_upcall[]) 	(	PFW_STACK_OBJ * managerStackObj, 	USHORT  port, 	PFW_STACK_OBJ * memberStackObj, 	BYTE response_code, 	char ** reason	) = {		bacp_upcall_bacp_is_started, 		bacp_upcall_bacp_is_up,		bacp_upcall_bacp_is_down,		bacp_upcall_bacp_is_stopped,		bap_upcall_call_request_status,		bap_upcall_call_request_received,		bap_upcall_drop_query_request,		bap_upcall_request_timeout,		bap_upcall_port_up,		bap_upcall_port_down,		bap_upcall_not_processed,		bap_upcall_request_full_nak,   		bap_upcall_processed      		};/***************************************************************************** BODA upcall function */LOCAL BYTE bap_event_upcall 	(	PFW_STACK_OBJ * managerStackObj, 	USHORT event,     USHORT portNumber, 	PFW_STACK_OBJ * memberStackObj, 	BYTE response_code, 	char ** reason	)	{	ULONG return_value;	if (event > BACP_EVENT_OPTIONS_EXHAUSTED)		{#ifdef BAP_DEBUG		logMsg ("Illegal Up Call Event %u \n",event,2,3,4,5,6);#endif		return(0);		}	return_value = (*fptr_upcall[event]) (managerStackObj, portNumber, memberStackObj, response_code, reason);	return (return_value);	}/******************************************************************************** toAddBandwidthUsingCallReq - routine to add bandwidth ** RETURNS: N/A*/void toAddBandwidthUsingCallReq(USHORT bandwidth)	{	/* If alreday Serial Port 1 is added remove from the portlist */	pmPortListDelete (1); /* can be done if really required */	initializeUpcallFunctionPtr ();	portManagerInitCallReq ();	addBandwidthUsingCallRequest (pManagerStackObj, bandwidth);	}/******************************************************************************** toAddBandwidthUsingCallBackReq - routine to add bandwidth ** RETURNS: N/A*/void toAddBandwidthUsingCallBackReq(USHORT bandwidth)	{	/* If alreday Serial Port 1 is added remove from the portlist */	pmPortListDelete (1); /* can be done if really required */	initializeUpcallFunctionPtr ();	portManagerInitCallBackReq ();	addBandwidthUsingCallBackRequest (pManagerStackObj, bandwidth);	}/******************************************************************************** toDropBandwidth - wrapper routine to remove bandwidth ** RETURNS: N/A*/void toDropBandwidth(USHORT bandwidth)	{	dropBandwidth (pManagerStackObj, bandwidth);	}/******************************************************************************** toRemoveBandwidth - wrapper routine to drop bandwidth ** RETURNS: N/A*/void toRemoveBandwidth(USHORT bandwidth)	{	removeBandwidth (pManagerStackObj, bandwidth);	}/******************************************************************************** portManagerInitCallBackReq - Portmanager init function to add port before making * call back request ** RETURNS: N/A*/void portManagerInitCallBackReq ()	{	char profileString [MAX_VALUE_STRING_LENGTH];	LINK_INFO *pLinkInfo;	unsigned int 			pppParam = 0;	pLinkInfo = (LINK_INFO *) pfwMalloc (pppSysFramework, sizeof (LINK_INFO));	pLinkInfo->pNext = NULL;	pLinkInfo->pLinkProfileObj = pfwProfileCreate ("pppNewProfile",pppSysProfile, 0);	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "1");	sprintf (profileString, "%d", (int)pManagerStackObj);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	pfwProfileSet (pLinkInfo->pLinkProfileObj, pppParam, profileString);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_memberLinkSpeed");	if (pfwProfileSet (pLinkInfo->pLinkProfileObj, pppParam, "9600") == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_linkDiscriminator");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Local:Negotiation Required, Not Negotiable:2"); 	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Remote:Negotiation Required, Negotiable:300"); 	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_authProtocol");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Local:");   	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Remote:");	pLinkInfo->isPortUsed = FALSE;	pLinkInfo->port_type = BAP_ANALOG_TYPE;	pLinkInfo->port_dial_type = PORT_DIAL_IN_AND_OUT;	pLinkInfo->port_number = 1;	pLinkInfo->port_dial_status = PORT_DIAL_DISCONNECTED;	pLinkInfo->bandwidth = 9600;	strcpy (pLinkInfo->port_remote_phone_number, "");	strcpy (pLinkInfo->port_local_phone_number, "215"); /* 91-4146-25192 */	strcpy (pLinkInfo->port_subaddress_phone_number, "");	pLinkInfo->port_unique_digits_phone_number_length = 3;	strcpy (pLinkInfo->port_unique_digits_phone_number, "");		pmPortToListAdd (pLinkInfo);	}/******************************************************************************** portManagerInitCallReq - Portmanager init function to add port before making * call request ** RETURNS: N/A*/void portManagerInitCallReq ()	{	char profileString [MAX_VALUE_STRING_LENGTH];	LINK_INFO *pLinkInfo;	unsigned int 			pppParam = 0;	pLinkInfo = (LINK_INFO *) pfwMalloc (pppSysFramework, sizeof (LINK_INFO));	pLinkInfo->pNext = NULL;	pLinkInfo->pLinkProfileObj = pfwProfileCreate ("pppNewProfile",pppSysProfile, 0);	pppParam = pfwParameterIdGet(pppSysFramework, "sio_channelNum");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "1");#ifdef BAP_DEBUG	printf ("Port is reserved for the Stack 0x%x\n",(int)pManagerStackObj);#endif	sprintf (profileString, "%d", (int)pManagerStackObj);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_managerStackId");	pfwProfileSet (pLinkInfo->pLinkProfileObj, pppParam, profileString);	pppParam = pfwParameterIdGet (pppSysFramework, "mpInterface_memberLinkSpeed");	if (pfwProfileSet (pLinkInfo->pLinkProfileObj, pppParam, "9600") == ERROR)		printf ("ERROR in configuring the profile\n");	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_linkDiscriminator");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Local:Negotiation Required, Not Negotiable:2"); 	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Remote:Negotiation Required, Negotiable:300"); 	pppParam = pfwParameterIdGet(pppSysFramework, "lcp_authProtocol");	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Local:");   	pfwProfileSet(pLinkInfo->pLinkProfileObj, pppParam, "Remote:");	pLinkInfo->isPortUsed = FALSE;	pLinkInfo->port_type = BAP_ANALOG_TYPE;	pLinkInfo->port_dial_type = PORT_DIAL_IN_AND_OUT;	pLinkInfo->port_number = 1;	pLinkInfo->port_dial_status = PORT_DIAL_DISCONNECTED;	pLinkInfo->bandwidth = 9600;	/* To Get Phone Number Information from other peer 3.3.23 */	strcpy (pLinkInfo->port_remote_phone_number,"215");	strcpy (pLinkInfo->port_local_phone_number, "215"); /* 91-4146-25192 */	strcpy (pLinkInfo->port_subaddress_phone_number, "");	pLinkInfo->port_unique_digits_phone_number_length = 3;	strcpy (pLinkInfo->port_unique_digits_phone_number, "");		pmPortToListAdd (pLinkInfo);	}/******************************************************************************** initializeUpcallFunctionPtr - Test script to Initialize up BODA UPCALL* 																function pointer** RETURNS: N/A*/void initializeUpcallFunctionPtr ()	{	PFW_PLUGIN_OBJ * pluginObj = NULL;	PFW_PLUGIN_OBJ_STATE * bacpPluginObjState;	STATUS status;	pppSysFramework = pfwObjGet (PPP_SYSTEM_DEFAULT_FRAMEWORK_NAME);    if (pppSysFramework == NULL)		{		logMsg("NULL PPP framework\n",1,2,3,4,5,6);		return;		}	pluginObj = pfwPluginObjGet (pppSysFramework, "PPP_BACP");	if (pluginObj == NULL)		{		logMsg("BACP NULL  PluginObj  \n",1,2,3,4,5,6);				return;		}	bacpPluginObjState = pfwPluginObjStateGet (pManagerStackObj, pluginObj);	if (bacpPluginObjState == NULL)		{		logMsg("BACP NULL Member PluginObjState \n",1,2,3,4,5,6);		return;		}	upcallFuncPtr = (BACP_UPCALL_FUNCTIONS *) pfwMalloc 									(pppSysFramework, sizeof (BACP_UPCALL_FUNCTIONS)); 	if (upcallFuncPtr == NULL)		{		logMsg("Error in getting memory for BACP_UPCALL_FUNCTIONS \n"												,1,2,3,4,5,6);		return;		}	upcallFuncPtr->bacpUpCallFunction = bap_event_upcall;	status = bacpUpCallInit (pManagerStackObj, upcallFuncPtr);	if (status == OK)		{#ifdef BAP_DEBUG		logMsg ("BACP Upcall Initilization is Success \n",1,2,3,4,5,6);		#endif		}	else		{#ifdef BAP_DEBUG		logMsg ("BACP Upcall Initilization Failed \n",1,2,3,4,5,6);		#endif		} 	}/******************************************************************************** initializeUpcallFunctionPtr - Test script to free the memory associated with * 									initializing the BODA UPCALL function pointer** RETURNS: N/A*/void bapUpcallMemoryFree ()	{	if (upcallFuncPtr == NULL)		{		logMsg("Memory already freed for BACP_UPCALL_FUNCTIONS \n",1,2,3,4,5,6);		return;		}    	    pfwFree (upcallFuncPtr);          upcallFuncPtr = NULL;  		}/******************************************************************************** addBandwidthUsingCallRequest - Add a link to a particular bundle with *																Call Request** Test script to add bandwidth using Call Request*

⌨️ 快捷键说明

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