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

📄 pppbacprx.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		netMblkClChainFree (contiguousPacket);		return;		}	/*	 * change the received packet header code to CONFIGURE REQUEST and compare	 * with the sent request packet 	 */	sptr_bacp_rx_packet->bacp_header.code = CONFIGURE_REQUEST;	sptr_bacp_last_tx_packet = mtod 	(pStackData->last_txed_bacp_configuration_request_packet, BACP_PACKET *);		if (memcmp (sptr_bacp_rx_packet, sptr_bacp_last_tx_packet,		pStackData->length_of_last_txed_bacp_packet) != 0x00)		{		logMsg ("PPP_BACP Rx Config Ack: ID = %d doesn't echo config request: stack 0x%x",			sptr_bacp_rx_packet->bacp_header.id,			(UINT32)pluginState->stackObj, 3, 4, 5, 6);		netMblkClChainFree (contiguousPacket);		return;		}	/* free the request 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;		}	netMblkClChainFree (contiguousPacket);	execute_bacp_state_machine (pluginState, PPP_RECEIVE_CONFIGURE_ACK_EVENT,				NULL);	}/******************************************************************************** bacp_configure_nak_received - process the configure nak received ** This routine is called by the bacp_packet_received () to process the BACP * configuration nak packet. The received BACP configuration nak packet is * verified against error conditions. The BACP options, from the configure nak * packet are parsed and processed using the parse_bacp_options_from_nak_configure() * function. The execute_ bacp_state_machine () is called to take appropriate action. **RETURNS:N/A*/LOCAL void bacp_configure_nak_received	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID packet							/* received BACP packet */	)	{	M_BLK_ID contiguousPacket = packet;	BACP_PACKET *sptr_bacp_rx_packet = NULL;	USHORT number_of_bytes_rxed = 0;	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;    OPTION_PARSE_RESULT parseResult;	if (packet == NULL)		return;	/* get a pointer to the BACP packet */	sptr_bacp_rx_packet = mtod (packet, BACP_PACKET *);	/* nak packet must have the same id as the request packet sent */	if (sptr_bacp_rx_packet->bacp_header.id != 		pStackData->last_id_of_bacp_packet_sent)		{		netMblkClChainFree (packet);		return;		}  	/* option processing expects a contiguous buffer */	if (packet->mBlkHdr.mNext != NULL)		{		number_of_bytes_rxed = packet->mBlkPktHdr.len;		contiguousPacket = m_pullup (packet,				ntohs (sptr_bacp_rx_packet->bacp_header.length));		if (contiguousPacket == NULL)			return;		}	else		number_of_bytes_rxed = packet->mBlkHdr.mLen;	sptr_bacp_rx_packet = mtod (contiguousPacket, BACP_PACKET *);	/* strip BACP header */	contiguousPacket->mBlkHdr.mLen -= BACP_PACKET_HEADER_SIZE;	contiguousPacket->mBlkHdr.mData += BACP_PACKET_HEADER_SIZE;	if (number_of_bytes_rxed > BACP_PACKET_HEADER_SIZE)		{		/* parse the options and modify the tx_accepted list */		parseResult = parse_bacp_options_from_nak_configure 						(pluginState->pluginObj->pfwObj,						&pStackData->option_lists,						contiguousPacket, pluginState);		}	else		{		netMblkClChainFree (contiguousPacket);		return;		}	/* option parsing error */	if (parseResult == OPTION_PARSING_ERROR)		{		netMblkClChainFree (contiguousPacket);		return;		}	/* free the request 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;		}	netMblkClChainFree (contiguousPacket);	execute_bacp_state_machine (pluginState, PPP_RECEIVE_CONFIGURE_NAK_EVENT,								NULL);	pStackData->number_of_configuration_requests = 0x0000;	}/******************************************************************************** bacp_configure_reject_received - process the configure reject received ** This routine is called by the bacp_packet_received () to process the BACP * configuration reject packet. The received BACP configuration reject packet * is verified against error conditions. The BACP options, from the configure * reject packet are parsed and processed using the * parse_ppp_options_from_reject_configure () function * The bacp_execute_state_machine () is called to take appropriate action. ** RETURNS:N/A*/LOCAL void bacp_configure_reject_received	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID packet							/* received BACP packet */	)	{	M_BLK_ID contiguousPacket = packet;	BACP_PACKET *sptr_bacp_rx_packet = NULL;	USHORT number_of_bytes_rxed = 0;	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	OPTION_PARSE_RESULT parseResult;	if (packet == NULL) 		return;	/* get a pointer to BACP packet */	sptr_bacp_rx_packet = mtod (packet, BACP_PACKET *);#ifdef PPP_DEBUG	logMsg ("PPP_BACP Rx configReject : time, %ld, ID %d\n", tickGet (),						sptr_bacp_rx_packet->bacp_header.id,3,4,5,6);#endif /* PPP_DEBUG */	/* option processing expects a contiguous buffer */	if (packet->mBlkHdr.mNext != NULL)		{		number_of_bytes_rxed = packet->mBlkPktHdr.len;		contiguousPacket = m_pullup (packet,				ntohs (sptr_bacp_rx_packet->bacp_header.length));		if (contiguousPacket == NULL)			return;		}	else		number_of_bytes_rxed = packet->mBlkHdr.mLen;	sptr_bacp_rx_packet = mtod (contiguousPacket, BACP_PACKET *);	/* configure reject must have the same ID as the sent request packet */	if (sptr_bacp_rx_packet->bacp_header.id ==							pStackData->last_id_of_bacp_packet_sent)		{		/* strip BACP header */		contiguousPacket->mBlkHdr.mLen -= BACP_PACKET_HEADER_SIZE;		contiguousPacket->mBlkHdr.mData += BACP_PACKET_HEADER_SIZE;		if (number_of_bytes_rxed > BACP_PACKET_HEADER_SIZE )		    {			/* parse the packet and modify the tx_accepted list */						if ((parseResult = parse_ppp_options_from_reject_configure 								(pluginState->pluginObj->pfwObj,								&pStackData->option_lists, contiguousPacket))												== SOME_OPTIONS_ARE_REJECTED)				{				netMblkClChainFree (contiguousPacket);				execute_bacp_state_machine (pluginState, PPP_CLOSE_EVENT, NULL);				return;				}			else				{				/* option parsing error */				if (parseResult == OPTION_PARSING_ERROR)					{					netMblkClChainFree (contiguousPacket);					return;					}				}			}		netMblkClChainFree (contiguousPacket);		/*  free the request 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;			}		execute_bacp_state_machine (pluginState,				PPP_RECEIVE_CONFIGURE_REJECT_EVENT, NULL);		pStackData->number_of_configuration_requests = 0x0000;		}	else 		netMblkClChainFree (contiguousPacket);	}/******************************************************************************** bacp_termination_request_received - process the termination request received** This routine is called by the bacp_packet_received () to process the BACP * termination request packet. execute_bacp_state_machine () function is called * to take appropriate action.** RETURNS: N/A*/LOCAL void bacp_termination_request_received	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID packet							/* received BACP packet */	)	{	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	BACP_PROFILE_DATA *pProfileData = 				(BACP_PROFILE_DATA *)pluginState->profileData;	if (packet == NULL)		return;#ifdef PPP_DEBUG    logMsg ("PPP_BACP Rx Termination Req: stack 0x%x\n",						(int)pluginState->stackObj,2,3,4,5,6);#endif /* PPP_DEBUG */	/* Save the received packet */	pStackData->last_rxed_bacp_termination_request_packet = packet;  	execute_bacp_state_machine (pluginState, PPP_RECEIVE_TERMINATE_REQUEST_EVENT,							NULL);	/*	 * wait 1 cycle for other side to terminate the link before trying to	 * reset so we can come back up. rfc 1661 sect. 3.7;	 *	 * generate TO- event	 */	if ((pStackData->number_of_termination_requests == 0) &&	(pStackData->stateData.state == PPP_STOPPING_STATE ||	pStackData->stateData.state == PPP_CLOSING_STATE))		{		pStackData->number_of_termination_requests = 			(USHORT) pProfileData->maximum_number_of_bacp_termination_requests;		if (pfwTimerStart (pStackData->retryTimer, PFW_SECOND,			pProfileData->maximum_bacp_termination_request_send_interval,			retry_bacp_termination_request, 0) == ERROR)			{			logMsg ("PPP_BACP Rx Termination request : timerStart failed \				state = %d\n", pStackData->stateData.state, 2, 3, 4, 5, 6);			}		}	}/******************************************************************************** bacp_termination_ack_received - process termination ack received** This routine is called by the bacp_packet_received () to process the BACP * termination ack packet. The sequence identifier is verified and * execute_bacp_state_machine () function is called with * PPP_RECEIVE_TERMINATE_ACK_EVENT to take appropriate action.** RETURNS:N/A*/LOCAL void bacp_termination_ack_received 	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID packet							/* received BACP packet */	)	{	BACP_PACKET *sptr_bacp_rx_packet = NULL;	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;	if (packet == NULL)		return;	/* get a pointer to BACP packet */	sptr_bacp_rx_packet = mtod (packet, BACP_PACKET *);	/* terminate ack packet must have the same id as the sent request packet */	if (sptr_bacp_rx_packet->bacp_header.id != 				pStackData->last_id_of_bacp_packet_sent)		{		netMblkClChainFree (packet);		return;		}	netMblkClChainFree (packet);#ifdef PPP_DEBUG	logMsg ("PPP_BACP Rx Termination Ack: stack 0x%x\n",						(int)pluginState->stackObj,2,3,4,5,6);#endif /* PPP_DEBUG */	execute_bacp_state_machine (pluginState, 								PPP_RECEIVE_TERMINATE_ACK_EVENT, NULL);	}/******************************************************************************** bacp_code_reject_received - process the code reject received** This routine is called by the bacp_packet_received () to process the BACP * code reject packet. execute_bacp_state_machine () function is called with * PPP_RECEIVE_CODE_REJECT_PERMITTED_EVENT to take appropriate action.** RETURNS: N/A*/LOCAL void bacp_code_reject_received	(	PFW_PLUGIN_OBJ_STATE * pluginState,		/* state for the stack */	M_BLK_ID packet							/* received BACP packet */	)	{	BACP_CODE_REJECT_PACKET *sptr_bacp_rx_packet = NULL;	BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData;    char * rejectedPacket = NULL;	UINT8  rejectedCode;	if (packet == NULL)		return;	/* get a pointer to CODE_REJECT_PACKET */	sptr_bacp_rx_packet = mtod (packet, BACP_CODE_REJECT_PACKET *);	/* get the code of the rejected packet */	rejectedPacket = (char *)&sptr_bacp_rx_packet->rejected_packet;	rejectedCode = rejectedPacket[0];	/* if packet length is > local MRRU, free the packet and return */		if ((ntohs (sptr_bacp_rx_packet->length) - sizeof (BACP_HEADER)) >											pStackData->bundleLocalMRRU)		{		netMblkClChainFree (packet);		}	else		if (rejectedCode > 0 && rejectedCode < PROTOCOL_REJECT)			{			netMblkClChainFree (packet);			execute_bacp_state_machine (pluginState,				PPP_RECEIVE_CODE_REJECT_CATASTROPHIC_EVENT, NULL);			}		else			{			/* free the last txed configure request packet, if not NULL */			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;				}			netMblkClChainFree (packet);			execute_bacp_state_machine (pluginState,					PPP_RECEIVE_CODE_REJECT_PERMITTED_EVENT, NULL);			}#ifdef PPP_DEBUG        logMsg ("PPP_BACP Rx Code Reject : stack 0x%x\n",                            (int)pluginState->stackObj,2,3,4,5,6);#endif /* PPP_DEBUG */	}

⌨️ 快捷键说明

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