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

📄 bacpoptn.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
			return PASS;			}		else			{						/* generate alternate option */			alternateOption = htonl (random ()); 			memcpy (sptr_remote_option->uptr_data, &alternateOption, 					sizeof (UINT32));			return FAIL;						}		}	/* if it is negotiable, accept whatever the peer has suggested */	if (sptr_local_option->option_flags.negotiable == PPP_FLAG_ON)		return (PASS);	/* if the value is same as the one locally configured for remote peer,		accept it */	if (option_value_match (sptr_local_option, sptr_remote_option) != NULL)		return (PASS);	/* if the value is in the alternate values configured, accept it */	if (alternate_option_value_match (sptr_local_option, sptr_remote_option)								!= NULL)		return (PASS);	/* else if the value is in range values configured accept it */	if (range_option_value_match (sptr_local_option, sptr_remote_option) == TRUE)		return (PASS);	/* else generate value to be nacked with */    if (set_option_values_for_nak (pluginState->pluginObj->pfwObj,				sptr_local_option, sptr_remote_option)== FAIL)		{		/* 		 * set_option_values_for_nak resets the nak_option_selected counter 		 * allowing us to start with the first configured value. In this		 * scheme we rely on the MAX_FAILURE (max # naks before a reject) 		 * mechanism to terminate the nak value selection loop		 */	    ppp_negotiation_error (pluginState, sptr_remote_option,							    sptr_option_lists);		}	return (FAIL);	}/******************************************************************************** parse_bacp_options_from_nak_configure - parse options from BACP configure nak * 											packet** This function parses the received configure nak packet, calls * bacp_configure_nak_option_processor to process the nacked options and copy* alternate values into tx_accepted list.** RETURNS: OPTION_PARSE_RESULT*/OPTION_PARSE_RESULT parse_bacp_options_from_nak_configure	(	PFW_OBJ * pfw,						/* framework reference */	OPTION_LISTS *sptr_option_lists,	/* 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;	return_code = OPTIONS_RECEIVED_ARE_OK;	free_ppp_option_list (&sptr_option_lists->received);	free_ppp_option_list (&sptr_option_lists->rx_nak);	free_ppp_option_list (&sptr_option_lists->tx_reject);		/* copy the received options to received option list */	if (parse_ppp_options_from_packet 			(pfw, &sptr_option_lists->received, packet)	== FAIL)		return (OPTION_PARSING_ERROR);#ifdef PPP_DEBUG	logMsg ("%s Rx ConfigNak: ",(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 */	/* process the nacked option */	sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list 						((LINK *) &sptr_option_lists->received);	sptr_configured_option = find_matching_option (							&sptr_option_lists->configured,							sptr_receive_list_option->type.generic);	while (sptr_receive_list_option != NULL)		{		if (sptr_configured_option == NULL)			{			free_ppp_option_list (&sptr_option_lists->received);			return (OPTION_PARSING_ERROR);			}		else			{			option_value_ok = bacp_configure_nak_option_processor 										(sptr_receive_list_option,										sptr_option_lists, pluginState);		    if (option_value_ok == FAIL)			    {			    free_ppp_option_list (&sptr_option_lists->received);			    return (OPTION_PARSING_ERROR);			    }			}		sptr_receive_list_option = (OPTION_LIST_ENTRY *) get_entry_from_list										((LINK *) &sptr_option_lists->received);		if (sptr_receive_list_option == NULL)			break;		sptr_configured_option = find_matching_option_beyond 									(sptr_configured_option,									 sptr_receive_list_option->type.generic);		}	return (return_code);	}/******************************************************************************** bacp_configure_nak_option_processor - process the nacked options** This routine is called to process the options received in the configuration * nak packet. This function checks if the alternate value suggested is * acceptable, then returns PASS, else returns FAIL.** RETURNS: PASS/FAIL*/LOCAL TEST bacp_configure_nak_option_processor	(	OPTION_LIST_ENTRY *sptr_remote_option,	/* nacked 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;	ALTERNATE_OPTION *sptr_alternate_option = NULL;	BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *) pluginState->stackData;	UINT32	alternateOption = 0;	ULONG   localFavoredPeerId = 0;  	sptr_local_option = find_matching_option 						(&sptr_option_lists->tx_accepted,			             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)		{			localFavoredPeerId = ntohl (sptr_remote_option->uptr_data->_ulong);		/* if value is acceptable update stack data */		if ((localFavoredPeerId != 0) && 			(localFavoredPeerId != pStackData->remote_favored_peer_id))			{			/* update the stack data */						pStackData->local_favored_peer_id = localFavoredPeerId; 			if (pStackData->local_favored_peer_id < 								pStackData->remote_favored_peer_id)						pStackData->favored_peer_is_me = TRUE;			else				pStackData->favored_peer_is_me = FALSE;				replace_data_field_in_option (pluginState->pluginObj->pfwObj,					sptr_local_option,					sptr_remote_option->uptr_data,sptr_remote_option->length);			return PASS;			}		else			{			/* generate alternate option */			alternateOption = random ();			replace_data_field_in_option (pluginState->pluginObj->pfwObj,					sptr_local_option,				(UNION_OPTION_DATA_TYPES *)&alternateOption, sizeof (UINT32));				pStackData->local_favored_peer_id = alternateOption;			if (pStackData->local_favored_peer_id < 								pStackData->remote_favored_peer_id)				pStackData->favored_peer_is_me = TRUE;			else				pStackData->favored_peer_is_me = FALSE;			return PASS; 			}		}	if (sptr_local_option->option_flags.negotiable == PPP_FLAG_ON)		{		if (option_value_match (sptr_local_option,sptr_remote_option) != NULL)			return (PASS);		sptr_alternate_option = alternate_option_value_match (sptr_local_option,							    sptr_remote_option);		if (sptr_alternate_option != NULL)			{			replace_data_field_in_option (pluginState->pluginObj->pfwObj,					sptr_local_option,					sptr_alternate_option->uptr_data,					sptr_alternate_option->length);			return (PASS);			}		if (range_option_value_match (sptr_local_option,sptr_remote_option)			== TRUE)			{			replace_data_field_in_option (pluginState->pluginObj->pfwObj,					sptr_local_option,					sptr_remote_option->uptr_data,sptr_remote_option->length);			return (PASS);			}		replace_data_field_in_option (pluginState->pluginObj->pfwObj,					sptr_local_option,					sptr_remote_option->uptr_data,sptr_remote_option->length);		return (PASS);		}	else		{		ppp_negotiation_error (pluginState, sptr_remote_option,							    sptr_option_lists);		return (FAIL);		}	}

⌨️ 快捷键说明

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