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

📄 ospf_cfg_routines.c

📁 vxworks下ospf协议栈
💻 C
字号:
/* ospf_cfg_routines.c - OSPF APIs *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------02b,29may03,agi Changed from RWOS calls to OSPF calls02a,14may03,agi Changed RWOS semaphores to vxWorks semaphores01a,10oct01,jkw Added new configuration routines for OSPF.*//*DESCRIPTIONThis file contains OSPF APIs which can enable and disable OSPF functionality.These APIs can be called from the target shell or from an independentapplication.  Each API is mutex protected so that the internal data structures are not corrupted.*/#include <ctype.h>#include "ospf.h"#if defined (__OSPF_VIRTUAL_STACK__)#include "ospf_vs_lib.h"#endif /* __OSPF_VIRTUAL_STACK__ */#if defined (__OSPF_PASSIVE_INTERFACE__)/******************************************************************************* ospfSetPassiveMode - Sets all OSPF interfaces to passive or non-passive mode** This routine sets all the interfaces to passive or non-passive mode in OSPF.* When setting all the interfaces to passive mode, all the interfaces will be * brought down and brought back up with the interfaces set to not accept * any Hello packets.  This will cause all the interfaces to be calculated * as stub networks.* When setting all the interfaces to non-passive mode, all the interfaces will* be brought down and brought back up with the interfaces to function in normal* mode.** <commands> Specifies whether to enable or disable passive mode.* DEFAULT - sets all interfaces to passive* NONE - sets all interfaces to normal** RETURNS: TRUE or FALSE** ERRNO: N/A*/STATUS ospfSetPassiveMode (char *commands){	char *p_token;	char *tokenizer; 	int pass = 0, error = 0;	int result;	OSPF_INTERFACE *sptr_interface = NULL;	OSPF_INTERFACE *sptr_next_interface = NULL;	semTake (ospf_global_mutex , WAIT_FOREVER);	while (*commands != '\0')		{		pass = 0;		p_token = commands;		while (*p_token == ' ' || *p_token == ',')			{			p_token++;			}						tokenizer = p_token; 		while (*tokenizer != ' ' && *tokenizer != ',' && *tokenizer !='\0')			{			*tokenizer = toupper( *tokenizer );			tokenizer++;			}		if (*tokenizer == '\0')			{			commands = tokenizer; 			}			else				{				*tokenizer = '\0';				commands = tokenizer + 1; 				}		result = strcmp(p_token,"DEFAULT");		if (!result)			{			pass = 1;			for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface)				{				sptr_next_interface = sptr_interface->sptr_forward_link;				/* Change interface to passive */				sptr_interface->passive = TRUE;				/* Bring interface down */				sptr_interface->state = OSPF_INTERFACE_IS_DOWN;				ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections(sptr_interface, OSPF_INTERFACE_DOWN, OSPF_INTERFACE_IS_DOWN);				sptr_interface->sptr_area->build_router = TRUE;				ospf_generate_network_and_router_link_state_advertisements (sptr_interface);				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE DOWN with address (HEX) %lx\r\n", sptr_interface->address);				/* Bring interface up */				sptr_interface->state = OSPF_INTERFACE_WAITING;				ospf_execute_interface_state_machine (OSPF_INTERFACE_UP, OSPF_INTERFACE_IS_DOWN, sptr_interface);				sptr_interface->sptr_area->build_router = TRUE;				ospf_generate_network_and_router_link_state_advertisements (sptr_interface);				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE UP with address (HEX) %lx\r\n", sptr_interface->address);				}			}		result = strcmp(p_token,"NONE");		if (!result)			{			pass = 1;			for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface)				{				sptr_next_interface = sptr_interface->sptr_forward_link;				/* Change interface to passive */				sptr_interface->passive = FALSE;				/* Bring interface down */				sptr_interface->state = OSPF_INTERFACE_IS_DOWN;				ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections(sptr_interface, OSPF_INTERFACE_DOWN, OSPF_INTERFACE_IS_DOWN);				sptr_interface->sptr_area->build_router = TRUE;				ospf_generate_network_and_router_link_state_advertisements (sptr_interface);				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE DOWN with address (HEX) %lx\r\n", sptr_interface->address);				/* Bring interface up */				sptr_interface->state = OSPF_INTERFACE_WAITING;				ospf_execute_interface_state_machine (OSPF_INTERFACE_UP, OSPF_INTERFACE_IS_DOWN, sptr_interface);				sptr_interface->sptr_area->build_router = TRUE;				ospf_generate_network_and_router_link_state_advertisements (sptr_interface);				OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE UP with address (HEX) %lx\r\n", sptr_interface->address);				}			}		if (!pass)			{			if (!error)				{				error = 1;				printf("Error : Unknown parameter ");				}			printf(" %s ",p_token);			}		} 	if (error)		{		printf(" \n ");		}	if (!pass)		{		printf("USAGE: ospfSetPassiveMode(\"KEYWORD1\") \n\n KEYWORD: DEFAULT|NONE\n");		}	if (pass) 		{		semGive (ospf_global_mutex );		return (OK);		}	else 		{		semGive (ospf_global_mutex );		return (ERROR);		}}/******************************************************************************* ospfSetPassivePort - Sets an OSPF interface to passive or non-passive mode** This routine sets an interface to passive or non-passive mode in OSPF.* When setting the interfaces to passive mode, the interfaces will be * brought down and brought back up with the interface set to not accept * any Hello packets.  This will cause the interface to be calculated * as a stub network.* When setting the interface to non-passive mode, the interface will* be brought down and brought back up with the interface to function in normal* mode.** <cptr_ip_address_string> IP address *		* <mode> Mode to set interface. PASSIVE or NONE.** RETURNS: TRUE or FALSE** ERRNO: N/A*/STATUS ospfSetPassivePort (char *cptr_ip_address_string, enum OSPF_MODE mode){	OSPF_INTERFACE *sptr_interface = NULL;	OSPF_INTERFACE *sptr_next_interface = NULL;	ULONG offset = 0x00000000;	ULONG ip_address;	ULONG ulptr_base = 0x00000000;	semTake (ospf_global_mutex , WAIT_FOREVER);	ulptr_base = (ULONG)(&ip_address);	ospf_set_ip_address (cptr_ip_address_string,offset,ulptr_base);		for (sptr_interface = ospf.sptr_interface_list; sptr_interface != NULL; sptr_interface = sptr_next_interface)		{		sptr_next_interface = sptr_interface->sptr_forward_link;		if (sptr_interface->address == ip_address)			{			if (mode == PASSIVE)				{				if (sptr_interface->passive == TRUE)					{					semGive (ospf_global_mutex );					return OK;					}				else					{							/* Change interface to passive */					sptr_interface->passive = TRUE;					/* Bring interface down */					sptr_interface->state = OSPF_INTERFACE_IS_DOWN;					ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections(sptr_interface, OSPF_INTERFACE_DOWN, OSPF_INTERFACE_IS_DOWN);					sptr_interface->sptr_area->build_router = TRUE;					ospf_generate_network_and_router_link_state_advertisements (sptr_interface);					OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE DOWN with address (HEX) %lx\r\n", sptr_interface->address);					/* Bring interface up */					sptr_interface->state = OSPF_INTERFACE_WAITING;					ospf_execute_interface_state_machine (OSPF_INTERFACE_UP, OSPF_INTERFACE_IS_DOWN, sptr_interface);					sptr_interface->sptr_area->build_router = TRUE;					ospf_generate_network_and_router_link_state_advertisements (sptr_interface);					OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE UP with address (HEX) %lx\r\n", sptr_interface->address);					}				}			else				{				if (sptr_interface->passive == FALSE)					{					semGive (ospf_global_mutex );					return OK;					}				else					{					/* Change interface to passive */					sptr_interface->passive = FALSE;					/* Bring interface down */					sptr_interface->state = OSPF_INTERFACE_IS_DOWN;					ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections(sptr_interface, OSPF_INTERFACE_DOWN, OSPF_INTERFACE_IS_DOWN);					sptr_interface->sptr_area->build_router = TRUE;					ospf_generate_network_and_router_link_state_advertisements (sptr_interface);					OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE DOWN with address (HEX) %lx\r\n", sptr_interface->address);					/* Bring interface up */					sptr_interface->state = OSPF_INTERFACE_WAITING;					ospf_execute_interface_state_machine (OSPF_INTERFACE_UP, OSPF_INTERFACE_IS_DOWN, sptr_interface);					sptr_interface->sptr_area->build_router = TRUE;					ospf_generate_network_and_router_link_state_advertisements (sptr_interface);					OSPF_PRINTF_ALARM (OSPF_ALARM_PRINTF, "OSPF: INTERFACE UP with address (HEX) %lx\r\n", sptr_interface->address);					}				}			}		}	semGive (ospf_global_mutex );	return OK;}#endif /*__OSPF_PASSIVE_INTERFACE__*/#if defined (__OPAQUE_LSA__)/******************************************************************************* ospfSetOpaqueEnable - Sets the OSPF router to be opaque enabled.** This routine sets the OSPF router to be opaque enabled.  This means* that the OSPF router can accept opaque lsas and store them.** RETURNS: N/A** ERRNO: N/A*/STATUS ospfSetOpaqueEnable(){	semTake (ospf_global_mutex , WAIT_FOREVER);	ospf.opaque_capability = TRUE;	semGive (ospf_global_mutex );	return OK;}/******************************************************************************* ospfSetOpaqueEnable - Sets the OSPF router to be opaque disabled.** This routine sets the OSPF router to be opaque disabled.  This means* that the OSPF router can no longer accept opaque lsas.** RETURNS: N/A** ERRNO: N/A*/STATUS ospfSetOpaqueDisable(){	semTake (ospf_global_mutex , WAIT_FOREVER);	ospf.opaque_capability = FALSE;	semGive (ospf_global_mutex );	return OK;}#endif /* __OPAQUE_LSA__ *//******************************************************************************* ospfSetTotalAreaAddressRange - Sets the total number of area address ranges*		in OSPF.** This routine sets the total number of area address ranges in the OSPF router.* This number is based upon the total number of area address ranges in all the * areas in the OSPF router.** RETURNS: N/A** ERRNO: N/A*/STATUS ospfSetTotalAreaAddressRange(ULONG total_number_area_ranges){	semTake (ospf_global_mutex , WAIT_FOREVER);	ospf.number_of_area_address_ranges = total_number_area_ranges;	semGive (ospf_global_mutex );	return OK;}/******************************************************************************* ospf_cfg_routines_stub - Stub function for compiling all functions into code.** This routine ensures that all the above functions will be added to the image.** RETURNS: N/A** ERRNO: N/A* * NOMANUAL*/void ospf_cfg_routines_stub(){	return;}

⌨️ 快捷键说明

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