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

📄 bacpoptn.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* bacpoptn.c - option list manager *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------04e,07aug03,rp updating include path for random.h04d,06aug02,jr fixed build warnings 03C,16feb02,jr modifications as part of memory reduction process02b,30jun01,as receive list option validation 01a,14feb01,sd created  *//*DESCRIPTIONThis module implements the option processing functions of BACP component.The functions are called to process the options received in the configure request, configure nak packets. For a BACP configure request received, the options are parsed and verified, and the options are copied to the nak, reject and rx_accepted list used forsending the corresponding response packet i.e ack, nak, reject packet.For a BACP configure nak received, the options are parsed and if the value is acceptable copied to the tx_accepted list else alaternate option is generated and copied to tx_accepted list. The tx_accepted list is used tosend the configure request*/#include "vxWorks.h"#include "stddef.h"#include "stdio.h"#include "ctype.h"#include "string.h"#include "stdlib.h"#include "ppp/kstart.h"#include "ppp/kppp.h"#include "private/ppp/pppoptn.h"#include "pfw/pfw.h"#include "pfw/pfwMemory.h"#include "ppp/pppBacpComponent.h"#include "private/ppp/pppBacpComponentP.h"#include "wrn/util/random.h"/* externs */IMPORT OPTION_LIST_ENTRY *find_matching_option_beyond 				(OPTION_LIST_ENTRY *sptr_starting_option, BYTE type);IMPORT TEST parse_ppp_options_from_packet (PFW_OBJ *,					    OPTION_LIST *sptr_option_list,						M_BLK_ID packet);IMPORT OPTION_PARSE_RESULT set_missing_required_options_in_nak 					(PFW_OBJ *,					OPTION_LIST *sptr_configured_option_list,					OPTION_LIST *sptr_rxed_option_list,					OPTION_LIST *sptr_nak_option_list);IMPORT OPTION_LIST_ENTRY *find_next_matching_option 			    (OPTION_LIST_ENTRY *sptr_option);IMPORT void ppp_negotiation_error (PFW_PLUGIN_OBJ_STATE *pluginState,			OPTION_LIST_ENTRY *sptr_received_option,			OPTION_LISTS *sptr_option_lists);IMPORT TEST set_option_values_for_nak (PFW_OBJ *,		OPTION_LIST_ENTRY *sptr_local_option,		OPTION_LIST_ENTRY *sptr_remote_option);IMPORT void option_list_print ( OPTION_LIST *sptr_option_list);/* locals and forwards */LOCAL TEST bacp_configure_request_option_processor 				(OPTION_LIST_ENTRY *sptr_remote_option, 				OPTION_LISTS *sptr_option_lists,				PFW_PLUGIN_OBJ_STATE * pluginState);LOCAL TEST bacp_configure_nak_option_processor 				(OPTION_LIST_ENTRY *sptr_remote_option, 				OPTION_LISTS *sptr_option_lists,				PFW_PLUGIN_OBJ_STATE * pluginState);/******************************************************************************** parse_bacp_options_from_configure_request - parse options in received BACP *											configure request ** This function parses the received configure request packet, if the * negotiated option is not recognized, it is copied into tx_reject list. If the * option is recognized and the value is acceptable then it is copied into * rx_accepted list else it is copied into tx_nak list. The non negotiated * option which is required is also copied into tx_nak list.** RETURNS: OPTION_PARSE_RESULT*/OPTION_PARSE_RESULT parse_bacp_options_from_configure_request	(	PFW_OBJ * pfw,						/* framework reference */	OPTION_LISTS *sptr_option_lists,	/* BACP option lists */	M_BLK_ID    packet,					/* received packet */	PFW_PLUGIN_OBJ_STATE * pluginState	/* state for the stack */	)	{	OPTION_LIST_ENTRY *sptr_configured_option = NULL;	OPTION_LIST_ENTRY *sptr_receive_list_option = NULL;	TEST option_value_ok;	OPTION_PARSE_RESULT return_code = OPTIONS_RECEIVED_ARE_OK; 	free_ppp_option_list (&sptr_option_lists->received);	free_ppp_option_list (&sptr_option_lists->tx_nak);	free_ppp_option_list (&sptr_option_lists->tx_reject);	free_ppp_option_list (&sptr_option_lists->rx_accepted);	/* copy the received options in received option list*/	if (parse_ppp_options_from_packet (pfw,&sptr_option_lists->received, packet)																		== FAIL)		{		printf ("OPTION_PARSING_ERROR \n");		return (OPTION_PARSING_ERROR);		}#ifdef PPP_DEBUG	logMsg ("%s Rx ConfigReq: ",(int)pluginState->pluginObj->name,2,3,4,5,6);	option_list_print(&sptr_option_lists->received);	logMsg("\n",1,2,3,4,5,6);#endif /* PPP_DEBUG */	/* option which should be negotiated, but not negotiated by the peer,		nak it */	return_code = set_missing_required_options_in_nak (pfw,			&sptr_option_lists->remote_configured,			&sptr_option_lists->received,			&sptr_option_lists->tx_nak);	/* get the first option */	sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list					((LINK *) &sptr_option_lists->received);	while (sptr_receive_list_option != NULL)		{#ifdef CHECK_FOR_DUPLICATE_OPTIONS_IN_CONFIG_REQUEST		/* check if the same option is listed again */		if (find_matching_option (&sptr_option_lists->received,				sptr_receive_list_option->type.generic) != NULL)			{			return (OPTION_PARSING_ERROR);				}#endif /*CHECK_FOR_DUPLICATE_OPTIONS_IN_CONFIG_REQUEST*/			sptr_configured_option = find_matching_option (					&sptr_option_lists->remote_configured,					sptr_receive_list_option->type.generic);		/* if option is not recognized, reject it */		if (sptr_configured_option == NULL)		    {			add_entry_to_list ((LINK *) &sptr_option_lists->tx_reject,				(LINK *) sptr_receive_list_option);			return_code = SOME_OPTIONS_ARE_REJECTED;			}		else			{			/* process the options, if the value is not acceptable generate				 alternate value */			option_value_ok = bacp_configure_request_option_processor						(sptr_receive_list_option,						sptr_option_lists,pluginState);			if (option_value_ok == PASS)				{							/* value is acceptable copy to rx_accepted list */				add_entry_to_list ((LINK *) &sptr_option_lists->rx_accepted,							(LINK *) sptr_receive_list_option);				}			else				{						/* value is not acceptable copy to tx_nak list */				if (return_code == OPTIONS_RECEIVED_ARE_OK)					{					return_code = SOME_OPTIONS_ARE_NACKED;					}				add_entry_to_list ((LINK *) &sptr_option_lists->tx_nak,						(LINK *) sptr_receive_list_option);				}			}		/* get the next option */		sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list						((LINK *) &sptr_option_lists->received);		}	return (return_code);	}/******************************************************************************** bacp_configure_request_option_processor - process the options in configure *											request** This function checks the negotiated option value, if acceptable returns PASS* else generates alternate value to be negotiated and returns FAIL. * For the BACP favored peer option the stack data is also updated.** RETURNS: PASS/FAIL*/LOCAL TEST bacp_configure_request_option_processor	(	OPTION_LIST_ENTRY *sptr_remote_option,	/* received option*/	OPTION_LISTS      *sptr_option_lists,	/* BACP option lists */	PFW_PLUGIN_OBJ_STATE * pluginState		/* state for the stack */	)	{	OPTION_LIST_ENTRY *sptr_local_option = NULL;	BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *) pluginState->stackData;	UINT32	alternateOption;	ULONG   remoteFavoredPeerId; 	sptr_local_option = find_matching_option(								&sptr_option_lists->remote_configured,								sptr_remote_option->type.generic);	/* this should never happen but just in case */	if (sptr_local_option == NULL)		return (FAIL); 		/* if it is favored peer option, handle it seperately */		if (sptr_remote_option->type.generic == BACP_FAVORED_PEER) 		{		remoteFavoredPeerId = ntohl (sptr_remote_option->uptr_data->_ulong);		if ((remoteFavoredPeerId != 0) && 			(remoteFavoredPeerId != pStackData->local_favored_peer_id)) 			{			/* update the stack data */			pStackData->remote_favored_peer_id = remoteFavoredPeerId; 			if (pStackData->local_favored_peer_id < 								pStackData->remote_favored_peer_id)						pStackData->favored_peer_is_me = TRUE;			else				pStackData->favored_peer_is_me = FALSE;			

⌨️ 快捷键说明

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