bacpaction.c

来自「这是全套的PPP协议的源码」· C语言 代码 · 共 348 行

C
348
字号
/* bacpaction.c - BACP state machine actions *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02a,05nov01,as  code cleanup to support an extra parameter in bacpUpcall01a,10feb01,sd 	created*//*DESCRIPTIONThis module implements the action table functions of BACP component.These functions are called from the execute state machine functions to take the corresponding action. These functions also raise the BACP_UP and BACP_DOWN event. Once the BACP is UP, the MP's interface is usedto initialize the active port queue.*//* includes */#include "private/ppp/pppoptn.h"#include "ppp/pppBacpComponent.h"#include "private/ppp/pppBacpComponentP.h"#include "sllLib.h"/* defines */LOCAL void bacp_this_layer_start (PFW_PLUGIN_OBJ_STATE * pluginObjState,					M_BLK_ID pMblk, PPP_STATE end_state);LOCAL void bacp_this_layer_finished (PFW_PLUGIN_OBJ_STATE * pluginObjState,					M_BLK_ID pMblk, PPP_STATE end_state);LOCAL void bacp_this_layer_up (PFW_PLUGIN_OBJ_STATE * pluginObjState,					M_BLK_ID pMblk, PPP_STATE end_state);LOCAL void bacp_this_layer_down (PFW_PLUGIN_OBJ_STATE * pluginObjState,					M_BLK_ID pMblk, PPP_STATE end_state);LOCAL void bacp_initialize_restart_counters 				(PFW_PLUGIN_OBJ_STATE * pluginObjState,				 M_BLK_ID pMblk, PPP_STATE end_state);LOCAL void bacp_zero_restart_counters (PFW_PLUGIN_OBJ_STATE * pluginObjState,					M_BLK_ID pMblk, PPP_STATE end_state);STATE_MACHINE_ACTION_TABLE bacpStateActionTable =				{				bacpSetState,				bacpNullState,				bacp_this_layer_start,				bacp_this_layer_finished,				bacp_this_layer_up,				bacp_this_layer_down,				bacp_initialize_restart_counters,				bacp_zero_restart_counters,				NULL,/* send_configuration_request */				NULL,/* send_configuration_ack */				NULL,/* send_configuration_nak */				NULL,/* send_configuration_reject */				NULL,/* send_termination_request */				NULL,/* send_termination_ack */				NULL,/* send_code_reject */				};/******************************************************************************** bacp_this_layer_start - this layer start action** This function is called when this layer moves on to start state. * stackData state is updated to the input state.** RETURNS: N/A*/LOCAL void bacp_this_layer_start	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_CONTROL_PROTOCOL_STATE_DATA *pStateData = 				(BACP_CONTROL_PROTOCOL_STATE_DATA *) pluginState->stackData;	BACP_STACK_DATA *pStackData = pluginState->stackData;	PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj;	/* set the end state */	pStateData->state = end_state;	/* call the BODA upcall */	if (pStackData->bacpUpcall != NULL)		{		pStackData->bacpUpcall->bacpUpCallFunction (			pManagerStackObj, BACP_EVENT_THIS_LAYER_START, 0, NULL, 0, NULL);		}	if (packet != NULL)		{		netMblkClChainFree (packet);		}    }/******************************************************************************** bacp_this_layer_finished - this layer finished action.** This function is called when this layer moves on to finished state.* Control layer's interface function is called to inform the same.** RETURNS: N/A*/LOCAL void bacp_this_layer_finished	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *)pluginState->stackData;	PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj;	PARAMETER_NOT_USED (end_state);	if (packet != NULL)		{		netMblkClChainFree (packet);		}	/* reset the counters */	pStackData->number_of_configuration_requests = 0x0000;	pStackData->number_of_termination_requests   = 0x0000;	/* cancel retry timer */	pfwTimerCancel (pStackData->retryTimer);	if (pStackData->last_txed_bacp_configuration_request_packet != NULL)		{		netMblkClChainFree (		pStackData->last_txed_bacp_configuration_request_packet);		pStackData->last_txed_bacp_configuration_request_packet = NULL;		}	/* tell other components on this stack that BACP is DOWN */	pfwEventRaise (pluginState->stackObj, pStackData->bacpDownEventObj,				NULL);	/* call the BODA upcall */	if (pStackData->bacpUpcall != NULL)		{		pStackData->bacpUpcall->bacpUpCallFunction (			pManagerStackObj, BACP_EVENT_THIS_LAYER_FINISHED, 0, NULL, 0, NULL);		}	/* tell layer that bacp is finished */	pStackData->controlLayerInterface->protocolFinished (pluginState);    }/******************************************************************************** bacp_this_layer_up - this layer up action** This function is called when this layer is "UP". * Control layer's interface function is called to inform the same.** RETURNS: N/A*/LOCAL void bacp_this_layer_up	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj;		PARAMETER_NOT_USED (end_state);	/* cancel config request retry */	pfwTimerCancel (pStackData->retryTimer);	/* tell other components on this stack that BACP is done negotiating */	pfwEventRaise (pluginState->stackObj, pStackData->bacpUpEventObj,				pluginState);	/* free the packets */	if (packet != NULL)		netMblkClChainFree (packet);	if (pStackData->last_txed_bacp_configuration_request_packet != NULL)		{		netMblkClChainFree (			pStackData->last_txed_bacp_configuration_request_packet);		pStackData->last_txed_bacp_configuration_request_packet = NULL;		}	/* tell layer that BACP is up */	pStackData->controlLayerInterface->protocolUp (pluginState);	/* call the BODA upcall */	if (pStackData->bacpUpcall != NULL)		pStackData->bacpUpcall->bacpUpCallFunction 					(pManagerStackObj, BACP_EVENT_THIS_LAYER_UP, 0, NULL, 0, NULL);    }/******************************************************************************** bacp_this_layer_down - this layer down action * * This function is called when this layer is down. Control layer's interface * function is called to inform the same.** RETURNS: N/A*/LOCAL void bacp_this_layer_down	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj;	PARAMETER_NOT_USED (end_state);	/* cancel the timer */	pfwTimerCancel (pStackData->retryTimer); 	/* free the packet */	if (packet != NULL)		{		netMblkClChainFree (packet);		}	if (pStackData->last_txed_bacp_configuration_request_packet != NULL)		{		netMblkClChainFree (			pStackData->last_txed_bacp_configuration_request_packet);		pStackData->last_txed_bacp_configuration_request_packet = NULL;		}		/* reset the counters */	pStackData->number_of_configuration_requests = 0x0000;	pStackData->number_of_termination_requests   = 0x0000;    /* free tx_accepted list to allow fresh start from configured options */	free_ppp_tx_accepted_option_list (&pStackData->option_lists.tx_accepted);	/* call the BODA upcall */	if (pStackData->bacpUpcall != NULL)		{		pStackData->bacpUpcall->bacpUpCallFunction 					(pManagerStackObj, BACP_EVENT_THIS_LAYER_DOWN, 0, NULL, 0, NULL);		}	/* tell layer that BACP is down */	pStackData->controlLayerInterface->protocolDown (pluginState, end_state);    }/******************************************************************************** bacp_initialize_restart_counters - initialize restart counters** This function is called when this layer is needed to go into Initialization * State. All the necessary counters are initialized.** RETURNS: N/A*/LOCAL void bacp_initialize_restart_counters	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	PARAMETER_NOT_USED (end_state);	pStackData->number_of_configuration_requests = 0x0000;	pStackData->number_of_termination_requests   = 0x0000;	if (packet != NULL)		netMblkClChainFree (packet);    }/******************************************************************************** bacp_zero_restart_counters - zero restart counters** This function is called when this layer is needed to zero the various counters. * All the necessary counters are initialized to zero.** RETURNS: N/A*/LOCAL void bacp_zero_restart_counters	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID  packet,						/* BACP packet */	PPP_STATE end_state						/* end state */	)	{	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	PARAMETER_NOT_USED (end_state);	pStackData->number_of_configuration_requests = 0x0000;	pStackData->number_of_termination_requests   = 0x0000;	if (packet != NULL)		netMblkClChainFree (packet);    }

⌨️ 快捷键说明

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