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

📄 ospf_interface_events.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 2 页
字号:
	return;}/*************************************************************************** ospf_process_interface_unloop_indication_event - execute when interface unloop indication event is received** This routine will change the interface to a down state.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*************************************************************************************//* section 9.3, State: Loopback (p. 68-69) */void ospf_process_interface_unloop_indication_event (OSPF_INTERFACE *sptr_interface){	enum OSPF_INTERFACE_STATE old_state;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_unloop_indication_event\r\n");	old_state = sptr_interface->state;	sptr_interface->state = OSPF_INTERFACE_IS_DOWN;	ospf_interface_state_transition_printf (sptr_interface, OSPF_UNLOOP_INDICATION, old_state);	++sptr_interface->events;	return;}/*************************************************************************** ospf_process_interface_down_event - execute when interface down event is received** This routine will reset all the interface variables and timers and* destroy all associated neighbor connections.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//*********************************************************************************************//* section 9.3, State: Any (p. 68) */void ospf_process_interface_down_event (OSPF_INTERFACE *sptr_interface){	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_process_interface_down_event\r\n");	ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections (sptr_interface, OSPF_INTERFACE_DOWN, OSPF_INTERFACE_IS_DOWN);    /* SPR# 85573 fix start     * The interface has gone down, so build, install & flood new router LSA    */    ospf_generate_network_and_router_link_state_advertisements (sptr_interface);    /* SPR# 85573 fix end */	return;}/*************************************************************************** ospf_calculate_backup_designated_router_and_designated_router_for_attached_network - calculate the DR and BDR for the attached network** This routine will calculate the DR and BDR for the* attached network.** <sptr_interface> OSPF interface** <event> Interface event** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//**********************************************************************************************************************************/static void ospf_calculate_backup_designated_router_and_designated_router_for_attached_network (OSPF_INTERFACE *sptr_interface,	enum OSPF_INTERFACE_EVENT event){	enum OSPF_INTERFACE_STATE old_state;	ULONG address_of_old_designated_router =0;	BYTE old_build_router;	BYTE old_build_network;	USHORT age = 0x00;	OSPF_LS_DATABASE_ENTRY *sptr_network_database_entry=NULL;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_backup_designated_router_and_designated_router_for_attached_network\r\n");	old_state = sptr_interface->state;	address_of_old_designated_router = sptr_interface->designated_router.address;	ospf_run_designated_router_election (sptr_interface);/*********************************************************************************************************************	A router that has formerly been the Designated Router for a network,	but is no longer, should flush the network-LSA that it had previously SPR#75785***********************************************************************************************************************/     if(((sptr_interface->designated_router.address) != (address_of_old_designated_router)) &&         (address_of_old_designated_router == sptr_interface->address))  {        /*search for the old network LSA entry in the  database and set age= OSPF_MAX_AGE */ 		/* SPR#76812 -- Begin */		sptr_network_database_entry = ospf_find_LSA (sptr_interface->sptr_area, address_of_old_designated_router,ospf.router_id, OSPF_LS_NETWORK);		/* SPR#76812 -- End */			if(sptr_network_database_entry != NULL)			{				age = OSPF_MAXIMUM_AGE;				age = host_to_net_short (age);				/* Assign OSPF_MAX_AGE value to network LSA*/				sptr_network_database_entry->advertisement.sptr_network->ls_header.age = age;			}	}	if ((sptr_interface->state != old_state) || (sptr_interface->designated_router.address != address_of_old_designated_router))		{		sptr_interface->sptr_area->build_router = TRUE;			/* section 12.4, items (2) & (3) (page 115) */		}	old_build_router = sptr_interface->sptr_area->build_router;   /*#$-NOTE:put net links-$#*/	old_build_network = sptr_interface->flags._bit.build_network;	ospf_generate_network_and_router_link_state_advertisements (sptr_interface);	sptr_interface->sptr_area->build_router = old_build_router;	sptr_interface->flags._bit.build_network = old_build_network;	ospf_interface_state_transition_printf (sptr_interface, event, old_state);	++sptr_interface->events;	return;}/*************************************************************************** ospf_calculate_point_to_point_network - generate a new router lsa for the point to point network** This routine will generate a new router lsa for the point to point* network.** <sptr_interface> OSPF interface** RETURNS: N/A** ERRNO: N/A** NOMANUAL*//**********************************************************************************************************************************/static void ospf_calculate_point_to_point_network (OSPF_INTERFACE *sptr_interface){	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_calculate_point_to_point_network\r\n");	sptr_interface->sptr_area->build_router = TRUE;	/* POINT_TO_POINT and POINT_TO_MULTIPOINT interface do not generate Network-LSA __NBMA_PTMP__*/	if((sptr_interface->type != OSPF_POINT_TO_POINT) &&	   (sptr_interface->type != OSPF_POINT_TO_MULTIPOINT))	{		sptr_interface->flags._bit.build_network = TRUE;	}	ospf_generate_network_and_router_link_state_advertisements (sptr_interface);	return;}/*************************************************************************** ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections - reset all timers and variables** This routine will reset the interface variables and destroy* all associated neighbor connections.** <sptr_interface> OSPF interface** <event> Interface event** <new_state> New interface state** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections (OSPF_INTERFACE *sptr_interface,	enum OSPF_INTERFACE_EVENT event,enum OSPF_INTERFACE_STATE new_state){	enum OSPF_INTERFACE_STATE old_state;	OSPF_NEIGHBOR *sptr_neighbor =NULL;	OSPF_NEIGHBOR *sptr_next_neighbor = NULL;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_reset_interface_variables_and_timers_and_destroy_all_associated_neighbor_connections\r\n");	OSPF_PRINTF_DEBUG (OSPF_DEBUG_PRINTF, "OSPF: Set build_network on interface with address (HEX) %lx  to FALSE ",sptr_interface->address);	old_state = sptr_interface->state;	sptr_interface->state = new_state;	sptr_interface->wait_timer_enabled = FALSE;	sptr_interface->flags._bit.network_scheduled = FALSE;	sptr_interface->flags._bit.build_network = FALSE;	sptr_interface->potential_neighbor.designated_router = 0x00000000L;	sptr_interface->potential_neighbor.backup_designated_router = 0x00000000L;	sptr_interface->designated_router.address = 0x00000000L;	sptr_interface->backup_designated_router.address = 0x00000000L;	ospf_free_interface_acknowledgement_list (sptr_interface, FALSE);	    for (sptr_neighbor = sptr_interface->sptr_neighbor;          sptr_neighbor != NULL;          sptr_neighbor = sptr_next_neighbor)		{		sptr_next_neighbor = sptr_neighbor->sptr_forward_link;        ospf_flush_lsdb_of_external_lsas_associated_with_neighbor (            sptr_neighbor);		        ospf_execute_neighbor_state_machine (            OSPF_KILL_NEIGHBOR,             sptr_neighbor->state,             sptr_interface,             sptr_neighbor);		}    ospf_schedule_routing_table_build ();	if (sptr_interface->type == OSPF_VIRTUAL_LINK)		{		sptr_interface->sptr_transit_area->flags._bit.virtual_up = FALSE;		--ospf.number_of_virtual_links_in_Up_state;		}	--sptr_interface->sptr_area->number_of_interfaces_in_up_state;	if ( sptr_interface->sptr_area->number_of_interfaces_in_up_state == 0 )        {        /* if there is no more active interface operates in the area to which the         * interface is currently connected, flush all lsas associated with the area         */        ospf_free_areas_link_state_database( sptr_interface->sptr_area );        }	ospf_interface_state_transition_printf (sptr_interface, event, old_state);	++sptr_interface->events;	return;}/*************************************************************************** ospf_interface_state_transition_printf - print the transition of interface states** This routine will print the transition of interface states and* the event that causes the interface state to change.** <sptr_interface> OSPF interface** <event> Interface event** <old_state> Old interface state** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/static void ospf_interface_state_transition_printf (OSPF_INTERFACE *sptr_interface,enum OSPF_INTERFACE_EVENT event,	enum OSPF_INTERFACE_STATE old_state){	char print_buffer[PRINT_BUFFER_SIZE];	ULONG address =0;	OSPF_PRINTF_PROLOGUE (OSPF_PROLOGUE_PRINTF, "OSPF: Entering ospf_interface_state_transition_printf\r\n");	if (sptr_interface->type == OSPF_VIRTUAL_LINK)		{		address = sptr_interface->potential_neighbor.address;		}	else		{		address = sptr_interface->address;		}	OSPF_CONVERT_IP_ADDRESS_TO_DOT_FORMAT_FOR_DEBUG (print_buffer, address);	OSPF_PRINTF_INTERFACE (OSPF_INTERFACE_PRINTF, "OSPF: %s interface %s has transitioned from state %s to state %s because of event %s\r\n",		ospf_interface_types[sptr_interface->type], print_buffer, ospf_interface_states[old_state],		ospf_interface_states[sptr_interface->state], ospf_interface_events[event]);	return;}

⌨️ 快捷键说明

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