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

📄 bacptimer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* bacptimer.c - BACP timer functions *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03b,06aug02,jr  fixed build warnings 03a,05nov01,as  code cleanup to support an extra parameter in bacpUpcall02c,08oct01,as  added memory clean-up for call-back [for multiple phone option]02b,19jun01,sd  included pppInterfaces.h for warning free compilation02a,16feb01,as  added the BAP functions01a,12feb01,sd 	created*//*DESCRIPTIONThis module implements the timer handler routines for BACP component.The functions when called check if the maximum number, for that packet is notexceeded, then the packet is sent again else the corrective action is taken.The handlers are given for BACP configure request, BACP terminate request, BAP call request, BAP call back request, BAP link drop request and BAP call statusindication packet sent.*//**$Log:: $ *  * 4     4/ * Bacp * v4.2.0 * check in *  * 1     4 * code * cleanup * , code * style * changes * , * linted, * system * level * test * BACP * v4.2.0*//* includes */#include "ppp/pppBacpComponent.h"#include "private/ppp/pppBacpComponentP.h"#include "ppp/pppInterfaces.h"#include "ppp/portmanager.h"/* locals and forwards */LOCAL void bap_delete_outstanding_request (PFW_PLUGIN_OBJ_STATE * pluginState, 				int packetId, BYTE bapPacketType);/******************************************************************************** retry_bacp_configure_request - retry BACP configure request** This function is the handler function for the timer started on sending the* BACP_CONFIGURATION_REQUEST. This handler function will be called until * number_of_bacp_configuration_requests is less than the * maximum_number_of_configuration_requests.** RETURNS: OK or ERROR*/STATUS retry_bacp_configure_request	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	int                   backoffStarted	/* back off */    )    {	BACP_STACK_DATA * pStackData = (BACP_STACK_DATA * )pluginState->stackData;	BACP_PROFILE_DATA * pProfileData = 						(BACP_PROFILE_DATA * )pluginState->profileData;	if ((pStackData->stateData.state == PPP_STOPPED_STATE) &&						(backoffStarted > 0))		{		execute_bacp_state_machine (pluginState, PPP_DOWN_EVENT, NULL);		execute_bacp_state_machine (pluginState, PPP_UP_EVENT, NULL);		pStackData->configuration_request_backoff_period_started = FALSE;		logMsg ("state is PPP_STOPPED_STATE and back off is < = 0 \n",					pStackData->stateData.state, 2, 3, 4, 5, 6);		return OK;		}	if ((pStackData->stateData.state > PPP_STOPPING_STATE) && 			(pStackData->stateData.state < PPP_OPENED_STATE))		{		/* if counter < max retries  resend the request */		if (++pStackData->number_of_configuration_requests <				(pProfileData->maximum_number_of_bacp_configuration_requests))			{			execute_bacp_state_machine (pluginState,				PPP_TIMEOUT_WITH_COUNTER_GREATER_THAN_ZERO_EVENT, NULL);			}		else			{			/* if counter > max retries start the backoff */			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;				}			execute_bacp_state_machine (pluginState,						PPP_TIMEOUT_WITH_COUNTER_EXPIRED_EVENT, NULL);			pStackData->number_of_configuration_requests = 0x00000000L;						if (pStackData->stateData.state == PPP_STOPPED_STATE &&		pProfileData->maximum_bacp_configuration_request_backoff_interval > 0)				{				if (pfwTimerStart (pStackData->retryTimer, PFW_SECOND,				pProfileData->maximum_bacp_configuration_request_backoff_interval,				retry_bacp_configure_request, 1) == ERROR)					{					logMsg ("Back off start failed: state = %d\n",						pStackData->stateData.state, 2, 3, 4, 5, 6);					}				pStackData->configuration_request_backoff_period_started = TRUE;				}			}		}	return OK;	}/******************************************************************************** retry_bacp_termination_request - retry BCAP terminate request** This function is the handler function for the timer started on sending the* BACP_TERMINATE_REQUEST. This handler function will be called until * number_of_bacp_termination_requests is less than the * maximum_number_of_termination_requests.** RETURNS: OK or ERROR*/STATUS retry_bacp_termination_request	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	int arg									/* unused */	)	{	BACP_STACK_DATA * pStackData = (BACP_STACK_DATA * )pluginState->stackData;	BACP_PROFILE_DATA * pProfileData = 					(BACP_PROFILE_DATA * )pluginState->profileData;	if ((pStackData->stateData.state == PPP_CLOSING_STATE) ||			(pStackData->stateData.state == PPP_STOPPING_STATE))		{		if (pStackData->number_of_termination_requests < 			pProfileData->maximum_number_of_bacp_termination_requests)			{			execute_bacp_state_machine (pluginState,				PPP_TIMEOUT_WITH_COUNTER_GREATER_THAN_ZERO_EVENT, NULL);			}		else			{			execute_bacp_state_machine (pluginState,				PPP_TIMEOUT_WITH_COUNTER_EXPIRED_EVENT, NULL);			}		}	return OK;	}/******************************************************************************** retry_bap_call_request - timer handler routine for the call request packet** This function is timer handler routine for CALL_REQUEST. This handler function * will be called when the timer expires for a call request packet. The request * is resent until number_of_bap_call_requests is less than the * maximum_number_of_bap_call_requests else recovery action is taken. ** RETURNS: OK, or ERROR */STATUS retry_bap_call_request     (    PFW_PLUGIN_OBJ_STATE * pluginState,	/* state for the stack */	int id								/* BAP packet id */    )    {	BAP_BUFFER * sptr_bap_buffer;	M_BLK_ID packet;    BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;    BACP_PROFILE_DATA * pProfileData =				(BACP_PROFILE_DATA *)pluginState->profileData;	sptr_bap_buffer = bap_match_received_response_to_outstanding_request 						((LINK *) &pStackData->call_request_send_queue, id);	if (sptr_bap_buffer == NULL)		{		logMsg ("Retry Bap Call Request NULL packet for id = %d\n", 											id, 2, 3, 4, 5, 6);		return OK;		}	if (++pStackData->number_of_bap_call_requests <  					pProfileData->maximum_number_of_bap_call_requests)		{		packet = sptr_bap_buffer->bap; 		sptr_bap_buffer->bap = bacpDupPkt (packet); 		if (sptr_bap_buffer->bap == NULL) 			{			logMsg ("retry_bap_call_request - Packet duplication Error \n",							1, 2, 3, 4, 5, 6);			return ERROR;			}#ifdef PPP_DEBUG    	printf ("BAP: Tx BAP CALL REQUEST RETRY : ID %d\n",id);#endif /* PPP_DEBUG */		pfwSend (pluginState, packet);		pfwTimerCancel (pStackData->callRequestRetryTimer);    	pfwTimerStart (pStackData->callRequestRetryTimer, 				PFW_100_MILLISECOND,				pProfileData->maximum_bap_call_request_send_interval * 10,				retry_bap_call_request, id); 		return OK;		}		else  /* number is > maximum */ 		{		bap_delete_outstanding_request (pluginState, id, BAP_CALL_REQUEST); 		}	return OK;	}/******************************************************************************** retry_bap_callback_request - 						timer handler routine for the callback request packet** This function is timer handler routine for CALL_BACK_REQUEST. This handler * function will be called when the timer expires for a callback request packet. * The request is resent until number_of_bap_callback_requests is less than the * maximum_number_of_bap_callback_requests else recovery action is taken. ** RETURNS: OK or ERROR */STATUS retry_bap_callback_request     (    PFW_PLUGIN_OBJ_STATE * pluginState,	/* state for the stack */	int id								/* BAP packet id */    )    {	BAP_BUFFER * sptr_bap_buffer;	M_BLK_ID packet;    BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;    BACP_PROFILE_DATA * pProfileData =				(BACP_PROFILE_DATA *)pluginState->profileData;	sptr_bap_buffer = bap_match_received_response_to_outstanding_request 							((LINK *) &pStackData->callback_request_send_queue,								id);	if (sptr_bap_buffer == NULL)		{		logMsg ("Retry Bap Call Back Request NULL packet for id = %d\n", 													id, 2, 3, 4, 5, 6);		return OK;		}	if (++pStackData->number_of_bap_callback_requests < 					pProfileData->maximum_number_of_bap_callback_requests)		{		packet = sptr_bap_buffer->bap;		sptr_bap_buffer->bap = bacpDupPkt (packet);		if (sptr_bap_buffer->bap == NULL)			{			logMsg ("retry_bap_callback_request - Packet duplication Error \n",							1, 2, 3, 4, 5, 6);			return ERROR;			}#ifdef PPP_DEBUG    	printf ("BAP: Tx BAP CALL BACK REQUEST RETRY : ID %d\n",id);#endif /* PPP_DEBUG */		pfwSend (pluginState, packet);		pfwTimerCancel (pStackData->callbackRequestRetryTimer);    	pfwTimerStart (pStackData->callbackRequestRetryTimer, 				PFW_100_MILLISECOND,				pProfileData->maximum_bap_callback_request_send_interval * 10,				retry_bap_callback_request , id); 		return OK;		}		else  /* number is > maximum */		{		bap_delete_outstanding_request (pluginState, id, BAP_CALLBACK_REQUEST); 		}	return OK;	}/******************************************************************************** retry_bap_status_indication - timer handler routine for *												call status indication packet** This function is timer handler routine for CALL_STATUS_INDICATION. This * handler function will be called when the timer expires for a call status * indication packet sent, with the retry of the packet sent. The request is * resent until number_of_bap_ status_indication is less than the * maximum_number_of_bap_status_indication else recovery action is taken. ** RETURNS: OK, or ERROR */STATUS retry_bap_status_indication    (    PFW_PLUGIN_OBJ_STATE * pluginState,	/* state for the stack */	int id								/* BAP packet id */    )    {	BAP_BUFFER * sptr_bap_buffer;	M_BLK_ID packet;

⌨️ 快捷键说明

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